Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions docs/workflow/testing/libraries/testing-wasm.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,26 +195,30 @@ stale staged assets can otherwise cause assembly-loading failures before tests s
The `LibraryTestsCoreCLR_R2R` CI jobs use the same configuration and archive the published
tests for execution on Helix. The existing interpreter jobs remain separate.

To run a library suite with a single composite ReadyToRun image instead of per-assembly
images, add `PublishReadyToRunComposite=true`:
CoreCLR browser ReadyToRun tests publish a single composite image
(`<test assembly>.r2r.wasm`) by default. It is staged into `wwwroot/_framework` beside
the component WebCIL stubs and listed in the boot config.

To run a library suite with per-assembly ReadyToRun images instead, add
`PublishReadyToRunComposite=false`:

```bash
XHARNESS_COMMAND=test-browser ./build.sh libs.tests -test -os browser -c Release \
--projects $PWD/src/libraries/System.Memory/tests/System.Memory.Tests.csproj \
/p:RuntimeFlavor=CoreCLR /p:TestWasmReadyToRun=true /p:PublishReadyToRunComposite=true \
/p:RuntimeFlavor=CoreCLR /p:TestWasmReadyToRun=true /p:PublishReadyToRunComposite=false \
/p:EnableAggressiveTrimming=true /p:Scenario=WasmTestOnChrome /p:InstallChromeForTests=true
```

The composite image (`<test assembly>.r2r.wasm`) is staged into `wwwroot/_framework` beside
the component WebCIL stubs and listed in the boot config. As with other mode switches, clean
the project-specific `bin` and `obj` outputs when switching between composite and per-assembly
images.
As with other mode switches, clean the project-specific `bin` and `obj` outputs when
switching between composite and per-assembly images.

For CoreCLR browser applications, set `PublishReadyToRun=true` and
`PublishReadyToRunComposite=true` to publish a single composite ReadyToRun image and
component WebCIL stubs instead of per-assembly images. Publishing requires a wasm-capable
crossgen2 and WebCIL enabled; the composite is loaded before the runtime starts.
`ReadyToRunTests.PublishRunAllPagesComposite` exercises trimmed, untrimmed, and
For CoreCLR browser applications, ReadyToRun remains opt-in: set
`PublishReadyToRun=true` to publish a single composite ReadyToRun image and component
WebCIL stubs. Set `PublishReadyToRunComposite=false` to retain per-assembly images.
Publishing requires a wasm-capable crossgen2. Composite publishing additionally requires
ReadyToRun SDK tasks that support wasm composite output naming and WebCIL enabled;
the composite is loaded before the runtime starts.
`ReadyToRunTests.PublishRunAllPagesComposite` exercises the default mode with trimmed, untrimmed, and
native-relinked publishes in a browser, including asset fingerprinting when
`USE_FINGERPRINTING_FOR_TESTS=true`.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ Copyright (c) .NET Foundation. All rights reserved.
<!-- Override only the incompatible SDK default: net11+ defaults ContainerFormat=pe (unloadable on wasm).
An explicit unsupported value is left as-is and rejected by _WasmCoreClrValidateReadyToRun. -->
<PublishReadyToRunContainerFormat Condition="'$(PublishReadyToRunContainerFormat)' == '' or '$(PublishReadyToRunContainerFormat)' == 'pe'">wasm</PublishReadyToRunContainerFormat>
<!-- Keep the existing per-assembly behavior unless composite is explicitly requested. -->
<PublishReadyToRunComposite Condition="'$(PublishReadyToRunComposite)' == ''">false</PublishReadyToRunComposite>
<!-- Compile every assembly into one shared (large) version bubble. -->
<PublishReadyToRunCrossgen2ExtraArgs>$(PublishReadyToRunCrossgen2ExtraArgs);--opt-cross-module:*</PublishReadyToRunCrossgen2ExtraArgs>
<PublishReadyToRunCrossgen2ExtraArgs Condition="'$(WasmEnableRelaxedSimd)' == 'true'">$(PublishReadyToRunCrossgen2ExtraArgs);--instruction-set:relaxed-simd</PublishReadyToRunCrossgen2ExtraArgs>
Expand Down Expand Up @@ -83,7 +81,7 @@ Copyright (c) .NET Foundation. All rights reserved.
<Error Condition="'@(_WasmMissingReadyToRunPgoFile)' != ''"
Text="PublishReadyToRunPgoFiles item '@(_WasmMissingReadyToRunPgoFile)' does not exist. Specify an existing .mibc file generated for the assemblies being published." />
<Error Condition="'$(PublishReadyToRunComposite)' == 'true' and '$(_WasmEnableWebcil)' != 'true'"
Text="PublishReadyToRunComposite for CoreCLR browser-wasm requires WebCIL-in-Wasm assemblies; enable WasmEnableWebcil." />
Text="PublishReadyToRunComposite for CoreCLR browser-wasm requires WebCIL-in-Wasm assemblies; enable WasmEnableWebcil. To opt out of composite mode, set PublishReadyToRunComposite=false." />
<Error Condition="'$(PublishReadyToRunContainerFormat)' != 'wasm'"
Text="PublishReadyToRunContainerFormat '$(PublishReadyToRunContainerFormat)' is not supported for CoreCLR browser-wasm; only 'wasm' is supported." />
<Error Condition="('$(_IsPublishing)' == 'true' or '$(WasmBuildingForNestedPublish)' == 'true' or '$(WasmBuildOnlyAfterPublish)' == 'true') and ('$(Crossgen2InBuildDir)' == '' or !Exists('$(Crossgen2InBuildDir)')) and '@(ResolvedCrossgen2Pack)' == ''"
Expand All @@ -101,7 +99,7 @@ Copyright (c) .NET Foundation. All rights reserved.
<_WasmCompositeOwnerEntry Include="@(_ReadyToRunCompileList->WithMetadataValue('CreateCompositeImage', 'true'))" />
</ItemGroup>
<Error Condition="'@(_WasmCompositeOwnerEntry)' != '' and !$([System.String]::Copy('%(_WasmCompositeOwnerEntry.OutputR2RImage)').EndsWith('.r2r.wasm'))"
Text="PublishReadyToRunComposite for CoreCLR browser-wasm requires ReadyToRun SDK tasks that name the composite image '&lt;entry&gt;.r2r.wasm', but they planned '$([System.IO.Path]::GetFileName('%(_WasmCompositeOwnerEntry.OutputR2RImage)'))'. Use an SDK with wasm ReadyToRun output naming (dotnet/sdk#56395), or set Crossgen2SdkOverridePropsPath and Crossgen2SdkOverrideTargetsPath to the dotnet/runtime Crossgen2Tasks." />
Text="PublishReadyToRunComposite for CoreCLR browser-wasm requires ReadyToRun SDK tasks that name the composite image '&lt;entry&gt;.r2r.wasm', but they planned '$([System.IO.Path]::GetFileName('%(_WasmCompositeOwnerEntry.OutputR2RImage)'))'. Use an SDK with wasm ReadyToRun output naming (dotnet/sdk#56395), or set Crossgen2SdkOverridePropsPath and Crossgen2SdkOverrideTargetsPath to the dotnet/runtime Crossgen2Tasks. To opt out of composite mode, set PublishReadyToRunComposite=false." />
</Target>

<!-- PublishTrimmed selects the staged closure (untrimmed pack vs linker output) exactly like
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ Copyright (c) .NET Foundation. All rights reserved.
<!-- Turn off symbol publishing by default -->
<CopyOutputSymbolsToPublishDirectory>false</CopyOutputSymbolsToPublishDirectory>

<PublishReadyToRunComposite Condition="'$(PublishReadyToRunComposite)' == ''">true</PublishReadyToRunComposite>

<!-- Trimmer defaults -->
<TrimMode Condition="'$(TrimMode)' == '' and '$(UsingMicrosoftNETSdkBlazorWebAssembly)' == 'true'">partial</TrimMode>
<TrimMode Condition="'$(TrimMode)' == '' and '$(UsingMicrosoftNETSdkBlazorWebAssembly)' != 'true'">full</TrimMode>
Expand Down
1 change: 1 addition & 0 deletions src/mono/sample/wasm/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
<PropertyGroup>
<RuntimeFlavor Condition="'$(Nested_RuntimeFlavor)' != ''">$(Nested_RuntimeFlavor)</RuntimeFlavor>
<PublishReadyToRun Condition="'$(PublishReadyToRun)' == '' and '$(Nested_PublishReadyToRun)' != ''">$(Nested_PublishReadyToRun)</PublishReadyToRun>
<PublishReadyToRunComposite Condition="'$(PublishReadyToRunComposite)' == '' and '$(Nested_PublishReadyToRunComposite)' != ''">$(Nested_PublishReadyToRunComposite)</PublishReadyToRunComposite>
<PublishReadyToRun Condition="'$(PublishReadyToRun)' == ''">false</PublishReadyToRun>
</PropertyGroup>

Expand Down
1 change: 1 addition & 0 deletions src/mono/sample/wasm/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<NestedBuildProperty Include="InvariantTimezone" />
<NestedBuildProperty Include="PublishTrimmed" />
<NestedBuildProperty Include="PublishReadyToRun" />
<NestedBuildProperty Include="PublishReadyToRunComposite" />
<NestedBuildProperty Include="RunAOTCompilation" />
<NestedBuildProperty Include="UsingNativeAOT" />
<NestedBuildProperty Include="WasmBuildNative" />
Expand Down
2 changes: 1 addition & 1 deletion src/mono/wasm/Wasm.Build.Tests/NativeLibraryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ private async Task ProjectWithNativeReferenceCore(Configuration config, bool aot
string extraItems = $"<NativeFileReference Include=\"{objectFilename}\" />";
string extraProperties = "<WasmBuildNative>true</WasmBuildNative>";
if (readyToRun)
extraProperties += "<PublishReadyToRun>true</PublishReadyToRun>";
extraProperties += "<PublishReadyToRun>true</PublishReadyToRun><PublishReadyToRunComposite>false</PublishReadyToRunComposite>";
Comment thread
radekdoulik marked this conversation as resolved.
Resolved
string insertAtEnd = readyToRun
? """
<Target Name="PrintReadyToRunPInvokeModules" AfterTargets="_WasmConfigureReadyToRunPInvokes">
Expand Down
3 changes: 2 additions & 1 deletion src/mono/wasm/Wasm.Build.Tests/ReadyToRunTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,9 @@ private async Task PublishRunAllPagesCore(Configuration config, bool trimmed, bo
string extraItems = composite
? """<ProjectReference Include="../R2rSuffixLibrary/R2rSuffixLibrary.csproj" />"""
: string.Empty;
string compositeProperty = composite ? string.Empty : "<PublishReadyToRunComposite>false</PublishReadyToRunComposite>";
ProjectInfo info = CopyTestAsset(config, aot: false, TestAsset.BlazorBasicTestApp, label,
extraProperties: $"<PublishReadyToRun>true</PublishReadyToRun><PublishReadyToRunComposite>{(composite ? "true" : "false")}</PublishReadyToRunComposite><PublishTrimmed>{(trimmed ? "true" : "false")}</PublishTrimmed>",
extraProperties: $"<PublishReadyToRun>true</PublishReadyToRun>{compositeProperty}<PublishTrimmed>{(trimmed ? "true" : "false")}</PublishTrimmed>",
extraItems: extraItems);
if (composite)
LogR2RSuffixLibraryMarker();
Expand Down
Loading