[net11.0] Enable R2R for System.Private.CoreLib only (Debug)#25567
Closed
davidnguyen-tech wants to merge 5 commits into
Closed
[net11.0] Enable R2R for System.Private.CoreLib only (Debug)#25567davidnguyen-tech wants to merge 5 commits into
davidnguyen-tech wants to merge 5 commits into
Conversation
…acCatalyst Port the CoreLib-only R2R composite mechanism into the macios SDK targets as the default behavior for Debug iOS/tvOS/MacCatalyst CoreCLR builds. The two new targets: - _ConfigureCoreLibOnlyCompositeRoots adds System.Private.CoreLib.dll as the sole root of @(PublishReadyToRunCompositeRoots), so every other framework assembly selected by _SelectR2RAssemblies becomes an unrooted composite input. crossgen2 rewrites the unrooted inputs' component R2R header owner pointer to the local <App>.r2r.dylib (no codegen). Gated on Debug + CoreCLR + iOS/tvOS/MacCatalyst + composite-macho R2R + inner build. - _DedupUnrootedReadyToRunPublish works around an asymmetry in Microsoft.NET.CrossGen.targets where _ReadyToRunCompositeUnrootedBuildInput is not removed from ResolvedFileToPublish (rooted inputs are), causing NETSDK1152 'multiple publish output files with the same relative path'. Gated structurally on any user (or this SDK) having set composite roots. Effect on a Debug iOS bundle: one <App>.r2r.dylib in place of Microsoft.NETCore.App.r2r.dylib + per-module BCL dylibs. Smaller bundle, faster cold startup, faster incremental build. The default can be overridden per-project by declaring PublishReadyToRunCompositeRoots statically in the csproj (or any imported props/targets file) — see the build-properties.md docs and the follow-up commit that enforces this opt-out gate. Release builds and macOS/Mono/NativeAOT targets are not affected. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…mposite roots
Add '@(PublishReadyToRunCompositeRoots->Count())' == '0' to the
_ConfigureCoreLibOnlyCompositeRoots target condition so any user-provided
set in csproj/imported props takes precedence over the macios default.
The previously documented opt-out idiom (Remove="System.Private.CoreLib.dll")
was incorrect: at static evaluation the item group is empty, so the Remove is
a no-op, and the target subsequently Includes CoreLib regardless. Replace the
comment with the working opt-out pattern (static Include of any roots).
Verified locally with two builds:
* Default Debug build: target fires, restricts roots to CoreLib only.
* Build with Directory.Build.props that statically Includes
PublishReadyToRunCompositeRoots: target does NOT fire (no 'Restricting'
message), user's roots win. _DedupUnrootedReadyToRunPublish still fires
because its gate stays decoupled from this policy decision.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…efault Three tests covering the new _ConfigureCoreLibOnlyCompositeRoots and _DedupUnrootedReadyToRunPublish targets in dotnet/targets/Microsoft.Sdk.R2R.targets: 1. Debug_DefaultsToCoreLibOnlyCompositeRoot — builds MySimpleApp Debug for iOS / tvOS / MacCatalyst CoreCLR, asserts both targets ran, and verifies the bundle contains exactly one <App>.r2r.framework with no upstream Microsoft.NETCore.App.r2r.framework or per-module *.r2r.dylib files. 2. Debug_UserSetCompositeRoots_OptsOutOfDefault — builds an inline csproj that statically declares PublishReadyToRunCompositeRoots (Include CoreLib + Linq), asserts _ConfigureCoreLibOnlyCompositeRoots did NOT run (the opt-out gate trips) and _DedupUnrootedReadyToRunPublish DID run (decoupled, fires whenever anyone sets composite roots). 3. Release_DoesNotRestrictCompositeRoots — builds MySimpleApp Release for the same three platforms and asserts the CoreLib-only policy target stays inert (the Configuration=Debug gate keeps the full per-module composite in Release). Single-RID test cases throughout, mirroring the RuntimeIdentifiers == '' clause on _SelectR2RAssemblies that the policy target intentionally shadows. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
9e607c2 to
7d7c63b
Compare
Add a BreakingChanges.md note for the Debug iOS/tvOS/MacCatalyst CoreCLR bundle composition change: the bundle now contains a single per-app .r2r.framework instead of the upstream Microsoft.NETCore.App.r2r.framework plus per-module BCL .r2r.framework bundles. Include the Include-based opt-out recipe for users who need to restore the previous all-rooted composite, and call out that macOS / NativeAOT / Mono / Release builds are unaffected. PublishReadyToRunCompositeRoots itself is defined by the .NET SDK in Microsoft.NET.CrossGen.targets; this commit only documents the macios-side behavior change, not the SDK item group. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
7d7c63b to
72e0405
Compare
…ompositeTest The Debug_DefaultsToCoreLibOnlyCompositeRoot test ran for iOS, tvOS and Mac Catalyst but AssertCoreLibOnlyBundleComposition only understood the iOS/tvOS shape (a <App>.r2r.framework under Frameworks/). Mac Catalyst packages the composite as a <App>.r2r.dylib under Contents/MonoBundle/ instead (see _CreateR2RModuleDylibs and the MacCatalyst-CoreCLR-R2R-size.txt baseline), so the Mac Catalyst case would have failed both the "exactly one .r2r.framework" and the "no *.r2r.dylib anywhere" assertions. Make the helper platform-aware: assert the framework shape for iOS/tvOS and the MonoBundle dylib shape for Mac Catalyst, and in both cases assert the upstream Microsoft.NETCore.App.r2r.* image is not carried into the bundle. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Member
Author
|
Closing in favor of #25583 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Restrict the Debug iOS / tvOS / Mac Catalyst CoreCLR R2R composite to root only on
System.Private.CoreLib.dll. Every other R2R-eligible BCL / framework assembly becomesan unrooted composite input — crossgen2 re-headers it to point at the per-app
<App>.r2r.dyliband skips codegen for it.Net Debug-bundle change: a single
<App>.r2r.frameworkreplaces the upstreamMicrosoft.NETCore.App.r2r.frameworkplus the per-module BCL frameworks.Release, NativeAOT, Mono, and macOS are unchanged.