Skip to content

Commit 3aaeb13

Browse files
committed
bootstrap: Memoize the LLVM rebuild hash to avoid very slow x check
1 parent 601a427 commit 3aaeb13

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,15 @@ pub fn prebuilt_llvm_config(
105105
let llvm_cmake_dir = out_dir.join("lib/cmake/llvm");
106106
let res = LlvmResult { llvm_config: build_llvm_config, llvm_cmake_dir };
107107

108-
let smart_stamp_hash = generate_smart_stamp_hash(
109-
&builder.config.src.join("src/llvm-project"),
110-
&builder.in_tree_llvm_info.sha().unwrap_or_default(),
111-
);
108+
let smart_stamp_hash = builder.llvm_stamp_hash.get_or_init(|| {
109+
generate_smart_stamp_hash(
110+
&builder.config.src.join("src/llvm-project"),
111+
&builder.in_tree_llvm_info.sha().unwrap_or_default(),
112+
)
113+
});
112114

113115
let stamp = out_dir.join("llvm-finished-building");
114-
let stamp = HashStamp::new(stamp, Some(&smart_stamp_hash));
116+
let stamp = HashStamp::new(stamp, Some(smart_stamp_hash));
115117

116118
if stamp.is_done() {
117119
if stamp.hash.is_none() {

src/bootstrap/src/core/builder.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use std::io::{BufRead, BufReader};
1010
use std::ops::Deref;
1111
use std::path::{Path, PathBuf};
1212
use std::process::Command;
13+
use std::sync::OnceLock;
1314
use std::time::{Duration, Instant};
1415

1516
use crate::core::build_steps::llvm;
@@ -44,6 +45,7 @@ pub struct Builder<'a> {
4445
stack: RefCell<Vec<Box<dyn Any>>>,
4546
time_spent_on_dependencies: Cell<Duration>,
4647
pub paths: Vec<PathBuf>,
48+
pub(crate) llvm_stamp_hash: OnceLock<String>,
4749
}
4850

4951
impl<'a> Deref for Builder<'a> {
@@ -917,6 +919,7 @@ impl<'a> Builder<'a> {
917919
stack: RefCell::new(Vec::new()),
918920
time_spent_on_dependencies: Cell::new(Duration::new(0, 0)),
919921
paths,
922+
llvm_stamp_hash: OnceLock::new(),
920923
}
921924
}
922925

0 commit comments

Comments
 (0)