[net11.0] R2R-compile only System.Private.CoreLib for Debug CoreCLR mobile builds#25583
[net11.0] R2R-compile only System.Private.CoreLib for Debug CoreCLR mobile builds#25583kotlarmilos wants to merge 5 commits into
Conversation
…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>
There was a problem hiding this comment.
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
_NonUserAssembliestoSystem.Private.CoreLib. - Routes all other assemblies through the existing
PublishReadyToRunExcludepath. - Keeps Release behavior unchanged through the existing
FilterReadyToRunAssembliesgating.
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
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@kotlarmilos the test failures (crashes) look related to this PR: |
…eLib-only R2R composite Restricting the R2R composite to only System.Private.CoreLib makes the SDK flag every other framework assembly as hidden from the composite and drop it from the crossgen2 -r list. The composite is then built with zero references, producing a native image CoreCLR rejects at startup (FailFast in NativeImage::Open). Add a target that re-injects the excluded assemblies into _ReadyToRunCompositeBuildReferences (excluding the composite inputs), so crossgen2 receives them via -r while they still run as plain IL. Gated to filtered composite builds, so non-filtered builds are unaffected. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
@rolfbjarne If the last commit fixes the CI, then we should proceed with dotnet/sdk#54576 instead of the workaround added here |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Root cause of the crash The crash ( The CoreCLR runtime pack ships its BCL/framework assemblies already R2R-compiled as components of one composite native image. Each component DLL's R2R header records its owning composite by name ( macios never ships that upstream composite. It runs crossgen2 to build a per-app composite (
CoreLib survives because it's the one assembly still rooted into the per-app composite (frame 40, Fix: instead of excluding the other assemblies, keep them as unrooted composite inputs via Generated by Copilot. |
This comment has been minimized.
This comment has been minimized.
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
✅ [PR Build #60c8581] Build passed (Detect API changes) ✅Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
✅ [PR Build #60c8581] Build passed (Build packages) ✅Pipeline on Agent |
✅ API diff for current PR / commitNET (empty diffs)✅ API diff vs stableNET (empty diffs)ℹ️ Generator diffGenerator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes) Pipeline on Agent |
✅ [PR Build #60c8581] Build passed (Build macOS tests) ✅Pipeline on Agent |
🔥 [CI Build #60c8581] Test results 🔥Test results❌ Tests failed on VSTS: test results 0 tests crashed, 2 tests failed, 193 tests passed. Failures❌ monotouch tests (iOS)1 tests failed, 23 tests passed.Failed tests
Html Report (VSDrops) Download ❌ monotouch tests (tvOS)1 tests failed, 23 tests passed.Failed tests
Html Report (VSDrops) Download Successes✅ cecil: All 1 tests passed. Html Report (VSDrops) Download macOS tests✅ Tests on macOS Sonoma (14): All 5 tests passed. Html Report (VSDrops) Download Linux Build VerificationPipeline on Agent |
|
The composite-roots approach fixed the R2R crash — introspection, the linker jobs, and macOS tests are all green now. The two remaining failures on build 1. Flaky network test — it opens a real TLS connection and reads back the SNI server name, which comes back 2. Both look like infra/flaky noise; a re-run of the two jobs should green the PR. Generated by Copilot. |
Description
In Debug builds with CoreCLR on Apple mobile, narrow
_NonUserAssembliestoSystem.Private.CoreLibso that crossgen2 only ReadyToRun-compiles CoreLib and every other framework is excluded from R2R via the existingPublishReadyToRunExcludepath. Non-R2R'd methods fall back to the interpreter at runtime. The.appbundle 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.