Add extra rustc/rustdoc args to the fingerprint and metadata.
authorEric Huss <eric@huss.org>
Thu, 19 Apr 2018 02:54:01 +0000 (19:54 -0700)
committerEric Huss <eric@huss.org>
Fri, 27 Apr 2018 20:42:30 +0000 (13:42 -0700)
src/cargo/core/compiler/context/compilation_files.rs
src/cargo/core/compiler/context/mod.rs
src/cargo/core/compiler/fingerprint.rs
src/cargo/core/compiler/mod.rs

index e44414cb3366fe2a033c7f9daaf841d8ecf92c8d..358d320e6ca9576104471dfad6a25fa106f1018b 100644 (file)
@@ -427,6 +427,9 @@ fn compute_metadata<'a, 'cfg>(
     // settings like debuginfo and whatnot.
     unit.profile.hash(&mut hasher);
     unit.mode.hash(&mut hasher);
+    if let Some(ref args) = cx.extra_args_for(unit) {
+        args.hash(&mut hasher);
+    }
 
     // Artifacts compiled for the host should have a different metadata
     // piece than those compiled for the target, so make sure we throw in
index f231c13084a639b79dadcd1c546c595d69e2e104..f0ef400cd2d8f4a485ef6a10fbdf6898cddf0990 100644 (file)
@@ -97,7 +97,7 @@ pub struct Context<'a, 'cfg: 'a> {
     /// rustc` and `cargo rustdoc`.  These commands only support one target,
     /// but we don't want the args passed to any dependencies, so we include
     /// the `Unit` corresponding to the top-level target.
-    pub extra_compiler_args: Option<(Unit<'a>, Vec<String>)>,
+    extra_compiler_args: Option<(Unit<'a>, Vec<String>)>,
 
     target_info: TargetInfo,
     host_info: TargetInfo,
@@ -559,6 +559,15 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
             Kind::Target => &self.target_info,
         }
     }
+
+    pub fn extra_args_for(&self, unit: &Unit<'a>) -> Option<&Vec<String>> {
+        if let Some((ref args_unit, ref args)) = self.extra_compiler_args {
+            if args_unit == unit {
+                return Some(args);
+            }
+        }
+        None
+    }
 }
 
 /// Acquire extra flags to pass to the compiler from various locations.
index 35a7ca73169065c3e10857251c308add5c4c668e..e41f546f4ea1169a63444f69f08eb517380499fd 100644 (file)
@@ -102,7 +102,7 @@ pub fn prepare_target<'a, 'cfg>(
         }
     }
 
-    let allow_failure = cx.extra_compiler_args.is_some();
+    let allow_failure = cx.extra_args_for(unit).is_some();
     let target_root = cx.files().target_root().to_path_buf();
     let write_fingerprint = Work::new(move |_| {
         match fingerprint.update_local(&target_root) {
@@ -454,10 +454,16 @@ fn calculate<'a, 'cfg>(
     } else {
         cx.rustflags_args(unit)?
     };
+    let profile_hash = util::hash_u64(&(
+        &unit.profile,
+        unit.mode,
+        cx.extra_args_for(unit),
+        cx.incremental_args(unit)?,
+    ));
     let fingerprint = Arc::new(Fingerprint {
         rustc: util::hash_u64(&cx.build_config.rustc.verbose_version),
         target: util::hash_u64(&unit.target),
-        profile: util::hash_u64(&(&unit.profile, unit.mode, cx.incremental_args(unit)?)),
+        profile: profile_hash,
         // Note that .0 is hashed here, not .1 which is the cwd. That doesn't
         // actually affect the output artifact so there's no need to hash it.
         path: util::hash_u64(&super::path_args(cx, unit).0),
index e4a6617091cb18677d6e5860c7c0845d3567dd74..ad9ea2d0d5f939a154046acc1ac3dda069417a47 100644 (file)
@@ -777,10 +777,8 @@ fn rustdoc<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) -> CargoResult
         rustdoc.arg(format!("--edition={}", &manifest.edition()));
     }
 
-    if let Some((ref args_unit, ref args)) = cx.extra_compiler_args {
-        if args_unit == unit {
-            rustdoc.args(args);
-        }
+    if let Some(ref args) = cx.extra_args_for(unit) {
+        rustdoc.args(args);
     }
 
     build_deps_args(&mut rustdoc, cx, unit)?;
@@ -944,10 +942,8 @@ fn build_base_args<'a, 'cfg>(
         cmd.arg("-C").arg(format!("debuginfo={}", debuginfo));
     }
 
-    if let Some((ref args_unit, ref args)) = cx.extra_compiler_args {
-        if args_unit == unit {
-            cmd.args(args);
-        }
+    if let Some(ref args) = cx.extra_args_for(unit) {
+        cmd.args(args);
     }
 
     // -C overflow-checks is implied by the setting of -C debug-assertions,