Support multiple R2R images for ios/tvos apps#25072
Closed
jkoritzinsky wants to merge 1 commit intodotnet:net11.0from
Closed
Support multiple R2R images for ios/tvos apps#25072jkoritzinsky wants to merge 1 commit intodotnet:net11.0from
jkoritzinsky wants to merge 1 commit intodotnet:net11.0from
Conversation
Instead of linking all R2R .o files into a single large dylib/framework, create a separate framework (or dylib) for each R2R .o file. This way, when only one R2R input changes, only that module's framework needs to be relinked — significantly improving incremental build times. Each R2R .o file exports an RTR_HEADER symbol. To avoid collisions when multiple modules are loaded, each module's dylib uses the linker flags -Wl,-alias,_RTR_HEADER,_RTR_HEADER_<module> and -Wl,-unexported_symbol,_RTR_HEADER to export a uniquely-named alias. A new MSBuild task (GenerateR2RModuleRegistration) generates a native registration file (r2r_modules.mm) that maps module names to their header pointers. The file is compiled into the main executable and uses __attribute__((constructor)) to register the modules before main(). The runtime's xamarin_get_native_code_data callback now iterates the module table to find the correct R2R header for each owner_composite_name, with a fallback to the single xamarin_rtr_header for backward compat. Changes: - runtime/xamarin/main.h: Add struct xamarin_r2r_module and externs - runtime/runtime.m: Multi-module lookup in get_native_code_data - tools/common/Target.cs: Remove single RTR_HEADER from generated main.mm - msbuild/.../GenerateR2RModuleRegistration.cs: New task - dotnet/targets/Microsoft.Sdk.R2R.targets: Per-module framework/dylib creation with symbol renaming - dotnet/targets/Xamarin.Shared.Sdk.targets: Handle multiple R2R frameworks in post-processing Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Member
|
Recreated from origin as #25077 (due to CI with PRs from forks). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
This PR was generated with the help of GitHub Copilot.
Instead of linking all R2R .o files into a single large dylib/framework, create a separate framework (or dylib) for each R2R .o file. This way, when only one R2R input changes, only that module's framework needs to be relinked — significantly improving incremental build times.
Each R2R .o file exports an RTR_HEADER symbol. To avoid collisions when multiple modules are loaded, each module's dylib uses the linker flags
-Wl,-alias,_RTR_HEADER,_RTR_HEADER_<module>and-Wl,-unexported_symbol,_RTR_HEADERto export a uniquely-named alias.A new MSBuild task (GenerateR2RModuleRegistration) generates a native registration file (r2r_modules.mm) that maps module names to their header pointers. The file is compiled into the main executable and uses
__attribute__((constructor))to register the modules before main().The runtime's xamarin_get_native_code_data callback now iterates the module table to find the correct R2R header for each owner_composite_name, with a fallback to the single xamarin_rtr_header for backward compat.
Changes:
Contributes to dotnet/runtime#126194