diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index 8b8d4b237953..319aaafa549f 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -1275,7 +1275,8 @@ impl Build { options[0] = Some("-Clink-arg=-fuse-ld=lld".to_string()); } - let no_threads = util::lld_flag_no_threads(target.contains("windows")); + let no_threads = + util::lld_flag_no_threads(&self.initial_lld, target.contains("windows")); options[1] = Some(format!("-Clink-arg=-Wl,{no_threads}")); } diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index ba030f0f5251..0bf2cf2693b4 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -859,7 +859,10 @@ impl Step for RustdocTheme { if builder.is_fuse_ld_lld(self.compiler.host) { cmd.env( "RUSTDOC_LLD_NO_THREADS", - util::lld_flag_no_threads(self.compiler.host.contains("windows")), + util::lld_flag_no_threads( + &builder.initial_lld, + self.compiler.host.contains("windows"), + ), ); } builder.run_delaying_failure(&mut cmd); diff --git a/src/bootstrap/util.rs b/src/bootstrap/util.rs index 3c4a21434c00..847ad0c878a6 100644 --- a/src/bootstrap/util.rs +++ b/src/bootstrap/util.rs @@ -479,10 +479,11 @@ pub fn get_clang_cl_resource_dir(clang_cl_path: &str) -> PathBuf { clang_rt_dir.to_path_buf() } -pub fn lld_flag_no_threads(is_windows: bool) -> &'static str { +/// Find out which thread flags should be passed to LLD. +pub fn lld_flag_no_threads(lld: &Path, is_windows: bool) -> &'static str { static LLD_NO_THREADS: OnceCell<(&'static str, &'static str)> = OnceCell::new(); let (windows, other) = LLD_NO_THREADS.get_or_init(|| { - let out = output(Command::new("lld").arg("-flavor").arg("ld").arg("--version")); + let out = output(Command::new(lld).arg("-flavor").arg("ld").arg("--version")); let newer = match (out.find(char::is_numeric), out.find('.')) { (Some(b), Some(e)) => out.as_str()[b..e].parse::().ok().unwrap_or(14) > 10, _ => true,