Skip to content

[wasm][wasi] CoreCLR-WASI bring-up fixes: Checked build, PAL stubs, getHelperFtn, call helpers - #133239

Merged
pavelsavara merged 5 commits into
dotnet:mainfrom
pavelsavara:fix_wasi
Sep 4, 2026
Merged

[wasm][wasi] CoreCLR-WASI bring-up fixes: Checked build, PAL stubs, getHelperFtn, call helpers#133239
pavelsavara merged 5 commits into
dotnet:mainfrom
pavelsavara:fix_wasi

Conversation

@pavelsavara

@pavelsavarapavelsavara commented Sep 4, 2026

Copy link
Copy Markdown
Member

Contributes to #133240

A set of CoreCLR-on-WASI bring-up fixes discovered while getting JIT/CodeGenBringUpTests to run under wasmtime in a Checked build. Each is an independent commit.

Commits

  • Fix WASI PAL stubs for the CoreCLR Checked buildpal/src/debug/debug.cpp is excluded on WASI, so PAL_ProbeMemory (referenced by vm/debughelp.cpp under TARGET_UNIX) had no definition and wasm-ld failed with an undefined symbol in Checked (the reference is dead-stripped in Release). Provide it in arch/wasm/stubs.cpp next to the other replacements for the excluded PAL sources, and drop the now-dead TARGET_WASI branch in debug.cpp. Also: the WASI DebugBreak stub no longer calls _ASSERTAssertBreak calls DebugBreak, so asserting recursed until the stack was exhausted and masked the original assert.
  • Do not pass wasm EH flags to the MSVC cross-components build — guard the WASI exception-handling compile/link flags with NOT CLR_CROSS_COMPONENTS_BUILD (mirroring the browser block) so -fwasm-exceptions / -mllvm -wasm-use-legacy-eh don't leak onto the MSVC host-tool compiles (cl warning D9002).
  • Allow interpreter-preferred JIT helpers in 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 with HasNativeEntryPoint so it no longer asserts inside GetActualCode.
  • Regenerate WASI call helpers — regenerated callhelpers-interp-to-managed.cpp / callhelpers-pinvoke.cpp with 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 ExecuteAssembly entry-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.

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

Copy link
Copy Markdown
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.

@pavelsavarapavelsavara added arch-wasm WebAssembly architecture os-wasi Related to WASI variant of arch-wasm labels Sep 4, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @agocke
See info in area-owners.md if you want to be subscribed.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara
See info in area-owners.md if you want to be subscribed.

@pavelsavarapavelsavara added this to the 12.0.0 milestone Sep 4, 2026
@pavelsavara
pavelsavara marked this pull request as ready for review September 4, 2026 15:05
CopilotAI lite review requested due to automatic review settings September 4, 2026 15:05
@azure-pipelines

Copy link
Copy Markdown
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.

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 DebugBreak and PAL_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 getHelperFtn to allow interpreter-preferred IL helpers even when R2R is enabled.
File summaries
FileDescription
src/coreclr/vm/wasm/wasi/callhelpers-pinvoke.cppUpdate generated WASI P/Invoke override table (remove one compression entry and fix counts).
src/coreclr/vm/wasm/wasi/callhelpers-interp-to-managed.cppRegenerate generated WASI interp-to-managed portable signature thunks.
src/coreclr/vm/jitinterface.cppRelax R2R/native-code assertion for IL-based dynamic helpers by guarding with HasNativeEntryPoint.
src/coreclr/pal/src/debug/debug.cppRemove WASI-specific PAL_ProbeMemory branch from a file that is excluded on WASI.
src/coreclr/pal/src/arch/wasm/stubs.cppAdd WASI replacements for debug output and PAL_ProbeMemory.
eng/native/configureplatform.cmakeCorrect 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

Comment threadsrc/coreclr/pal/src/arch/wasm/stubs.cpp
@pavelsavara

Copy link
Copy Markdown
MemberAuthor

/ba-g failure is #133255

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arch-wasmWebAssembly architecturearea-VM-coreclros-wasiRelated to WASI variant of arch-wasm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@pavelsavara@lewing