build: byte-identical CI/local builds via --remap-path-prefix#9
Merged
Conversation
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>
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
Make CI and local builds bit-identical so the measured
stage0.efi(PCR4/14) reproduces independently.Why
CI builds with
CARGO_HOME=/tmp/.cargowhile local uses/src/.cargo; rustc embeds dependency source paths, so each baked different absolute registry paths intostage0.efi.Fix
--remap-path-prefix=/src/.cargo=/cargo+=/tmp/.cargo=/cargoin every artifact-producing target (musl x2, uefi x2) -> build isCARGO_HOME-independent. Verified locally:stage0.eficontains only/cargo/registrypaths (0/src, 0/tmp). (trim-pathswould 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/cargopaths (no/tmp//src), provingCARGO_HOME-independence. Local reference (x86_64):stage0.efi 433bea84,ena.efi e4957fe6.Pairs with lockboot/stage1's reproducibility PR.
🤖 Generated with Claude Code