Skip to content

Commit

Permalink
Auto merge of #6473 - Eh2406:rustc-0, r=alexcrichton
Browse files Browse the repository at this point in the history
don't write a an incorrect rustc version to the fingerprint file

In making holmgr/cargo-sweep#14 I noted that some fingerprint files related to build scripts report being built with a rustc that hashes to "0". To work around this I just marked them as still being needed, even though no rustc that hashes to "0" is currently installed.

I believe that this PR just filles in the correct info for the build script fingerprints. This makes it possible for outside tools to more reliably clean up after cargo, at basically no cost.
@ehuss Thanks again for the help.
  • Loading branch information
bors committed Dec 21, 2018
2 parents 1dff476 + eb8720a commit b61f3cc
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/cargo/core/compiler/fingerprint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,11 @@ pub fn prepare_build_cmd<'a, 'cfg>(
debug!("fingerprint at: {}", loc.display());

let (local, output_path) = build_script_local_fingerprints(cx, unit)?;
let mut fingerprint = Fingerprint { local, ..Fingerprint::new() };
let mut fingerprint = Fingerprint {
local,
rustc: util::hash_u64(&cx.bcx.rustc.verbose_version),
..Fingerprint::new()
};
let compare = compare_old_fingerprint(&loc, &fingerprint);
log_compare(unit, &compare);

Expand Down Expand Up @@ -648,6 +652,10 @@ fn local_fingerprints_deps(
}

fn write_fingerprint(loc: &Path, fingerprint: &Fingerprint) -> CargoResult<()> {
debug_assert_ne!(fingerprint.rustc, 0);
// fingerprint::new().rustc == 0, make sure it doesn't make it to the file system.
// This is mostly so outside tools can reliably find out what rust version this file is for,
// as we can use the full hash.
let hash = fingerprint.hash();
debug!("write fingerprint: {}", loc.display());
paths::write(loc, util::to_hex(hash).as_bytes())?;
Expand Down

0 comments on commit b61f3cc

Please sign in to comment.