build: honor SOURCE_DATE_EPOCH for reproducible builds - #6
Merged
Conversation
The build script baked chrono::Utc::now() into the binary (BUILD_TIME), making downstream builds non-reproducible. Honor SOURCE_DATE_EPOCH when set, falling back to the wall clock otherwise.
kcajf
added a commit
to kcajf/flyline
that referenced
this pull request
Jul 12, 2026
Neutralize the build-directory and timestamp leaks that made the dylib
differ between builds:
- --remap-path-prefix: strip the (randomised) build dir from rustc's
embedded panic/debug source paths.
- -install_name @rpath/libflyline.dylib: ld64 otherwise defaults a
dylib's install name to its absolute build-dir output path.
- -reproducible: let ld64 (956.6, shipped by nixpkgs) normalize the
LC_UUID, which in turn makes the ad-hoc code signature deterministic.
- flycomp bumped to a build that pins BUILD_TIME to SOURCE_DATE_EPOCH
(the last remaining wall-clock leak).
`nix build --rebuild` is byte-identical on aarch64-darwin (exit 0).
NOTE: flycomp temporarily points at a personal fork pending the upstream
PR (HalFrgrd/flycomp#6); re-point to the merged rev once available.
HalFrgrd
approved these changes
Jul 25, 2026
kcajf
added a commit
to kcajf/flyline
that referenced
this pull request
Jul 25, 2026
Neutralize the build-directory and timestamp leaks that made the dylib
differ between builds:
- --remap-path-prefix: strip the (randomised) build dir from rustc's
embedded panic/debug source paths.
- -install_name @rpath/libflyline.dylib: ld64 otherwise defaults a
dylib's install name to its absolute build-dir output path.
- -reproducible: let ld64 (956.6, shipped by nixpkgs) normalize the
LC_UUID, which in turn makes the ad-hoc code signature deterministic.
- flycomp bumped to a build that pins BUILD_TIME to SOURCE_DATE_EPOCH
(the last remaining wall-clock leak; HalFrgrd/flycomp#6).
`nix build --rebuild` is byte-identical on aarch64-darwin (exit 0).
HalFrgrd
pushed a commit
to HalFrgrd/flyline
that referenced
this pull request
Jul 25, 2026
## What `build.rs` currently stamps `BUILD_TIME` with `chrono::Utc::now()`, so every build 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`](https://reproducible-builds.org/specs/source-date-epoch/): when the env var is set, `BUILD_TIME` is derived from it; otherwise the behavior is unchanged (falls back to the current wall-clock time). A `rerun-if-env-changed=SOURCE_DATE_EPOCH` line ensures the build script re-runs when the value changes. ## Why `SOURCE_DATE_EPOCH` is the cross-ecosystem standard for reproducible builds and is set automatically by Nix, most distro build systems, and `cargo` tooling. No behavior changes for normal `cargo build`/`cargo install` — the wall clock is still used when the var is absent. ## Testing - `cargo build` with no env var: `BUILD_TIME` is the current time (unchanged). - `SOURCE_DATE_EPOCH=1700000000 cargo build`: `BUILD_TIME` is derived from the epoch, 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.
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.
flycomp's
build.rsbakeschrono::Utc::now()into the binary viaBUILD_TIME, which makes any downstream build (e.g. flyline, and flycomp itself) non-reproducible — the embeddedGenerated by flycomp … built <timestamp>string differs on every build.This honors
SOURCE_DATE_EPOCHwhen set (falling back to the wall clock otherwise), which is the standard mechanism build tools and distros use to pin build timestamps. It's the same fix applied to flyline's ownbuild.rs.Verified downstream: with this change,
nix build --rebuildof flyline is byte-identical on aarch64-darwin.