Skip to content

Conversation

@rolfbjarne
Copy link
Member

@rolfbjarne rolfbjarne commented Dec 12, 2025

Description

This PR adds ReadyToRun support for CoreCLR.

Changes

  • Introduce ReadyToRun configuration in Xamarin.Shared.Sdk.props.
  • Add ReadyToRun targets to Microsoft.Shared.R2R.targets (a new file).
  • Update bundler environment variables in Xamarin.Shared.Sdk.targets to support ReadyToRun
  • Add host_runtime_contract.h to the build process in Makefile
  • Update coreclr-bridge.m and runtime.m for R2R image handling and logging
  • Update runtime.h to reflect changes in the xamarin_pinvoke_override function signature
  • Add support in the CompileAppManifest target to create the Info.plist for frameworks.
  • Enable CoreCLR tests run R2R.
  • Add a test variation for CoreCLR for the app size test.

Fixes dotnet/runtime#120052.

Copy link
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 adds ReadyToRun (R2R) support for CoreCLR on Apple mobile platforms (iOS, tvOS). ReadyToRun is an ahead-of-time (AOT) compilation technology that improves app startup performance by pre-compiling managed assemblies to native code. The implementation involves integrating CoreCLR's R2R infrastructure through a new host runtime contract interface, generating composite R2R images into frameworks or dynamic libraries, and enabling the feature by default for non-macOS CoreCLR builds.

Key Changes

  • Added infrastructure to pass PublishReadyToRun configuration through the build pipeline
  • Implemented native code integration for R2R via the host_runtime_contract interface
  • Created MSBuild targets to build R2R composite images and link them into frameworks or dylibs
  • Removed libclrjit.dylib dependency when R2R is enabled (replaced with R2R interpretation)

Reviewed changes

Copilot reviewed 17 out of 18 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tools/dotnet-linker/LinkerConfiguration.cs Adds parsing for PublishReadyToRun configuration property
tools/common/Target.cs Generates extern declarations for RTR_HEADER symbol in generated main.m file
tools/common/Application.cs Adds PublishReadyToRun nullable boolean property to Application class
runtime/xamarin/runtime.h Changes xamarin_pinvoke_override return type to const void*
runtime/xamarin/main.h Declares xamarin_rtr_header global variable
runtime/runtime.m Implements R2R integration via host_runtime_contract and adds dyld image size calculation
runtime/coreclr-bridge.m Fixes logging bug where wrong variable was being accessed
runtime/Makefile Updates to download host_runtime_contract.h header from dotnet/runtime
runtime/.gitignore Ignores the downloaded host_runtime_contract.h file
msbuild/Xamarin.MacDev.Tasks/Tasks/CompileAppManifest.cs Adds IsFramework property and CFBundlePackageType support for frameworks
dotnet/targets/Xamarin.Shared.Sdk.targets Passes PublishReadyToRun to linker, removes libclrjit.dylib, imports R2R targets
dotnet/targets/Xamarin.Shared.Sdk.props Sets R2R as default for CoreCLR mobile builds, adds environment variable fallback
dotnet/targets/Microsoft.Sdk.R2R.targets New file implementing R2R composite image building and framework/dylib creation
dotnet/Makefile Includes new Microsoft.Sdk.R2R.targets in SDK package
tests/dotnet/UnitTests/AppSizeTest.cs Removes test ignore attribute and fixes assertion message logic
tests/dotnet/UnitTests/expected/iOS-CoreCLR-R2R-size.txt New baseline for R2R app sizes
tests/dotnet/UnitTests/expected/iOS-CoreCLR-Interpreter-size.txt Updated baseline reflecting removal of libclrjit.dylib

@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.

@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.

@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.

@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.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #55f9501] Tests on macOS M1 - Mac Ventura (13) passed 💻

All tests on macOS M1 - Mac Ventura (13) passed.

Pipeline on Agent
Hash: 55f95010f0e7d43d3303265aa29fff58fd313896 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@rolfbjarne rolfbjarne force-pushed the dev/rolf/coreclr-r2r branch from cee6af5 to 09ce0a5 Compare January 14, 2026 11:47
@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [CI Build #09ce0a5] Build passed (Build packages) ✅

Pipeline on Agent
Hash: 09ce0a526dcea397ef8456afe51e4332af6d5cf0 [PR build]

@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
Copy link
Collaborator

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

Pipeline on Agent
Hash: 09ce0a526dcea397ef8456afe51e4332af6d5cf0 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [CI Build #09ce0a5] Build passed (Build macOS tests) ✅

Pipeline on Agent
Hash: 09ce0a526dcea397ef8456afe51e4332af6d5cf0 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #09ce0a5] Tests on macOS X64 - Mac Sonoma (14) passed 💻

All tests on macOS X64 - Mac Sonoma (14) passed.

Pipeline on Agent
Hash: 09ce0a526dcea397ef8456afe51e4332af6d5cf0 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #09ce0a5] Tests on macOS arm64 - Mac Sequoia (15) passed 💻

All tests on macOS arm64 - Mac Sequoia (15) passed.

Pipeline on Agent
Hash: 09ce0a526dcea397ef8456afe51e4332af6d5cf0 [PR build]

@vs-mobiletools-engineering-service2
Copy link
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: 09ce0a526dcea397ef8456afe51e4332af6d5cf0 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #09ce0a5] Tests on macOS arm64 - Mac Tahoe (26) passed 💻

All tests on macOS arm64 - Mac Tahoe (26) passed.

Pipeline on Agent
Hash: 09ce0a526dcea397ef8456afe51e4332af6d5cf0 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

🚀 [CI Build #09ce0a5] Test results 🚀

Test results

✅ All tests passed on VSTS: test results.

🎉 All 123 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. [attempt 2] 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 4 tests passed. Html Report (VSDrops) Download
✅ linker: All 44 tests passed. Html Report (VSDrops) Download
✅ monotouch (iOS): All 9 tests passed. Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 17 tests passed. Html Report (VSDrops) Download
✅ monotouch (macOS): All 9 tests passed. Html Report (VSDrops) Download
✅ monotouch (tvOS): All 9 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
✅ windows: All 3 tests passed. Html Report (VSDrops) Download
✅ xcframework: All 4 tests passed. Html Report (VSDrops) Download
✅ xtro: All 1 tests passed. Html Report (VSDrops) Download

Pipeline on Agent
Hash: 09ce0a526dcea397ef8456afe51e4332af6d5cf0 [PR build]

@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.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@kotlarmilos kotlarmilos self-requested a review January 15, 2026 09:04
Copy link
Member

@kotlarmilos kotlarmilos left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@rolfbjarne rolfbjarne merged commit 3a2ccef into net11.0 Jan 15, 2026
43 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.

7 participants