Skip to content
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: add rpath entry to the correct lib folder #112247

Merged
merged 2 commits into from
Jun 4, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/bootstrap/llvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Mark-Simulacrum marked this conversation as resolved.
Show resolved Hide resolved
{
// 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);

Expand Down