mrustc
mrustc copied to clipboard
Fails to build with LLVM_LINK_SHARED=1
Many linux distros build LLVM as shared libraries only, so statically linking is not possible. For various reasons it's preferred to use the system LLVM instead of the bundled one, which requires that rustc
is also linked dynamically against LLVM libraries.
rustc
's configure
has an option --enable-llvm-link-shared
to do that, which internally sets the LLVM_LINK_SHARED
environment variable to 1
. Doing the same with mrustc
's bootstrap scripts works, but only until the final link of rustc_main
. I think this is because the rustc-link-lib=dylib=LLVM
flag from the rustc_llvm
crate's build config is not taken into account when linking the final rustc_main
binary. I added a hack to minicargo/build.cpp
to add -lLLVM
when building rustc_main
and the binary is built successfully that way.