Repository navigation
wasm2c: fix SIMD_FORCE_READ constraint for V-incapable RISC-V targets - #2880
Merged
Merged
Conversation
CSharperMantle
marked this pull request as ready for review
October 14, 2026 15:36
CSharperMantle
added a commit
to AOSC-Tracking/firefox-git
that referenced
this pull request
Oct 14, 2026
CSharperMantle
added a commit
to AOSC-Tracking/thunderbird
that referenced
this pull request
Oct 14, 2026
shravanrn
requested changes
Oct 19, 2026
| #elif defined(__aarch64__) | ||
| #define SIMD_FORCE_READ(var) __asm__("" ::"w"(var)); | ||
| #elif defined(__riscv) | ||
| #elif defined(__riscv) && defined(__riscv_vector) |
Collaborator
There was a problem hiding this comment.
This looks fine. Could you send a PR with only the RISC-v change that is not stacked on the PowerPC and default case change so we can land this separately?
CSharperMantle
force-pushed
the
fix-riscv-no-rvv-vr
branch
from
October 20, 2026 00:49
7bdb386 to
9f4e61e
Compare
shravanrn
approved these changes
Oct 20, 2026
shravanrn
enabled auto-merge (rebase)
October 20, 2026 14:36
shravanrn
force-pushed
the
fix-riscv-no-rvv-vr
branch
from
October 20, 2026 14:36
9f4e61e to
40eca66
Compare
When compiling wasm2c-generated programs for V-incapable RISC-V targets,
the following error occurs:
111:25.21 E /var/cache/acbs/build/acbs.05foslpj/firefox-158.0/obj-riscv64-unknown-linux-gnu/media/libsoundtouch/src/rlboxsoundtouch.wasm.c:962:1: error: couldn't allocate input reg for constraint 'vr'
111:25.22 E 962 | DEFINE_SIMD_LOAD_FUNC(v128_load64_zero, v128_impl_load64_zero, u64)
111:25.23 E | ^
111:25.24 E /var/cache/acbs/build/acbs.05foslpj/firefox-158.0/obj-riscv64-unknown-linux-gnu/media/libsoundtouch/src/rlboxsoundtouch.wasm.c:890:5: note: expanded from macro 'DEFINE_SIMD_LOAD_FUNC'
111:25.25 E 890 | SIMD_FORCE_READ(result); \
111:25.26 E | ^
111:25.26 E /var/cache/acbs/build/acbs.05foslpj/firefox-158.0/obj-riscv64-unknown-linux-gnu/media/libsoundtouch/src/rlboxsoundtouch.wasm.c:866:38: note: expanded from macro 'SIMD_FORCE_READ'
111:25.27 E 866 | #define SIMD_FORCE_READ(var) __asm__("" ::"vr"(var));
111:25.27 E | ^
Gate "vr" to V-capable RISC-V targets only and fall back to the default
path when V is not supported.
shravanrn
force-pushed
the
fix-riscv-no-rvv-vr
branch
from
October 20, 2026 16:20
40eca66 to
4842835
Compare
felixonmars
added a commit
to felixonmars/archriscv-packages
that referenced
this pull request
Oct 24, 2026
Use wasm2c's explicit bounds checks on RISC-V without vector registers. The instrumented build fails in rlboxsoundtouch.wasm.c with "could not allocate input reg for constraint 'vr'". The upstream RVV guard fix leaves an unsuitable floating-point fallback; upstream rejected a memory-operand fallback because it does not guarantee the reads needed by guard pages. No complete upstream fix was found. Retain RLBox sandboxing with bounds checks instead. Drop the XPTC tail-jump patch, included in Firefox 158.0.1 by upstream commit da6b7fa59644be65b8082c770d915c635377aa80 (bug 2077820). https://archriscv.felixc.at/.status/logs/firefox/firefox-158.0.1-1.log WebAssembly/wabt#2880 WebAssembly/wabt#2888 (review) https://github.com/mozilla-firefox/firefox/blob/FIREFOX_158_0_1_RELEASE/xpcom/reflect/xptcall/md/unix/xptcstubs_riscv64.cpp
felixonmars
added a commit
to felixonmars/archriscv-packages
that referenced
this pull request
Oct 25, 2026
Bundled wasm2c selects vector registers on baseline RISC-V, failing in rlboxsoundtouch.wasm.c with "could not allocate input reg for constraint 'vr'". Reuse the Firefox Developer Edition patch to require __riscv_vector for the vector constraint and use a memory operand otherwise, preserving forced SIMD reads and RLBox guard-page sandboxing. WABT PR #2880 gates RVV but retains the floating-point fallback. Apply the memory-operand approach from unmerged PR #2888 only to RISC-V in the prebuilt template consumed by the build. WebAssembly/wabt#2880 WebAssembly/wabt#2888 https://archriscv.felixc.at/.status/logs/thunderbird/thunderbird-158.0-1.log
CSharperMantle
added a commit
to AOSC-Tracking/firefox-git
that referenced
this pull request
Oct 29, 2026
CSharperMantle
added a commit
to AOSC-Tracking/thunderbird
that referenced
this pull request
Oct 29, 2026
felixonmars
added a commit
to felixonmars/archriscv-packages
that referenced
this pull request
Oct 30, 2026
Drop the XPCOM tail-call patch already included by Mozilla bug 2077820; prepare() rejects it as previously applied in the 159.0 source. Use the Firefox overlay's wasm2c bounds checks on RISC-V without RVV for "could not allocate input reg for constraint 'vr'". Upstream's RVV guard leaves an unsuitable floating-point fallback, and its rejected memory-operand fallback cannot guarantee the reads needed by guard pages. No complete upstream fix was found. Keep RLBox sandboxing and the llama.cpp RVV feature-detection fix. https://github.com/mozilla-firefox/firefox/blob/FIREFOX_159_0_RELEASE/xpcom/reflect/xptcall/md/unix/xptcstubs_riscv64.cpp#L142 WebAssembly/wabt#2880 WebAssembly/wabt#2888 (review) https://archriscv.felixc.at/.status/logs/librewolf/librewolf-159.0.0_1-1.log https://archriscv.felixc.at/.status/logs/librewolf/librewolf-158.0.1_1-1.log
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.
When building Firefox 158, which uses vendored wasm2c to compile WASM code, on RISC-V RVA20U64, the following error occurs:
Thus gating this arm by
defined(__riscv_vector).