From ed21b2483dcd9f920d7304390bda03315616c0df Mon Sep 17 00:00:00 2001 From: HaRoLd <303926+HarryR@users.noreply.github.com> Date: Thu, 9 Jul 2026 19:36:23 +0000 Subject: [PATCH 1/2] build: make CI and local builds byte-identical; align toolchain to 1.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 --- .cargo/config.toml | 6 ++++++ rust-toolchain.toml | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index a80c099..a2d6831 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -10,6 +10,10 @@ rustflags = [ "-C", "linker=rust-lld", "-C", "target-feature=+crt-static", "-C", "link-arg=-static", + # Remap the embedded dep source paths to a fixed prefix so the build does not depend on where + # CARGO_HOME is (CI uses /tmp/.cargo, local uses /src/.cargo); makes CI and local byte-identical. + "--remap-path-prefix=/src/.cargo=/cargo", + "--remap-path-prefix=/tmp/.cargo=/cargo", ] [target.x86_64-unknown-linux-gnu] @@ -24,6 +28,8 @@ rustflags = [ "-C", "linker=rust-lld", "-C", "target-feature=+crt-static", "-C", "link-arg=-static", + "--remap-path-prefix=/src/.cargo=/cargo", + "--remap-path-prefix=/tmp/.cargo=/cargo", ] [env] diff --git a/rust-toolchain.toml b/rust-toolchain.toml index b9f5441..13c453e 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,5 +1,5 @@ [toolchain] -channel = "1.91.0" +channel = "1.91.1" components = ["rustfmt", "clippy"] targets = ["x86_64-unknown-linux-musl"] profile = "minimal" From e2d9529db5b70693c119f8405ff884817f2f1d40 Mon Sep 17 00:00:00 2001 From: HaRoLd <303926+HarryR@users.noreply.github.com> Date: Fri, 10 Jul 2026 06:30:18 +0000 Subject: [PATCH 2/2] build: also remap the rust-src sysroot path so CI==local with rust-analyzer 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//lib/rustlib/src/rust/...) instead of the baked /rustc/ that CI produces. Remap that sysroot path to the same /rustc/ 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 --- .cargo/config.toml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.cargo/config.toml b/.cargo/config.toml index a2d6831..338ef03 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -14,6 +14,11 @@ rustflags = [ # CARGO_HOME is (CI uses /tmp/.cargo, local uses /src/.cargo); makes CI and local byte-identical. "--remap-path-prefix=/src/.cargo=/cargo", "--remap-path-prefix=/tmp/.cargo=/cargo", + # If rust-src is installed (rust-analyzer does this locally; CI's fresh toolchain has not), rustc + # emits std panic-location paths from the sysroot instead of the baked /rustc/. Remap the + # sysroot rust-src path to that same /rustc/ so local matches CI. UPDATE THE HASH when + # bumping the toolchain (rustc -Vv commit-hash); a stale value silently no-ops (CI==local catches it). + "--remap-path-prefix=/src/.rustup/toolchains/1.91.1-x86_64-unknown-linux-gnu/lib/rustlib/src/rust=/rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb", ] [target.x86_64-unknown-linux-gnu] @@ -30,6 +35,7 @@ rustflags = [ "-C", "link-arg=-static", "--remap-path-prefix=/src/.cargo=/cargo", "--remap-path-prefix=/tmp/.cargo=/cargo", + "--remap-path-prefix=/src/.rustup/toolchains/1.91.1-x86_64-unknown-linux-gnu/lib/rustlib/src/rust=/rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb", ] [env]