Skip to content

Commit

Permalink
rustbuild: Propagate LLD to more places when use-lld is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
petrochenkov committed Sep 6, 2020
1 parent 8e6b563 commit 5118a51
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/bootstrap/bin/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ fn main() {
if let Ok(host_linker) = env::var("RUSTC_HOST_LINKER") {
cmd.arg(format!("-Clinker={}", host_linker));
}
if env::var_os("RUSTC_HOST_FUSE_LD_LLD").is_some() {
cmd.arg("-Clink-args=-fuse-ld=lld");
}

if let Ok(s) = env::var("RUSTC_HOST_CRT_STATIC") {
if s == "true" {
Expand Down
5 changes: 4 additions & 1 deletion src/bootstrap/bin/rustdoc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,14 @@ fn main() {
if env::var_os("RUSTC_FORCE_UNSTABLE").is_some() {
cmd.arg("-Z").arg("force-unstable-if-unmarked");
}
if let Some(linker) = env::var_os("RUSTC_TARGET_LINKER") {
if let Some(linker) = env::var_os("RUSTDOC_LINKER") {
let mut arg = OsString::from("-Clinker=");
arg.push(&linker);
cmd.arg(arg);
}
if env::var_os("RUSTDOC_FUSE_LD_LLD").is_some() {
cmd.arg("-Clink-args=-fuse-ld=lld");
}

// Needed to be able to run all rustdoc tests.
if let Some(ref x) = env::var_os("RUSTDOC_RESOURCE_SUFFIX") {
Expand Down
8 changes: 7 additions & 1 deletion src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,10 @@ impl<'a> Builder<'a> {
cmd.env_remove("MFLAGS");

if let Some(linker) = self.linker(compiler.host) {
cmd.env("RUSTC_TARGET_LINKER", linker);
cmd.env("RUSTDOC_LINKER", linker);
}
if self.config.use_lld && !compiler.host.contains("msvc") {
cmd.env("RUSTDOC_FUSE_LD_LLD", "1");
}
cmd
}
Expand Down Expand Up @@ -1044,6 +1047,9 @@ impl<'a> Builder<'a> {
if let Some(host_linker) = self.linker(compiler.host) {
cargo.env("RUSTC_HOST_LINKER", host_linker);
}
if self.config.use_lld && !compiler.host.contains("msvc") {
cargo.env("RUSTC_HOST_FUSE_LD_LLD", "1");
}

if let Some(target_linker) = self.linker(target) {
let target = crate::envify(&target.triple);
Expand Down
5 changes: 4 additions & 1 deletion src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,10 @@ impl Step for RustdocTheme {
.env("RUSTDOC_REAL", builder.rustdoc(self.compiler))
.env("RUSTC_BOOTSTRAP", "1");
if let Some(linker) = builder.linker(self.compiler.host) {
cmd.env("RUSTC_TARGET_LINKER", linker);
cmd.env("RUSTDOC_LINKER", linker);
}
if builder.config.use_lld && !self.compiler.host.contains("msvc") {
cmd.env("RUSTDOC_FUSE_LD_LLD", "1");
}
try_run(builder, &mut cmd);
}
Expand Down

0 comments on commit 5118a51

Please sign in to comment.