Skip to content

Commit 2fd6057

Browse files
committed
Cache LLVM config invocations
1 parent 7379ff2 commit 2fd6057

File tree

5 files changed

+21
-6
lines changed

5 files changed

+21
-6
lines changed

src/bootstrap/src/core/build_steps/compile.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2022,6 +2022,7 @@ impl Step for Assemble {
20222022

20232023
let host_llvm_bin_dir = command(&host_llvm_config)
20242024
.arg("--bindir")
2025+
.cached()
20252026
.run_capture_stdout(builder)
20262027
.stdout()
20272028
.trim()

src/bootstrap/src/core/build_steps/dist.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2269,6 +2269,7 @@ fn maybe_install_llvm(
22692269
{
22702270
trace!("LLVM already built, installing LLVM files");
22712271
let mut cmd = command(host_llvm_config);
2272+
cmd.cached();
22722273
cmd.arg("--libfiles");
22732274
builder.verbose(|| println!("running {cmd:?}"));
22742275
let files = cmd.run_capture_stdout(builder).stdout();

src/bootstrap/src/core/build_steps/llvm.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -486,8 +486,11 @@ impl Step for Llvm {
486486
let LlvmResult { host_llvm_config, .. } =
487487
builder.ensure(Llvm { target: builder.config.host_target });
488488
if !builder.config.dry_run() {
489-
let llvm_bindir =
490-
command(&host_llvm_config).arg("--bindir").run_capture_stdout(builder).stdout();
489+
let llvm_bindir = command(&host_llvm_config)
490+
.arg("--bindir")
491+
.cached()
492+
.run_capture_stdout(builder)
493+
.stdout();
491494
let host_bin = Path::new(llvm_bindir.trim());
492495
cfg.define(
493496
"LLVM_TABLEGEN",
@@ -593,7 +596,13 @@ impl Step for Llvm {
593596
}
594597

595598
pub fn get_llvm_version(builder: &Builder<'_>, llvm_config: &Path) -> String {
596-
command(llvm_config).arg("--version").run_capture_stdout(builder).stdout().trim().to_owned()
599+
command(llvm_config)
600+
.arg("--version")
601+
.cached()
602+
.run_capture_stdout(builder)
603+
.stdout()
604+
.trim()
605+
.to_owned()
597606
}
598607

599608
pub fn get_llvm_version_major(builder: &Builder<'_>, llvm_config: &Path) -> u8 {

src/bootstrap/src/core/build_steps/test.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2043,6 +2043,7 @@ HELP: You can add it into `bootstrap.toml` in `rust.codegen-backends = [{name:?}
20432043
if !builder.config.dry_run() {
20442044
let llvm_version = get_llvm_version(builder, &host_llvm_config);
20452045
let llvm_components = command(&host_llvm_config)
2046+
.cached()
20462047
.arg("--components")
20472048
.run_capture_stdout(builder)
20482049
.stdout();
@@ -2062,8 +2063,11 @@ HELP: You can add it into `bootstrap.toml` in `rust.codegen-backends = [{name:?}
20622063
// separate compilations. We can add LLVM's library path to the
20632064
// rustc args as a workaround.
20642065
if !builder.config.dry_run() && suite.ends_with("fulldeps") {
2065-
let llvm_libdir =
2066-
command(&host_llvm_config).arg("--libdir").run_capture_stdout(builder).stdout();
2066+
let llvm_libdir = command(&host_llvm_config)
2067+
.cached()
2068+
.arg("--libdir")
2069+
.run_capture_stdout(builder)
2070+
.stdout();
20672071
let link_llvm = if target.is_msvc() {
20682072
format!("-Clink-arg=-LIBPATH:{llvm_libdir}")
20692073
} else {

src/bootstrap/src/core/builder/cargo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1082,7 +1082,7 @@ impl Builder<'_> {
10821082
&& let Some(llvm_config) = self.llvm_config(target)
10831083
{
10841084
let llvm_libdir =
1085-
command(llvm_config).arg("--libdir").run_capture_stdout(self).stdout();
1085+
command(llvm_config).cached().arg("--libdir").run_capture_stdout(self).stdout();
10861086
if target.is_msvc() {
10871087
rustflags.arg(&format!("-Clink-arg=-LIBPATH:{llvm_libdir}"));
10881088
} else {

0 commit comments

Comments
 (0)