Skip to content

Make apple mobile targets R2R size optimized by default - #130128

Closed
BrzVlad wants to merge 2 commits into
dotnet:mainfrom
BrzVlad:feature-ios-r2r-size
Closed

Make apple mobile targets R2R size optimized by default#130128
BrzVlad wants to merge 2 commits into
dotnet:mainfrom
BrzVlad:feature-ios-r2r-size

Conversation

@BrzVlad

@BrzVlad BrzVlad commented Jul 2, 2026

Copy link
Copy Markdown
Member

Pass --Os which should instruct the compiler to generate compact code. Refactor code to avoid conditional duplication.

Reduces code size by about 1.5%

This change needs to be done in the sdk as well.

BrzVlad added 2 commits July 2, 2026 17:43
Pass `--Os` which should instruct the compiler to generate compact code.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Updates the Crossgen2 MSBuild targets to make Apple mobile (iOS/tvOS/simulators/MacCatalyst) ReadyToRun compilation favor smaller code size by default, by adding the Crossgen2 --Os flag and consolidating RID checks into a single helper property.

Changes:

  • Introduces a _IsIOSLikeRid MSBuild property to centralize Apple mobile RID detection.
  • Applies existing iOS-like defaults (disable R2R symbol emission, strip inlining/debug info) using the new helper property.
  • Appends --Os to PublishReadyToRunCrossgen2ExtraArgs for iOS-like RIDs to favor size-optimized codegen.

Comment thread src/tasks/Crossgen2Tasks/Microsoft.NET.CrossGen.targets
@AndyAyersMS

Copy link
Copy Markdown
Member

We had two PRs cross which is causing a build break for Wasm. I'll get a PR up shortly.

@AndyAyersMS

Copy link
Copy Markdown
Member

#130131

@MichalPetryka

Copy link
Copy Markdown
Contributor

Should android and NAOT and WASM be the same? Also, i assume it'd be better to respect OptimizationPreference here and only do this when unset cc @MichalStrehovsky

@BrzVlad

BrzVlad commented Jul 6, 2026

Copy link
Copy Markdown
Member Author

@MichalPetryka For android it is less relevant since it has less reliance on r2r, using profiled aot by default due to jit fallback, and it is still early for r2r wasm configuration. I agree that OptimizationPreference sounds like a good place to control all the size/speed tradeoffs on all self contained publish platforms. I see this PR more as a temporary, quick improvement (to mitigate for some of the size regressions on the other front), with future plan to properly have size/speed/default configurations based on the OptimizationPreference. As we tweak r2r to detect more methods and as we tweak the release configurations used by these platforms, I think we will be in a better position to determine what the defaults should be, so I would leave that for a follow-up change.

@BrzVlad

BrzVlad commented Jul 7, 2026

Copy link
Copy Markdown
Member Author

Alternative implementation checking for the OptimizationPreference property while also doing some additional rework in the area: #130300

@BrzVlad BrzVlad closed this Jul 9, 2026
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.

6 participants