Skip to content

[wasm][coreclr] Strip R2R debug info by default for browser-wasm publish - #134689

Merged
lewing merged 3 commits into
lewing-enable-wasm-composite-r2rfrom
lewing-wasm-r2r-strip-debug-info
Sep 26, 2026
Merged

lewing merged 3 commits into
lewing-enable-wasm-composite-r2rfrom
lewing-wasm-r2r-strip-debug-info

Conversation

@lewing

@lewing lewing commented Sep 25, 2026 •

Copy link
Copy Markdown
Member

Summary

Pass --strip-debug-info to crossgen2 for CoreCLR browser-wasm ReadyToRun publish. This drops the R2R DebugInfo section (native-to-IL offset maps and variable locations) from shipped images. Opt out with PublishReadyToRunStripDebugInfo=false to keep the data for debugging R2R code (e.g. the cDAC work in #133086 / #133890).

Also makes crossgen2 argument changes invalidate per-app R2R images. _CreateR2RImages only tracks file inputs, so toggling PublishReadyToRunStripDebugInfo (or any PublishReadyToRunCrossgen2ExtraArgs change) previously left stale images in obj/R2R. The arguments are now written to obj/wasm-r2r-args.stamp (only when different) and added to _ReadyToRunCompilerInputs, mirroring the existing P/Invoke manifest input.

Important

Stacked on #134618, which rewrites the same targets file. Retarget to main after it merges.

Size impact

Per-assembly R2R images compiled directly with crossgen2 using the SDK's browser-wasm arguments (--obj-format:wasm --opt-cross-module:* --codegenopt:JitWasm*NyiToR2RUnsupported=1), with and without --strip-debug-info. Total for System.Private.CoreLib, System.Text.Json, System.Linq, and System.Collections:

Compiler Raw saved gzip -9 saved brotli -q 11 saved
Current (#134618 base) 859,712 B (2.4%) 624,690 B (7.1%) 565,366 B (9.4%)
With #133086 variable info 2,105,520 B (5.6%) 1,332,733 B (13.9%) 1,121,574 B (17.0%)
Per-assembly brotli sizes (bytes, keep → strip)
Assembly Current With #133086
System.Private.CoreLib 4,822,231 → 4,347,541 5,331,799 → 4,403,849
System.Text.Json 823,314 → 761,533 887,982 → 754,444
System.Linq 219,177 → 200,471 238,853 → 200,441
System.Collections 119,635 → 109,446 130,742 → 109,068

The #133086 compiler is based on an older commit, so compare keep vs. strip within a column rather than across columns.

Validation

  • MSBuild evaluation: --strip-debug-info is present by default, absent with PublishReadyToRunStripDebugInfo=false, and absent when PublishReadyToRun is off.
  • Incremental harness: _CreateR2RImages runs on first build, skips when unchanged, reruns on opt-out, skips when repeated, and reruns when switching back.
  • Not yet run: an end-to-end browser-wasm publish loading stripped images in a browser (Wasm.Build.Tests in CI will cover this).

Runtime-pack framework R2R images (used only by the dev-loop build) are unchanged; publish recompiles the whole closure through these targets. --strip-inlining-info is intentionally not included: it removes CrossModuleInlineInfo, and cross-module inlining is load-bearing on wasm, so it needs separate validation.

Note

This pull request was created with assistance from GitHub Copilot.

lewing and others added 2 commits September 25, 2026 17:38
Match the Apple mobile default: pass --strip-debug-info to crossgen2 for
CoreCLR browser-wasm ReadyToRun publish to minimize download size. Opt out
with PublishReadyToRunStripDebugInfo=false to keep IL offset maps and
variable locations for debugging R2R code.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
_CreateR2RImages only tracks file inputs, so toggling a crossgen2 argument
such as PublishReadyToRunStripDebugInfo left stale images in obj/R2R.
Stamp PublishReadyToRunCrossgen2ExtraArgs (written only when different)
and add it to _ReadyToRunCompilerInputs, mirroring the P/Invoke manifest.

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

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

@lewing
lewing marked this pull request as ready for review September 25, 2026 22:52
@lewing
lewing requested a review from akoeplinger as a code owner September 25, 2026 22:52
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @dotnet/crossgen-contrib
See info in area-owners.md if you want to be subscribed.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@lewing
lewing merged commit 43c27ac into lewing-enable-wasm-composite-r2r Sep 26, 2026
43 of 47 checks passed
@lewing
lewing deleted the lewing-wasm-r2r-strip-debug-info branch September 26, 2026 01:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants