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

LLVM version in compiler --version may be inaccurate #15353

Open
straight-shoota opened this issue Jan 17, 2025 · 0 comments · May be fixed by #15354
Open

LLVM version in compiler --version may be inaccurate #15353

straight-shoota opened this issue Jan 17, 2025 · 0 comments · May be fixed by #15354
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler:cli

Comments

@straight-shoota
Copy link
Member

straight-shoota commented Jan 17, 2025

The compiler reports which version of LLVM it was built with on crystal --version. The source of that is LibLLVM::VERSION which is baked in at compile time. It's the version of LLVM that the compiler is linked against.
But when running the binary and libllvm is loaded from a shared library, the library migth actually be a different version. Not too different because it needs to be binary compatible. But there's some wiggle room. A difference in the patch version is entirely possible, for example.

The issue was first reported on discord by @JarnaChao09 who had crystal installed from homebrew, which is linked against llvm from homebrew. Yet llvm-config --version and crystal --version disagreed, showing 19.1.7 and 19.1.6, respectively. The cause for this must be that crystal was built with 19.1.6, but in the mean time the library has been updated to 19.1.7. The compiler still works with the new version, but reports the wrong version number.

This behaviour is surprising and unexpected. I'd expect the version information to show which version of LLVM the compiler actually uses. Not which one happend to be available when it was linked.

The function LLVMGetVersion is available since LLVM 16.0 and makes it possible to query the version at runtime.
For earlier versions we could consider exposing the function in libllvm_ext. But I'm not sure that's worth it. We should rather be phasing out older LLVM versions.

@straight-shoota straight-shoota added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler:cli labels Jan 17, 2025
@straight-shoota straight-shoota linked a pull request Jan 17, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler:cli
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant