From: Nathanael Jones Date: Tue, 7 Feb 2017 00:16:33 +0000 (-0700) Subject: Fix #3658 .cargo/config prevents freshness (sort if sourced from HashMap) X-Git-Tag: archive/raspbian/0.35.0-2+rpi1~3^2^2^2^2^2^2^2~22^2~9^2~163^2~5 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=22096dee1c72f8aa35aae6edaab908bf18e6e504;p=cargo.git Fix #3658 .cargo/config prevents freshness (sort if sourced from HashMap) --- diff --git a/src/cargo/ops/cargo_compile.rs b/src/cargo/ops/cargo_compile.rs index ec13b2a2e..acc2fdf35 100644 --- a/src/cargo/ops/cargo_compile.rs +++ b/src/cargo/ops/cargo_compile.rs @@ -528,6 +528,10 @@ fn scrape_target_config(config: &Config, triple: &str) output.metadata.push((k.clone(), val.to_string())); } } + + // We randomized the data source with HashMaps, so we must sort the resulting vectors + // to produce a deterministic result + output.sort(); } ret.overrides.insert(lib_name, output); } diff --git a/src/cargo/ops/cargo_rustc/custom_build.rs b/src/cargo/ops/cargo_rustc/custom_build.rs index ea3e0f98c..431559868 100644 --- a/src/cargo/ops/cargo_rustc/custom_build.rs +++ b/src/cargo/ops/cargo_rustc/custom_build.rs @@ -406,6 +406,17 @@ impl BuildOutput { } Ok((library_paths, library_links)) } + + /// Sort the contents of the struct for consistent hashing. + /// Suggested if populated from a HashMap instead of a order-preserving data source + pub fn sort(&mut self){ + self.library_paths.sort(); + self.library_links.sort(); + self.cfgs.sort(); + self.metadata.sort(); + self.rerun_if_changed.sort(); + self.warnings.sort(); + } } /// Compute the `build_scripts` map in the `Context` which tracks what build