Skip to content

Commit d2c71ca

Browse files
committed
minimal changes to get the test to pass
1 parent b106390 commit d2c71ca

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

src/cargo/core/compiler/custom_build.rs

+4
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,10 @@ fn build_work<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) -> CargoRes
332332
state.build_plan(invocation_name, cmd.clone(), Arc::new(Vec::new()));
333333
} else {
334334
state.running(&cmd);
335+
paths::write(
336+
&output_file.with_file_name("invoked.timestamp"),
337+
b"This file has an mtime of when this build-script was started.",
338+
)?;
335339
let output = if extra_verbose {
336340
let prefix = format!("[{} {}] ", id.name(), id.version());
337341
state.capture_output(&cmd, Some(prefix), true)

src/cargo/core/compiler/fingerprint.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ impl Fingerprint {
239239
for local in self.local.iter() {
240240
match *local {
241241
LocalFingerprint::MtimeBased(ref slot, ref path) => {
242-
let path = root.join(path);
242+
let path = root.join(&path.with_file_name("invoked.timestamp"));
243243
let mtime = paths::mtime(&path)?;
244244
*slot.0.lock().unwrap() = Some(mtime);
245245
}
@@ -746,7 +746,7 @@ where
746746
I: IntoIterator,
747747
I::Item: AsRef<Path>,
748748
{
749-
let mtime = match paths::mtime(output) {
749+
let mtime = match paths::mtime(&output.with_file_name("invoked.timestamp")) {
750750
Ok(mtime) => mtime,
751751
Err(..) => return None,
752752
};
@@ -764,14 +764,14 @@ where
764764
// Note that equal mtimes are considered "stale". For filesystems with
765765
// not much timestamp precision like 1s this is a conservative approximation
766766
// to handle the case where a file is modified within the same second after
767-
// a build finishes. We want to make sure that incremental rebuilds pick that up!
767+
// a build starts. We want to make sure that incremental rebuilds pick that up!
768768
//
769769
// For filesystems with nanosecond precision it's been seen in the wild that
770770
// its "nanosecond precision" isn't really nanosecond-accurate. It turns out that
771771
// kernels may cache the current time so files created at different times actually
772772
// list the same nanosecond precision. Some digging on #5919 picked up that the
773773
// kernel caches the current time between timer ticks, which could mean that if
774-
// a file is updated at most 10ms after a build finishes then Cargo may not
774+
// a file is updated at most 10ms after a build starts then Cargo may not
775775
// pick up the build changes.
776776
//
777777
// All in all, the equality check here is a conservative assumption that,

src/cargo/core/compiler/mod.rs

+4
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,10 @@ fn rustc<'a, 'cfg>(
292292
}
293293

294294
state.running(&rustc);
295+
paths::write(
296+
&dep_info_loc.with_file_name("invoked.timestamp"),
297+
b"This file has an mtime of when rustc was started.",
298+
)?;
295299
if json_messages {
296300
exec.exec_json(
297301
rustc,

0 commit comments

Comments
 (0)