Skip to content

build: byte-identical CI/local builds via --remap-path-prefix; toolchain 1.91.1#18

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

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

Conversation

@HarryR

@HarryR HarryR commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

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 -> different stage1/linux.efi. (stage2 matched only because the leaf has no such deps.)

Fix

  • --remap-path-prefix=/src/.cargo=/cargo + =/tmp/.cargo=/cargo in both musl targets' rustflags -> the build no longer depends on where CARGO_HOME is. Verified locally: stage1 now contains only /cargo/registry paths (0 /src, 0 /tmp) and is bit-deterministic. (trim-paths would be cleaner but is nightly-only on 1.91.)
  • Bump rust-toolchain.toml 1.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/stage2 should match byte-for-byte). Local reference (x86_64): linux.efi 65c9fdbf, stage2 72978d6f.

🤖 Generated with Claude Code

HarryR and others added 2 commits July 9, 2026 19:36
…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>
@HarryR HarryR marked this pull request as ready for review July 10, 2026 06:49
@HarryR HarryR merged commit fd28f58 into main Jul 10, 2026
4 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