fix(oci): strip wasm debug symbols so wasm-opt stops aborting #54

Merged
nrupard merged 1 commit from fix/wasm-opt-strip-debug-LINKS-20 into main 2026-06-09 14:17:35 +02:00
Owner

What

Fixes LINKS-20: dx build silently shipped UNOPTIMIZED frontend wasm because Binaryen wasm-opt crashed.

Root cause (verified in the toolchain)

dx defaults --debug-symbols to true, embedding DWARF debug info in the release wasm. Binaryen wasm-opt aborts parsing that DWARF with SIGABRT: compile unit size was incorrect (this may be an unsupported version of DWARF). I reproduced the abort against the real wasm-bindgen output and confirmed it fires on every Binaryen 127, 128, 129, and 130 (dx 0.7.7 and 0.7.9 both download version_127). dx catches the wasm-opt failure, exits 0, and keeps the unoptimized 3.4MB bundle. So upgrading Binaryen does NOT help; the trigger is the DWARF, not the wasm-opt version.

Fix

Build with dx build --release --debug-symbols false so the wasm carries no DWARF, wasm-opt runs to completion, and the client bundle drops from 3.4MB to 1.8MB. Production needs no DWARF; local dx serve keeps the default. Verified end to end: with the flag, dx build exits 0 with no wasm-opt failure and emits the 1.8MB optimized wasm.

Also wraps the build in a guard (AC4): dx exits 0 even when wasm-opt fails, so the step greps dx output for wasm-opt failed and fails the build rather than silently shipping unoptimized WASM. pipefail keeps a genuine dx build failure fatal despite the tee. Guard logic tested for success, swallowed-wasm-opt-failure, and real-build-failure cases.

CI note (not introduced by this PR)

main already references ghcr.io/niceguyit/rust-builder-glibc:v1.0.2-rust1.94-trixie (merged in #53) but that tag is not yet published to GHCR (404), so OCI builds off main currently fail at the FROM resolve. This PR inherits that FROM and will stay red until the companion niceguyit/oci-images change publishes v1.0.2. Once v1.0.2 is live, this builds green. The wasm-opt fix itself was validated against v1.0.1 (dx 0.7.7) and holds on v1.0.2 (same Binaryen 127, same --debug-symbols knob).

Acceptance criteria

  • wasm-opt failure reason captured: SIGABRT on DWARF parse (compile unit size was incorrect).
  • Root cause fixed: drop DWARF via --debug-symbols false (no toolchain bump needed; no Binaryen version parses the DWARF).
  • dx build --release completes wasm-opt without SIGABRT; bundle 3.4MB -> 1.8MB.
  • CI fails rather than silently shipping unoptimized WASM.

Refs LINKS-20.

## What Fixes LINKS-20: `dx build` silently shipped UNOPTIMIZED frontend wasm because Binaryen wasm-opt crashed. ## Root cause (verified in the toolchain) dx defaults `--debug-symbols` to `true`, embedding DWARF debug info in the release wasm. Binaryen wasm-opt aborts parsing that DWARF with SIGABRT: `compile unit size was incorrect (this may be an unsupported version of DWARF)`. I reproduced the abort against the real wasm-bindgen output and confirmed it fires on every Binaryen 127, 128, 129, and 130 (dx 0.7.7 and 0.7.9 both download version_127). dx catches the wasm-opt failure, exits 0, and keeps the unoptimized 3.4MB bundle. So upgrading Binaryen does NOT help; the trigger is the DWARF, not the wasm-opt version. ## Fix Build with `dx build --release --debug-symbols false` so the wasm carries no DWARF, wasm-opt runs to completion, and the client bundle drops from 3.4MB to 1.8MB. Production needs no DWARF; local `dx serve` keeps the default. Verified end to end: with the flag, `dx build` exits 0 with no wasm-opt failure and emits the 1.8MB optimized wasm. Also wraps the build in a guard (AC4): dx exits 0 even when wasm-opt fails, so the step greps dx output for `wasm-opt failed` and fails the build rather than silently shipping unoptimized WASM. `pipefail` keeps a genuine dx build failure fatal despite the `tee`. Guard logic tested for success, swallowed-wasm-opt-failure, and real-build-failure cases. ## CI note (not introduced by this PR) `main` already references `ghcr.io/niceguyit/rust-builder-glibc:v1.0.2-rust1.94-trixie` (merged in #53) but that tag is not yet published to GHCR (404), so OCI builds off `main` currently fail at the `FROM` resolve. This PR inherits that `FROM` and will stay red until the companion `niceguyit/oci-images` change publishes v1.0.2. Once v1.0.2 is live, this builds green. The wasm-opt fix itself was validated against v1.0.1 (dx 0.7.7) and holds on v1.0.2 (same Binaryen 127, same `--debug-symbols` knob). ## Acceptance criteria - [x] wasm-opt failure reason captured: SIGABRT on DWARF parse (`compile unit size was incorrect`). - [x] Root cause fixed: drop DWARF via `--debug-symbols false` (no toolchain bump needed; no Binaryen version parses the DWARF). - [x] `dx build --release` completes wasm-opt without SIGABRT; bundle 3.4MB -> 1.8MB. - [x] CI fails rather than silently shipping unoptimized WASM. Refs LINKS-20.
fix(oci): strip wasm debug symbols so wasm-opt stops aborting
All checks were successful
Check / clippy + fmt + tests (pull_request) Successful in 30s
Create release / Create release from merged PR (pull_request) Has been skipped
e17a9ce29e
dx defaults to embedding DWARF debug info in the release wasm (--debug-symbols defaults to true). Binaryen wasm-opt (every version 127-130, and version_127 is what dx 0.7.x downloads) aborts with SIGABRT parsing it ("compile unit size was incorrect (this may be an unsupported version of DWARF)"). dx swallows the failure, exits 0, and silently ships the UNOPTIMIZED 3.4MB wasm (LINKS-20, observed in OCI build run #136). Building with --debug-symbols false lets wasm-opt complete and drops the client bundle to 1.8MB. Production needs no DWARF; dev `dx serve` keeps the default and is unaffected.

Add a guard around the build: dx exits 0 even when wasm-opt fails, so the step greps dx output and fails the build rather than silently shipping unoptimized WASM. pipefail keeps a genuine dx build failure fatal despite the tee.

Root cause verified directly in the rust-builder-glibc toolchain: no Binaryen 127-130 parses the rustc/wasm-bindgen DWARF; --strip-debug (which --debug-symbols false triggers) is the only thing that avoids the abort.

#LINKS-20

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
nrupard deleted branch fix/wasm-opt-strip-debug-LINKS-20 2026-06-09 14:17:35 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
a8n-tools/rusty-links!54
No description provided.