Skip to content

Force wasixcc to legacy EH to match the Rust toolchain - #84

Merged
Arshia001 merged 1 commit into
mainfrom
legacy-eh-default
Jul 15, 2026
Merged

Force wasixcc to legacy EH to match the Rust toolchain#84
Arshia001 merged 1 commit into
mainfrom
legacy-eh-default

Conversation

@Arshia001

Copy link
Copy Markdown
Contributor

Why

The Rust toolchain builds in the legacy EH configuration — build-wasix.sh bakes wasix-libc's sysroot32-eh/sysroot32-ehpic into the toolchain, and the target spec never passes --wasm-use-legacy-eh=false. wasixcc, however, defaults to exnref (WASM_EXCEPTIONS unset → sysroot-exnref-eh + --wasm-use-legacy-eh=false). So with the auto-CC integration, the C/C++ objects in a build were in a different EH configuration than the Rust/libc side.

In practice this happened to work — Rust is panic=abort (no catches), throw is style-neutral, and wasmer supports exnref — but it's an asymmetry waiting to bite (e.g. once anything on the Rust side emits legacy catches next to exnref C catches with wasm-opt = false set).

What

  • When wasixcc is on PATH, set WASIXCC_WASM_EXCEPTIONS=legacy unconditionally, overriding any environment value — a mismatched EH configuration must not reach the build. Everything is still translated to exnref by the mandatory wasm-opt --translate-to-exnref pass.
  • Drop the -dl target's old WASIXCC_WASM_EXCEPTIONS=1 (exnref) default; WASIXCC_PIC=1 remains, and with legacy EH it selects sysroot-ehpic — the same configuration as the Rust dl target's sysroot32-ehpic.

Verified

C setjmp/longjmp compiled via the cc crate into a Rust app:

  • pre-wasm-opt module: 1 legacy try, 0 try_table (wasixcc now matches the toolchain),
  • post-wasm-opt: 1 try_table, 0 legacy (translate-to-exnref unifies),
  • runs under wasmer, longjmp round-trips correctly.

Integration test updated: asserts legacy for the dl target and asserts that an exnref value in the environment is overridden.

🤖 Generated with Claude Code

The Rust toolchain builds in the legacy exception-handling configuration
(its sysroot is the legacy-EH wasix-libc build), but wasixcc defaults to
exnref, so the auto-configured C/C++ side of a build ended up in a
different EH configuration than the Rust side. Set
WASIXCC_WASM_EXCEPTIONS=legacy alongside the tool variables — overriding
any value from the environment, since a mismatched configuration must
not reach the build. wasm-opt still translates the final module to
exnref in post-processing.

The -dl target's WASIXCC_WASM_EXCEPTIONS=1 (exnref) default is gone for
the same reason; with legacy EH, WASIXCC_PIC=1 selects sysroot-ehpic,
matching the Rust dl target's sysroot32-ehpic.

Verified with C setjmp/longjmp linked through the cc crate: the object
now compiles as legacy EH (1 legacy try, 0 try_table pre-wasm-opt),
translate-to-exnref unifies the module (1 try_table post), and the
binary round-trips a longjmp under wasmer.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Arshia001
Arshia001 merged commit ad50e72 into main Jul 15, 2026
6 checks passed
@Arshia001
Arshia001 deleted the legacy-eh-default branch July 15, 2026 15:43
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