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
This commit is contained in:
Jorge Aparicio 2018-06-29 22:20:00 -05:00
parent 1029775ad5
commit 807cd36381
3 changed files with 13 additions and 5 deletions

View File

@ -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

View File

@ -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);
}

View File

@ -51,6 +51,9 @@ pub fn target() -> Result<Target, String> {
// 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 {