Skip to content

Add support for iOS sample app to publish and run with R2R on coreclr - #121824

Merged
elinor-fung merged 15 commits into
dotnet:mainfrom
elinor-fung:ios-sample-r2r
Nov 25, 2025
Merged

Add support for iOS sample app to publish and run with R2R on coreclr#121824
elinor-fung merged 15 commits into
dotnet:mainfrom
elinor-fung:ios-sample-r2r

Conversation

@elinor-fung

@elinor-fungelinor-fung commented Nov 19, 2025

Copy link
Copy Markdown
Member

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

CopilotAI 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

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
FileDescription
src/tasks/AppleAppBuilder/Xcode.csAdds host_runtime_contract.h to embedded resources for CoreCLR runtime
src/tasks/AppleAppBuilder/Templates/runtime-coreclr.mImplements host_runtime_contract with native code loading support via dlopen/dlsym for R2R composite images
src/tasks/AppleAppBuilder/Templates/CMakeLists.txt.templateAdds code signing for *.r2r.dylib files in app bundle
src/tasks/AppleAppBuilder/AppleAppBuilder.csprojIncludes host_runtime_contract.h as embedded resource
src/mono/sample/iOS/Program.csprojConfigures R2R publishing with composite images and Mach-O format, imports repo crossgen2 targets
src/mono/sample/iOS/MakefileAdds R2R parameter to build-appbundle target
src/mono/msbuild/apple/build/AppleBuild.targetsAdds condition to skip AOT when using CoreCLR runtime
src/mono/msbuild/apple/build/AppleBuild.InTree.targetsOverrides SDK target to use in-build crossgen2 for R2R compilation
src/coreclr/inc/clrconfigvalues.hEnables ReadyToRun by default for iOS/tvOS/macCatalyst platforms

Comment threadsrc/tasks/AppleAppBuilder/Templates/runtime-coreclr.m
Comment threadsrc/tasks/AppleAppBuilder/Templates/runtime-coreclr.m
Comment threadsrc/tasks/AppleAppBuilder/Templates/runtime-coreclr.m Outdated
Comment threadsrc/tasks/AppleAppBuilder/Templates/runtime-coreclr.m
Comment threadsrc/tasks/AppleAppBuilder/Templates/runtime-coreclr.m
Comment threadsrc/tasks/AppleAppBuilder/Templates/runtime-coreclr.m
Comment threadsrc/tasks/AppleAppBuilder/Templates/runtime-coreclr.m Outdated
Comment threadsrc/tasks/AppleAppBuilder/Templates/runtime-coreclr.m
Comment threadsrc/mono/sample/iOS/Program.csproj Outdated
Comment threadsrc/tasks/AppleAppBuilder/Templates/runtime-coreclr.m Outdated
Comment threadsrc/tasks/AppleAppBuilder/Templates/runtime-coreclr.m Outdated

@kotlarmiloskotlarmilos left a comment

Copy link
Copy Markdown
Member

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

elinor-fung commented Nov 20, 2025

Copy link
Copy Markdown
MemberAuthor

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.

Comment threadsrc/coreclr/inc/clrconfigvalues.h Outdated
@elinor-fung

Copy link
Copy Markdown
MemberAuthor

@jkotas@kotlarmilos any outstanding concerns here?

Comment threadsrc/coreclr/interpreter/eeinterp.cpp Outdated
Comment threadsrc/tasks/AppleAppBuilder/Templates/runtime-coreclr.m Outdated

@jkotasjkotas left a comment

Copy link
Copy Markdown
Member

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.

@kotlarmiloskotlarmilos left a comment

Copy link
Copy Markdown
Member

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 freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@elinor-fung@jkotas@kotlarmilos