Description
Describe the problem you are trying to solve
The primary problem I have is that when building my code on travis, the actual code in my workspace builds every time, even though much of it hasn't changed and I have target directory caching on. The reason is that travis makes a new clone of my git repo, which doesn't preserve mtimes. This can add about 5 minutes to every travis run. My project is mixed rust and non-rust code, so this adds 5 minutes to those runs even if no rust code has been affected. I started futzing with mtimes, but that seems fragile and not solving the root of the problem.
Additionally, edit-undo loops cause re-compilation locally, which is a little annoying.
Describe the solution you'd like
Add a new LocalFingerprint::ContentBased(Digest, PathBuf)
variant to
cargo/src/cargo/core/compiler/fingerprint.rs
Lines 204 to 209 in b84e625
PathBuf
, passes it through a SipHasher
, and mixes that into any aggregate fingerprints. Use this instead of LocalFingerprint::MtimeBased
.
Notes
This will probably slow down no-op builds slightly (in some circumstances, such as with large build script inputs over NFS, significantly), so may want to be behind a flag (perhaps --fingerprint-strategy={mtime,content}
).
This would probably also make more shared caching (that people talk about a lot, most recently at https://internals.rust-lang.org/t/idea-cargo-global-binary-cache/9002) easier.
I'd be happy to implement this if the PR is likely to be accepted :)
This would probably also fix
- Build is always executed if mtimes are missing #4425
- Files generated by build script into src/ are compiled twice #3076
- ecryptfs causes Cargo to rebuild when it shouldn't #7775
- Cargo does not rebuild if project got changed in the same second #5918
- Cargo is not rebuilding a project that has been modified #8868 ?
cargo check
not rebuilding dependency that has changed #10175 ?- Spurious rebuilds due to filesystem rounding file modification timestamps #12060
- Cargo always rebuilds the project even when no changes made on WSL #13119