Skip to content

[wasi][coreclr] wasm-opt runs out of memory composing large ReadyToRun composites #134953

Open

Description

@lewing

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-opt pass: apply the global simplification the shim needs during composition, or restrict wasm-opt to the passes that are required.
  • Drop -g from 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

  1. added
    arch-wasm
    on Sep 30, 2026
  2. dotnet-policy-service commented on Sep 30, 2026

    @dotnet-policy-service
    Contributor

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

  3. added
    untriaged
    on Sep 30, 2026
  4. added
    os-wasi
    and removed
    untriaged
    on Sep 30, 2026
  5. added this to the 12.0.0 milestone on Sep 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    arch-wasmarea-Build-monoos-wasi

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions