Repository navigation
wasm2c: report relaxed SIMD instructions as unsupported instead of aborting - #2908
Merged
Merged
Conversation
…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
marked this pull request as ready for review
October 23, 2026 10:02
sbc100
approved these changes
Oct 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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, sowasm2cdied with SIGABRT and no message oni8x16.relaxed_swizzle,i32x4.relaxed_trunc_f32x4_s,f32x4.relaxed_madd,i32x4.relaxed_laneselectand the like. The module is accepted bywasm-validateand
wasm2wat, so the abort comes only from the C writer.This replaces
WABT_UNREACHABLEin those four switches withWABT_FATAL, whichprints the name of the instruction and exits with status 1, the way
wasm2calreadyreports other things it cannot write:
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.add128and the others, #2895) aborts through a different path and is left fora separate change.
Testing:
test/wasm2c/relaxed-simd-unsupported.txtrunswasm2con a module withi8x16.relaxed_swizzleand expects the message and exit status 1. Before thechange the process aborted with status 134.
test/wasm2c/pass on Linux.Fixes #2886