Skip to content

Add support for emitting Mach-O R2R images - #121186

Merged
elinor-fung merged 36 commits into
dotnet:mainfrom
jkoritzinsky:macho-r2r
Nov 14, 2025
Merged

Add support for emitting Mach-O R2R images#121186
elinor-fung merged 36 commits into
dotnet:mainfrom
jkoritzinsky:macho-r2r

Conversation

@jkoritzinsky

@jkoritzinsky jkoritzinsky commented Oct 29, 2025

Copy link
Copy Markdown
Member

Adds support in crossgen2 for emitting Mach-O objects.

Does not yet do the runtime support as that depends on #120777

@jkoritzinsky

Copy link
Copy Markdown
Member Author

/azp run runtime-ioslike

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@jkoritzinsky

Copy link
Copy Markdown
Member Author

/azp run runtime-ioslike

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command.

@jkoritzinsky

Copy link
Copy Markdown
Member Author

/azp run runtime-ioslike

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@jkoritzinsky

Copy link
Copy Markdown
Member Author

/azp run runtime-ioslike

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

Comment thread src/tasks/Crossgen2Tasks/Microsoft.NET.CrossGen.targets Outdated
@elinor-fung

Copy link
Copy Markdown
Member

I pulled this down to check out the generated System.Private.CoreLib.dylib built on a mac - targeted osx and ios. dyld_info works fine, otool shows the sections I'd expect, nm -u doesn't show any undefined (for ios, it does show dyld_stub_binder, which I think is fine/expected). For the osx one, I checked I could dlopen it successfully.

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

Aside from the comment about the linker warnings, looks good to me.

Comment thread docs/project/library-servicing.md
Comment thread src/tasks/Crossgen2Tasks/Microsoft.NET.CrossGen.targets
Comment thread src/coreclr/crossgen-corelib.proj Outdated
Comment thread src/coreclr/crossgen-corelib.proj Outdated
Comment thread src/coreclr/crossgen-corelib.proj

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

Tested locally for macos (osx, not mobile) with the runtime/host changes. With the fix for the flipped *_RELOC_SUBTRACTOR/*_RELOC_UNSIGNED index, I can successfully run a runtime test using the Mach-O R2R SPCL and a Mach-O R2R image for the test assembly itself.

Comment thread src/coreclr/tools/Common/Compiler/ObjectWriter/MachObjectWriter.cs Outdated
Comment thread src/coreclr/tools/Common/Compiler/ObjectWriter/MachObjectWriter.cs Outdated
Comment thread src/coreclr/tools/Common/Compiler/ObjectWriter/MachObjectWriter.cs Outdated
Comment thread src/coreclr/tools/Common/Compiler/ObjectWriter/MachObjectWriter.cs Outdated
Comment thread src/coreclr/tools/Common/Compiler/ObjectWriter/MachObjectWriter.cs Outdated
Comment thread src/coreclr/tools/Common/Compiler/ObjectWriter/MachObjectWriter.cs Outdated
Comment thread src/coreclr/tools/Common/Compiler/ObjectWriter/MachObjectWriter.cs Outdated
Comment thread src/coreclr/tools/Common/Compiler/ObjectWriter/MachObjectWriter.cs Outdated
elinor-fung added a commit that referenced this pull request Nov 11, 2025
…composite R2R images (#121363)

Add the basic runtime flow for calling into the host to get information
about a platform-native R2R - see docs/design/coreclr/botr/readytorun-platform-native-envelope.md#runtime-consuming-a-platform-native-r2r-image.
- Add `get_native_code_data` callback to `host_runtime_contract`
- If a component R2R assembly has
`READYTORUN_FLAG_PLATFORM_NATIVE_IMAGE`, invoke the callback to get the
R2R header, image size, and image base address
- Currently only implemented and tested on Windows (with local changes
to include the flag)
- Mach-O support will need #121186

Contributes to #120065.
@elinor-fung

Copy link
Copy Markdown
Member

/azp run runtime-ioslike

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

Sign up for free to 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.

6 participants