Skip to content

[browser][coreclr] Add trimmed managed native flavors - #137440

Draft
pavelsavara wants to merge 3 commits into
pavelsavara-browser-coreclr-native-flavorsfrom
pavelsavara-browser-coreclr-trimmed-native-flavors
Draft

pavelsavara wants to merge 3 commits into
pavelsavara-browser-coreclr-native-flavorsfrom
pavelsavara-browser-coreclr-trimmed-native-flavors

Conversation

@pavelsavara

@pavelsavara pavelsavara commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Build separate production and diagnostics trimmed shared-framework closures for CoreCLR browser WebAssembly.
  • Generate and check in P/Invoke/QCall, reverse P/Invoke, and interpreter-to-managed helpers from each matching closure.
  • Build separate production and diagnostics helper archives and select the matching archive while prelinking browserhost; runtime builds no longer regenerate the helpers.
  • Package both managed closures and select the matching managed and native flavor without requiring wasm-tools.
  • Keep diagnostics-compatible runtime-pack ReadyToRun images for the diagnostics build flavor; production build uses trimmed IL, while publish keeps app-specific trimming and optional ReadyToRun compilation.
  • Treat EnableDiagnostics and EventSourceSupport as aliases for flavor selection without making either property independently trigger native relinking.

This is a stacked draft on #137014 and should be reviewed and merged after that PR.

Validation

  • .\build.cmd -bl -os browser -subset clr+libs+host -c Debug /p:RuntimeFlavor=CoreCLR /p:EnableHotReloadInRuntimeConfigDevFile=false
    • Passed with 0 warnings and 0 errors.
  • .\build.cmd -bl -os browser -subset clr+libs+host -c Release /p:RuntimeFlavor=CoreCLR /p:EnableHotReloadInRuntimeConfigDevFile=false
    • Passed with 0 warnings and 0 errors.
  • CoreClrPrelinkedNativeFlavorIsSelectedWithoutWorkload
    • 6 passed, 0 failed, 0 skipped.
    • Covers default and explicit production/diagnostics build and publish selection, matching managed CoreLib selection, diagnostics-only prebuilt ReadyToRun, exact native hashes, and Chrome startup.
  • TracingPropertySelectsNativeFlavor
    • 4 passed, 0 failed, 0 skipped.
    • Covers explicit tracing selection in plain Microsoft.NET.Sdk.WebAssembly projects.
  • PropertyDifferentFromRuntimePackTriggersRelinking
    • 21 passed, 0 failed, 0 skipped.
    • Confirms tracing properties use exact prelinks without forcing relinking, while unrelated native property mismatches still relink.
  • Full CoreCLRWasmNativeDefaultsTests
    • 39 passed, 0 failed, 0 skipped.
    • Covers the R2R directory/profile-flow cases that failed in the first CI run.
  • Exact CI globalization regressions:
    • IdnMappingIdnaConformanceTests.GetAscii_Success passed in Chrome.
    • StringTests.IndexOf_NullInStrings is correctly skipped when Browser uses ICU; the first CI run incorrectly selected NLS behavior and executed it.
  • BlazorEventPipeTestWithCpuSamplesPrelinked
    • 2 passed, 0 failed, 0 skipped.
  • WebAssembly SDK pack and workload manifest package builds passed with 0 warnings and 0 errors.
  • Canonical Release helper regeneration completed twice; all full, production, and diagnostics source hashes were unchanged on the second run.
  • The runtime pack contains the full, production, and diagnostics helper archives. Production and diagnostics browserhost link responses contain only their matching archive and no generated helper objects.
  • git diff --check, MSBuild XML parsing, and conflict-marker checks passed.

Release size comparison

Measurements are from the Release runtime-pack nupkg. Compressed values are the sum of the corresponding ZIP entry sizes.

Assets Production raw Diagnostics raw Delta Production compressed Diagnostics compressed Delta
Managed closure (181 assemblies) 21,662,720 21,699,584 +36,864 8,238,631 8,249,586 +10,955
Native trio 5,182,197 5,350,889 +168,692 1,897,775 1,956,899 +59,124
dotnet.native.wasm 4,418,991 4,573,643 +154,652 1,726,934 1,782,005 +55,071

System.Private.CoreLib.dll is 5,585,920 bytes in production and 5,600,768 bytes in diagnostics, a 14,848-byte difference.

The two additional checked-in helper archives add 794,822 raw bytes and 266,760 nupkg-compressed bytes. The existing full helper archive remains for corerun compatibility.

Reviewer notes

  • The public EnableDiagnostics to EventSourceSupport migration is intentionally postponed.
  • Both managed closures use ILLink all roots so they preserve the complete runtime implementation while applying EventSource feature substitutions. Production and diagnostics expose the same complete helper surface; their managed method bodies differ.
  • Per-app helper generation remains in the workload relink path, where the application closure is not known ahead of time.
  • Runtime-pack ReadyToRun remains diagnostics-compatible only. Production publish generates its selected trimmed and optional ReadyToRun closure as part of app publish.

Note

This pull request description was generated with GitHub Copilot.

Build production and diagnostics shared-framework closures, generate
flavor-specific interop helpers, and select matching managed and native
assets without wasm-tools.

Keep app publish trimming and workload relinking behavior unchanged.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
12 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@pavelsavara pavelsavara added the arch-wasm WebAssembly architecture label Nov 12, 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.

Generate and commit production and diagnostics call-helper tables, build
separate native archives, and select them when prelinking browserhost.

Keep the full framework helper archive for corerun and reserve dynamic
generation for application relinking.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Preserve the complete framework implementation while applying EventSource
substitutions, distinguish workload defaults from explicit settings, and
defer flavor asset validation until runtime-pack selection.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

This branch has not been deployed

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

Labels

arch-wasm WebAssembly architecture area-Build-mono

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant