-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Update R2R targets and tasks for Mach-O format support #51848
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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 Mach-O format in Ready-to-Run (R2R) compilation, upstreamed from dotnet/runtime#121186. The changes enable R2R compilation for Apple platforms (iOS, tvOS, macOS, Mac Catalyst) by introducing a new container format option and a linking step to convert crossgen2's Mach-O object files into dylibs.
Key changes:
- Adds
PublishReadyToRunContainerFormatproperty (defaults to "pe", can be set to "macho" for Apple platforms) - Disables R2R symbol emission for all Apple runtime identifiers
- Implements a new
_LinkReadyToRunMachOtarget that links crossgen2-generated.ofiles into.dylibfiles using Apple's clang toolchain
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| Microsoft.NET.CrossGen.targets | Adds container format property, Apple platform symbol emission settings, telemetry for the new format, and implements _FindMachOToolchain and _LinkReadyToRunMachO targets for Mach-O linking |
| RunReadyToRunCompiler.cs | Adds Crossgen2ContainerFormat parameter and passes it to crossgen2 via --obj-format argument |
| PrepareForReadyToRunCompilation.cs | Adds Mach-O-specific logic to generate intermediate .o files and final .dylib files, with metadata to trigger native linking |
| MetadataKeys.cs | Adds RequiresNativeLink and NativeLinkerInputPath metadata constants for coordinating the native linking step |
src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.CrossGen.targets
Outdated
Show resolved
Hide resolved
src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.CrossGen.targets
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <[email protected]>
| <PublishReadyToRunEmitSymbols Condition="'$(PublishReadyToRunEmitSymbols)' == '' and ('$(TargetPlatformIdentifier)' == 'ios' or '$(TargetPlatformIdentifier)' == 'tvos' or '$(TargetPlatformIdentifier)' == 'maccatalyst')">false</PublishReadyToRunEmitSymbols> | ||
| <PublishReadyToRunContainerFormat Condition="'$(PublishReadyToRunContainerFormat)' == ''">pe</PublishReadyToRunContainerFormat> | ||
|
|
||
| <PublishReadyToRunEmitSymbols Condition="$(RuntimeIdentifier.StartsWith('ios-'))">false</PublishReadyToRunEmitSymbols> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| <PublishReadyToRunEmitSymbols Condition="$(RuntimeIdentifier.StartsWith('ios-'))">false</PublishReadyToRunEmitSymbols> | |
| <PublishReadyToRunEmitSymbols Condition="'$(PublishReadyToRunEmitSymbols)' == '' and $(RuntimeIdentifier.StartsWith('ios-'))">false</PublishReadyToRunEmitSymbols> |
| <PublishReadyToRunContainerFormat Condition="'$(PublishReadyToRunContainerFormat)' == ''">pe</PublishReadyToRunContainerFormat> | ||
|
|
||
| <PublishReadyToRunEmitSymbols Condition="$(RuntimeIdentifier.StartsWith('ios-'))">false</PublishReadyToRunEmitSymbols> | ||
| <PublishReadyToRunEmitSymbols Condition="$(RuntimeIdentifier.StartsWith('tvos-'))">false</PublishReadyToRunEmitSymbols> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| <PublishReadyToRunEmitSymbols Condition="$(RuntimeIdentifier.StartsWith('tvos-'))">false</PublishReadyToRunEmitSymbols> | |
| <PublishReadyToRunEmitSymbols Condition="'$(PublishReadyToRunEmitSymbols)' == '' and $(RuntimeIdentifier.StartsWith('tvos-'))">false</PublishReadyToRunEmitSymbols> |
|
|
||
| <PublishReadyToRunEmitSymbols Condition="$(RuntimeIdentifier.StartsWith('ios-'))">false</PublishReadyToRunEmitSymbols> | ||
| <PublishReadyToRunEmitSymbols Condition="$(RuntimeIdentifier.StartsWith('tvos-'))">false</PublishReadyToRunEmitSymbols> | ||
| <PublishReadyToRunEmitSymbols Condition="$(RuntimeIdentifier.StartsWith('iossimulator-'))">false</PublishReadyToRunEmitSymbols> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| <PublishReadyToRunEmitSymbols Condition="$(RuntimeIdentifier.StartsWith('iossimulator-'))">false</PublishReadyToRunEmitSymbols> | |
| <PublishReadyToRunEmitSymbols Condition="'$(PublishReadyToRunEmitSymbols)' == '' and $(RuntimeIdentifier.StartsWith('iossimulator-'))">false</PublishReadyToRunEmitSymbols> |
| <PublishReadyToRunEmitSymbols Condition="$(RuntimeIdentifier.StartsWith('ios-'))">false</PublishReadyToRunEmitSymbols> | ||
| <PublishReadyToRunEmitSymbols Condition="$(RuntimeIdentifier.StartsWith('tvos-'))">false</PublishReadyToRunEmitSymbols> | ||
| <PublishReadyToRunEmitSymbols Condition="$(RuntimeIdentifier.StartsWith('iossimulator-'))">false</PublishReadyToRunEmitSymbols> | ||
| <PublishReadyToRunEmitSymbols Condition="$(RuntimeIdentifier.StartsWith('tvossimulator-'))">false</PublishReadyToRunEmitSymbols> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| <PublishReadyToRunEmitSymbols Condition="$(RuntimeIdentifier.StartsWith('tvossimulator-'))">false</PublishReadyToRunEmitSymbols> | |
| <PublishReadyToRunEmitSymbols Condition="'$(PublishReadyToRunEmitSymbols)' == '' and $(RuntimeIdentifier.StartsWith('tvossimulator-'))">false</PublishReadyToRunEmitSymbols> |
| <PublishReadyToRunEmitSymbols Condition="$(RuntimeIdentifier.StartsWith('tvos-'))">false</PublishReadyToRunEmitSymbols> | ||
| <PublishReadyToRunEmitSymbols Condition="$(RuntimeIdentifier.StartsWith('iossimulator-'))">false</PublishReadyToRunEmitSymbols> | ||
| <PublishReadyToRunEmitSymbols Condition="$(RuntimeIdentifier.StartsWith('tvossimulator-'))">false</PublishReadyToRunEmitSymbols> | ||
| <PublishReadyToRunEmitSymbols Condition="$(RuntimeIdentifier.StartsWith('maccatalyst-'))">false</PublishReadyToRunEmitSymbols> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| <PublishReadyToRunEmitSymbols Condition="$(RuntimeIdentifier.StartsWith('maccatalyst-'))">false</PublishReadyToRunEmitSymbols> | |
| <PublishReadyToRunEmitSymbols Condition="'$(PublishReadyToRunEmitSymbols)' == '' and $(RuntimeIdentifier.StartsWith('maccatalyst-'))">false</PublishReadyToRunEmitSymbols> |
| <PublishReadyToRunEmitSymbols Condition="$(RuntimeIdentifier.StartsWith('iossimulator-'))">false</PublishReadyToRunEmitSymbols> | ||
| <PublishReadyToRunEmitSymbols Condition="$(RuntimeIdentifier.StartsWith('tvossimulator-'))">false</PublishReadyToRunEmitSymbols> | ||
| <PublishReadyToRunEmitSymbols Condition="$(RuntimeIdentifier.StartsWith('maccatalyst-'))">false</PublishReadyToRunEmitSymbols> | ||
| <PublishReadyToRunEmitSymbols Condition="$(RuntimeIdentifier.StartsWith('osx-'))">false</PublishReadyToRunEmitSymbols> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| <PublishReadyToRunEmitSymbols Condition="$(RuntimeIdentifier.StartsWith('osx-'))">false</PublishReadyToRunEmitSymbols> | |
| <PublishReadyToRunEmitSymbols Condition="'$(PublishReadyToRunEmitSymbols)' == '' and $(RuntimeIdentifier.StartsWith('osx-'))">false</PublishReadyToRunEmitSymbols> |
Upstream changes from dotnet/runtime#121186
cc @dotnet/appmodel @kotlarmilos