-
Notifications
You must be signed in to change notification settings - Fork 2.7k
fix(fingerprint): force update mtime of cargo-check artifacts #16262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
See rust-lang/cargo 16104 for what we're testing against
This mtime shift for .rmeta is a workaround as rustc incremental build since rust-lang/rust 114669 (1.90.0) skips unnecessary rmeta generation. The situation is like this: 1. When build script execution's external dependendies (rerun-if-changed, rerun-if-env-changed) got updated, the execution unit reran and got a newer mtime. 2. rustc type-checked the associated crate, though with incremental compilation, no rmeta regeneration. Its `.rmeta` stays old. 3. Run `cargo check` again. Cargo found build script execution had a new mtime than existing crate rmeta, so re-checking the crate. However the check is a no-op (input has no change), so stuck.
|
It would be nice for us to have a way to have early cut off but we can look into how to get both later The next question is what to do about beta
Thoughts? |
|
We probably want to backport to beta ASAP, as this affects rust-lang/rust developers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, doing this on mobile seemed to have failed me
| // 3. Run `cargo check` again. Cargo found build script execution had | ||
| // a new mtime than existing crate rmeta, so re-checking the crate. | ||
| // However the check is a no-op (input has no change), so stuck. | ||
| if mode.is_check() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it make sense to do this for all modes?
I guess eventually we have to clarify the contract between rustc and cargo here: is rustc allowed to just do nothing if an output file is up-to-date, or is it required to always at least update the mtime?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I personally don't think rustc should care and update mtime.
keeping this patch small and suitable for backport, but yeah to be more robust and future proof, we probably want to do it for all modes, or at least adding tests to capture possible regression in a full cargo build.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other build systems will probably get confused by the exact same issue, so perhaps this should actually be changed in rustc itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, though OTOH a build system also shouldn't get into an internally inconsistent state (like what we saw in #16104) just because a tool it invokes has slightly odd behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make can't have any other behavior than continuous rebuilding as it doesn't store any information and only uses the mtime stored in the filesystem as would ninja I believe (which together with make are the main backends of cmake and which is the only backend of meson that supports Linux). Basically any mtime based build system (which is the fast majority of the build systems that are used) is broken when a build doesn't update the mtime of output files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imo not updating on no difference in output is great in terms of early cut off. It is just getting all of the semantics right that is the issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not discuss this in a closed PR... I have opened rust-lang/rust#148948.
|
Beta backport is filed: #16273. |
Update cargo submodule 13 commits in 2d4fa139552ebdd5f091a1401ed03f7dc62cb43f..5c0343317ce45d2ec17ecf41eaa473a02d73e29c 2025-11-12 15:56:06 +0000 to 2025-11-18 19:05:44 +0000 - feat: emit a warning when both `package.publish` and `--index` are specified (rust-lang/cargo#16268) - docs(cargo-yank): clarify yank behavior with leaked credentials (rust-lang/cargo#16274) - feat(generate-lockfile): Add unstable --publish-time flag (rust-lang/cargo#16265) - Do not lock the artifact-dir for check builds (rust-lang/cargo#16230) - fix(fingerprint): force update mtime of cargo-check artifacts (rust-lang/cargo#16262) - fix(manifest): Point out when a key belongs to config (rust-lang/cargo#16256) - Use raw false during cfg test (rust-lang/cargo#16261) - Suppress metadata warnings for non–crates.io publishable packages (rust-lang/cargo#16241) - feat(tree): Support long forms for --format variables (rust-lang/cargo#16204) - fix(config): Fallback to non-canonical path for workspace-path-hash (rust-lang/cargo#16248) - fix: update mtime for generated files after unpacking (rust-lang/cargo#16250) - feat(cli): Add support for completing `--config` values in Bash (rust-lang/cargo#16245) - feat: Add a typos CI job (rust-lang/cargo#16122)
Update cargo submodule 13 commits in 2d4fa139552ebdd5f091a1401ed03f7dc62cb43f..5c0343317ce45d2ec17ecf41eaa473a02d73e29c 2025-11-12 15:56:06 +0000 to 2025-11-18 19:05:44 +0000 - feat: emit a warning when both `package.publish` and `--index` are specified (rust-lang/cargo#16268) - docs(cargo-yank): clarify yank behavior with leaked credentials (rust-lang/cargo#16274) - feat(generate-lockfile): Add unstable --publish-time flag (rust-lang/cargo#16265) - Do not lock the artifact-dir for check builds (rust-lang/cargo#16230) - fix(fingerprint): force update mtime of cargo-check artifacts (rust-lang/cargo#16262) - fix(manifest): Point out when a key belongs to config (rust-lang/cargo#16256) - Use raw false during cfg test (rust-lang/cargo#16261) - Suppress metadata warnings for non–crates.io publishable packages (rust-lang/cargo#16241) - feat(tree): Support long forms for --format variables (rust-lang/cargo#16204) - fix(config): Fallback to non-canonical path for workspace-path-hash (rust-lang/cargo#16248) - fix: update mtime for generated files after unpacking (rust-lang/cargo#16250) - feat(cli): Add support for completing `--config` values in Bash (rust-lang/cargo#16245) - feat: Add a typos CI job (rust-lang/cargo#16122)
Update cargo submodule 13 commits in 2d4fa139552ebdd5f091a1401ed03f7dc62cb43f..5c0343317ce45d2ec17ecf41eaa473a02d73e29c 2025-11-12 15:56:06 +0000 to 2025-11-18 19:05:44 +0000 - feat: emit a warning when both `package.publish` and `--index` are specified (rust-lang/cargo#16268) - docs(cargo-yank): clarify yank behavior with leaked credentials (rust-lang/cargo#16274) - feat(generate-lockfile): Add unstable --publish-time flag (rust-lang/cargo#16265) - Do not lock the artifact-dir for check builds (rust-lang/cargo#16230) - fix(fingerprint): force update mtime of cargo-check artifacts (rust-lang/cargo#16262) - fix(manifest): Point out when a key belongs to config (rust-lang/cargo#16256) - Use raw false during cfg test (rust-lang/cargo#16261) - Suppress metadata warnings for non–crates.io publishable packages (rust-lang/cargo#16241) - feat(tree): Support long forms for --format variables (rust-lang/cargo#16204) - fix(config): Fallback to non-canonical path for workspace-path-hash (rust-lang/cargo#16248) - fix: update mtime for generated files after unpacking (rust-lang/cargo#16250) - feat(cli): Add support for completing `--config` values in Bash (rust-lang/cargo#16245) - feat: Add a typos CI job (rust-lang/cargo#16122)
Update cargo submodule 13 commits in 2d4fa139552ebdd5f091a1401ed03f7dc62cb43f..5c0343317ce45d2ec17ecf41eaa473a02d73e29c 2025-11-12 15:56:06 +0000 to 2025-11-18 19:05:44 +0000 - feat: emit a warning when both `package.publish` and `--index` are specified (rust-lang/cargo#16268) - docs(cargo-yank): clarify yank behavior with leaked credentials (rust-lang/cargo#16274) - feat(generate-lockfile): Add unstable --publish-time flag (rust-lang/cargo#16265) - Do not lock the artifact-dir for check builds (rust-lang/cargo#16230) - fix(fingerprint): force update mtime of cargo-check artifacts (rust-lang/cargo#16262) - fix(manifest): Point out when a key belongs to config (rust-lang/cargo#16256) - Use raw false during cfg test (rust-lang/cargo#16261) - Suppress metadata warnings for non–crates.io publishable packages (rust-lang/cargo#16241) - feat(tree): Support long forms for --format variables (rust-lang/cargo#16204) - fix(config): Fallback to non-canonical path for workspace-path-hash (rust-lang/cargo#16248) - fix: update mtime for generated files after unpacking (rust-lang/cargo#16250) - feat(cli): Add support for completing `--config` values in Bash (rust-lang/cargo#16245) - feat: Add a typos CI job (rust-lang/cargo#16122)
What does this PR try to resolve?
This mtime shift for .rmeta is a workaround as rustc incremental build
since rust-lang/rust#114669 (1.90.0) skips unnecessary rmeta generation.
The situation is like this:
(rerun-if-changed, rerun-if-env-changed) got updated,
the execution unit reran and got a newer mtime.
compilation, no rmeta regeneration. Its
.rmetastays old.cargo checkagain. Cargo found build script execution hada new mtime than existing crate rmeta, so re-checking the crate.
However the check is a no-op (input has no change), so stuck.
Fixes #16104
How to test and review this PR?
Tests pass.
There is a reproduction in #16104 (comment),but actually a minimal one is touching a file of build script dependency, than
cargo check. It'll easily get stuck.This is an ugly workaround. And
-Zchecksum-freshnessdoesn't help because build script is involved.