Skip to content

Commit 8d08c2e

Browse files
authored
Rollup merge of #64156 - cuviper:gitless-llvm, r=alexcrichton
Assume non-git LLVM is fresh if the stamp file exists Rustbuild usually writes the LLVM submodule commit in a stamp file, so we can avoid rebuilding it unnecessarily. However, for builds from a source tarball (non-git), we were assuming a rebuild is always needed. This can cause a lot of extra work if any environment like `CFLAGS` changed between steps like build and install, which are often separate in distro builds. Now we also write an empty stamp file if the git commit is unknown, and its presence is trusted to indicate that no rebuild is needed. An info message reports that this is happening, along with the stamp file path that can be deleted to force a rebuild anyway. Fixes #61206.
2 parents c686756 + 53fe764 commit 8d08c2e

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

src/bootstrap/native.rs

+14-13
Original file line numberDiff line numberDiff line change
@@ -81,26 +81,29 @@ impl Step for Llvm {
8181
(info, "src/llvm-project/llvm", builder.llvm_out(target), dir.join("bin"))
8282
};
8383

84-
if !llvm_info.is_git() {
85-
println!(
86-
"git could not determine the LLVM submodule commit hash. \
87-
Assuming that an LLVM build is necessary.",
88-
);
89-
}
90-
9184
let build_llvm_config = llvm_config_ret_dir
9285
.join(exe("llvm-config", &*builder.config.build));
9386
let done_stamp = out_dir.join("llvm-finished-building");
9487

95-
if let Some(llvm_commit) = llvm_info.sha() {
96-
if done_stamp.exists() {
88+
if done_stamp.exists() {
89+
if let Some(llvm_commit) = llvm_info.sha() {
9790
let done_contents = t!(fs::read(&done_stamp));
9891

9992
// If LLVM was already built previously and the submodule's commit didn't change
10093
// from the previous build, then no action is required.
10194
if done_contents == llvm_commit.as_bytes() {
102-
return build_llvm_config
95+
return build_llvm_config;
10396
}
97+
} else {
98+
builder.info(
99+
"Could not determine the LLVM submodule commit hash. \
100+
Assuming that an LLVM rebuild is not necessary.",
101+
);
102+
builder.info(&format!(
103+
"To force LLVM to rebuild, remove the file `{}`",
104+
done_stamp.display()
105+
));
106+
return build_llvm_config;
104107
}
105108
}
106109

@@ -303,9 +306,7 @@ impl Step for Llvm {
303306

304307
cfg.build();
305308

306-
if let Some(llvm_commit) = llvm_info.sha() {
307-
t!(fs::write(&done_stamp, llvm_commit));
308-
}
309+
t!(fs::write(&done_stamp, llvm_info.sha().unwrap_or("")));
309310

310311
build_llvm_config
311312
}

0 commit comments

Comments
 (0)