[wasm] Support browser-wasm/wasi-wasm ReadyToRun in ResolveReadyToRunCompilers - #55785
Open
pavelsavara wants to merge 3 commits into
Open
[wasm] Support browser-wasm/wasi-wasm ReadyToRun in ResolveReadyToRunCompilers#55785pavelsavara wants to merge 3 commits into
pavelsavara wants to merge 3 commits into
Conversation
…Compilers crossgen2 can target WebAssembly (--obj-format:wasm), but ResolveReadyToRunCompilers rejected browser-wasm/wasi-wasm target RIDs: ExtractTargetPlatformAndArchitecture had no 'wasm' architecture case and GetCrossgen2TargetOS did not map the 'browser'/'wasi' OS, so PublishReadyToRun failed with ReadyToRunTargetNotSupportedError. Add the wasm architecture and browser/wasi target OS. The wasm cross-JIT (clrjit_universal_wasm_<host>) is auto-loaded by crossgen2 from its tools/ dir, so no JitPath change is needed for crossgen2 v6+.
|
Azure Pipelines: Successfully started running 1 pipeline(s). 2 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
The wasm cross-JIT ships only in the .NET 11+ crossgen2 pack, so older packs would resolve as supported and then fail to load the JIT. Require crossgen2 pack major >= 11 for browser/wasi targets.
The wasm container format wraps a per-assembly ECMA manifest, so it does not require composite compilation. Forcing --composite for any non-PE container produced a composite-of-one image whose only metadata was the R2R manifest (no assembly manifest), causing CoreCLR-on-wasm to fail loading with COR_E_BADIMAGEFORMAT (module expected to contain an assembly manifest). Assisted-by: GitHub Copilot
|
Azure Pipelines: Successfully started running 1 pipeline(s). 2 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR enables PublishReadyToRun for WebAssembly RIDs (browser-wasm / wasi-wasm) by teaching the SDK’s ReadyToRun tool resolution logic to recognize the wasm architecture and map browser/wasi as valid crossgen2 target OS values. It also adjusts crossgen2 argument generation so the wasm container format doesn’t incorrectly force composite compilation, and gates wasm R2R support to .NET 11+ crossgen2 packs (where the wasm cross-JIT is available).
Changes:
- Extend RID parsing and architecture string mapping to support
wasm(Architecture.Wasm) inResolveReadyToRunCompilers. - Recognize
browserandwasias valid--targetosvalues and gate wasm R2R to crossgen2 pack version 11+. - Avoid forcing
--compositepurely due to--obj-format:wasminRunReadyToRunCompiler.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/Tasks/Microsoft.NET.Build.Tasks/RunReadyToRunCompiler.cs | Prevents --obj-format:wasm from implicitly forcing --composite during response-file generation. |
| src/Tasks/Microsoft.NET.Build.Tasks/ResolveReadyToRunCompilers.cs | Adds wasm RID support (arch + OS mapping) and gates wasm R2R to .NET 11+ crossgen2 packs. |
maraf
approved these changes
Aug 15, 2026
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.
Summary
crossgen2 can already target WebAssembly (
--obj-format:wasm), but the SDK'sResolveReadyToRunCompilerstask rejectedbrowser-wasm/wasi-wasmtarget RIDs, soPublishReadyToRunfailed withReadyToRunTargetNotSupportedErrorbefore crossgen2 was ever invoked.Two gaps in the task:
ExtractTargetPlatformAndArchitecturehad nowasmarchitecture case → returnedfalse.GetCrossgen2TargetOSdid not includebrowser/wasiin the runtime-graph match list or the OS switch → returnednull.Related dotnet/runtime#132339
Change
case "wasm" → Architecture.Wasm(guarded by#if !NETFRAMEWORK, sinceArchitecture.Wasmis .NET 5+, matching the existingRiscV64/LoongArch64handling).Architecture.Wasm => "wasm"inArchitectureToString.browserandwasito theGetCrossgen2TargetOScandidate list and switch.crossgen2PackVersion.Major >= 11): the wasm cross-JIT ships only in the .NET 11+ crossgen2 pack, so for older packsbrowser/wasitargets fall back to the existingReadyToRunTargetNotSupportedErrorrather than resolving and then failing to load the JIT.No
JitPathplumbing is needed: for crossgen2 v6+ the task sets no jit path, and crossgen2 auto-loads the wasm cross-JIT (clrjit_universal_wasm_<hostArch>) from its owntools/directory.Merge ordering
This can merge independently of the dotnet/runtime side. The change is inert for every existing scenario:
default → falsecases now match, but only forwasm/browser/wasi).PublishReadyToRunon live in dotnet/runtime. Until those ship, nothing in the shipped SDK reaches this path by default (browser/wasi CoreCLR R2R is experimental and not enabled by default).Context
Unblocks ReadyToRun for the experimental CoreCLR-on-WebAssembly target. The consuming runtime-pack / SDK targets work (per-assembly R2R webcil-in-wasm) lives in dotnet/runtime and is validated end-to-end there. The runtime repo currently masks this task gap with an in-tree
ResolveReadyToRunCompilerstarget override that is not shipped; this PR removes the need for that override in the shipped SDK.Validation
Verified in dotnet/runtime by forcing the SDK-native task path (bypassing the in-tree override): the task resolves
arch = Wasm,os = browser, and — given the standard crossgen2 packtools/layout — locates crossgen2, runs it, and the published assemblies are byte-identical to the crossgen R2R output. Compiles clean; no new strings/localization.Note
This PR description and change were drafted with GitHub Copilot.