You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The bindings for libllvm have some specific requirements for discovering LLVM configuration. The details differ between Unix and Windows, but either way they expect a specific setup and the availability of llvm-config or llvm_VERSION (the latter is only provided for the packaged libllvm in the Crystal package on Windows).
This all works for the most common use cases. But there are serious challenges for more advanced use cases such as cross-compiling, targeting a non-default LLVM version, or just doing semantic analysis without codegen.
For example, when cross-compiling the LLVM bindings from a Unix-like system to Windows, compilation fails due to missing llvm_VERSION file:
$ make crystal target=x86_64-windows-mscvUsing /home/linuxbrew/.linuxbrew/bin/llvm-config [version=17.0.6]CRYSTAL_CONFIG_BUILD_COMMIT="b11be6a74" CRYSTAL_CONFIG_PATH='$ORIGIN/../share/crystal/src' SOURCE_DATE_EPOCH="1710852755" CC="/home/linuxbrew/.linuxbrew/bin/gcc-13 -fuse-ld=lld" CRYSTAL_CONFIG_LIBRARY_PATH='$ORIGIN/../lib/crystal' ./bin/crystal build -D strict_multi_assign -D preview_overload_order --cross-compile --target x86_64-windows-mscv -Dwithout_interpreter -o .build/crystal src/compiler/crystal.cr -D without_openssl -D without_zlib -D use_pcre2Showing last frame. Use --error-trace for full trace.In src/llvm/lib_llvm.cr:9:10 9 | {% raise "Cannot determine LLVM configuration; ensure the file `llvm_VERSION` exists under `CRYSTAL_LIBRARY_PATH`" %} ^----Error: Cannot determine LLVM configuration; ensure the file `llvm_VERSION` exists under `CRYSTAL_LIBRARY_PATH`
It's not possible to explicitly set $LLVM_VERSION or $LLVM_CONFIG, they'll just get ignored.
$LLVM_CONFIG of course could only work if an approriate llvm-config is available. Cross-compiling from Windows to Unix, this wouldn't be the case, for example.
I think this should all work without special requirements and I can't see a reason why it couldn't be possible to pass in all the necessary information explicitly.
We should also consider what information is really needed for the llvm bindings. llvm_VERSION currently provides the version, build targets and ldflags. On Unix-like sytems, the same information is retrieved from llvm-config
As far as I can see, only the LLVM version is strictly required. We need it in order to target the correct API version.
Build targets could assume just the current target if no other information is available.
Linker flags are potentially irrelevant when cross-compiling, so it shouldn't be a show-stopper if they're missing. You can always provide them on the command line explicitly.
So I think we should make it that the LLVM bindings work (for both Unix and Windows) when only $LLVM_VERSION is provided and neither llvm_VERSION nor llvm-config are available.
The text was updated successfully, but these errors were encountered:
The bindings for
libllvm
have some specific requirements for discovering LLVM configuration. The details differ between Unix and Windows, but either way they expect a specific setup and the availability ofllvm-config
orllvm_VERSION
(the latter is only provided for the packaged libllvm in the Crystal package on Windows).This all works for the most common use cases. But there are serious challenges for more advanced use cases such as cross-compiling, targeting a non-default LLVM version, or just doing semantic analysis without codegen.
For example, when cross-compiling the LLVM bindings from a Unix-like system to Windows, compilation fails due to missing
llvm_VERSION
file:It's not possible to explicitly set
$LLVM_VERSION
or$LLVM_CONFIG
, they'll just get ignored.$LLVM_CONFIG
of course could only work if an approriatellvm-config
is available. Cross-compiling from Windows to Unix, this wouldn't be the case, for example.I think this should all work without special requirements and I can't see a reason why it couldn't be possible to pass in all the necessary information explicitly.
We should also consider what information is really needed for the llvm bindings.
llvm_VERSION
currently provides the version, build targets and ldflags. On Unix-like sytems, the same information is retrieved fromllvm-config
As far as I can see, only the LLVM version is strictly required. We need it in order to target the correct API version.
Build targets could assume just the current target if no other information is available.
Linker flags are potentially irrelevant when cross-compiling, so it shouldn't be a show-stopper if they're missing. You can always provide them on the command line explicitly.
So I think we should make it that the LLVM bindings work (for both Unix and Windows) when only
$LLVM_VERSION
is provided and neitherllvm_VERSION
norllvm-config
are available.The text was updated successfully, but these errors were encountered: