Description
Description
CoreCLR WASI ReadyToRun app builds compose the crossgen2 composite into the host module with ComposeWasiReadyToRun (src/tasks/WasmAppBuilder/ComposeWasiReadyToRun.cs). wasm-merge joins the host, a generated shim and the composite, then wasm-opt --all-features -g --simplify-globals rewrites the merged module.
When an app's composite includes Roslyn, the merged module is large enough that wasm-opt is killed for running out of memory on the CI build agent (exit code 137, "Free memory is lower than 5%"). Microsoft.Extensions.Options.SourceGeneration.Unit.Tests produces a composite of 485,659 functions with a 34 MB payload. The failure aborts the whole LibraryTestsCoreCLR_WASI_R2R build step, so no suite reaches Helix.
src/mono/wasi/build/WasiApp.CoreCLR.targets(481,5): error : wasm-opt failed with exit code 137:
[.../Microsoft.Extensions.Options.SourceGeneration.Unit.Tests.csproj::TargetFramework=net11.0]
Seen in the wasi-wasm linux Release LibraryTestsCoreCLR_WASI_R2R lane of #134813 (build 1617382 and build 1617446). The same suite composes successfully on a developer machine with more memory.
Possible directions
- Avoid the whole-module
wasm-optpass: apply the global simplification the shim needs during composition, or restrictwasm-optto the passes that are required. - Drop
-gfrom the merge and optimize steps for CI builds, if names are not needed there. - Otherwise, bound the size of test composites, for example by keeping Roslyn out of the composite.
Note
This issue was drafted with the help of GitHub Copilot.
Activity
dotnet-policy-service commentedon Sep 30, 2026
Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara
See info in area-owners.md if you want to be subscribed.
[wasi] Compose ReadyToRun without wasm-opt by default
[wasi] Compose ReadyToRun without wasm-opt by default
[wasi] Compose ReadyToRun without wasm-opt by default
[wasi] Compose ReadyToRun without wasm-opt by default
[wasi] Compose ReadyToRun without wasm-opt by default
[wasi] Compose ReadyToRun without wasm-opt by default
[browser][coreclr] Support WasmRunWasmOpt for ReadyToRun images (#136772