Skip to content

Commit 418b1fa

Browse files
committed
Fix LLVM rebuild with download-ci-llvm.
1 parent 9cf699d commit 418b1fa

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/bootstrap/native.rs

+13
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,19 @@ pub(crate) fn maybe_download_ci_llvm(builder: &Builder<'_>) {
150150
for binary in ["llvm-config", "FileCheck"] {
151151
builder.fix_bin_or_dylib(&llvm_root.join("bin").join(binary));
152152
}
153+
154+
// Update the timestamp of llvm-config to force rustc_llvm to be
155+
// rebuilt. This is a hacky workaround for a deficiency in Cargo where
156+
// the rerun-if-changed directive doesn't handle changes very well.
157+
// https://github.com/rust-lang/cargo/issues/10791
158+
// Cargo only compares the timestamp of the file relative to the last
159+
// time `rustc_llvm` build script ran. However, the timestamps of the
160+
// files in the tarball are in the past, so it doesn't trigger a
161+
// rebuild.
162+
let now = filetime::FileTime::from_system_time(std::time::SystemTime::now());
163+
let llvm_config = llvm_root.join("bin/llvm-config");
164+
t!(filetime::set_file_times(&llvm_config, now, now));
165+
153166
let llvm_lib = llvm_root.join("lib");
154167
for entry in t!(fs::read_dir(&llvm_lib)) {
155168
let lib = t!(entry).path();

0 commit comments

Comments
 (0)