From 5118a51b4d49a139ea21d280001105948de298f7 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Sun, 6 Sep 2020 22:07:14 +0300 Subject: [PATCH] rustbuild: Propagate LLD to more places when `use-lld` is enabled --- src/bootstrap/bin/rustc.rs | 3 +++ src/bootstrap/bin/rustdoc.rs | 5 ++++- src/bootstrap/builder.rs | 8 +++++++- src/bootstrap/test.rs | 5 ++++- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs index 4dd71ebade1a4..3694bdbf67054 100644 --- a/src/bootstrap/bin/rustc.rs +++ b/src/bootstrap/bin/rustc.rs @@ -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" { diff --git a/src/bootstrap/bin/rustdoc.rs b/src/bootstrap/bin/rustdoc.rs index ab846adf9423b..cb58eb89ad870 100644 --- a/src/bootstrap/bin/rustdoc.rs +++ b/src/bootstrap/bin/rustdoc.rs @@ -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") { diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 33b03d57dd43c..ca2e159d2d948 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -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 } @@ -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); diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index f56c994523c13..98a219e39792d 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -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); }