Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when find-llvm-config is unsuccessful #13045

Conversation

straight-shoota
Copy link
Member

@straight-shoota straight-shoota commented Feb 3, 2023

If find-llvm-config can't find an LLVM installation, it silent about it, print nothing and exiting as success. This results in undecipherable errors later on when LibLLVM::LLVM_CONFIG is called.

This patch changes the helper to error with status 1 and print an informative message to stderr if LLVM_CONFIG was not found.

Before:

$ bin/crystal spec spec/std/llvm/
--: line 0: : Permission denied
Showing last frame. Use --error-trace for full trace.

In src/llvm/lib_llvm.cr:13:17

 13 | VERSION = {{`#{LibLLVM::LLVM_CONFIG} --version`.chomp.stringify}}
                  ^
Error: error executing command: "" --version, got exit status 127

After:

$ bin/crystal spec spec/std/llvm/
Error: Could not find location of llvm-config. Please specify path in environment variable LLVM_CONFIG.
Supported LLVM versions: 14 13 12 11.1 11 10 9 8
Showing last frame. Use --error-trace for full trace.

In src/llvm/lib_llvm.cr:3:42

 3 | LLVM_CONFIG = {{ env("LLVM_CONFIG") || `#{__DIR__}/ext/find-llvm-config`.stringify }}
                                            ^
Error: error executing command: /app/src/llvm/ext/find-llvm-config, got exit status 1

Resolves https://forum.crystal-lang.org/t/problem-compiling-crystalline-for-the-vscode-plugin/5316

Copy link
Member

@sdogruyol sdogruyol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @straight-shoota 🙏

@straight-shoota straight-shoota added this to the 1.8.0 milestone Feb 3, 2023
@straight-shoota straight-shoota removed this from the 1.8.0 milestone Feb 3, 2023
@straight-shoota
Copy link
Member Author

I added another line to print the supported LLVM versions.

@straight-shoota straight-shoota added this to the 1.8.0 milestone Feb 3, 2023
@straight-shoota straight-shoota merged commit b05f354 into crystal-lang:master Feb 6, 2023
@straight-shoota straight-shoota deleted the feature/find-llvm-config-error branch February 6, 2023 12:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants