From: Eric Huss Date: Thu, 19 Apr 2018 02:54:01 +0000 (-0700) Subject: Add extra rustc/rustdoc args to the fingerprint and metadata. X-Git-Tag: archive/raspbian/0.35.0-2+rpi1~3^2^2^2^2^2^2^2~22^2~1^2~41^2~17 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=768f5739557074fa493dda01b8c3ca30fad610b4;p=cargo.git Add extra rustc/rustdoc args to the fingerprint and metadata. --- diff --git a/src/cargo/core/compiler/context/compilation_files.rs b/src/cargo/core/compiler/context/compilation_files.rs index e44414cb3..358d320e6 100644 --- a/src/cargo/core/compiler/context/compilation_files.rs +++ b/src/cargo/core/compiler/context/compilation_files.rs @@ -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 diff --git a/src/cargo/core/compiler/context/mod.rs b/src/cargo/core/compiler/context/mod.rs index f231c1308..f0ef400cd 100644 --- a/src/cargo/core/compiler/context/mod.rs +++ b/src/cargo/core/compiler/context/mod.rs @@ -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)>, + extra_compiler_args: Option<(Unit<'a>, Vec)>, 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> { + 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. diff --git a/src/cargo/core/compiler/fingerprint.rs b/src/cargo/core/compiler/fingerprint.rs index 35a7ca731..e41f546f4 100644 --- a/src/cargo/core/compiler/fingerprint.rs +++ b/src/cargo/core/compiler/fingerprint.rs @@ -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), diff --git a/src/cargo/core/compiler/mod.rs b/src/cargo/core/compiler/mod.rs index e4a661709..ad9ea2d0d 100644 --- a/src/cargo/core/compiler/mod.rs +++ b/src/cargo/core/compiler/mod.rs @@ -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,