about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorEric Huss <eric@huss.org>2022-06-25 16:49:00 -0700
committerEric Huss <eric@huss.org>2022-06-25 16:49:00 -0700
commit418b1fa77af366b3784c35d88927ec7f4d869dea (patch)
tree64e85728fef4070e15d05a07fa3d9955fe819555 /src
parent9cf699d2ff4ff23a6d6862a35727f4d5d3567dae (diff)
downloadrust-418b1fa77af366b3784c35d88927ec7f4d869dea.tar.gz
rust-418b1fa77af366b3784c35d88927ec7f4d869dea.zip
Fix LLVM rebuild with download-ci-llvm.
Diffstat (limited to 'src')
-rw-r--r--src/bootstrap/native.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs
index 329bb68672e..ea410849694 100644
--- a/src/bootstrap/native.rs
+++ b/src/bootstrap/native.rs
@@ -150,6 +150,19 @@ pub(crate) fn maybe_download_ci_llvm(builder: &Builder<'_>) {
         for binary in ["llvm-config", "FileCheck"] {
             builder.fix_bin_or_dylib(&llvm_root.join("bin").join(binary));
         }
+
+        // Update the timestamp of llvm-config to force rustc_llvm to be
+        // rebuilt. This is a hacky workaround for a deficiency in Cargo where
+        // the rerun-if-changed directive doesn't handle changes very well.
+        // https://github.com/rust-lang/cargo/issues/10791
+        // Cargo only compares the timestamp of the file relative to the last
+        // time `rustc_llvm` build script ran. However, the timestamps of the
+        // files in the tarball are in the past, so it doesn't trigger a
+        // rebuild.
+        let now = filetime::FileTime::from_system_time(std::time::SystemTime::now());
+        let llvm_config = llvm_root.join("bin/llvm-config");
+        t!(filetime::set_file_times(&llvm_config, now, now));
+
         let llvm_lib = llvm_root.join("lib");
         for entry in t!(fs::read_dir(&llvm_lib)) {
             let lib = t!(entry).path();