Skip to content

Commit e960ab8

Browse files
bootstrap: Make LLD available to run-make tests.
1 parent 0644eb6 commit e960ab8

File tree

1 file changed

+27
-14
lines changed

1 file changed

+27
-14
lines changed

src/bootstrap/tool.rs

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use std::fs;
22
use std::env;
3-
use std::iter;
43
use std::path::PathBuf;
54
use std::process::{Command, exit};
65
use std::collections::HashSet;
@@ -666,27 +665,41 @@ impl<'a> Builder<'a> {
666665

667666
// Add the llvm/bin directory to PATH since it contains lots of
668667
// useful, platform-independent tools
669-
if tool.uses_llvm_tools() {
668+
if tool.uses_llvm_tools() && !self.config.dry_run {
669+
let mut additional_paths = vec![];
670+
670671
if let Some(llvm_bin_path) = self.llvm_bin_path() {
671-
if host.contains("windows") {
672-
// On Windows, PATH and the dynamic library path are the same,
673-
// so we just add the LLVM bin path to lib_path
674-
lib_paths.push(llvm_bin_path);
675-
} else {
676-
let old_path = env::var_os("PATH").unwrap_or_default();
677-
let new_path = env::join_paths(iter::once(llvm_bin_path)
678-
.chain(env::split_paths(&old_path)))
679-
.expect("Could not add LLVM bin path to PATH");
680-
cmd.env("PATH", new_path);
681-
}
672+
additional_paths.push(llvm_bin_path);
673+
}
674+
675+
// If LLD is available, add that too.
676+
if self.config.lld_enabled {
677+
let lld_install_root = self.ensure(native::Lld {
678+
target: self.config.build,
679+
});
680+
681+
let lld_bin_path = lld_install_root.join("bin");
682+
additional_paths.push(lld_bin_path);
683+
}
684+
685+
if host.contains("windows") {
686+
// On Windows, PATH and the dynamic library path are the same,
687+
// so we just add the LLVM bin path to lib_path
688+
lib_paths.extend(additional_paths);
689+
} else {
690+
let old_path = env::var_os("PATH").unwrap_or_default();
691+
let new_path = env::join_paths(additional_paths.into_iter()
692+
.chain(env::split_paths(&old_path)))
693+
.expect("Could not add LLVM bin path to PATH");
694+
cmd.env("PATH", new_path);
682695
}
683696
}
684697

685698
add_lib_path(lib_paths, cmd);
686699
}
687700

688701
fn llvm_bin_path(&self) -> Option<PathBuf> {
689-
if self.config.llvm_enabled && !self.config.dry_run {
702+
if self.config.llvm_enabled {
690703
let llvm_config = self.ensure(native::Llvm {
691704
target: self.config.build,
692705
emscripten: false,

0 commit comments

Comments
 (0)