Skip to content

Commit 860d299

Browse files
committed
Auto merge of #7952 - ehuss:fingerprint-mtime-debug-extra, r=alexcrichton
Add more fingerprint mtime debug logging. Adding some more debug logging on top of #7888. There was a mistake in the original PR, where `dep.pkg_id` should have been `dep.name`.
2 parents cc5a5e5 + 298b770 commit 860d299

File tree

4 files changed

+21
-12
lines changed

4 files changed

+21
-12
lines changed

src/cargo/core/compiler/custom_build.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,11 @@ fn build_work<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) -> CargoRes
364364
// state informing what variables were discovered via our script as
365365
// well.
366366
paths::write(&output_file, &output.stdout)?;
367+
log::debug!(
368+
"rewinding custom script output mtime {:?} to {}",
369+
output_file,
370+
timestamp
371+
);
367372
filetime::set_file_times(output_file, timestamp, timestamp)?;
368373
paths::write(&err_file, &output.stderr)?;
369374
paths::write(&root_output_file, util::path2bytes(&script_out_dir)?)?;

src/cargo/core/compiler/fingerprint.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,7 @@ impl Fingerprint {
796796
// This path failed to report its `mtime`. It probably doesn't
797797
// exists, so leave ourselves as stale and bail out.
798798
Err(e) => {
799-
log::debug!("failed to get mtime of {:?}: {}", output, e);
799+
debug!("failed to get mtime of {:?}: {}", output, e);
800800
return Ok(());
801801
}
802802
};
@@ -830,26 +830,26 @@ impl Fingerprint {
830830
// If our dependency edge only requires the rmeta file to be present
831831
// then we only need to look at that one output file, otherwise we
832832
// need to consider all output files to see if we're out of date.
833-
let dep_mtime = if dep.only_requires_rmeta {
833+
let (dep_path, dep_mtime) = if dep.only_requires_rmeta {
834834
dep_mtimes
835835
.iter()
836-
.filter_map(|(path, mtime)| {
837-
if path.extension().and_then(|s| s.to_str()) == Some("rmeta") {
838-
Some(mtime)
839-
} else {
840-
None
841-
}
836+
.filter(|(path, _mtime)| {
837+
path.extension().and_then(|s| s.to_str()) == Some("rmeta")
842838
})
843839
.next()
844840
.expect("failed to find rmeta")
845841
} else {
846-
match dep_mtimes.values().max() {
847-
Some(mtime) => mtime,
842+
match dep_mtimes.iter().max_by_key(|kv| kv.1) {
843+
Some(dep_mtime) => dep_mtime,
848844
// If our dependencies is up to date and has no filesystem
849845
// interactions, then we can move on to the next dependency.
850846
None => continue,
851847
}
852848
};
849+
debug!(
850+
"max dep mtime for {:?} is {:?} {}",
851+
pkg_root, dep_path, dep_mtime
852+
);
853853

854854
// If the dependency is newer than our own output then it was
855855
// recompiled previously. We transitively become stale ourselves in
@@ -861,7 +861,7 @@ impl Fingerprint {
861861
if dep_mtime > max_mtime {
862862
info!(
863863
"dependency on `{}` is newer than we are {} > {} {:?}",
864-
dep.pkg_id, dep_mtime, max_mtime, pkg_root
864+
dep.name, dep_mtime, max_mtime, pkg_root
865865
);
866866
return Ok(());
867867
}
@@ -1410,6 +1410,7 @@ fn compare_old_fingerprint(
14101410
if mtime_on_use {
14111411
// update the mtime so other cleaners know we used it
14121412
let t = FileTime::from_system_time(SystemTime::now());
1413+
debug!("mtime-on-use forcing {:?} to {}", loc, t);
14131414
filetime::set_file_times(loc, t, t)?;
14141415
}
14151416

src/cargo/core/compiler/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@ fn rustc<'a, 'cfg>(
322322
rustc_dep_info_loc.display()
323323
))
324324
})?;
325+
debug!("rewinding mtime of {:?} to {}", dep_info_loc, timestamp);
325326
filetime::set_file_times(dep_info_loc, timestamp, timestamp)?;
326327
}
327328

src/cargo/util/paths.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,9 @@ pub fn set_invocation_time(path: &Path) -> CargoResult<FileTime> {
192192
&timestamp,
193193
b"This file has an mtime of when this was started.",
194194
)?;
195-
mtime(&timestamp)
195+
let ft = mtime(&timestamp)?;
196+
log::debug!("invocation time for {:?} is {}", path, ft);
197+
Ok(ft)
196198
}
197199

198200
#[cfg(unix)]

0 commit comments

Comments
 (0)