Skip to content

Commit 807cd36

Browse files
committed
rename rustc's lld to rust-lld
to not shadow the system installed LLD when linking with LLD. Before: - `-C linker=lld -Z linker-flavor=ld.lld` uses rustc's LLD - It's not possible to use a system installed LLD that's named `lld` With this commit: - `-C linker=rust-lld -Z linker-flavor=ld.lld` uses rustc's LLD - `-C linker=lld -Z linker-flavor=ld.lld` uses the system installed LLD
1 parent 1029775 commit 807cd36

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

src/bootstrap/compile.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -786,8 +786,11 @@ fn copy_lld_to_sysroot(builder: &Builder,
786786
.join("bin");
787787
t!(fs::create_dir_all(&dst));
788788

789-
let exe = exe("lld", &target);
790-
builder.copy(&lld_install_root.join("bin").join(&exe), &dst.join(&exe));
789+
let src_exe = exe("lld", &target);
790+
let dst_exe = exe("rust-lld", &target);
791+
// we prepend this bin directory to the user PATH when linking Rust binaries. To
792+
// avoid shadowing the system LLD we rename the LLD we provide to `rust-lld`.
793+
builder.copy(&lld_install_root.join("bin").join(&src_exe), &dst.join(&dst_exe));
791794
}
792795

793796
/// Cargo's output path for the standard library in a given stage, compiled

src/bootstrap/dist.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -491,16 +491,18 @@ impl Step for Rustc {
491491

492492
// Copy over lld if it's there
493493
if builder.config.lld_enabled {
494-
let exe = exe("lld", &compiler.host);
494+
let src_exe = exe("lld", &compiler.host);
495+
let dst_exe = exe("rust-lld", &compiler.host);
495496
let src = builder.sysroot_libdir(compiler, host)
496497
.parent()
497498
.unwrap()
498499
.join("bin")
499-
.join(&exe);
500+
.join(&src_exe);
501+
// for the rationale about this rename check `compile::copy_lld_to_sysroot`
500502
let dst = image.join("lib/rustlib")
501503
.join(&*host)
502504
.join("bin")
503-
.join(&exe);
505+
.join(&dst_exe);
504506
t!(fs::create_dir_all(&dst.parent().unwrap()));
505507
builder.copy(&src, &dst);
506508
}

src/librustc_target/spec/wasm32_unknown_unknown.rs

+3
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ pub fn target() -> Result<Target, String> {
5151
// no dynamic linking, no need for default visibility!
5252
default_hidden_visibility: true,
5353

54+
// we use the LLD shipped with the Rust toolchain by default
55+
linker: Some("rust-lld".to_owned()),
56+
5457
.. Default::default()
5558
};
5659
Ok(Target {

0 commit comments

Comments
 (0)