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

Add Catalyst (iOS apps running on macOS) target #63467

Merged

Conversation

@terhechte
Copy link
Contributor

commented Aug 11, 2019

This is a first attempt of adding support for the new Apple Catalyst target (i.e. running iOS apps on macOS). Currently, rustc supports the iOS and iOS simulator targets for iOS:

  • iOS: ARM cpu, iOS SDK, linked agains the iOS ABI
  • Simulator: X86_64 cpu, iOS SDK, linked against the iOS ABI

Apple Catalyst will add an additional target:

  • Macabi: X86_64 CPU, iOS SDK, linked again the macOS ABI.

Note, it the actual SDK is the also the macOS 10.15 SDK, but the symbols are the iOS SDK symbols as they were added to macOS with 10.15.

I've collected additional information via links in the open question sections below. This is way out of my comfort zone so please excuse whatever errors I may have made.

Open Questions:

Clang Version

It seems to me that macabi has not been merged into clang yet, I don't know whether that is a requirement rustc to compile, or if it is sufficient if the Clang that is used on a developers system is the correct one supporting macabi (that comes with current Xcode)

Hardcoded iOS version

swift-llvm actually used x86_64-apple-ios13.0-macabi as the target triple which hard-codes the current iOS version. A post on stackoverflow points out that MIN_IOS_VERSION and MIN_OSX_VERSION should be used when compiling C code for clang (-target x86_64-apple-ios${MIN_IOS_VERSION}-macabi). However, I wasn't entirely sure how to do that in this PR. Pointers welcome.

Data Layout

I'm probably using the wrong data-layout. I don't know whether it should be the macOS version or the iOS version. This is probably easier to answer for somebody who understands these things much better than me. I just copied the iOS Simulator X86_64 version as it seems to be (based on what I understand) that Catalyst is just the simulator target build against a different SDK.

Current State

  1. I got it to compile
  2. I could successfully compile a macabi libcore via cargo build --target x86_64-apple-ios-macabi

I'm not sure what needs to be done next. Supposedly I need to compile everything into a toolchain somehow that I can then test via rustup to make sure that a binary compiled against the toolchain also works with Catalyst. I read this article, but I'm still lost and would love pointers what to do next here.

Additional Information

Add initial files for iOS catalyst / macabi support
This is a first attempt of adding support for the new Apple Catalyst ABI (i.e. running iOS apps on macOS). Currently, `rustc` supports the iOS and iOS simulator targets for iOS:
- iOS: ARM cpu, iOS SDK, linked agains the iOS ABI
- Simulator: X86_64 cpu, iOS SDK, linked against the iOS ABI

Apple Catalyst will add an additional target:
- Macabi: X86_64 CPU, iOS SDK, linked again the macOS ABI.

Note, it the actual SDK is the also the macOS 10.15 SDK, but the symbols are the iOS SDK symbols as they were added to macOS with 10.15.

This commits adds the files for this new target triple.
@rust-highfive

This comment has been minimized.

Copy link
Collaborator

commented Aug 11, 2019

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @estebank (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@estebank

This comment has been minimized.

Copy link
Contributor

commented Aug 12, 2019

cc @alexcrichton everything seems correct, but I am unsure about:

It seems to me that macabi has not been merged into clang yet, I don't know whether that is a requirement rustc to compile, or if it is sufficient if the Clang that is used on a developers system is the correct one supporting macabi (that comes with current Xcode)

@alexcrichton

This comment has been minimized.

Copy link
Member

commented Aug 13, 2019

In general we're extremely liberal with adding new targets to the compiler, so there's not much oversight nor much verification for correctness as targets are added. In that sense if a target wants to be added here before clang, that's ok. We don't really have anyone to say whether that's a good idea or not, it depends on who's adding the target basically to make that judgement call.

In terms of things like target naming, data layout, etc, afaik we don't really have answers and/or someone to answer questions. It's largely up to you adding the target to test it out and make sure it works

@terhechte

This comment has been minimized.

Copy link
Contributor Author

commented Aug 13, 2019

@alexcrichton Thanks for the info! I'll try to get this into a custom toolchain then so that I can see if it works as expected.

Just to make sure I'm understanding this correctly. The rust build will not fail just because this new Catalyst target is not supported by the default clang compiler (yet)?

Thanks!

@alexcrichton

This comment has been minimized.

Copy link
Member

commented Aug 13, 2019

Correct yeah, we don't build all targets by default, only a whitelist of targets. That means that if there's a bug in this target or something doesn't work as expected it won't block other builds

@estebank

This comment has been minimized.

Copy link
Contributor

commented Aug 14, 2019

Given @alexcrichton's comment,

@bors r+

@bors

This comment has been minimized.

Copy link
Contributor

commented Aug 14, 2019

📌 Commit af1e668 has been approved by estebank

@Centril Centril added this to the 1.39 milestone Aug 15, 2019

Centril added a commit to Centril/rust that referenced this pull request Aug 15, 2019

Rollup merge of rust-lang#63467 - terhechte:support-ios-catalyst-maca…
…bi-target-triple, r=estebank

Add Catalyst (iOS apps running on macOS) target

This is a first attempt of adding support for the new [Apple Catalyst](https://developer.apple.com/ipad-apps-for-mac/) target (i.e. running iOS apps on macOS). Currently, `rustc` supports the iOS and iOS simulator targets for iOS:
- iOS: ARM cpu, iOS SDK, linked agains the iOS ABI
- Simulator: X86_64 cpu, iOS SDK, linked against the iOS ABI

Apple Catalyst will add an additional target:
- Macabi: X86_64 CPU, iOS SDK, linked again the macOS ABI.

Note, it the actual SDK is the also the macOS 10.15 SDK, but the symbols are the iOS SDK symbols as they were added to macOS with 10.15.

I've collected additional information via links in the open question sections below. This is way out of my comfort zone so please excuse whatever errors I may have made.

# Open Questions:

## Clang Version
It seems to me that `macabi` has not been merged into `clang` yet, I don't know whether that is a requirement rustc to compile, or if it is sufficient if the Clang that is used on a developers system is the correct one supporting macabi (that comes with current Xcode)

## Hardcoded iOS version

`swift-llvm` actually used [x86_64-apple-ios13.0-macabi](apple/swift-llvm@3f1fd4f) as the target triple which hard-codes the current iOS version. A post on stackoverflow [points out that `MIN_IOS_VERSION` and `MIN_OSX_VERSION` should be used when compiling C code for clang (`-target x86_64-apple-ios${MIN_IOS_VERSION}-macabi`)](https://stackoverflow.com/questions/56487645/how-to-compile-a-3rd-party-library-to-be-used-with-uikit-for-mac-catalyst). However, I wasn't entirely sure how to do that in this PR. Pointers welcome.

## Data Layout
I'm probably using the wrong data-layout. I don't know whether it should be the macOS version or the iOS version. This is probably easier to answer for somebody who understands these things much better than me. I just copied the iOS Simulator X86_64 version as it seems to be (based on what I understand) that Catalyst is just the simulator target build against a different SDK.

# Current State
1. I got it to compile
2. I could successfully compile a `macabi` `libcore` via `cargo build --target x86_64-apple-ios-macabi`

I'm not sure what needs to be done next. Supposedly I need to compile everything into a toolchain somehow that I can then test via `rustup` to make sure that a binary compiled against the toolchain also works with Catalyst. [I read this article, but I'm still lost](https://www.reddit.com/r/rust/comments/5ag60z/how_do_i_bootstrap_rust_to_crosscompile_for_a_new/d9gicr2/) and would love pointers what to do next here.

# Additional Information
- [Commit adding Catalyst support to the Swift Clang Fork](CocoaPods/CocoaPods#8877)
- [Compiling C to Catalyst Discussion](CocoaPods/CocoaPods#8877)
- [CocoaPods Discussion on Adding Catalyst support](CocoaPods/CocoaPods#8877)

bors added a commit that referenced this pull request Aug 15, 2019

Auto merge of #63588 - Centril:rollup-9ad6qs2, r=Centril
Rollup of 12 pull requests

Successful merges:

 - #63155 (Add UWP MSVC targets)
 - #63165 (Add builtin targets for mips64(el)-unknown-linux-muslabi64)
 - #63467 (Add Catalyst (iOS apps running on macOS) target)
 - #63470 (Utilize -Zbinary-dep-depinfo in rustbuild)
 - #63495 ( Remove redundant `ty` fields from `mir::Constant` and `hair::pattern::PatternRange`.)
 - #63525 (Make sure that all file loading happens via SourceMap)
 - #63546 (Remove uses of `mem::uninitialized()` from cloudabi)
 - #63559 (rustc_codegen_utils: account for 1-indexed anonymous lifetimes in v0 mangling.)
 - #63572 (remove unused Level::PhaseFatal)
 - #63577 (Test HRTB issue accepted by compiler)
 - #63582 (Fix ICE #63226)
 - #63586 (cleanup: Remove `Spanned` where possible)

Failed merges:

r? @ghost

Centril added a commit to Centril/rust that referenced this pull request Aug 15, 2019

Rollup merge of rust-lang#63467 - terhechte:support-ios-catalyst-maca…
…bi-target-triple, r=estebank

Add Catalyst (iOS apps running on macOS) target

This is a first attempt of adding support for the new [Apple Catalyst](https://developer.apple.com/ipad-apps-for-mac/) target (i.e. running iOS apps on macOS). Currently, `rustc` supports the iOS and iOS simulator targets for iOS:
- iOS: ARM cpu, iOS SDK, linked agains the iOS ABI
- Simulator: X86_64 cpu, iOS SDK, linked against the iOS ABI

Apple Catalyst will add an additional target:
- Macabi: X86_64 CPU, iOS SDK, linked again the macOS ABI.

Note, it the actual SDK is the also the macOS 10.15 SDK, but the symbols are the iOS SDK symbols as they were added to macOS with 10.15.

I've collected additional information via links in the open question sections below. This is way out of my comfort zone so please excuse whatever errors I may have made.

# Open Questions:

## Clang Version
It seems to me that `macabi` has not been merged into `clang` yet, I don't know whether that is a requirement rustc to compile, or if it is sufficient if the Clang that is used on a developers system is the correct one supporting macabi (that comes with current Xcode)

## Hardcoded iOS version

`swift-llvm` actually used [x86_64-apple-ios13.0-macabi](apple/swift-llvm@3f1fd4f) as the target triple which hard-codes the current iOS version. A post on stackoverflow [points out that `MIN_IOS_VERSION` and `MIN_OSX_VERSION` should be used when compiling C code for clang (`-target x86_64-apple-ios${MIN_IOS_VERSION}-macabi`)](https://stackoverflow.com/questions/56487645/how-to-compile-a-3rd-party-library-to-be-used-with-uikit-for-mac-catalyst). However, I wasn't entirely sure how to do that in this PR. Pointers welcome.

## Data Layout
I'm probably using the wrong data-layout. I don't know whether it should be the macOS version or the iOS version. This is probably easier to answer for somebody who understands these things much better than me. I just copied the iOS Simulator X86_64 version as it seems to be (based on what I understand) that Catalyst is just the simulator target build against a different SDK.

# Current State
1. I got it to compile
2. I could successfully compile a `macabi` `libcore` via `cargo build --target x86_64-apple-ios-macabi`

I'm not sure what needs to be done next. Supposedly I need to compile everything into a toolchain somehow that I can then test via `rustup` to make sure that a binary compiled against the toolchain also works with Catalyst. [I read this article, but I'm still lost](https://www.reddit.com/r/rust/comments/5ag60z/how_do_i_bootstrap_rust_to_crosscompile_for_a_new/d9gicr2/) and would love pointers what to do next here.

# Additional Information
- [Commit adding Catalyst support to the Swift Clang Fork](CocoaPods/CocoaPods#8877)
- [Compiling C to Catalyst Discussion](CocoaPods/CocoaPods#8877)
- [CocoaPods Discussion on Adding Catalyst support](CocoaPods/CocoaPods#8877)

bors added a commit that referenced this pull request Aug 15, 2019

Auto merge of #63592 - Centril:rollup-7c6dg3e, r=Centril
Rollup of 9 pull requests

Successful merges:

 - #63155 (Add UWP MSVC targets)
 - #63165 (Add builtin targets for mips64(el)-unknown-linux-muslabi64)
 - #63306 (Adapt AddRetag for shallow retagging)
 - #63467 (Add Catalyst (iOS apps running on macOS) target)
 - #63546 (Remove uses of `mem::uninitialized()` from cloudabi)
 - #63572 (remove unused Level::PhaseFatal)
 - #63577 (Test HRTB issue accepted by compiler)
 - #63582 (Fix ICE #63226)
 - #63586 (cleanup: Remove `Spanned` where possible)

Failed merges:

r? @ghost
@terhechte

This comment has been minimized.

Copy link
Contributor Author

commented Aug 15, 2019

Thanks! I'll continue and try to build a toolchain that can be used to compile a library that has the correct macabi and then report back.

@bors bors merged commit af1e668 into rust-lang:master Aug 15, 2019

3 checks passed

pr Build #20190811.23 succeeded
Details
pr (Linux mingw-check) Linux mingw-check succeeded
Details
pr (Linux x86_64-gnu-llvm-6.0) Linux x86_64-gnu-llvm-6.0 succeeded
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants
You can’t perform that action at this time.