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 tvOS and watchOS (and simulator) targets #48862

Closed
comex opened this issue Mar 9, 2018 · 19 comments
Closed

Support tvOS and watchOS (and simulator) targets #48862

comex opened this issue Mar 9, 2018 · 19 comments
Labels
A-target-specs Area: compile-target specifications C-feature-request Category: A feature request, i.e: not implemented / a PR. O-ios Operating system: iOS O-macos Operating system: macOS O-tvos Operating system: tvOS (including simulator) O-watchos Operating System: watchOS T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@comex
Copy link
Contributor

comex commented Mar 9, 2018

Apple's division of OS targets is a bit odd: apps for iPhones and iPads both use an iOS or "iPhoneOS" target, but watchOS and tvOS are treated as entirely separate targets or "platforms".

rustc currently supports macOS ({x86_64,i686}-apple-darwin), iOS ({armv7,armv7s,aarch64}-apple-ios), and the iOS Simulator (i386-apple-ios), but not tvOS or watchOS.

Here's the full list of platforms. (I'm not sure if the version-min argument is needed for rustc, but it would be needed in cc-rs, which is also missing support.)

Edit (9/10/19): Changes since this was originally posted:

OS Name Xcode Platform Name Valid Architectures LLVM Triple Clang -mxxx-version-min
macOS MacOSX i386 x86_64 x86_64-apple-macosx10.13.0 -mmacosx-version-min or -mmacos-version-min
iOS iPhoneOS arm64 armv7 armv7s arm64-apple-ios11.2.0 -miphoneos-version-min or -mios-version-min
iOS Simulator iPhoneOSSimulator i386 x86_64 x86_64-apple-ios11.2.0 -miphonesimulator-version-min or -mios-simulator-version-min
watchOS WatchOS armv7k thumbv7k-apple-watchos4.2.0 -mwatchos-version-min
watchOS Simulator WatchSimulator i386 x86_64 x86_64-apple-watchos4.2.0 -mwatchsimulator-version-min or -mwatchos-simulator-version-min
tvOS AppleTVOS arm64 arm64-apple-tvos11.2.0 -mappletvos-version-min or -mtvos-version-min
tvOS Simulator AppleTVSimulator x86_64 x86_64-apple-tvos11.2.0 -mappletvsimulator-version-min or -mtvos-simulator-version-min

Example output of xcodebuild -showsdks:

iOS SDKs:
	iOS 11.2                      	-sdk iphoneos11.2

iOS Simulator SDKs:
	Simulator - iOS 11.2          	-sdk iphonesimulator11.2

macOS SDKs:
	macOS 10.13                   	-sdk macosx10.13

tvOS SDKs:
	tvOS 11.2                     	-sdk appletvos11.2

tvOS Simulator SDKs:
	Simulator - tvOS 11.2         	-sdk appletvsimulator11.2

watchOS SDKs:
	watchOS 4.2                   	-sdk watchos4.2

watchOS Simulator SDKs:
	Simulator - watchOS 4.2       	-sdk watchsimulator4.2
@Centril Centril added the A-target-specs Area: compile-target specifications label Mar 10, 2018
@XAMPPRocky XAMPPRocky added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-feature-request Category: A feature request, i.e: not implemented / a PR. labels May 14, 2018
@appaquet
Copy link

appaquet commented Mar 1, 2019

Starting from the iOS implementation in rustc, I got i386 and armv7k for watchos to compile and link in Xcode 10.2 beta 3. It requires quite a few modifications to support the watchos platform, but I think it's quite trivial as watchOS is based on iOS. Unfortunatelly, it will require changes in quite a few crates that have conditional compilation on iOS target (cc, compiler-rt, backtrace, etc.).

Unfortunately, this isn't sufficient for Apple Store release... Apple now requires a new arm64_32 target as of watchOS 5.0. There is a very recent proposal to upstream it. Xcode comes with a bitcode translation tool that takes armv7k code and translates it to arm64_32 (which I understand being possible as they have same pointer/int size), but couldn't make it work with armv7k generated by rustc...

As mentionned in #35968, in order to prevent this never ending catching up on Xcode, I think using Swift's llvm is the only way to fully support Apple ecosystem...

@lerouxrgd
Copy link

Would it be feasible to add a codegen-backends implementation based on Swift's llvm ? (In the same way emscripten was added)

@pruthvikar
Copy link

pruthvikar commented Jan 30, 2020

@appaquet Would you be able to share how you managed to compile and link for armv7k?

@appaquet
Copy link

@pruthvikar Unfortunately it's been a while and I haven't touched it since, so I may not be very helpful... But here are the changes I had made on rustc: master...appaquet:watchos

But as I had mentioned, arm64_32 was impossible to target since it required changes that had not been merged in LLVM back when I tested it.

@pruthvikar
Copy link

That should come in very handy, thanks!

bors added a commit that referenced this issue Feb 27, 2020
Added tvOS as targets

This is a first attempt of adding support tvOS as described in #48862. It's got a lot of overlap with [src/librustc_target/spec/apple_ios_base.rs](https://github.com/rust-lang/rust/blob/31dd4f4acbcbdb02b0745d2136399ed664a28050/src/librustc_target/spec/apple_ios_base.rs).

I thought about refactoring `apple_ios_base.rs` to include this as well but that would require each of the ios and tvos targets to be of the something like the form `let base = opts(AppleOS::TV, Arch::Arm64)?;` I also did the same thing for watchOS because from what I can tell, all three targets (iOS, tvOS, and watchOS) have the same logic but have different parameters being sent to `xcrun`. Thoughts?

As far as the `data_layout` and other parameters to `Target`, I did as much research as I could but it really seems that processor in the [iPhone 11 is the same as the apple TV](https://en.wikipedia.org/wiki/Apple-designed_processors) so I didn't change any of those parameters.

I did get this to build and tested that it's actually running the the below logic (because the parameter to `xcrun` is `appletvos` not `tvos`).

I didn't manage to get it to actually compile a file with `fn main(){}` because I don't have the stdlib for `aarch64-apple-tvos` compiled it seems. Is there documentation for this?

Similar to the ending of #63467, I'm not sure what to do next.
Centril added a commit to Centril/rust that referenced this issue Mar 11, 2020
Added tvOS as targets

This is a first attempt of adding support tvOS as described in rust-lang#48862. It's got a lot of overlap with [src/librustc_target/spec/apple_ios_base.rs](https://github.com/rust-lang/rust/blob/31dd4f4acbcbdb02b0745d2136399ed664a28050/src/librustc_target/spec/apple_ios_base.rs).

I thought about refactoring `apple_ios_base.rs` to include this as well but that would require each of the ios and tvos targets to be of the something like the form `let base = opts(AppleOS::TV, Arch::Arm64)?;` I also did the same thing for watchOS because from what I can tell, all three targets (iOS, tvOS, and watchOS) have the same logic but have different parameters being sent to `xcrun`. Thoughts?

As far as the `data_layout` and other parameters to `Target`, I did as much research as I could but it really seems that processor in the [iPhone 11 is the same as the apple TV](https://en.wikipedia.org/wiki/Apple-designed_processors) so I didn't change any of those parameters.

I did get this to build and tested that it's actually running the the below logic (because the parameter to `xcrun` is `appletvos` not `tvos`).

I didn't manage to get it to actually compile a file with `fn main(){}` because I don't have the stdlib for `aarch64-apple-tvos` compiled it seems. Is there documentation for this?

Similar to the ending of rust-lang#63467, I'm not sure what to do next.
Centril added a commit to Centril/rust that referenced this issue Mar 11, 2020
Added tvOS as targets

This is a first attempt of adding support tvOS as described in rust-lang#48862. It's got a lot of overlap with [src/librustc_target/spec/apple_ios_base.rs](https://github.com/rust-lang/rust/blob/31dd4f4acbcbdb02b0745d2136399ed664a28050/src/librustc_target/spec/apple_ios_base.rs).

I thought about refactoring `apple_ios_base.rs` to include this as well but that would require each of the ios and tvos targets to be of the something like the form `let base = opts(AppleOS::TV, Arch::Arm64)?;` I also did the same thing for watchOS because from what I can tell, all three targets (iOS, tvOS, and watchOS) have the same logic but have different parameters being sent to `xcrun`. Thoughts?

As far as the `data_layout` and other parameters to `Target`, I did as much research as I could but it really seems that processor in the [iPhone 11 is the same as the apple TV](https://en.wikipedia.org/wiki/Apple-designed_processors) so I didn't change any of those parameters.

I did get this to build and tested that it's actually running the the below logic (because the parameter to `xcrun` is `appletvos` not `tvos`).

I didn't manage to get it to actually compile a file with `fn main(){}` because I don't have the stdlib for `aarch64-apple-tvos` compiled it seems. Is there documentation for this?

Similar to the ending of rust-lang#63467, I'm not sure what to do next.
bors added a commit that referenced this issue Mar 12, 2020
Added tvOS as targets

This is a first attempt of adding support tvOS as described in #48862. It's got a lot of overlap with [src/librustc_target/spec/apple_ios_base.rs](https://github.com/rust-lang/rust/blob/31dd4f4acbcbdb02b0745d2136399ed664a28050/src/librustc_target/spec/apple_ios_base.rs).

I thought about refactoring `apple_ios_base.rs` to include this as well but that would require each of the ios and tvos targets to be of the something like the form `let base = opts(AppleOS::TV, Arch::Arm64)?;` I also did the same thing for watchOS because from what I can tell, all three targets (iOS, tvOS, and watchOS) have the same logic but have different parameters being sent to `xcrun`. Thoughts?

As far as the `data_layout` and other parameters to `Target`, I did as much research as I could but it really seems that processor in the [iPhone 11 is the same as the apple TV](https://en.wikipedia.org/wiki/Apple-designed_processors) so I didn't change any of those parameters.

I did get this to build and tested that it's actually running the the below logic (because the parameter to `xcrun` is `appletvos` not `tvos`).

I didn't manage to get it to actually compile a file with `fn main(){}` because I don't have the stdlib for `aarch64-apple-tvos` compiled it seems. Is there documentation for this?

Similar to the ending of #63467, I'm not sure what to do next.
@iMonZ
Copy link

iMonZ commented Jun 5, 2022

rustc --print target-list shows "aarch64-apple-tvos" but then I get the error:

~/Downloads/rust   …  rustup target add aarch64-apple-tvos 111ms  Sun 5 Jun 03:43:10 2022
error: toolchain 'beta-aarch64-apple-darwin' does not contain component 'rust-std' for target 'aarch64-apple-tvos'; did you mean 'aarch64-apple-ios'?
note: not all platforms have the standard library pre-compiled: https://doc.rust-lang.org/nightly/rustc/platform-support.html

@jinleili
Copy link

From https://doc.rust-lang.org/nightly/rustc/platform-support.html, aarch64-apple-tvos target only supports no_std development.

@hakonk
Copy link

hakonk commented Jun 18, 2023

Hi! Is support for Rust std on tvOS something that is worked on, and if so, are there any plans for when it will be rolled out?

@hakonk
Copy link

hakonk commented Jun 18, 2023

I'm also curious about what's needed to make std work on tvOS.

@workingjubilee workingjubilee added O-macos Operating system: macOS O-ios Operating system: iOS O-tvos Operating system: tvOS (including simulator) labels Jul 22, 2023
@workingjubilee
Copy link
Contributor

See #103503
All of these targets are at the status they should be, I believe.

Closing.

@hakonk
Copy link

hakonk commented Jul 23, 2023

Great, @workingjubilee ! I'm happy to see this!

@bcardarella
Copy link

am I understanding this issue as indicating that the TvOS simulator is supported? We cannot compile to it but we can compile directly to TvOS

@bcardarella
Copy link

Just to confirm I'm on the correct version of rustc:

➜  ~ rustc --version
rustc 1.72.0 (5680fa18f 2023-08-23)
➜  ~ rustc --print target-list | grep tvos
aarch64-apple-tvos
x86_64-apple-tvos

@workingjubilee
Copy link
Contributor

The tuple naming may be somewhat nonintuitive. The x86_64-apple-tvos target is a simulator target, and the aarch64-apple-tvos target is not, as you can see by the table in comex's original post. I hope that clarifies things? If you desire a rename, more tuples, etc., I recommend pursuing that in a new proposal as due to various circumstances this one is about to be out-of-date for any discussion of how these targets actually are.

@bcardarella
Copy link

@workingjubilee you're right, let me dig in and see why we're not able to compile for the simulator. Thank you for the quick reply

@bcardarella
Copy link

@workingjubilee wouldn't the x86_64-apple-tvos architecture not work on the M1/M2 macs as the simulator?

@bcardarella
Copy link

For example, if I get the compiler targets for WatchOS:

➜  ~ rustc --print target-list | grep watchos
aarch64-apple-watchos-sim
arm64_32-apple-watchos
armv7k-apple-watchos
x86_64-apple-watchos-sim

it includes both the x86 and aarch64 targets for the simulator

@bcardarella
Copy link

@workingjubilee
Copy link
Contributor

@workingjubilee wouldn't the x86_64-apple-tvos architecture not work on the M1/M2 macs as the simulator?

Uhhh, it probably seems obvious to you, but for some reason I am missing the last 20% of context here so I'm not immediately certain what you're actually asking. Which is the other reason why I suggested you open a new issue: It would be nice to see the full "problem statement" ("I want to do X, I tried Y, it didn't work, this was what the compiler vomited out").

You can @ me in that issue if you want my attention specifically, but it is also more likely to get attention in general, because it will be visible to people immediately triaging the issues (especially recently-opened ones). And we may need to determine it's a regression and triage it as such and so on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-target-specs Area: compile-target specifications C-feature-request Category: A feature request, i.e: not implemented / a PR. O-ios Operating system: iOS O-macos Operating system: macOS O-tvos Operating system: tvOS (including simulator) O-watchos Operating System: watchOS 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