-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
rust-lld fails with "dyld: Library not loaded: @rpath/libLLVM.dylib" on 1.30.0-nightly (02cb8f2a4 2018-08-29) #53813
Comments
Searching the source tree for 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
|
I have this issue too! |
I believe this issue is caused by 3cf6f0d: "Link LLVM tools dynamically...". It only enables dynamic linking 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. |
@alexcrichton @michaelwoerister this may have been caused by #53245. Also, I don't see this issue on Linux: $ ldd $(rustc --print sysroot)/lib/rustlib/x86_64-unknown-linux-gnu/bin/rust-lld
linux-vdso.so.1 (0x00007ffe1cd74000)
libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007fab8c935000)
libLLVM-7.so => /home/japaric/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/libLLVM-7.so (0x00007fab88ecb000)
libm.so.6 => /usr/lib/libm.so.6 (0x00007fab88d46000)
libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x00007fab88d2c000)
libc.so.6 => /usr/lib/libc.so.6 (0x00007fab88b68000)
/lib64/ld-linux-x86-64.so.2 => /usr/lib64/ld-linux-x86-64.so.2 (0x00007fab8c984000)
librt.so.1 => /usr/lib/librt.so.1 (0x00007fab88b5c000)
libdl.so.2 => /usr/lib/libdl.so.2 (0x00007fab88b57000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007fab889c8000)
$ $(rustc --print sysroot)/lib/rustlib/x86_64-unknown-linux-gnu/bin/rust-lld -flavor gnu -version
LLD 7.0.0 (compatible with GNU linkers)
$ rustc -V
rustc 1.30.0-nightly (02cb8f2a4 2018-08-29) |
@japaric I keep my toolchain updated with rustup, yet it seems I don't have
|
@GabrielMajeri it seems that libLLVM.so is provided by the @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 However, checking rust-lld's RPATH shows Doing
does (temporarily) fix the problem. |
I'm working on a fix for this! |
A recent change (rust-lang#53245) started to build LLVM with ThinLTO enabled and to ensure that compile times are kept down it builds LLVM dynamically by default to ensure that all the various LLVM tools aren't redoing all that optimization work. This means, however, that all LLVM tools depend on LLVM's dynamic library by default. While the LLVM tools and LLDB components were updated to include the shared library we accidentally forgot about LLD, included with the main rustc component. LLD also links dynamically to LLVM and ships a non-working binary right now because of this! This commit updates our distribution to ship the LLVM dynamic library with the compiler libraries. While not technically needed for rustc itself to operate (right now) it may be needed for LLD, and otherwise it serves as a good basis for the other LLVM tools components to work with as well. This should... Closes rust-lang#53813
Thanks, @alexcrichton! |
rustbuild: Distribute libLLVM.so with rustc A recent change (#53245) started to build LLVM with ThinLTO enabled and to ensure that compile times are kept down it builds LLVM dynamically by default to ensure that all the various LLVM tools aren't redoing all that optimization work. This means, however, that all LLVM tools depend on LLVM's dynamic library by default. While the LLVM tools and LLDB components were updated to include the shared library we accidentally forgot about LLD, included with the main rustc component. LLD also links dynamically to LLVM and ships a non-working binary right now because of this! This commit updates our distribution to ship the LLVM dynamic library with the compiler libraries. While not technically needed for rustc itself to operate (right now) it may be needed for LLD, and otherwise it serves as a good basis for the other LLVM tools components to work with as well. This should... Closes #53813
Doesn't work for me on macOS by the way. |
Edit I was wrong. It's still nightly I get this with stable rust too (1.28.0):
|
@thehappycoder |
@fitzgen thanks for pointing out. I just noticed that it is using nightly version. I am new to rust, so I have no idea how to rollback to previous nightly version to use as a workaround. |
For future reference, you can use rustup to install any nightly, for instructions see the rustup github page. |
Still getting this issue on the latest nightly:
|
It seems to work fine for me (on arch linux)
|
I agree with @pepyakin It is still not working on macOS.
|
Seems like a number of people (including myself) are still having this issue, can we re-open? |
Apparently #53828 did not fix this entirely on Mac OS X. |
I'm working on a fix for this and should be able to post it soon |
I'm getting this on Linux too: https://travis-ci.org/intermezzOS/kernel/jobs/424491132#L185 |
This commit tweaks the layout of a few components that we distribute to hopefully fix across all platforms the recent issues with LLD being unable to find the LLVM shared object. In rust-lang#53245 we switched to building LLVM as a dynamic library, which means that LLVM tools by default link to LLVM dynamically rather than statically. This in turn means that the tools, at runtime, need to find the LLVM shared library. LLVM's shared library is currently distributed as part of the rustc component. This library is located, however, at `$sysroot/lib`. The LLVM tools we ship are in two locations: * LLD is shipped at `$sysroot/lib/rustlib/$host/bin/rust-lld` * Other LLVM tools are shipped at `$sysroot/bin` Each LLVM tool has an embedded rpath directive indicating where it will search for dynamic libraries. This currently points to `../lib` and is presumably inserted by LLVM's build system. Unfortunately, though, this directive is only correct for the LLVM tools at `$sysroot/bin`, not LLD! This commit is targeted at fixing this situation by making two changes: * LLVM tools other than LLD are moved in the distribution to `$sysroot/lib/rustlib/$host/bin`. This moves them next to LLD and should position them for... * The LLVM shared object is moved to `$sysroot/lib/rustlib/$host/lib` Together this means that all tools should natively be able to find the shared object and the shared object should be installed all the time for the various tools. Overall this should... Closes rust-lang#53813
rustbuild: Tweak LLVM distribution layout This commit tweaks the layout of a few components that we distribute to hopefully fix across all platforms the recent issues with LLD being unable to find the LLVM shared object. In #53245 we switched to building LLVM as a dynamic library, which means that LLVM tools by default link to LLVM dynamically rather than statically. This in turn means that the tools, at runtime, need to find the LLVM shared library. LLVM's shared library is currently distributed as part of the rustc component. This library is located, however, at `$sysroot/lib`. The LLVM tools we ship are in two locations: * LLD is shipped at `$sysroot/lib/rustlib/$host/bin/rust-lld` * Other LLVM tools are shipped at `$sysroot/bin` Each LLVM tool has an embedded rpath directive indicating where it will search for dynamic libraries. This currently points to `../lib` and is presumably inserted by LLVM's build system. Unfortunately, though, this directive is only correct for the LLVM tools at `$sysroot/bin`, not LLD! This commit is targeted at fixing this situation by making two changes: * LLVM tools other than LLD are moved in the distribution to `$sysroot/lib/rustlib/$host/bin`. This moves them next to LLD and should position them for... * The LLVM shared object is moved to `$sysroot/lib/rustlib/$host/lib` Together this means that all tools should natively be able to find the shared object and the shared object should be installed all the time for the various tools. Overall this should... Closes #53813
Thanks for your super-fast help, @alexcrichton! 🚀 |
This commit tweaks the layout of a few components that we distribute to hopefully fix across all platforms the recent issues with LLD being unable to find the LLVM shared object. In rust-lang#53245 we switched to building LLVM as a dynamic library, which means that LLVM tools by default link to LLVM dynamically rather than statically. This in turn means that the tools, at runtime, need to find the LLVM shared library. LLVM's shared library is currently distributed as part of the rustc component. This library is located, however, at `$sysroot/lib`. The LLVM tools we ship are in two locations: * LLD is shipped at `$sysroot/lib/rustlib/$host/bin/rust-lld` * Other LLVM tools are shipped at `$sysroot/bin` Each LLVM tool has an embedded rpath directive indicating where it will search for dynamic libraries. This currently points to `../lib` and is presumably inserted by LLVM's build system. Unfortunately, though, this directive is only correct for the LLVM tools at `$sysroot/bin`, not LLD! This commit is targeted at fixing this situation by making two changes: * LLVM tools other than LLD are moved in the distribution to `$sysroot/lib/rustlib/$host/bin`. This moves them next to LLD and should position them for... * The LLVM shared object is moved to `$sysroot/lib/rustlib/$host/lib` Together this means that all tools should natively be able to find the shared object and the shared object should be installed all the time for the various tools. Overall this should... Closes rust-lang#53813
rustbuild: Tweak LLVM distribution layout This commit tweaks the layout of a few components that we distribute to hopefully fix across all platforms the recent issues with LLD being unable to find the LLVM shared object. In #53245 we switched to building LLVM as a dynamic library, which means that LLVM tools by default link to LLVM dynamically rather than statically. This in turn means that the tools, at runtime, need to find the LLVM shared library. LLVM's shared library is currently distributed as part of the rustc component. This library is located, however, at `$sysroot/lib`. The LLVM tools we ship are in two locations: * LLD is shipped at `$sysroot/lib/rustlib/$host/bin/rust-lld` * Other LLVM tools are shipped at `$sysroot/bin` Each LLVM tool has an embedded rpath directive indicating where it will search for dynamic libraries. This currently points to `../lib` and is presumably inserted by LLVM's build system. Unfortunately, though, this directive is only correct for the LLVM tools at `$sysroot/bin`, not LLD! This commit is targeted at fixing this situation by making two changes: * LLVM tools other than LLD are moved in the distribution to `$sysroot/lib/rustlib/$host/bin`. This moves them next to LLD and should position them for... * The LLVM shared object is moved to `$sysroot/lib/rustlib/$host/lib` Together this means that all tools should natively be able to find the shared object and the shared object should be installed all the time for the various tools. Overall this should... Closes #53813
For anyone wondering, the osx fix is not on the current nightly – |
Why's this issue closed then? 🤔 |
Is it because the fix will be in tomorrow's nightly build? |
Yes this fix missed last night's nightly but it should be in tonight's nightly! |
I'm still getting this error with |
Looks like there's at least one more bug to fix -- #54018 |
Finally, I managed to compile on a mac with the latest nightly build of rust! |
Short description: I am building for a
no_std
environment usingcargo-xbuild
, and the embeddedlld
as my linker of choice. The linker fails to load since it depends on a dynamic library that doesn't actually exist.Rolling back to
nightly-2018-08-27-x86_64-apple-darwin
worksThe text was updated successfully, but these errors were encountered: