Skip to content

wasm2c: report relaxed SIMD instructions as unsupported instead of aborting - #2908

Merged
sbc100 merged 2 commits into
WebAssembly:mainfrom
natify-sh:wasm2c-relaxed-simd-error
Oct 23, 2026
Merged

sbc100 merged 2 commits into
WebAssembly:mainfrom
natify-sh:wasm2c-relaxed-simd-error

Conversation

@o-murphy

Copy link
Copy Markdown
Contributor

relaxed SIMD is on by default (#2837), but the C writer has no translation for its
instructions. The switches over the unary, binary, convert and ternary opcodes ended
in WABT_UNREACHABLE, so wasm2c died with SIGABRT and no message on
i8x16.relaxed_swizzle, i32x4.relaxed_trunc_f32x4_s, f32x4.relaxed_madd,
i32x4.relaxed_laneselect and the like. The module is accepted by wasm-validate
and wasm2wat, so the abort comes only from the C writer.

This replaces WABT_UNREACHABLE in those four switches with WABT_FATAL, which
prints the name of the instruction and exits with status 1, the way wasm2c already
reports other things it cannot write:

error: wasm2c does not support the i8x16.relaxed_swizzle instruction

This does not add the translation of relaxed SIMD (SIMDe has most of it in
relaxed-simd.h); it only makes the failure a diagnostic. Wide arithmetic
(i64.add128 and the others, #2895) aborts through a different path and is left for
a separate change.

Testing:

  • New test/wasm2c/relaxed-simd-unsupported.txt runs wasm2c on a module with
    i8x16.relaxed_swizzle and expects the message and exit status 1. Before the
    change the process aborted with status 134.
  • The tests in test/wasm2c/ pass on Linux.

Fixes #2886

…orting

relaxed SIMD is enabled by default, but the C writer has no translation for
its instructions. The switches over the unary, binary, convert and ternary
opcodes ended in WABT_UNREACHABLE, so wasm2c died with SIGABRT and no message
on i8x16.relaxed_swizzle, i32x4.relaxed_trunc_f32x4_s, f32x4.relaxed_madd and
the like.

Print an error that names the instruction, keep the type stack consistent and
fail the conversion, as for the other things wasm2c cannot write.
@o-murphy
o-murphy marked this pull request as ready for review October 23, 2026 10:02
@sbc100
sbc100 merged commit d6df044 into WebAssembly:main Oct 23, 2026
17 checks passed
@o-murphy
o-murphy deleted the wasm2c-relaxed-simd-error branch October 23, 2026 16:45
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.

wasm2c aborts (SIGABRT, no message) on relaxed SIMD instructions

2 participants