about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMark Rousskov <mark.simulacrum@gmail.com>2020-05-02 18:39:33 -0400
committerMark Rousskov <mark.simulacrum@gmail.com>2020-05-02 18:43:55 -0400
commit7f645aba107e4b952c1ed47178ff74c5976b2663 (patch)
treec0ef206680bbe3ef303c830ff643a8c2f083f698
parent131e120585e635929051a6b3e0b450eb943a3636 (diff)
downloadrust-7f645aba107e4b952c1ed47178ff74c5976b2663.tar.gz
rust-7f645aba107e4b952c1ed47178ff74c5976b2663.zip
Don't skip building LLVM if already built
-rw-r--r--src/bootstrap/builder.rs12
-rw-r--r--src/bootstrap/compile.rs10
-rw-r--r--src/librustc_llvm/build.rs2
3 files changed, 18 insertions, 6 deletions
diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs
index c0018c613ba..a878c730706 100644
--- a/src/bootstrap/builder.rs
+++ b/src/bootstrap/builder.rs
@@ -765,9 +765,17 @@ impl<'a> Builder<'a> {
         }
 
         // Set a flag for `check`/`clippy`/`fix`, so that certain build
-        // scripts can do less work (e.g. not building/requiring LLVM).
+        // scripts can do less work (i.e. not building/requiring LLVM).
         if cmd == "check" || cmd == "clippy" || cmd == "fix" {
-            cargo.env("RUST_CHECK", "1");
+            // If we've not yet built LLVM, or it's stale, then bust
+            // the librustc_llvm cache. That will always work, even though it
+            // may mean that on the next non-check build we'll need to rebuild
+            // librustc_llvm. But if LLVM is stale, that'll be a tiny amount
+            // of work comparitively, and we'd likely need to rebuild it anyway,
+            // so that's okay.
+            if crate::native::prebuilt_llvm_config(self, target).is_err() {
+                cargo.env("RUST_CHECK", "1");
+            }
         }
 
         let stage = if compiler.stage == 0 && self.local_rebuild {
diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs
index 0a193d91244..0c754936bc2 100644
--- a/src/bootstrap/compile.rs
+++ b/src/bootstrap/compile.rs
@@ -517,9 +517,13 @@ pub fn rustc_cargo_env(builder: &Builder<'_>, cargo: &mut Cargo, target: Interne
     // librustc_llvm and librustc_codegen_llvm.
     //
     // Note that this is disabled if LLVM itself is disabled or we're in a check
-    // build, where if we're in a check build there's no need to build all of
-    // LLVM and such.
-    if builder.config.llvm_enabled() && builder.kind != Kind::Check {
+    // build. If we are in a check build we still go ahead here presuming we've
+    // detected that LLVM is alreay built and good to go which helps prevent
+    // busting caches (e.g. like #71152).
+    if builder.config.llvm_enabled()
+        && (builder.kind != Kind::Check
+            || crate::native::prebuilt_llvm_config(builder, target).is_ok())
+    {
         if builder.is_rust_llvm(target) {
             cargo.env("LLVM_RUSTLLVM", "1");
         }
diff --git a/src/librustc_llvm/build.rs b/src/librustc_llvm/build.rs
index f14fc9fc2eb..e97fa4345fe 100644
--- a/src/librustc_llvm/build.rs
+++ b/src/librustc_llvm/build.rs
@@ -15,9 +15,9 @@ fn detect_llvm_link() -> (&'static str, &'static str) {
 }
 
 fn main() {
+    println!("cargo:rerun-if-env-changed=RUST_CHECK");
     if env::var_os("RUST_CHECK").is_some() {
         // If we're just running `check`, there's no need for LLVM to be built.
-        println!("cargo:rerun-if-env-changed=RUST_CHECK");
         return;
     }