Skip to content
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

Support "zippered" macOS binaries #131216

Open
madsmtm opened this issue Oct 3, 2024 · 2 comments
Open

Support "zippered" macOS binaries #131216

madsmtm opened this issue Oct 3, 2024 · 2 comments
Labels
A-targets Area: Concerning the implications of different compiler targets C-feature-request Category: A feature request, i.e: not implemented / a PR. O-ios Operating system: iOS O-macos Operating system: macOS T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@madsmtm
Copy link
Contributor

madsmtm commented Oct 3, 2024

Dynamic libraries on macOS can be built in a way that allows loading them when running under Mac Catalyst as well. This is similar in spirit to universal binaries, but technologically different in that only a single binary and architecture is actually built, which allows for a lot of code sharing.

This can be used in Xcode when creating XCFramework bundles, and is underpinned by the the -darwin-target-variant flag in Clang - but that's the only official docs I could find on it. I did find this note though that explains the details really well.

If we wanted to support this in rustc, there's two questions that need answering:

  • How does the user activate it? A separate triple? An extra commandline flag?
  • How does the user detect this mode of compilation in their code? cfg(all(target_os = "macos", target_abi = "macabi"))? target_abi = "zippered"?

Opening this issue to have a place to refer back to, I'm undecided whether it's worth the effort to try to support, would like to see a concrete use-case first (if you know of one, please comment below!)

@rustbot label O-ios O-macos C-feature-request A-targets

@rustbot rustbot added needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. A-targets Area: Concerning the implications of different compiler targets C-feature-request Category: A feature request, i.e: not implemented / a PR. O-ios Operating system: iOS O-macos Operating system: macOS labels Oct 3, 2024
@saethlin saethlin added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Oct 3, 2024
@bjorn3
Copy link
Member

bjorn3 commented Oct 4, 2024

How does the user detect this mode of compilation in their code? cfg(all(target_os = "macos", target_abi = "macabi"))? target_abi = "zippered"?

According to the document you linked, clang pretends the target is macOS and there is no reference to a way for the code itself to detect it is a zippered build.

@madsmtm
Copy link
Contributor Author

madsmtm commented Mar 18, 2025

I just submitted rust-lang/compiler-builtins#794 (EDIT: now #138944), in which it could be useful to have a cfg!(zippered), for optimization purposes. But that's also the only thing I know of that will require it, it's a very low-level detail in compiler-builtins where we could provide the flag via. bootstrap instead, and the perf gains are very, very slim. So probably fine to not have a way to detect zippered builds.

Regarding activating it, I think it'd be enough to have some sort of -Zzippered=ios-macabi; the architecture has to stay the same (so an extra --target would be overkill), and the iOS version could be determined from IPHONE_DEPLOYMENT_TARGET like we do today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-targets Area: Concerning the implications of different compiler targets C-feature-request Category: A feature request, i.e: not implemented / a PR. O-ios Operating system: iOS O-macos Operating system: macOS T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants