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
{{ message }}
Repository navigation
rust-lld fails with "dyld: Library not loaded: @rpath/libLLVM.dylib" on 1.30.0-nightly (02cb8f2a4 2018-08-29) #53813
Short description: I am building for a no_std environment using cargo-xbuild, and the embedded lld as my linker of choice. The linker fails to load since it depends on a dynamic library that doesn't actually exist.
$ rustc --version
rustc 1.30.0-nightly (02cb8f2a4 2018-08-29)
$ rustc --print sysroot
/Users/parasyte/.rustup/toolchains/nightly-x86_64-apple-darwin
$ /Users/parasyte/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/bin/rust-lld --help
dyld: Library not loaded: @rpath/libLLVM.dylib
Referenced from: /Users/parasyte/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/bin/rust-lld
Reason: image not found
Abort trap: 6
$ otool -L /Users/parasyte/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/bin/rust-lld
/Users/parasyte/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/bin/rust-lld:
@rpath/libLLVM.dylib (compatibility version 1.0.0, current version 7.0.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.50.4)
Rolling back to nightly-2018-08-27-x86_64-apple-darwin works
$ rustup override set nightly-2018-08-27-x86_64-apple-darwin
info: using existing install for 'nightly-2018-08-27-x86_64-apple-darwin'
info: override toolchain for '/Users/parasyte/projects/technek' set to 'nightly-2018-08-27-x86_64-apple-darwin'
nightly-2018-08-27-x86_64-apple-darwin unchanged - rustc 1.30.0-nightly (721913067 2018-08-26)
$ rustc --version
rustc 1.30.0-nightly (721913067 2018-08-26)
$ rustc --print sysroot
/Users/parasyte/.rustup/toolchains/nightly-2018-08-27-x86_64-apple-darwin
$ /Users/parasyte/.rustup/toolchains/nightly-2018-08-27-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/bin/rust-lld --help
lld is a generic driver.
Invoke ld.lld (Unix), ld64.lld (macOS), lld-link (Windows), wasm-lld (WebAssembly) instead
$ otool -L /Users/parasyte/.rustup/toolchains/nightly-2018-08-27-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/bin/rust-lld
/Users/parasyte/.rustup/toolchains/nightly-2018-08-27-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/bin/rust-lld:
/usr/lib/libxml2.2.dylib (compatibility version 10.0.0, current version 10.9.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.50.4)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.0)
Reacted by Casey Primozic, Florent Bécart, Tyler Wilcock, rashad, Matthieu Bizien, Shridhar Sundarraj and Luke Fan
@GabrielMajeri it seems that libLLVM.so is provided by the llvm-tools-preview component which I have installed. Try running rustup component add llvm-tools-preview and see if that fixes LLD.
@alexcrichton@michaelwoerister it sounds like libLLVM.so should always by shipped with the compiler since rust-lld depends on it.
@japaric I installed them, but it didn't help. The LLVM tools do seem to work, and I now have the libLLVM.so library in the <rust-sysroot>/lib directory.
However, checking rust-lld's RPATH shows $ORIGIN/../lib,
i.e. it points to <rust-sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/lib/.
Activity
parasyte commentedon Aug 30, 2018
Searching the source tree for
rpathturns up some humorous comments...rust/src/bootstrap/bin/rustc.rs
Lines 199 to 232 in 4f1e235
rust/src/librustc_codegen_llvm/back/linker.rs
Lines 368 to 371 in 9d69e81
TejasQ commentedon Aug 30, 2018
I have this issue too!
GabrielMajeri commentedon Aug 30, 2018
I believe this issue is caused by 3cf6f0d: "Link LLVM tools dynamically...".
It only enables dynamic linking
libllvmon Linux and Mac OS, and since no Windows users complained so far I can only assume it's the probable cause.Speaking of which, it might be a good idea to add testing the built LLVM tools / LLD to Rust's CI, to ensure issues like this are caught earlier on.
japaric commentedon Aug 30, 2018
@alexcrichton @michaelwoerister this may have been caused by #53245.
Also, I don't see this issue on Linux:
GabrielMajeri commentedon Aug 30, 2018
@japaric I keep my toolchain updated with rustup, yet it seems I don't have
libllvm.so...?rustup updateoutput:japaric commentedon Aug 30, 2018
@GabrielMajeri it seems that libLLVM.so is provided by the
llvm-tools-previewcomponent which I have installed. Try runningrustup component add llvm-tools-previewand see if that fixes LLD.@alexcrichton @michaelwoerister it sounds like libLLVM.so should always by shipped with the compiler since rust-lld depends on it.
GabrielMajeri commentedon Aug 30, 2018
@japaric I installed them, but it didn't help. The LLVM tools do seem to work, and I now have the
libLLVM.solibrary in the<rust-sysroot>/libdirectory.However, checking rust-lld's RPATH shows
$ORIGIN/../lib,i.e. it points to
<rust-sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/lib/.Doing
does (temporarily) fix the problem.
alexcrichton commentedon Aug 30, 2018
I'm working on a fix for this!
rustbuild: Distribute libLLVM.so with rustc
alexcrichton commentedon Aug 30, 2018
@japaric's diagnosis is spot on and this should be fixed in #53828
To recap, interim fixes include:
rustup component add llvm-tools-preview --toolchain nightlyTejasQ commentedon Aug 30, 2018
Thanks, @alexcrichton!
Auto merge of #53828 - alexcrichton:dist-llvm-shared, r=japaric
pepyakin commentedon Aug 31, 2018
Doesn't work for me on macOS by the way.
thehappycoder commentedon Aug 31, 2018
Edit I was wrong. It's still nightly
I get this with stable rust too (1.28.0):
11 remaining items
rustbuild: Tweak LLVM distribution layout
Auto merge of #53955 - alexcrichton:fix-dist-again, r=<try>
TejasQ commentedon Sep 5, 2018
Thanks for your super-fast help, @alexcrichton! 🚀
Update for new nightly (hits rust-lang/rust#53813 on macOS though)
Auto merge of #53955 - alexcrichton:fix-dist-again, r=japaric
dvdplm commentedon Sep 6, 2018
For anyone wondering, the osx fix is not on the current nightly –
rustc 1.30.0-nightly (6e0f1cc15 2018-09-05)– yet.TejasQ commentedon Sep 6, 2018
Why's this issue closed then? 🤔
jcaudle commentedon Sep 6, 2018
Is it because the fix will be in tomorrow's nightly build?
alexcrichton commentedon Sep 6, 2018
Yes this fix missed last night's nightly but it should be in tonight's nightly!
kzvi commentedon Sep 7, 2018
I'm still getting this error with
rustc 1.30.0-nightly (a8c11d216 2018-09-06).alexcrichton commentedon Sep 7, 2018
Looks like there's at least one more bug to fix -- #54018
thehappycoder commentedon Sep 8, 2018
Finally, I managed to compile on a mac with the latest nightly build of rust!