Skip to content

Conversation

@elinor-fung
Copy link
Member

@elinor-fung elinor-fung commented Nov 19, 2025

Runtime:

  • Stop disabling R2R by default on Apple mobile
  • Update runtime to interpret everything on Apple moblie

iOS sample app:

  • Update AppleAppBuilder host template to use host_runtime_contract
  • Use in-build crossgen2 and in-repo targets when publishing iOS app
  • Make AppleAppBuilder sign *.r2r.dylib

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 support for publishing and running iOS sample apps with ReadyToRun (R2R) compilation on CoreCLR. The implementation updates the AppleAppBuilder host template to use the new host_runtime_contract API for loading R2R composite images, configures the build system to use in-repo crossgen2 tools with Mach-O format support, and enables code signing for R2R dylib files.

Key changes:

  • Implement native code loading callback via get_native_code_data to support R2R composite images on iOS
  • Configure build system to use in-build crossgen2 with Mach-O container format for R2R
  • Update environment variables to set DOTNET_InterpMode=1 when R2R is enabled

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
src/tasks/AppleAppBuilder/Xcode.cs Adds host_runtime_contract.h to embedded resources for CoreCLR runtime
src/tasks/AppleAppBuilder/Templates/runtime-coreclr.m Implements host_runtime_contract with native code loading support via dlopen/dlsym for R2R composite images
src/tasks/AppleAppBuilder/Templates/CMakeLists.txt.template Adds code signing for *.r2r.dylib files in app bundle
src/tasks/AppleAppBuilder/AppleAppBuilder.csproj Includes host_runtime_contract.h as embedded resource
src/mono/sample/iOS/Program.csproj Configures R2R publishing with composite images and Mach-O format, imports repo crossgen2 targets
src/mono/sample/iOS/Makefile Adds R2R parameter to build-appbundle target
src/mono/msbuild/apple/build/AppleBuild.targets Adds condition to skip AOT when using CoreCLR runtime
src/mono/msbuild/apple/build/AppleBuild.InTree.targets Overrides SDK target to use in-build crossgen2 for R2R compilation
src/coreclr/inc/clrconfigvalues.h Enables ReadyToRun by default for iOS/tvOS/macCatalyst platforms

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.

Could we enable interpreter + R2R in the iOS.Simulator.CoreCLR.Interpreter.Test.csproj functional test in CI? This requires setting the same properties and items used in the sample app.

@elinor-fung
Copy link
Member Author

elinor-fung commented Nov 20, 2025

Could we enable interpreter + R2R in the iOS.Simulator.CoreCLR.Interpreter.Test.csproj functional test in CI? This requires setting the same properties and items used in the sample app.

With your suggestion in #121824 (comment), interpreter + R2R is enabled by default now. That test itself won't publish as R2R, but it will default be able to load R2R images. I think we should have a smoke test that includes R2R, but separate from this specific change.

Edit: kept the InterpMode environment variable in the test, so for now R2R is still disabled in it. I'll revisit separately.

@elinor-fung
Copy link
Member Author

@jkotas @kotlarmilos any outstanding concerns here?

Copy link
Member

@jkotas jkotas left a comment

Choose a reason for hiding this comment

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

The parts that I understand LGTM.

@kotlarmilos should sign-off too.

@jkotas jkotas requested a review from kotlarmilos November 24, 2025 21:11
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!

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.

3 participants