Cache LLVM config invocations

This commit is contained in:
Jakub Beránek 2025-08-25 14:39:34 +02:00
parent 7379ff2809
commit 2fd6057c31
No known key found for this signature in database
GPG key ID: 909CD0D26483516B
5 changed files with 21 additions and 6 deletions

View file

@ -2022,6 +2022,7 @@ impl Step for Assemble {
let host_llvm_bin_dir = command(&host_llvm_config)
.arg("--bindir")
.cached()
.run_capture_stdout(builder)
.stdout()
.trim()

View file

@ -2269,6 +2269,7 @@ fn maybe_install_llvm(
{
trace!("LLVM already built, installing LLVM files");
let mut cmd = command(host_llvm_config);
cmd.cached();
cmd.arg("--libfiles");
builder.verbose(|| println!("running {cmd:?}"));
let files = cmd.run_capture_stdout(builder).stdout();

View file

@ -486,8 +486,11 @@ impl Step for Llvm {
let LlvmResult { host_llvm_config, .. } =
builder.ensure(Llvm { target: builder.config.host_target });
if !builder.config.dry_run() {
let llvm_bindir =
command(&host_llvm_config).arg("--bindir").run_capture_stdout(builder).stdout();
let llvm_bindir = command(&host_llvm_config)
.arg("--bindir")
.cached()
.run_capture_stdout(builder)
.stdout();
let host_bin = Path::new(llvm_bindir.trim());
cfg.define(
"LLVM_TABLEGEN",
@ -593,7 +596,13 @@ impl Step for Llvm {
}
pub fn get_llvm_version(builder: &Builder<'_>, llvm_config: &Path) -> String {
command(llvm_config).arg("--version").run_capture_stdout(builder).stdout().trim().to_owned()
command(llvm_config)
.arg("--version")
.cached()
.run_capture_stdout(builder)
.stdout()
.trim()
.to_owned()
}
pub fn get_llvm_version_major(builder: &Builder<'_>, llvm_config: &Path) -> u8 {

View file

@ -2043,6 +2043,7 @@ HELP: You can add it into `bootstrap.toml` in `rust.codegen-backends = [{name:?}
if !builder.config.dry_run() {
let llvm_version = get_llvm_version(builder, &host_llvm_config);
let llvm_components = command(&host_llvm_config)
.cached()
.arg("--components")
.run_capture_stdout(builder)
.stdout();
@ -2062,8 +2063,11 @@ HELP: You can add it into `bootstrap.toml` in `rust.codegen-backends = [{name:?}
// separate compilations. We can add LLVM's library path to the
// rustc args as a workaround.
if !builder.config.dry_run() && suite.ends_with("fulldeps") {
let llvm_libdir =
command(&host_llvm_config).arg("--libdir").run_capture_stdout(builder).stdout();
let llvm_libdir = command(&host_llvm_config)
.cached()
.arg("--libdir")
.run_capture_stdout(builder)
.stdout();
let link_llvm = if target.is_msvc() {
format!("-Clink-arg=-LIBPATH:{llvm_libdir}")
} else {

View file

@ -1082,7 +1082,7 @@ impl Builder<'_> {
&& let Some(llvm_config) = self.llvm_config(target)
{
let llvm_libdir =
command(llvm_config).arg("--libdir").run_capture_stdout(self).stdout();
command(llvm_config).cached().arg("--libdir").run_capture_stdout(self).stdout();
if target.is_msvc() {
rustflags.arg(&format!("-Clink-arg=-LIBPATH:{llvm_libdir}"));
} else {