build: byte-identical CI/local builds via --remap-path-prefix; toolchain 1.91.1#18
Merged
Conversation
…91.1 CI and local produced different binaries (and thus a different measured linux.efi / PCR). 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, so the two bake different absolute registry paths into every binary that has path-embedding deps. stage2 matched only because the leaf pulls none. Fix: --remap-path-prefix in the per-target rustflags 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 the stage1 binary contains only /cargo/registry paths (0 /src, 0 /tmp) and is bit-deterministic. (trim-paths would be cleaner but is still nightly-only on 1.91.) Also bump rust-toolchain 1.91.0 -> 1.91.1 to match stage0: the toolchain file was left at .0 since the v0.1.0 tag while stage0 moved to .1, and two repos that must produce byte-compatible framing should share a compiler (std/sysroot paths are toolchain-version-specific). 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 (/src/.rustup/toolchains/<tc>/lib/rustlib/src/rust/...) instead of the baked /rustc/<hash> that CI produces. Remap that sysroot path to the same /rustc/<hash> so the two converge. Verified: local now builds linux.efi / stage2 / stage1 byte-identical to the CI-built artifacts (4b6aa700 / 0eb6f0e7 / 1a0d586a). The remap is a no-op in CI (no rust-src there), so CI output is unchanged. The hash is toolchain-specific; update it when bumping the toolchain (a stale value silently no-ops, which the CI==local check 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
linux.efi(and its PCR) reproduces independently.Why
CI builds with
CARGO_HOME=/tmp/.cargo(the Makefile CI cache redirect) while local uses/src/.cargo. rustc embeds dependency source paths, so the two baked different absolute registry paths into every binary with path-embedding deps -> differentstage1/linux.efi. (stage2matched only because the leaf has no such deps.)Fix
--remap-path-prefix=/src/.cargo=/cargo+=/tmp/.cargo=/cargoin both musl targets' rustflags -> the build no longer depends on whereCARGO_HOMEis. Verified locally:stage1now contains only/cargo/registrypaths (0/src, 0/tmp) and is bit-deterministic. (trim-pathswould be cleaner but is nightly-only on 1.91.)rust-toolchain.toml1.91.0 -> 1.91.1 to match stage0 (drifted since the v0.1.0 tag; std/sysroot paths are toolchain-version-specific).Verification
This PR's CI run builds the artifacts; comparing them to a local build with the same config is the acceptance test (
linux.efi/stage2should match byte-for-byte). Local reference (x86_64):linux.efi 65c9fdbf,stage2 72978d6f.🤖 Generated with Claude Code