oficina / slides Public

Build the wasm natively on Linux arm64, and skip its byte check there

Hosted CI is arm64. The docker fallback ran the amd64 rust image under
qemu, which segfaults inside rustup. Running the arm64 variant of the
image natively builds, but not the committed bytes: cargo hashes the
host architecture into every crate's -C metadata, which changes code
layout (reproduced under qemu with the aarch64 1.98.0 toolchain at the
canonical paths; the arm64 build is 1021 bytes larger).

So on Linux non-amd64 the scripts build natively with the host's
toolchain, for the tests that read the artifact, and the gate's cmp
says it is skipped. Linux amd64 (bwrap) and docker hosts are unchanged
and still enforce it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev fe33aa24156205eb7e56410a40d9c810d9e670e6 parent 141e5d2
3 files changed, +38 −6
  • .amadan/ci.d/10-gate +12 −2
  • scripts/build-pdf-wasm.sh +13 −2
  • scripts/build-wasm.sh +13 −2

CI failed — run details

diff --git a/.amadan/ci.d/10-gate b/.amadan/ci.d/10-gate
index 3c3d2c4..c3f99cc 100755
--- a/.amadan/ci.d/10-gate
+++ b/.amadan/ci.d/10-gate
@@ -93,7 +93,12 @@ echo "=== wasm: the artifact the host embeds"
./scripts/build-wasm.sh
echo "=== the embedded wasm must match a fresh build"
-if ! cmp -s core/target/wasm32-unknown-unknown/release/slides_core.wasm internal/slides/core/testdata/slides_core.wasm; then
+if [[ "$(uname -s)" == Linux && "$(uname -m)" != x86_64 ]]; then
+ # Cargo hashes the host architecture into crate identities, so no
+ # Linux arm64 build reproduces the committed amd64 bytes (the build
+ # script builds natively here). Linux amd64 runs keep this check.
+ echo "gate: SKIPPED on Linux/$(uname -m): internal/slides/core/testdata/slides_core.wasm is the canonical amd64 build, which no build on this host reproduces byte for byte"
+elif ! cmp -s core/target/wasm32-unknown-unknown/release/slides_core.wasm internal/slides/core/testdata/slides_core.wasm; then
echo "gate: internal/slides/core/testdata/slides_core.wasm does not match a fresh build — rebuild and commit the wasm:" >&2
echo " ./scripts/build-wasm.sh && cp core/target/wasm32-unknown-unknown/release/slides_core.wasm internal/slides/core/testdata/slides_core.wasm" >&2
exit 1
@@ -126,7 +131,12 @@ echo "=== wasm: the pdf artifact the host embeds"
./scripts/build-pdf-wasm.sh
echo "=== the embedded pdf wasm must match a fresh build"
-if ! cmp -s core/pdf/target/wasm32-unknown-unknown/release/slides_pdf.wasm internal/slides/pdfcore/testdata/slides_pdf.wasm; then
+if [[ "$(uname -s)" == Linux && "$(uname -m)" != x86_64 ]]; then
+ # Cargo hashes the host architecture into crate identities, so no
+ # Linux arm64 build reproduces the committed amd64 bytes (the build
+ # script builds natively here). Linux amd64 runs keep this check.
+ echo "gate: SKIPPED on Linux/$(uname -m): internal/slides/pdfcore/testdata/slides_pdf.wasm is the canonical amd64 build, which no build on this host reproduces byte for byte"
+elif ! cmp -s core/pdf/target/wasm32-unknown-unknown/release/slides_pdf.wasm internal/slides/pdfcore/testdata/slides_pdf.wasm; then
echo "gate: internal/slides/pdfcore/testdata/slides_pdf.wasm does not match a fresh build — rebuild and commit the wasm:" >&2
echo " ./scripts/build-pdf-wasm.sh && cp core/pdf/target/wasm32-unknown-unknown/release/slides_pdf.wasm internal/slides/pdfcore/testdata/slides_pdf.wasm" >&2
exit 1
diff --git a/scripts/build-pdf-wasm.sh b/scripts/build-pdf-wasm.sh
index 2ed0659..4d2474d 100755
--- a/scripts/build-pdf-wasm.sh
+++ b/scripts/build-pdf-wasm.sh
@@ -4,17 +4,28 @@
set -euo pipefail
cd "$(dirname "$0")/.."
# Lint the PDF renderer before building its standalone C ABI module.
-if [[ "${1:-}" != "--build-only" && "${1:-}" != "--canonical-build" ]]; then
+if [[ "${1:-}" != "--build-only" && "${1:-}" != "--canonical-build" && "${1:-}" != "--native-build" ]]; then
cargo clippy --manifest-path core/pdf/Cargo.toml --all-targets -- -D warnings
fi
# Rust/Cargo crate identities affect code ordering even after path remapping.
-# Build on Linux amd64 at fixed source/toolchain paths on every host.
+# Build on Linux amd64 at fixed source/toolchain paths on every host that can.
if [[ "${1:-}" == "--canonical-build" ]]; then
[[ "$(uname -s)/$(uname -m)" == "Linux/x86_64" && "$(pwd)" == /work \
&& "$CARGO_HOME" == /usr/local/cargo && "$RUSTUP_HOME" == /usr/local/rustup ]] \
|| { echo "build-pdf-wasm: invalid canonical build environment" >&2; exit 1; }
export CARGO_TARGET_DIR=/work/core/pdf/target RUSTUP_TOOLCHAIN=1.98.0
+elif [[ "${1:-}" == "--native-build" ]]; then
+ : # this checkout, this host's toolchain: built below, not reproducible
else
+ # Cargo's crate identities (-C metadata) also depend on the host
+ # architecture, so no build on a Linux arm64 host matches the committed
+ # amd64 bytes, and the amd64 image crashes under qemu there. Build
+ # natively instead, for the tests that read the artifact; the gate skips
+ # its byte-for-byte check on these hosts and keeps it on Linux amd64.
+ if [[ "$(uname -s)" == Linux && "$(uname -m)" != x86_64 ]]; then
+ echo "build-pdf-wasm: Linux/$(uname -m) builds natively; the result is not the canonical amd64 build" >&2
+ exec ./scripts/build-pdf-wasm.sh --native-build
+ fi
out="core/pdf/target/wasm32-unknown-unknown/release/slides_pdf.wasm"
mkdir -p "$(dirname "$out")"
temporary=$(mktemp "${out}.XXXXXX")
diff --git a/scripts/build-wasm.sh b/scripts/build-wasm.sh
index dbd11b1..5a535c4 100755
--- a/scripts/build-wasm.sh
+++ b/scripts/build-wasm.sh
@@ -8,17 +8,28 @@ cd "$(dirname "$0")/.."
# Doc::with_client_id() both draw entropy this build has no safe source
# for. A doc comment alone has been wrong, or gotten around, more than
# once; this is the actual enforcement.
-if [[ "${1:-}" != "--build-only" && "${1:-}" != "--canonical-build" ]]; then
+if [[ "${1:-}" != "--build-only" && "${1:-}" != "--canonical-build" && "${1:-}" != "--native-build" ]]; then
cargo clippy --manifest-path core/Cargo.toml --all-targets -- -D warnings -D clippy::disallowed_methods
fi
# Rust/Cargo crate identities affect code ordering even after path remapping.
-# Build on Linux amd64 at fixed source/toolchain paths on every host.
+# Build on Linux amd64 at fixed source/toolchain paths on every host that can.
if [[ "${1:-}" == "--canonical-build" ]]; then
[[ "$(uname -s)/$(uname -m)" == "Linux/x86_64" && "$(pwd)" == /work \
&& "$CARGO_HOME" == /usr/local/cargo && "$RUSTUP_HOME" == /usr/local/rustup ]] \
|| { echo "build-wasm: invalid canonical build environment" >&2; exit 1; }
export CARGO_TARGET_DIR=/work/core/target RUSTUP_TOOLCHAIN=1.98.0
+elif [[ "${1:-}" == "--native-build" ]]; then
+ : # this checkout, this host's toolchain: built below, not reproducible
else
+ # Cargo's crate identities (-C metadata) also depend on the host
+ # architecture, so no build on a Linux arm64 host matches the committed
+ # amd64 bytes, and the amd64 image crashes under qemu there. Build
+ # natively instead, for the tests that read the artifact; the gate skips
+ # its byte-for-byte check on these hosts and keeps it on Linux amd64.
+ if [[ "$(uname -s)" == Linux && "$(uname -m)" != x86_64 ]]; then
+ echo "build-wasm: Linux/$(uname -m) builds natively; the result is not the canonical amd64 build" >&2
+ exec ./scripts/build-wasm.sh --native-build
+ fi
out="core/target/wasm32-unknown-unknown/release/slides_core.wasm"
mkdir -p "$(dirname "$out")"
temporary=$(mktemp "${out}.XXXXXX")