Skip to content

Commit 3a2a442

Browse files
committed
Avoid llvm-config in more situations, like bootstrap test runs
1 parent e1a6a30 commit 3a2a442

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

src/bootstrap/builder.rs

+19-8
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,20 @@ impl<'a> Builder<'a> {
698698
cmd
699699
}
700700

701+
/// Return the path to `llvm-config` for the target, if it exists.
702+
///
703+
/// Note that this returns `None` if LLVM is disabled, or if we're in a
704+
/// check build or dry-run, where there's no need to build all of LLVM.
705+
fn llvm_config(&self, target: Interned<String>) -> Option<PathBuf> {
706+
if self.config.llvm_enabled() && self.kind != Kind::Check && !self.config.dry_run {
707+
let llvm_config = self.ensure(native::Llvm { target });
708+
if llvm_config.is_file() {
709+
return Some(llvm_config);
710+
}
711+
}
712+
None
713+
}
714+
701715
/// Prepares an invocation of `cargo` to be run.
702716
///
703717
/// This will create a `Command` that represents a pending execution of
@@ -1038,14 +1052,11 @@ impl<'a> Builder<'a> {
10381052
// requirement, but the `-L` library path is not propagated across
10391053
// separate Cargo projects. We can add LLVM's library path to the
10401054
// platform-specific environment variable as a workaround.
1041-
//
1042-
// Note that this is disabled if LLVM itself is disabled or we're in a
1043-
// check build, where if we're in a check build there's no need to build
1044-
// all of LLVM and such.
1045-
if self.config.llvm_enabled() && self.kind != Kind::Check && mode == Mode::ToolRustc {
1046-
let llvm_config = self.ensure(native::Llvm { target });
1047-
let llvm_libdir = output(Command::new(&llvm_config).arg("--libdir"));
1048-
add_link_lib_path(vec![llvm_libdir.trim().into()], &mut cargo);
1055+
if mode == Mode::ToolRustc {
1056+
if let Some(llvm_config) = self.llvm_config(target) {
1057+
let llvm_libdir = output(Command::new(&llvm_config).arg("--libdir"));
1058+
add_link_lib_path(vec![llvm_libdir.trim().into()], &mut cargo);
1059+
}
10491060
}
10501061

10511062
if self.config.incremental {

0 commit comments

Comments
 (0)