Skip to content

Commit b61f3cc

Browse files
committed
Auto merge of #6473 - Eh2406:rustc-0, r=alexcrichton
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.
2 parents 1dff476 + eb8720a commit b61f3cc

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/cargo/core/compiler/fingerprint.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,11 @@ pub fn prepare_build_cmd<'a, 'cfg>(
545545
debug!("fingerprint at: {}", loc.display());
546546

547547
let (local, output_path) = build_script_local_fingerprints(cx, unit)?;
548-
let mut fingerprint = Fingerprint { local, ..Fingerprint::new() };
548+
let mut fingerprint = Fingerprint {
549+
local,
550+
rustc: util::hash_u64(&cx.bcx.rustc.verbose_version),
551+
..Fingerprint::new()
552+
};
549553
let compare = compare_old_fingerprint(&loc, &fingerprint);
550554
log_compare(unit, &compare);
551555

@@ -648,6 +652,10 @@ fn local_fingerprints_deps(
648652
}
649653

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

0 commit comments

Comments
 (0)