Skip to content

Commit

Permalink
Restore prior behavior with less duplicate info in dep file
Browse files Browse the repository at this point in the history
  • Loading branch information
Xaeroxe committed Oct 2, 2024
1 parent 15efbc6 commit b48c5f1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 22 deletions.
35 changes: 14 additions & 21 deletions compiler/rustc_interface/src/passes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -536,35 +536,16 @@ 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()
.map(|(path, _file_len, _checksum_hash_algo)| path.as_str())
.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
Expand Down Expand Up @@ -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(())
};

Expand Down
4 changes: 3 additions & 1 deletion tests/run-make/checksum-freshness/expected.d
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit b48c5f1

Please sign in to comment.