Skip to content

Commit 22bae0c

Browse files
committed
fix caching/rebuild logic
1 parent d4c38c0 commit 22bae0c

File tree

1 file changed

+25
-3
lines changed
  • src/bootstrap/src/core/build_steps

1 file changed

+25
-3
lines changed

Diff for: src/bootstrap/src/core/build_steps/llvm.rs

+25-3
Original file line numberDiff line numberDiff line change
@@ -881,13 +881,35 @@ impl Step for Enzyme {
881881

882882
let LlvmResult { llvm_config, .. } = builder.ensure(Llvm { target: self.target });
883883

884+
static STAMP_HASH_MEMO: OnceLock<String> = OnceLock::new();
885+
let smart_stamp_hash = STAMP_HASH_MEMO.get_or_init(|| {
886+
generate_smart_stamp_hash(
887+
builder,
888+
&builder.config.src.join("src/tools/enzyme"),
889+
builder.enzyme_info.sha().unwrap_or_default(),
890+
)
891+
});
892+
884893
let out_dir = builder.enzyme_out(target);
885-
let done_stamp = out_dir.join("enzyme-finished-building");
886-
if done_stamp.exists() {
894+
let stamp = out_dir.join("enzyme-finished-building");
895+
let stamp = HashStamp::new(stamp, Some(smart_stamp_hash));
896+
897+
if stamp.is_done() {
898+
if stamp.hash.is_none() {
899+
builder.info(
900+
"Could not determine the Enzyme submodule commit hash. \
901+
Assuming that an Enzyme rebuild is not necessary.",
902+
);
903+
builder.info(&format!(
904+
"To force Enzyme to rebuild, remove the file `{}`",
905+
stamp.path.display()
906+
));
907+
}
887908
return out_dir;
888909
}
889910

890911
builder.info(&format!("Building Enzyme for {}", target));
912+
t!(stamp.remove());
891913
let _time = helpers::timeit(builder);
892914
t!(fs::create_dir_all(&out_dir));
893915

@@ -915,7 +937,7 @@ impl Step for Enzyme {
915937

916938
cfg.build();
917939

918-
t!(File::create(&done_stamp));
940+
t!(stamp.write());
919941
out_dir
920942
}
921943
}

0 commit comments

Comments
 (0)