build: honor SOURCE_DATE_EPOCH for reproducible build timestamp - #826
Merged
Conversation
The build script baked chrono::Utc::now() into the binary (surfaced by `flyline --version`), making builds non-reproducible. Honor SOURCE_DATE_EPOCH when set, falling back to the wall clock otherwise.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
build.rscurrently stampsBUILD_TIMEwithchrono::Utc::now(), so everybuild embeds the wall-clock time. This makes the compiled artifact differ on
each build — the last remaining source of non-determinism when packaging
flyline (e.g. for Nix, where builds are checked for bit-for-bit
reproducibility).
This change honors
SOURCE_DATE_EPOCH:when the env var is set,
BUILD_TIMEis derived from it; otherwise thebehavior is unchanged (falls back to the current wall-clock time). A
rerun-if-env-changed=SOURCE_DATE_EPOCHline ensures the build script re-runswhen the value changes.
Why
SOURCE_DATE_EPOCHis the cross-ecosystem standard for reproducible builds andis set automatically by Nix, most distro build systems, and
cargotooling. Nobehavior changes for normal
cargo build/cargo install— the wall clock isstill used when the var is absent.
Testing
cargo buildwith no env var:BUILD_TIMEis the current time (unchanged).SOURCE_DATE_EPOCH=1700000000 cargo build:BUILD_TIMEis derived from theepoch, and repeated builds produce byte-identical output.
This is the flyline-side counterpart to HalFrgrd/flycomp#6, which applied the
same fix to flycomp's build script.