Skip to content

[browser][CoreCLR] Enable trimmed ReadyToRun library-test CI - #133656

Open
lewing wants to merge 23 commits into
dotnet:mainfrom
lewing:lewing-wasm-r2r-library-tests
Open

lewing wants to merge 23 commits into
dotnet:mainfrom
lewing:lewing-wasm-r2r-library-tests

Conversation

@lewing

@lewing lewing commented Sep 11, 2026

Copy link
Copy Markdown
Member

Summary

Addresses #133193 by enabling aggressively trimmed browser CoreCLR library tests and adding separate LibraryTestsCoreCLR_R2R Chrome CI lanes. Uses the existing browser trimming configuration and descriptors; no Apple-mobile descriptor imports are added.

  • Introduce test-scoped TestWasmReadyToRun, avoiding global PublishReadyToRun=true reaching host-side build tools.
  • Pass identical R2R/trimming properties through build and Helix submission, with distinct test-run names. Existing interpreter lanes remain separate; the R2R lane selects the full supported inner-loop project set. R2R jobs have a 480-minute timeout; the interpreter default remains 240 minutes.
  • Set TEST_READY_TO_RUN_MODE=1 and use PlatformDetection.IsWasmReadyToRun for browser/WASI-scoped quarantines, preserving interpreter coverage.
  • Keep only TestUtilities.dll interpreted for the open platform-probe issue; CoreLib, libraries, and test assemblies remain R2R.
  • Remove stale .ilproj Link metadata from the TestILAssembly reference so its DLL is staged with the correct VFS name.
  • Preserve function-table/RuntimeFunctions ordering for WebAssembly virtual-dispatch thunks so async resume fixups resolve generated R2R resume stubs correctly.
  • Document the local workflow and retain WasmBuildNativeImplicitInReleaseConfiguration=false.

Integrated prerequisites and fixes

The original browser R2R publishing prerequisite #133378 has landed on main and is incorporated by the main merges in this branch. Other landed fixes incorporated here include:

Function-table ordering fix

#133146 introduced virtual-dispatch thunks into the Wasm function table before compiled methods and transition thunks. Existing resumption fixups intentionally encode relative function-table indices and correlate them with RuntimeFunctions ordinals. The inserted table-only thunk shifted those spaces apart.

Nesm decoded the live failure before the fix:

Continuation_Wrapper_0 expected (i32 i32 i32 i32) -> i32
table[95189] = RuntimeAsync_YieldAtEachLevel_CallstackShrinks_Marker
actual signature: (i32 i32 i32) -> void

The correct adjacent generated <Resume> stub had the expected four-argument signature. The fix moves WasmVirtualDispatchThunkNode after compiled method and transition-thunk nodes, restoring the invariant without changing dispatch codegen or adding steady-state overhead. New compiler regression coverage validates both ResumptionStubEntryPoint and StoreMultiCallableAddrOfCode targets in the presence of virtual dispatch.

Remaining quarantines

Issue Scope
#133614 TestUtilities.dll stays interpreted; product/test assemblies remain R2R. Fix PR #133773 is still open.
#133618 Closed-static-delegate struct return test remains excluded. Fix PR #134108 is still open.
#134145 Three StateMachineAsync/V1 callstack-identity methods remain excluded; #133768 fixed the V2 path only.
#133627 RuntimeAsync_WhenAny_TracksAllBranches remains excluded for its independent memory-OOB transition failure.

Local validation

macOS arm64 host, browser-wasm CoreCLR Release, Chromium 154.

Rebuilt Release tasks and matched browser CoreCLR, crossgen2, CoreLib, libraries, host, and packs after merging main and applying the ordering fix.

Focused fix validation supplied and independently integrated:

Current full smoke after the revised fix has completed successfully for System.Runtime, HTTP, WebSockets, JavaScript interop, and Threading; the initial Tasks run reached only the known #133627 failure. After restoring that one exclusion, the standalone full Tasks project passed as reported above.

The full supported R2R library selection is still running at the time of this update. Results will be added before the draft is marked ready.

Earlier descriptor-ablation comparisons ran full UnmanagedMemoryStream, FileSystem, Cryptography, Data.Common, Globalization, and LINQ suites in both actual EAT and trimmed R2R with the original browser roots: 136,138 passed, 1,141 skipped, zero failed per configuration, with identical counts. No Apple-only roots or replacement descriptors were required.

ActiveIssue-filtered cases are omitted from totals rather than counted as skipped. No performance claim is made; the ordering fix changes deterministic table placement only and has no steady-state dispatch cost.

Note

This PR description and changes were prepared with GitHub Copilot assistance.

@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.

@dotnet-policy-service dotnet-policy-service Bot added the linkable-framework Issues associated with delivering a linker friendly framework label Sep 11, 2026
@lewing
lewing requested review from maraf, pavelsavara and radekdoulik and a lite review from Copilot September 11, 2026 03:02
@lewing lewing added arch-wasm WebAssembly architecture area-Infrastructure-libraries os-browser Browser variant of arch-wasm and removed area-Build-mono labels Sep 11, 2026
@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: @dotnet/area-infrastructure-libraries
See info in area-owners.md if you want to be subscribed.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Unresolved configuration, trimmed-closure assertion, and MVID image-validation findings remain.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review tier: Lite
Findings: 1 High severity · 1 Medium severity

New issues introduced by this change (2)
Severity Finding
High severity src/​tasks/​Microsoft.NET.Sdk.WebAssembly.Pack.Tasks/​ConvertDllsToWebCil.cs — Reject unreadable prebuilt images before staging
Medium severity src/​mono/​nuget/​Microsoft.NET.Sdk.WebAssembly.Pack/​build/​Microsoft.NET.Sdk.WebAssembly.Browser.props — Gate the CoreCLR crossgen override away from Mono builds
What changed in this PR

Enables trimmed CoreCLR browser library-test CI with ReadyToRun while preserving separate interpreter coverage.

Changes:

  • Adds scoped trimming/R2R properties and dedicated CI lanes.
  • Adds CoreCLR browser publishing, Crossgen2 resolution, WebCIL staging, and MVID validation.
  • Adds R2R test coverage, quarantines, Helix propagation, and workflow documentation.
File Summary
src/​tasks/​Microsoft.NET.WebAssembly.Webcil/​WebcilReader.cs Corrects metadata-reader disposal.
src/​tasks/​Microsoft.NET.Sdk.WebAssembly.Pack.Tasks/​ConvertDllsToWebCil.cs Validates and stages R2R WebCIL images.
src/​mono/​wasm/​Wasm.Build.Tests/​WebcilInWasmSizesTests.cs Covers WebCIL/R2R staging behavior.
src/​mono/​wasm/​Wasm.Build.Tests/​Templates/​WasmTemplateTestsBase.cs Pins Crossgen2 pack versions.
src/​mono/​wasm/​Wasm.Build.Tests/​ReadyToRunTests.cs Tests R2R publishing and trimmed closure behavior.
src/​mono/​wasm/​Wasm.Build.Tests/​Common/​EnvironmentVariables.cs Adds test environment configuration.
src/​mono/​wasm/​testassets/​BlazorBasicTestApp/​App/​Pages/​Weather.razor Supports browser interaction testing.
src/​mono/​sample/​wasm/​Directory.Build.props Updates sample build properties.
src/​mono/​nuget/​Microsoft.NET.Sdk.WebAssembly.Pack/​build/​Microsoft.NET.Sdk.WebAssembly.Browser.props Activates CoreCLR R2R wiring.
src/​mono/​nuget/​Microsoft.NET.Sdk.WebAssembly.Pack/​build/​Microsoft.NET.Sdk.WebAssembly.Browser.CoreCLR.targets Implements CoreCLR browser R2R publishing.
src/​mono/​nuget/​Microsoft.NET.Sdk.WebAssembly.Pack/​build/​Microsoft.NET.Sdk.WebAssembly.Browser.CoreCLR.ReadyToRun.targets Resolves browser-compatible Crossgen2 tooling.
src/​mono/​nuget/​Microsoft.NET.Sdk.WebAssembly.Pack/​build/​Microsoft.NET.Sdk.WebAssembly.Browser.CoreCLR.props Imports CoreCLR R2R configuration.
src/​mono/​browser/​build/​WasmApp.ReadyToRun.targets Updates browser R2R target wiring.
src/​mono/​browser/​build/​WasmApp.InTree.props Updates in-tree browser build properties.
src/​libraries/​System.Runtime/​tests/​System.Threading.Tasks.Tests/​System.Runtime.CompilerServices/​AsyncProfilerV2Tests.cs Adds targeted R2R quarantines.
src/​libraries/​System.Runtime/​tests/​System.Threading.Tasks.Tests/​System.Runtime.CompilerServices/​AsyncProfilerV1Tests.cs Adds targeted R2R quarantines.
src/​libraries/​System.Runtime/​tests/​System.Runtime.Tests/​System/​Runtime/​CompilerServices/​MethodImplAttributeTests.cs Adds R2R-specific test handling.
src/​libraries/​System.Runtime/​tests/​System.Runtime.Tests/​System/​Reflection/​MethodBaseTests.cs Adds R2R-specific test handling.
src/​libraries/​System.Runtime/​tests/​System.Runtime.Tests/​System/​Reflection/​CustomAttributeDataTests.cs Adds R2R-specific test handling.
src/​libraries/​System.Runtime/​tests/​System.Runtime.Tests/​System/​ExceptionTests.cs Adds R2R-specific test handling.
src/​libraries/​System.Runtime/​tests/​System.Runtime.Tests/​System/​DelegateTests.cs Adds R2R-specific test handling.
src/​libraries/​System.Runtime/​tests/​System.Runtime.Tests/​System/​ArrayTests.cs Adds R2R-specific test handling.
src/​libraries/​System.Runtime/​tests/​System.Runtime.Tests/​System.Runtime.Tests.csproj Updates trimming and assembly staging metadata.
src/​libraries/​System.Runtime.InteropServices.JavaScript/​tests/​System.Runtime.InteropServices.JavaScript.UnitTests/​System.Runtime.InteropServices.JavaScript.Tests.csproj Configures JavaScript interop test publishing.
src/​libraries/​sendtohelix-browser.targets Propagates browser test settings.
src/​libraries/​Directory.Build.props Adds test-scoped R2R enablement.
src/​libraries/​Common/​tests/​TestUtilities/​System/​PlatformDetection.cs Adds WASM R2R detection.
src/​coreclr/​System.Private.CoreLib/​System.Private.CoreLib.csproj Updates CoreLib trimming configuration.
eng/​testing/​tests.browser.targets Configures browser trimming and R2R settings.
eng/​pipelines/​runtime.yml Adds standard browser R2R coverage.
eng/​pipelines/​extra-platforms/​runtime-extra-platforms-wasm.yml Adds extra-platform R2R coverage.
eng/​pipelines/​common/​templates/​wasm-coreclr-library-tests.yml Propagates R2R and trimming parameters.
eng/​liveILLink.targets Enables browser test trimming configuration.
docs/​workflow/​testing/​libraries/​testing-wasm.md Documents local trimmed R2R testing.

@lewing

lewing commented Sep 11, 2026

Copy link
Copy Markdown
Member Author

@AndyAyersMS are the AsyncProfilerTests expected to work on wasm, the session disabled them individually but I can make it blanket if preferred?

@AndyAyersMS

Copy link
Copy Markdown
Member

@AndyAyersMS are the AsyncProfilerTests expected to work on wasm, the session disabled them individually but I can make it blanket if preferred?

I'm not sure what surface these cover. If they rely on the ResumeInfo.DiagnosticIP then they're not going to work now and possibly for quite some time.

@lewing

lewing commented Sep 11, 2026

Copy link
Copy Markdown
Member Author

#133707 has a fix for the MethodBase.GetCurrentMethod failures currently marked ActiveIssue here

lewing added a commit that referenced this pull request Sep 11, 2026
)

Fixes #133617.

## Problem

The Wasm portable-entrypoint slow path retains a `PrestubMethodFrame`
while invoking a resolved R2R body. Function-only stack walks can report
both the real managed activation and that transition frame.
`MethodBase.GetCurrentMethod` can therefore accept its own prestub frame
as the caller.

A Checked-runtime capture confirmed this: the stack marker was
`0x4fe71c`; the real `GetCurrentMethod` body at SP `0x4fe710` did not
pass the caller-marker comparison, but its explicit `PrestubMethodFrame`
at SP `0x4fe720` did. The result was `GetCurrentMethod` instead of the
calling method. This also reproduces without trimming.

#133610 addressed the duplicate in `GetStackFramesCallback`, but
caller-sensitive reflection uses a different callback and did not
benefit from that filter.

## Change

- Mark completed non-FCall Wasm prestub transitions as not representing
an additional managed activation.
- Filter those frames centrally for `FUNCTIONSONLY` walks, covering both
ordinary and skipped explicit frames.
- Retain the frame, MethodDesc, argument-root reporting, and physical
unwind/exception lifetime. Popping early or clearing the MethodDesc
would lose GC protection and the unwind bridge across interpreter-to-R2R
transitions.
- Replace #133610's StackTrace-specific adjacency filter. Filtering by
lifecycle rather than matching method identities preserves genuine
recursion.
- Extend the existing `github60486` regression with
direct/inlineable/generic caller identity, assembly lookup, recursive
frame counts, and compacting-GC object/byref/struct argument coverage.
Its original DIM frame-sequence and exception-stack checks remain
intact.

Native FCalls retain their existing representation. Non-Wasm filtering
behavior is unchanged.

## Validation

### CoreCLR runtime regression

Built browser-Wasm and macOS arm64 Checked runtimes with Release
libraries. The expanded
`Loader/classloader/DefaultInterfaceMethods/regressions/github60486`
passes with fixed Wasm R2R, the interpreter, and native arm64. The
identical final regression assembly fails against the saved original
Wasm runtime: expected `ValidateCurrentMethod`, actual
`GetCurrentMethod`.

These fixed runs include the original regression checks from #133610,
with its `debugdebugger.cpp` filter removed.

### Original browser library lane

Validated the exact patch in an isolated checkout of #133656 at
`282d12dfe220a1f34d0bb81a85239cab60c779ce`, which supplies the browser
R2R publishing/test prerequisites. Built matched original/fixed CoreCLR
Release products locally and ran Chromium 153. Temporarily enabled only
the nine #133617-quarantined methods, preserving every original
assertion and unrelated exclusion; all annotations were restored
afterward. This PR contains no library-test quarantine changes.

| Coverage | Original | Fixed |
|---|---:|---:|
| Cold trimmed direct GetCurrentMethod | 1 failed | 1 passed |
| Cold trimmed inlineable GetCurrentMethod | 1 failed | 1 passed |
| Trimmed targeted batch | 7 passed, 1 failed | 8 passed |
| Untrimmed R2R targeted batch | 8 passed, 1 failed | 9 passed |
| Full trimmed System.Runtime | 77,396 passed, 1 failed, 175 skipped |
77,397 passed, 0 failed, 175 skipped |

The affected-class fixed run also passed: 23 passed, 3 existing skips.
`CrossAssembly2` remains excluded when trimmed by dotnet/linker#2078 and
passes untrimmed; it is not counted as a trimmed pass.

Main test IL and main R2R images are byte-identical across each
original/fixed pair; skip sets are identical. Served assets were
verified against their respective rebuilt packs. This is a
matched-product A/B, not a native-module-only swap: CoreLib R2R image
bytes also differ.

### Existing reflection compatibility controls

`System.Reflection.Tests` caller-assembly theory, real cross-assembly
delegate invocation, static-constructor caller lookup,
executing-assembly lookup, and reflected first/second invocation all
pass: six cases on each original/fixed, trimmed/untrimmed browser R2R
configuration. Fresh-process delegate and reflective-invocation probes
also pass in all four configurations. All existing annotations remained
intact. These are compatibility controls, not failing-before
reproductions.

Full browser reflection suites have identical original/fixed results:

- Untrimmed: 1,750 passed, 1 failed, 23 skipped.
- Trimmed: 1,747 passed, 2 failed, 23 skipped.

Existing failures are `GetEntryAssembly` (browser host expectation
versus R2R expectation) and, trimmed only,
`AssemblyGetForwardedTypesLoadFailure` (underlying trimming cause not
isolated). Failure signatures and skip sets match before/after; neither
was suppressed.

Native arm64 Checked reflection control: six focused cases passed; full
suite 1,776 passed, 2 platform skips, zero failures.

## Remaining scope

Draft for review of the frame-lifecycle distinction and FCall exception.
Dedicated FCall cold/warm stack-identity coverage, a broader CoreCLR
GC-stress campaign, and other browsers have not been run. No performance
claim is made.

> [!NOTE]
> This change and pull request description were developed with GitHub
Copilot assistance.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings September 18, 2026 22:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The new R2R checker compares StoreMultiCallableAddrOfCode targets against the fixup owner rather than the encoded target method, potentially rejecting valid cross-method resume fixups.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 Medium severity

Open (1)
Resolved since last review (1)

Apply the test-lane ReadyToRun opt-in after projects finalize IsTestProject, and strip only that implicit value from all final project references. This keeps support projects and host build tools out of ReadyToRun while referenced browser test apps independently opt in.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings September 18, 2026 22:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

It combines broad CI/trimming changes with Wasm ReadyToRun codegen ordering changes, requiring final end-to-end validation and human review.

Review effort: Lite
Findings: 1 Medium severity

Open (1)

Validate ResumptionStub targets against their owning async methods, then require StoreMulti targets to match any registered resume target without assuming the fixup owner and target are the same method.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings September 18, 2026 22:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

It combines broad CI/build orchestration with low-level WebAssembly ReadyToRun ordering changes requiring final integrated human validation.

Review effort: Lite
Findings: None

Resolved since last review (1)

lewing and others added 2 commits September 18, 2026 23:16
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings September 19, 2026 05:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

AdminHelpers now uses OperatingSystem.IsBrowser() in TestUtilities, which also targets .NET Framework and requires a compatible fallback or framework guard.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 High severity

Open (1)

Comment thread src/libraries/Common/tests/TestUtilities/System/AdminHelpers.cs
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings September 19, 2026 08:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

The R2R environment variable is wired only for browser targets, so WASI R2R tests cannot activate the new readiness detection and quarantines.

Review effort: Lite
Findings: None

Resolved since last review (1)
Previously missed (1)

In code that hasn't changed since last review

Medium severity Set IsWasmReadyToRun for WASI test projects

eng/​testing/​tests.browser.targets:105

This environment variable is added only from tests.browser.targets; WASI test projects import tests.wasm.targets directly and never see it. Consequently a future/current WASI CoreCLR R2R app reports IsWasmReadyToRun == false, so all of the new WASI-scoped quarantines (and the R2R-specific GetEntryAssembly branch) run as if they were interpreter tests. Put the setting in the shared wasm targets or add the equivalent WASI target so the helper matches its documented browser/WASI contract.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings September 19, 2026 08:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

It combines broad trimming/CI changes with low-level Wasm R2R code-ordering behavior that requires human validation across build and Helix execution.

Review effort: Lite
Findings: None

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arch-wasm WebAssembly architecture area-Infrastructure-libraries linkable-framework Issues associated with delivering a linker friendly framework os-browser Browser variant of arch-wasm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants