Skip to content

Do not use CORINFO_HELP_INITCLASS on native AOT - #135760

Merged
MichalStrehovsky merged 1 commit into
dotnet:mainfrom
MichalStrehovsky:nativeaot-wasm-cctor-helper
Oct 14, 2026
Merged

MichalStrehovsky merged 1 commit into
dotnet:mainfrom
MichalStrehovsky:nativeaot-wasm-cctor-helper

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

Limit Wasm's CORINFO_HELP_INITCLASS early return in fgGetSharedCCtor to CoreCLR. NativeAOT can then use its existing ReadyToRun class-constructor/static-base helper selection instead of requesting a helper ILC cannot implement.

The observed failure was System.NotImplementedException: CORINFO_HELP_INITCLASS while compiling System.AppContext.OnUnhandledException(object). The corrected JIT dump selects CORINFO_HELP_READYTORUN_NONGCSTATIC_BASE. CoreCLR Wasm still avoids dynamically created helpers.

Validation

  • .\src\coreclr\build-runtime.cmd -checked -x64 -component wasmjit - passed.
  • The real-CoreLib startup method compiled past the original helper-selection failure.
  • Both local Hello objects ultimately compiled with normal scanning and -NoDebug; with the rest of the series, both linked and ran successfully 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.

We cannot implement this helper, it's considered reflection. We have no problem emitting the R2R helpers needed.

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.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 5 pipeline(s).
11 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.

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