Skip to content

[dotnet] Fix R2R --instruction-set computation for iOS/tvOS device builds#25337

Merged
rolfbjarne merged 3 commits intonet11.0from
dev/fix-r2r-instruction-set-tfm
May 7, 2026
Merged

[dotnet] Fix R2R --instruction-set computation for iOS/tvOS device builds#25337
rolfbjarne merged 3 commits intonet11.0from
dev/fix-r2r-instruction-set-tfm

Conversation

@kotlarmilos
Copy link
Copy Markdown
Member

@kotlarmilos kotlarmilos commented May 5, 2026

Summary

_ComputeInstructionSetForCrossgen2 was passing $(TargetFramework) (the short form like net11.0-ios) as TargetFrameworkMoniker. The base task calls TargetFramework.Parse, which only handles the long comma-delimited form (.NETCoreApp,Version=v11.0,Profile=ios); the short form silently parses to an empty TargetFramework whose Platform getter falls through to ApplePlatform.MacOSX.

For an ios-arm64 build the platform was therefore reported as macOS, so ComputeMinimumInstructionSet routed to ComputeMacInstructionSet, which returns apple-m1 for any arm64 RID. crossgen2 was then invoked with --instruction-set:apple-m1 even on iOS device builds.

Impact

apple-m1 requires ARMv8.5 features. Pre-A14 iOS devices (iPhone XR/A12, iPhone 11/A13, etc.) do not implement them, so the runtime rejects the R2R image at load time and falls back to the interpreter — defeating R2R on a wide range of supported devices and visibly regressing cold-start.

This was originally observed in MAUI/M365 startup measurements where CoreCLR Release on iPhone XR was ~2× slower than Mono Release; profiling pointed at interpreter fallback, and the binlog showed --instruction-set:apple-m1 on the crossgen2 line plus the misleading Computed instruction set 'apple-m1' for macOS 15.0 log message for an iOS build.

Fix

The other call sites in the same file already use $(_ComputedTargetFrameworkMoniker) (the long form expanded by the shared targets). Align this one with them — one-line change.

…ilds

`_ComputeInstructionSetForCrossgen2` was passing `$(TargetFramework)` (the
short form like `net11.0-ios`) as `TargetFrameworkMoniker`. The base task
calls `TargetFramework.Parse` which only handles the long
comma-delimited form (`.NETCoreApp,Version=v11.0,Profile=ios`); the short
form silently parses to an empty `TargetFramework` whose `Platform` getter
falls through to `ApplePlatform.MacOSX`.

For an `ios-arm64` build the platform was therefore reported as macOS,
so `ComputeMinimumInstructionSet` routed to `ComputeMacInstructionSet`,
which returns `apple-m1` for any arm64 RID. crossgen2 was then invoked
with `--instruction-set:apple-m1` even on iOS device builds.

`apple-m1` requires ARMv8.5 features. Pre-A14 iOS devices (iPhone XR/A12,
iPhone 11/A13) do not implement them, so the runtime rejects the R2R
image at load time and falls back to the interpreter, defeating R2R on
a wide range of supported devices.

The other call sites in the file already use $(_ComputedTargetFrameworkMoniker)
(the long form). Align this one with them.

After the fix, `ios-arm64` device builds pick the oldest-supported-device
ISA via the device table walk (e.g. `armv8-a` for SupportedOSPlatformVersion
15.0–17.x, `armv8.3-a` for iOS 18.0+).

Verified locally on a fresh `dotnet new maui` project (`net11.0-ios`,
ios pack 26.4.11531-net11-p5):

  - Before: `Computed instruction set 'apple-m1' for macOS 15.0` and
    `--instruction-set:apple-m1` on the crossgen2 cmdline.
  - After:  `Computed instruction set 'armv8-a' for iOS 15.0` and
    `--instruction-set:armv8-a` on the crossgen2 cmdline.

iPhone 13 (A15, ARMv8.5) cold-start unchanged within noise (~228 ms);
older devices should now actually use R2R instead of the interpreter.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 5, 2026 17:21
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 fixes an iOS/tvOS device R2R regression by ensuring the ComputeInstructionSet MSBuild task receives the long-form TargetFrameworkMoniker, so platform detection and instruction-set selection match the actual target platform (instead of incorrectly falling back to macOS and apple-m1).

Changes:

  • Update _ComputeInstructionSetForCrossgen2 to pass $(_ComputedTargetFrameworkMoniker) instead of $(TargetFramework) to TargetFrameworkMoniker.
Show a summary per file
File Description
dotnet/targets/Microsoft.Sdk.R2R.targets Passes the correct long-form TFM to ComputeInstructionSet so crossgen2 gets the right --instruction-set for iOS/tvOS device builds.

Copilot's findings

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

@kotlarmilos kotlarmilos requested a review from rolfbjarne May 5, 2026 17:25
@kotlarmilos kotlarmilos self-assigned this May 5, 2026
@kotlarmilos kotlarmilos added this to the .NET 11 milestone May 5, 2026
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@rolfbjarne rolfbjarne self-assigned this May 6, 2026
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@rolfbjarne rolfbjarne enabled auto-merge (squash) May 6, 2026 06:37
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Copy Markdown
Collaborator

✅ [PR Build #f3d04c0] Build passed (Detect API changes) ✅

Pipeline on Agent
Hash: f3d04c0e47dcf0fdbb067db2e3d10934782c1e59 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Copy Markdown
Collaborator

✅ [PR Build #f3d04c0] Build passed (Build packages) ✅

Pipeline on Agent
Hash: f3d04c0e47dcf0fdbb067db2e3d10934782c1e59 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Copy Markdown
Collaborator

✅ API diff for current PR / commit

NET (empty diffs)

✅ API diff vs stable

NET (empty diffs)

ℹ️ Generator diff

Generator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes)

Pipeline on Agent
Hash: f3d04c0e47dcf0fdbb067db2e3d10934782c1e59 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Copy Markdown
Collaborator

✅ [PR Build #f3d04c0] Build passed (Build macOS tests) ✅

Pipeline on Agent
Hash: f3d04c0e47dcf0fdbb067db2e3d10934782c1e59 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Copy Markdown
Collaborator

🔥 Failed to compute test summaries on VSTS: test results 🔥

Failed to compute test summaries:
{
"message": "We couldn\u0027t respond to your request in time. Sorry about that. Please try resubmitting your request and contact us if the problem persists."
}.

Pipeline on Agent
Merge f3d04c0 into 35e8d5d

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Copy Markdown
Collaborator

🚀 [CI Build #f3d04c0] Test results 🚀

Test results

✅ All tests passed on VSTS: test results.

🎉 All 181 tests passed 🎉

Tests counts

✅ cecil: All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (iOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (MacCatalyst): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (macOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (Multiple platforms): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (tvOS): All 1 tests passed. Html Report (VSDrops) Download
✅ framework: All 2 tests passed. Html Report (VSDrops) Download
✅ fsharp: All 4 tests passed. Html Report (VSDrops) Download
✅ generator: All 5 tests passed. Html Report (VSDrops) Download
✅ interdependent-binding-projects: All 4 tests passed. Html Report (VSDrops) Download
✅ introspection: All 9 tests passed. Html Report (VSDrops) Download
✅ linker: All 44 tests passed. Html Report (VSDrops) Download
✅ monotouch (iOS): All 19 tests passed. [attempt 5] Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 25 tests passed. Html Report (VSDrops) Download
✅ monotouch (macOS): All 18 tests passed. Html Report (VSDrops) Download
✅ monotouch (tvOS): All 19 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
✅ sharpie: All 1 tests passed. Html Report (VSDrops) Download
✅ windows: All 3 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ xcframework: All 4 tests passed. Html Report (VSDrops) Download
✅ xtro: All 1 tests passed. Html Report (VSDrops) Download

macOS tests

✅ Tests on macOS Sonoma (14): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Sequoia (15): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Tahoe (26): All 5 tests passed. Html Report (VSDrops) Download

Linux Build Verification

Linux build succeeded

Pipeline on Agent
Hash: f3d04c0e47dcf0fdbb067db2e3d10934782c1e59 [PR build]

@rolfbjarne rolfbjarne merged commit fe65f5d into net11.0 May 7, 2026
47 checks passed
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.

4 participants