Uh oh!
There was an error while loading. Please reload this page.
[wasm][wasi] CoreCLR-WASI bring-up fixes: Checked build, PAL stubs, getHelperFtn, call helpers - #133239
Conversation
Provide PAL_ProbeMemory in arch/wasm/stubs.cpp: pal/src/debug/debug.cpp is excluded on WASI so its definition was missing, and wasm-ld reported an undefined symbol in Checked (the reference is dead-stripped in Release). Remove the now-dead TARGET_WASI branch from debug.cpp. DebugBreak no longer calls _ASSERT. AssertBreak calls DebugBreak, so asserting recursed until the stack was exhausted and masked the original assert; trap directly instead.
…uild Guard the WASI exception-handling compile/link flags with NOT CLR_CROSS_COMPONENTS_BUILD, mirroring the browser block, so -fwasm-exceptions and -mllvm -wasm-use-legacy-eh do not leak onto MSVC host-tool compiles (cl warning D9002).
An IL-based dynamic JIT helper (for example VirtualFunctionPointer) can run interpreted with no native code even when ReadyToRun is enabled. Guard the published-native-code assert with HasNativeEntryPoint so it no longer asserts inside GetActualCode.
Regenerated callhelpers-interp-to-managed.cpp and callhelpers-pinvoke.cpp with the crossgen2 PortableCallHelpers generator over the WASI framework closure.
|
Azure Pipelines: Successfully started running 3 pipeline(s). 13 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Tagging subscribers to this area: @agocke |
Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara |
|
Azure Pipelines: Successfully started running 3 pipeline(s). 13 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
🟡 Changes recommended
The new WASI PAL_ProbeMemory stub performs unchecked pointer/size arithmetic that can overflow and incorrectly validate out-of-bounds ranges.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR makes a set of CoreCLR-on-WASI bring-up fixes to improve Checked-build viability and interpreter execution, including providing missing PAL stubs, tightening build-flag gating for WASI exception handling, relaxing a ReadyToRun-related assert for interpreter-preferred helpers, and regenerating WASI call-helper tables.
Changes:
- Add/adjust WASI-specific PAL stubs (notably
DebugBreakandPAL_ProbeMemory) while simplifying non-WASI PAL code paths. - Gate WASI wasm-exception compile/link flags to avoid leaking them into cross-components host-tool builds.
- Regenerate WASI call-helper thunks and P/Invoke override tables; update
getHelperFtnto allow interpreter-preferred IL helpers even when R2R is enabled.
File summaries
| File | Description |
|---|---|
| src/coreclr/vm/wasm/wasi/callhelpers-pinvoke.cpp | Update generated WASI P/Invoke override table (remove one compression entry and fix counts). |
| src/coreclr/vm/wasm/wasi/callhelpers-interp-to-managed.cpp | Regenerate generated WASI interp-to-managed portable signature thunks. |
| src/coreclr/vm/jitinterface.cpp | Relax R2R/native-code assertion for IL-based dynamic helpers by guarding with HasNativeEntryPoint. |
| src/coreclr/pal/src/debug/debug.cpp | Remove WASI-specific PAL_ProbeMemory branch from a file that is excluded on WASI. |
| src/coreclr/pal/src/arch/wasm/stubs.cpp | Add WASI replacements for debug output and PAL_ProbeMemory. |
| eng/native/configureplatform.cmake | Correct host-vs-target WASI detection and guard WASI EH flags for non-cross-components builds. |
Review details
- Files reviewed: 6/6 changed files
- Comments generated: 1
- Review effort level: Lite
Uh oh!
There was an error while loading. Please reload this page.
pavelsavara
commented
Sep 4, 2026
/ba-g failure is #133255 |
Uh oh!
There was an error while loading. Please reload this page.
Contributes to #133240
A set of CoreCLR-on-WASI bring-up fixes discovered while getting
JIT/CodeGenBringUpTeststo run under wasmtime in a Checked build. Each is an independent commit.Commits
pal/src/debug/debug.cppis excluded on WASI, soPAL_ProbeMemory(referenced byvm/debughelp.cppunderTARGET_UNIX) had no definition andwasm-ldfailed with an undefined symbol in Checked (the reference is dead-stripped in Release). Provide it inarch/wasm/stubs.cppnext to the other replacements for the excluded PAL sources, and drop the now-deadTARGET_WASIbranch indebug.cpp. Also: the WASIDebugBreakstub no longer calls_ASSERT—AssertBreakcallsDebugBreak, so asserting recursed until the stack was exhausted and masked the original assert.NOT CLR_CROSS_COMPONENTS_BUILD(mirroring the browser block) so-fwasm-exceptions/-mllvm -wasm-use-legacy-ehdon't leak onto the MSVC host-tool compiles (clwarning D9002).getHelperFtn— an IL-based dynamic helper (e.g.VirtualFunctionPointer) can run interpreted with no native code even when ReadyToRun is enabled. Guard the published-native-code assert withHasNativeEntryPointso it no longer asserts insideGetActualCode.callhelpers-interp-to-managed.cpp/callhelpers-pinvoke.cppwith the crossgen2 PortableCallHelpers generator over the WASI framework closure.Status
With these applied, a Checked WASI corerun now boots and executes interpreted managed code through to
ExecuteAssemblyentry-point launch. Remaining bring-up work (entry-point resolution and the EH stack-frame-iterator path) is being investigated separately. Related tracking: #133124, #133187.Note
Portions of this PR description were generated with the assistance of GitHub Copilot.