Skip to content

build: byte-identical CI/local builds via --remap-path-prefix#9

Merged
HarryR merged 2 commits into
mainfrom
reproducible-builds
Jul 10, 2026
Merged

build: byte-identical CI/local builds via --remap-path-prefix#9
HarryR merged 2 commits into
mainfrom
reproducible-builds

Conversation

@HarryR

@HarryR HarryR commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

What

Make CI and local builds bit-identical so the measured stage0.efi (PCR4/14) reproduces independently.

Why

CI builds with CARGO_HOME=/tmp/.cargo while local uses /src/.cargo; rustc embeds dependency source paths, so each baked different absolute registry paths into stage0.efi.

Fix

--remap-path-prefix=/src/.cargo=/cargo + =/tmp/.cargo=/cargo in every artifact-producing target (musl x2, uefi x2) -> build is CARGO_HOME-independent. Verified locally: stage0.efi contains only /cargo/registry paths (0 /src, 0 /tmp). (trim-paths would be cleaner but is nightly-only on 1.91.)

Verification

This PR's CI run builds the db-signed BOOTX64.EFI; grepping it should show only /cargo paths (no /tmp//src), proving CARGO_HOME-independence. Local reference (x86_64): stage0.efi 433bea84, ena.efi e4957fe6.

Pairs with lockboot/stage1's reproducibility PR.

🤖 Generated with Claude Code

HarryR and others added 2 commits July 9, 2026 19:36
CI and local produced different measured binaries (stage0.efi and thus PCR4/14).
Root cause: rustc embeds dependency source paths, and CI runs with
CARGO_HOME=/tmp/.cargo (the Makefile's CI cache redirect) while local uses
/src/.cargo, baking different absolute registry paths into the binary.

Fix: --remap-path-prefix in every artifact-producing target's rustflags (musl
x2, uefi x2) rewrites both /src/.cargo and /tmp/.cargo to a fixed /cargo, so the
build no longer depends on where CARGO_HOME is. Verified: after the remap
stage0.efi contains only /cargo/registry paths (0 /src, 0 /tmp). trim-paths
would be cleaner but is still nightly-only on 1.91.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…alyzer

The CARGO_HOME remap left one divergence: when rust-src is installed (rust-
analyzer does this in the local shared rustup; CI's fresh toolchain has not),
rustc emits std panic-location paths from the sysroot instead of the baked
/rustc/<hash> that CI produces. Remap that sysroot path to the same
/rustc/<hash> on every artifact target so the two converge.

Verified: local stage0.efi is now fully path-canonical (0 /src/.cargo, 0
/src/.rustup; only /cargo + /rustc), matching CI's build. The remap is a no-op
in CI (no rust-src there). The hash is toolchain-specific; update it when
bumping the toolchain (a stale value silently no-ops, which CI==local catches).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@HarryR HarryR marked this pull request as ready for review July 10, 2026 06:49
@HarryR HarryR merged commit 7e60a62 into main Jul 10, 2026
3 checks passed
@HarryR HarryR deleted the reproducible-builds branch July 10, 2026 06:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant