Skip to content

Do not emit try table on native AOT - #135761

Merged
MichalStrehovsky merged 3 commits into
dotnet:mainfrom
MichalStrehovsky:nativeaot-wasm-try-blocks
Oct 15, 2026
Merged

MichalStrehovsky merged 3 commits into
dotnet:mainfrom
MichalStrehovsky:nativeaot-wasm-try-blocks

Conversation

@MichalStrehovsky

Copy link
Copy Markdown
Member

Part of a series of pull requests that enable compiling, linking, and running a Console.WriteLine hello world on WASI/native AOT.

Summary

Emit an ordinary Wasm block for NativeAOT try intervals instead of CoreCLR's try_table/catch-resumption scheme. This avoids emitting WASM_CLR_RESTORE_CONTEXT_EXCEPTION_TAG_LEB, which the NativeAOT object-writing path does not support.

Interval nesting, funclet emission, scanner dependencies, and normal-path finally execution are retained. CoreCLR keeps its existing behavior.

This is a bringup workaround, not an exception-handling implementation. Managed catch/filter execution and exception resumption remain unsupported.

Validation

  • .\src\coreclr\build-runtime.cmd -checked -x64 -component wasmjit - passed.
  • Both local real-CoreLib Hello probes compiled successfully with ILC debug information disabled (compile-hello.ps1 -NoDebug, including the -Variant CoreLib control).
  • With the rest of the series, the CoreLib Preview 1 module and Console Preview 2 component both printed Hello world from WASI CoreLib! and exited 0 under Wasmtime.

These results are from the combined local bringup tree, including prerequisite NativeAOT/Wasm enablement, not a fresh build of this isolated main-based branch. The probe scripts are local fixtures, not tests added by this PR.

Note

This PR description was generated by GitHub Copilot.

Not sure if the EH scheme is supposed to work with native AOT. LLVM-WASM does things differently. For now, do not generate any try tables on native AOT, EH doesn't work anyway.

Avoids relocs to WASM_CLR_RESTORE_CONTEXT_EXCEPTION_TAG_LEB.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: c78266f3-08e3-4918-b2e5-9fe0ddf2ca17
@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.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 6 pipeline(s).
10 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@MichalStrehovsky MichalStrehovsky added area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI and removed area-NativeAOT-coreclr labels Oct 14, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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

Comment thread src/coreclr/jit/codegenwasm.cpp Resolved
Updated TODO comment for clarity regarding NativeAOT.
@MichalStrehovsky
MichalStrehovsky merged commit 34ac16e into dotnet:main Oct 15, 2026
126 of 129 checks passed
@MichalStrehovsky
MichalStrehovsky deleted the nativeaot-wasm-try-blocks branch October 15, 2026 00:51
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Oct 19, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 19, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

arch-wasm WebAssembly architecture area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants