From 807cd3638192a86e51c9bd0018144d32214f2b9d Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Fri, 29 Jun 2018 22:20:00 -0500 Subject: [PATCH 1/2] 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 --- src/bootstrap/compile.rs | 7 +++++-- src/bootstrap/dist.rs | 8 +++++--- src/librustc_target/spec/wasm32_unknown_unknown.rs | 3 +++ 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index 11d9154ba696c..50023b3a3be8d 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -786,8 +786,11 @@ fn copy_lld_to_sysroot(builder: &Builder, .join("bin"); t!(fs::create_dir_all(&dst)); - let exe = exe("lld", &target); - builder.copy(&lld_install_root.join("bin").join(&exe), &dst.join(&exe)); + let src_exe = exe("lld", &target); + let dst_exe = exe("rust-lld", &target); + // we prepend this bin directory to the user PATH when linking Rust binaries. To + // avoid shadowing the system LLD we rename the LLD we provide to `rust-lld`. + builder.copy(&lld_install_root.join("bin").join(&src_exe), &dst.join(&dst_exe)); } /// Cargo's output path for the standard library in a given stage, compiled diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index 4fd6c81e59786..c61f360544ff8 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -491,16 +491,18 @@ impl Step for Rustc { // Copy over lld if it's there if builder.config.lld_enabled { - let exe = exe("lld", &compiler.host); + let src_exe = exe("lld", &compiler.host); + let dst_exe = exe("rust-lld", &compiler.host); let src = builder.sysroot_libdir(compiler, host) .parent() .unwrap() .join("bin") - .join(&exe); + .join(&src_exe); + // for the rationale about this rename check `compile::copy_lld_to_sysroot` let dst = image.join("lib/rustlib") .join(&*host) .join("bin") - .join(&exe); + .join(&dst_exe); t!(fs::create_dir_all(&dst.parent().unwrap())); builder.copy(&src, &dst); } diff --git a/src/librustc_target/spec/wasm32_unknown_unknown.rs b/src/librustc_target/spec/wasm32_unknown_unknown.rs index 56170bbb869f3..6f51495bae9d6 100644 --- a/src/librustc_target/spec/wasm32_unknown_unknown.rs +++ b/src/librustc_target/spec/wasm32_unknown_unknown.rs @@ -51,6 +51,9 @@ pub fn target() -> Result { // no dynamic linking, no need for default visibility! default_hidden_visibility: true, + // we use the LLD shipped with the Rust toolchain by default + linker: Some("rust-lld".to_owned()), + .. Default::default() }; Ok(Target { From 31ed5c7a01d9826c10bdd166ffcd23efd95b1efe Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Wed, 4 Jul 2018 23:10:10 -0500 Subject: [PATCH 2/2] in the second copy lld is already named rust-lld --- src/bootstrap/dist.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index c61f360544ff8..381e4beec4d17 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -491,18 +491,17 @@ impl Step for Rustc { // Copy over lld if it's there if builder.config.lld_enabled { - let src_exe = exe("lld", &compiler.host); - let dst_exe = exe("rust-lld", &compiler.host); + let exe = exe("rust-lld", &compiler.host); let src = builder.sysroot_libdir(compiler, host) .parent() .unwrap() .join("bin") - .join(&src_exe); + .join(&exe); // for the rationale about this rename check `compile::copy_lld_to_sysroot` let dst = image.join("lib/rustlib") .join(&*host) .join("bin") - .join(&dst_exe); + .join(&exe); t!(fs::create_dir_all(&dst.parent().unwrap())); builder.copy(&src, &dst); }