diff options
| author | Rémy Rakic <remy.rakic+github@gmail.com> | 2023-06-03 16:19:09 +0000 |
|---|---|---|
| committer | Rémy Rakic <remy.rakic+github@gmail.com> | 2023-06-03 16:19:09 +0000 |
| commit | 17d321cd11a938ac3eaeeded12969d6b83f9aa26 (patch) | |
| tree | a5e04718a9deb723451bc90e8d2949cb24ce6bb8 | |
| parent | 7d5b746e1c83f23bc015e73582e102528f05db24 (diff) | |
| download | rust-17d321cd11a938ac3eaeeded12969d6b83f9aa26.tar.gz rust-17d321cd11a938ac3eaeeded12969d6b83f9aa26.zip | |
rust-lld: add rpath to the root LLVM shared lib
rust-lld is not located in the same directory as the other binaries that point to ../lib, but in a deeper directory in lib. So we need to point a few layers up for rust-lld to find the LLVM shared library without rustup's LD_LIBRARY_PATH overrides.
| -rw-r--r-- | src/bootstrap/llvm.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/bootstrap/llvm.rs b/src/bootstrap/llvm.rs index 3fd0cca40e5..ab7906d0383 100644 --- a/src/bootstrap/llvm.rs +++ b/src/bootstrap/llvm.rs @@ -834,6 +834,30 @@ impl Step for Lld { } } + // LLD is built as an LLVM tool, but is distributed outside of the `llvm-tools` component, + // which impacts where it expects to find LLVM's shared library. This causes #80703. + // + // LLD is distributed at "$root/lib/rustlib/$host/bin/rust-lld", but the `libLLVM-*.so` it + // needs is distributed at "$root/lib". The default rpath of "$ORIGIN/../lib" points at the + // lib path for LLVM tools, not the one for rust binaries. + // + // (The `llvm-tools` component copies the .so there for the other tools, and with that + // component installed, one can successfully invoke `rust-lld` directly without rustup's + // `LD_LIBRARY_PATH` overrides) + // + if builder.config.rust_rpath + && builder.config.llvm_link_shared() + && target.contains("linux") + { + // So we inform LLD where it can find LLVM's libraries by adding an rpath entry to the + // expected parent `lib` directory. + // + // Be careful when changing this path, we need to ensure it's quoted or escaped: + // `$ORIGIN` would otherwise be expanded when the `LdFlags` are passed verbatim to + // cmake. + ldflags.push_all("-Wl,-rpath,'$ORIGIN/../../../'"); + } + configure_cmake(builder, target, &mut cfg, true, ldflags, &[]); configure_llvm(builder, target, &mut cfg); |
