-
-
Notifications
You must be signed in to change notification settings - Fork 14.6k
Description
I tried this code with -Zchecksum-freshness enabled on cargo side:
// random_bytes have to be binary. include_bytes!(".gitignore") does not allow one to repro, for instance.
pub static CONTENTS: &[u8] = include_bytes!("../random_bytes.bin");I expected to see this happen: subsequent builds of the crate with such static to not trigger a rebuild.
Instead, this happened: crate gets rebuilt over and over
Extra bits:
Cargo's rebuild reason states that file length does not match up:
Dirty inner v0.1.0 (/Users/hiro/Projects/build_playground/checksum-freshness/inner): file size changed (0 != 40) for
random_bytes.bin
This means that rustc reports such files as having a length of 0, whereas on a subsequent build Cargo compares that 0 with correct length, triggering a rebuild in a process. I believe that this is a rustc bug (and not a cargo bug), as it incorrectly reports the checksum/file length of binary files.
Meta
rustc --version --verbose:
rustc 1.94.0-nightly (2f1bd3f37 2026-01-12)
Backtrace
<backtrace>