diff --git a/src/bootstrap/download-ci-llvm-stamp b/src/bootstrap/download-ci-llvm-stamp index 58691539edfa3..7c2096206166d 100644 --- a/src/bootstrap/download-ci-llvm-stamp +++ b/src/bootstrap/download-ci-llvm-stamp @@ -1,4 +1,4 @@ Change this file to make users of the `download-ci-llvm` configuration download a new version of LLVM from CI, even if the LLVM submodule hasn’t changed. -Last change is for: https://github.com/rust-lang/rust/pull/163954 +Last change is for: https://github.com/rust-lang/rust/pull/164064 diff --git a/src/bootstrap/src/core/build_steps/llvm.rs b/src/bootstrap/src/core/build_steps/llvm.rs index 4ac0f6ea85679..10d6e84b0cc19 100644 --- a/src/bootstrap/src/core/build_steps/llvm.rs +++ b/src/bootstrap/src/core/build_steps/llvm.rs @@ -561,6 +561,24 @@ impl CommandLineStep for Llvm { cfg.define("LLVM_LINK_LLVM_DYLIB", "ON"); // Keep the pre-LLVM23 behavior for now. cfg.define("LLVM_VERSIONED_DYLIB_NAME_ON_DARWIN", "OFF"); + + // `llvm-objcopy` is also shipped in the `rustc` component as + // "$root/lib/rustlib/$host/bin/rust-objcopy", where the default rpath of + // "$ORIGIN/../lib" does not reach the LLVM shared library distributed at "$root/lib". + // Add the same rpath entry as `Lld::run` does for `rust-lld`, so `rust-objcopy` can + // be invoked without rustup's library path overrides or the `llvm-tools` component. + // + // 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. + if builder.config.rpath_enabled(target) && helpers::use_host_linker(target) { + if target.contains("linux") { + ldflags.exe.push(" -Wl,-rpath,'$ORIGIN/../../../'"); + } + if target.contains("apple-darwin") { + ldflags.exe.push(" -Wl,-rpath,'@loader_path/../../../'"); + } + } } if (target.starts_with("csky")