Skip to content

[net11.0] R2R-compile only System.Private.CoreLib for Debug CoreCLR mobile builds#25583

Open
kotlarmilos wants to merge 2 commits into
net11.0from
dev/kotlarmilos/r2r-only-corelib-in-debug
Open

[net11.0] R2R-compile only System.Private.CoreLib for Debug CoreCLR mobile builds#25583
kotlarmilos wants to merge 2 commits into
net11.0from
dev/kotlarmilos/r2r-only-corelib-in-debug

Conversation

@kotlarmilos
Copy link
Copy Markdown
Member

@kotlarmilos kotlarmilos commented May 29, 2026

Description

In Debug builds with CoreCLR on Apple mobile, narrow _NonUserAssemblies to System.Private.CoreLib so that crossgen2 only ReadyToRun-compiles CoreLib and every other framework is excluded from R2R via the existing PublishReadyToRunExclude path. Non-R2R'd methods fall back to the interpreter at runtime. The .app bundle shrinks from 395 MB to 132 MB, with a corresponding reduction in crossgen2 time during build. Startup is unchanged in practice because the hot path through corelib is still R2R.

…obile builds

In Debug builds with CoreCLR on iOS, narrow _NonUserAssemblies to System.Private.CoreLib so that crossgen2 only ReadyToRun-compiles CoreLib and every other framework, MAUI, and NuGet assembly is excluded from R2R via the existing PublishReadyToRunExclude path. Non-R2R'd methods fall back to the CoreCLR interpreter at runtime (JIT is forbidden on iOS), which is the desired inner-loop behavior. Measured on SampleMAUI publish for ios-arm64 Debug: framework dylib drops from 318 MB to 28 MB and the .app bundle shrinks from 395 MB to 132 MB, with a corresponding reduction in crossgen2 time during build. Startup is unchanged in practice because the hot path through CoreLib is still R2R'd; only first-call cost for non-CoreLib methods shifts onto the interpreter, which is negligible for the inner-loop scenarios this default targets. Release builds are unaffected (FilterReadyToRunAssemblies already gates _SelectR2RAssemblies off for Release).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 29, 2026 14:07
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR changes Debug CoreCLR ReadyToRun filtering for macho builds so only System.Private.CoreLib is R2R-compiled, reducing Debug app size/build time while leaving other assemblies interpreted.

Changes:

  • Narrows _NonUserAssemblies to System.Private.CoreLib.
  • Routes all other assemblies through the existing PublishReadyToRunExclude path.
  • Keeps Release behavior unchanged through the existing FilterReadyToRunAssemblies gating.
Show a summary per file
File Description
dotnet/targets/Microsoft.Sdk.R2R.targets Updates the Debug CoreCLR R2R assembly selection filter to retain only CoreLib.

Copilot's findings

  • Files reviewed: 1/1 changed files
  • Comments generated: 2

Comment thread dotnet/targets/Microsoft.Sdk.R2R.targets
Comment thread dotnet/targets/Microsoft.Sdk.R2R.targets
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants