about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEric Huss <eric@huss.org>2020-07-04 14:46:04 -0700
committerEric Huss <eric@huss.org>2020-07-04 14:46:04 -0700
commit310c97b6ba7e6b8d4e3e7f337db0cff97f45f5c0 (patch)
tree335d865a3c2132b1add0a1a73027e7455340f10c
parent0cd7ff7ddfb75a38dca81ad3e76b1e984129e939 (diff)
downloadrust-310c97b6ba7e6b8d4e3e7f337db0cff97f45f5c0.tar.gz
rust-310c97b6ba7e6b8d4e3e7f337db0cff97f45f5c0.zip
Fix caching issue when building tools.
-rw-r--r--src/bootstrap/bin/rustc.rs4
-rw-r--r--src/bootstrap/builder.rs18
2 files changed, 18 insertions, 4 deletions
diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs
index 3072a4a1ae7..fd36cd9bd8b 100644
--- a/src/bootstrap/bin/rustc.rs
+++ b/src/bootstrap/bin/rustc.rs
@@ -76,6 +76,10 @@ fn main() {
         cmd.env("RUST_BACKTRACE", "1");
     }
 
+    if let Ok(lint_flags) = env::var("RUSTC_LINT_FLAGS") {
+        cmd.args(lint_flags.split_whitespace());
+    }
+
     if target.is_some() {
         // The stage0 compiler has a special sysroot distinct from what we
         // actually downloaded, so we just always pass the `--sysroot` option,
diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs
index 3cbecbbaa06..557fb1aa550 100644
--- a/src/bootstrap/builder.rs
+++ b/src/bootstrap/builder.rs
@@ -1130,22 +1130,32 @@ impl<'a> Builder<'a> {
         cargo.env("RUSTC_VERBOSE", self.verbosity.to_string());
 
         if source_type == SourceType::InTree {
+            let mut lint_flags = Vec::new();
             // When extending this list, add the new lints to the RUSTFLAGS of the
             // build_bootstrap function of src/bootstrap/bootstrap.py as well as
             // some code doesn't go through this `rustc` wrapper.
-            rustflags.arg("-Wrust_2018_idioms");
-            rustflags.arg("-Wunused_lifetimes");
+            lint_flags.push("-Wrust_2018_idioms");
+            lint_flags.push("-Wunused_lifetimes");
 
             if self.config.deny_warnings {
-                rustflags.arg("-Dwarnings");
+                lint_flags.push("-Dwarnings");
             }
 
             // FIXME(#58633) hide "unused attribute" errors in incremental
             // builds of the standard library, as the underlying checks are
             // not yet properly integrated with incremental recompilation.
             if mode == Mode::Std && compiler.stage == 0 && self.config.incremental {
-                rustflags.arg("-Aunused-attributes");
+                lint_flags.push("-Aunused-attributes");
             }
+            // This does not use RUSTFLAGS due to caching issues with Cargo.
+            // Clippy is treated as an "in tree" tool, but shares the same
+            // cache as other "submodule" tools. With these options set in
+            // RUSTFLAGS, that causes *every* shared dependency to be rebuilt.
+            // By injecting this into the rustc wrapper, this circumvents
+            // Cargo's fingerprint detection. This is fine because lint flags
+            // are always ignored in dependencies. Eventually this should be
+            // fixed via better support from Cargo.
+            cargo.env("RUSTC_LINT_FLAGS", lint_flags.join(" "));
         }
 
         if let Mode::Rustc | Mode::Codegen = mode {