[dotnet] Fix R2R --instruction-set computation for iOS/tvOS device builds#25337
[dotnet] Fix R2R --instruction-set computation for iOS/tvOS device builds#25337rolfbjarne merged 3 commits intonet11.0from
Conversation
…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>
There was a problem hiding this comment.
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
_ComputeInstructionSetForCrossgen2to pass$(_ComputedTargetFrameworkMoniker)instead of$(TargetFramework)toTargetFrameworkMoniker.
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
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.
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.
✅ [PR Build #f3d04c0] Build passed (Detect API changes) ✅Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
✅ [PR Build #f3d04c0] 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 #f3d04c0] Build passed (Build macOS tests) ✅Pipeline on Agent |
🔥 Failed to compute test summaries on VSTS: test results 🔥Failed to compute test summaries: |
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.
🚀 [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 macOS tests✅ Tests on macOS Sonoma (14): All 5 tests passed. Html Report (VSDrops) Download Linux Build VerificationPipeline on Agent |
Summary
_ComputeInstructionSetForCrossgen2was passing$(TargetFramework)(the short form likenet11.0-ios) asTargetFrameworkMoniker. The base task callsTargetFramework.Parse, which only handles the long comma-delimited form (.NETCoreApp,Version=v11.0,Profile=ios); the short form silently parses to an emptyTargetFrameworkwhosePlatformgetter falls through toApplePlatform.MacOSX.For an
ios-arm64build the platform was therefore reported as macOS, soComputeMinimumInstructionSetrouted toComputeMacInstructionSet, which returnsapple-m1for any arm64 RID. crossgen2 was then invoked with--instruction-set:apple-m1even on iOS device builds.Impact
apple-m1requires 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-m1on the crossgen2 line plus the misleadingComputed instruction set 'apple-m1' for macOS 15.0log 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.