-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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 Apple tvOS in libstd #103503
Support Apple tvOS in libstd #103503
Changes from all commits
bdc3db9
f978d7e
3785a17
abb1911
df96402
b18ff59
6e62961
a3f5566
b80e0b7
49da0ac
37854aa
a7ecc71
5ef4d1f
af0662f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -240,7 +240,12 @@ fn link_env_remove(arch: Arch, os: &'static str) -> StaticCow<[StaticCow<str>]> | |
// Remove the `SDKROOT` environment variable if it's clearly set for the wrong platform, which | ||
// may occur when we're linking a custom build script while targeting iOS for example. | ||
if let Ok(sdkroot) = env::var("SDKROOT") { | ||
if sdkroot.contains("iPhoneOS.platform") || sdkroot.contains("iPhoneSimulator.platform") | ||
if sdkroot.contains("iPhoneOS.platform") | ||
|| sdkroot.contains("iPhoneSimulator.platform") | ||
|| sdkroot.contains("AppleTVOS.platform") | ||
|| sdkroot.contains("AppleTVSimulator.platform") | ||
|| sdkroot.contains("WatchOS.platform") | ||
|| sdkroot.contains("WatchSimulator.platform") | ||
{ | ||
env_remove.push("SDKROOT".into()) | ||
} | ||
|
@@ -249,6 +254,7 @@ fn link_env_remove(arch: Arch, os: &'static str) -> StaticCow<[StaticCow<str>]> | |
// "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld", | ||
// although this is apparently ignored when using the linker at "/usr/bin/ld". | ||
env_remove.push("IPHONEOS_DEPLOYMENT_TARGET".into()); | ||
env_remove.push("TVOS_DEPLOYMENT_TARGET".into()); | ||
Comment on lines
256
to
+257
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Uh, preexisting so it doesn't have to be addressed here, but should we be doing this for "WATCHOS_DEPLOYMENT_TARGET"? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll catch this after this PR merges. I think this mainly matters in cases involving build scripts that want to use SDK tools, but I could be mistaken. |
||
env_remove.into() | ||
} else { | ||
// Otherwise if cross-compiling for a different OS/SDK, remove any part | ||
|
@@ -299,6 +305,16 @@ fn tvos_lld_platform_version() -> String { | |
format!("{major}.{minor}") | ||
} | ||
|
||
pub fn tvos_llvm_target(arch: Arch) -> String { | ||
let (major, minor) = tvos_deployment_target(); | ||
format!("{}-apple-tvos{}.{}.0", arch.target_name(), major, minor) | ||
} | ||
|
||
pub fn tvos_sim_llvm_target(arch: Arch) -> String { | ||
let (major, minor) = tvos_deployment_target(); | ||
format!("{}-apple-tvos{}.{}.0-simulator", arch.target_name(), major, minor) | ||
} | ||
|
||
fn watchos_deployment_target() -> (u32, u32) { | ||
// If you are looking for the default deployment target, prefer `rustc --print deployment-target`. | ||
from_set_deployment_target("WATCHOS_DEPLOYMENT_TARGET").unwrap_or((5, 0)) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
use super::apple_base::{opts, Arch}; | ||
use super::apple_base::{opts, tvos_sim_llvm_target, Arch}; | ||
use crate::spec::{StackProbeType, Target, TargetOptions}; | ||
|
||
pub fn target() -> Target { | ||
let arch = Arch::X86_64_sim; | ||
Target { | ||
llvm_target: "x86_64-apple-tvos".into(), | ||
llvm_target: tvos_sim_llvm_target(arch).into(), | ||
pointer_width: 64, | ||
data_layout: "e-m:o-i64:64-f80:128-n8:16:32:64-S128".into(), | ||
data_layout: "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems all of our There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure. In general this comes from LLVM/Clang via the magic of TableGen (I think), so I'm hesitant on trying to unify it given there's no reason for us to assume that these must be the same in the future. I'll ask around though. I don't think we should try to unify these in this PR anyway. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Leaving it for another PR sounds fine, I just had to ask. |
||
.into(), | ||
arch: arch.target_arch(), | ||
options: TargetOptions { | ||
max_atomic_width: Some(128), | ||
|
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.
Same question but now it's about "WatchOS.platform".