Restore prior behavior with less duplicate info in dep file

This commit is contained in:
Jacob Kiesel 2024-10-01 23:05:24 -06:00
parent 15efbc6e8d
commit b48c5f19e0
2 changed files with 17 additions and 22 deletions

View File

@ -536,9 +536,9 @@ fn write_out_deps(tcx: TyCtxt<'_>, outputs: &OutputFilenames, out_filenames: &[P
let write_deps_to_file = |file: &mut dyn Write| -> io::Result<()> {
for path in out_filenames {
write!(
writeln!(
file,
"{}: {}",
"{}: {}\n",
path.display(),
files
.iter()
@ -546,25 +546,6 @@ fn write_out_deps(tcx: TyCtxt<'_>, outputs: &OutputFilenames, out_filenames: &[P
.intersperse(" ")
.collect::<String>()
)?;
// If caller requested this information, add special comments about source file checksums.
// These are not necessarily the same checksums as was used in the debug files.
if sess.opts.unstable_opts.checksum_hash_algorithm().is_some() {
assert!(
files.iter().all(|(_path, _file_len, hash_algo)| hash_algo.is_some()),
"all files must have a checksum hash computed to output checksum hashes"
);
write!(file, " #")?;
files
.iter()
.filter_map(|(_path, file_len, hash_algo)| {
hash_algo.map(|hash_algo| (path, file_len, hash_algo))
})
.try_for_each(|(_path, file_len, checksum_hash)| {
write!(file, " checksum:{checksum_hash} file_len:{file_len}")
})?;
}
write!(file, "\n\n")?;
}
// Emit a fake target for each input file to the compilation. This
@ -594,6 +575,18 @@ fn write_out_deps(tcx: TyCtxt<'_>, outputs: &OutputFilenames, out_filenames: &[P
}
}
// If caller requested this information, add special comments about source file checksums.
// These are not necessarily the same checksums as was used in the debug files.
if sess.opts.unstable_opts.checksum_hash_algorithm().is_some() {
for (path, file_len, checksum_hash) in
files.iter().filter_map(|(path, file_len, hash_algo)| {
hash_algo.map(|hash_algo| (path, file_len, hash_algo))
})
{
writeln!(file, "# checksum:{checksum_hash} file_len:{file_len} {path}")?;
}
}
Ok(())
};

View File

@ -1,4 +1,6 @@
lib.d: lib.rs foo.rs # checksum:blake3=94af75ee4ed805434484c3de51c9025278e5c3ada2315e2592052e102168a503 file_len:120 checksum:blake3=2720e17bfda4f3b2a5c96bb61b7e76ed8ebe3359b34128c0e5d8032c090a4f1a file_len:119
lib.d: lib.rs foo.rs
lib.rs:
foo.rs:
# checksum:blake3=94af75ee4ed805434484c3de51c9025278e5c3ada2315e2592052e102168a503 file_len:120 lib.rs
# checksum:blake3=2720e17bfda4f3b2a5c96bb61b7e76ed8ebe3359b34128c0e5d8032c090a4f1a file_len:119 foo.rs