1
Fork 0

Fix the tvOS targets to use the right LLVM target and respect the deployment target environment variables

This commit is contained in:
Thom Chiovoloni 2023-03-14 21:24:15 -07:00
parent 3785a17dd9
commit abb1911682
No known key found for this signature in database
3 changed files with 19 additions and 5 deletions

View file

@ -1,10 +1,10 @@
use super::apple_base::{opts, Arch}; use super::apple_base::{opts, tvos_llvm_target, Arch};
use crate::spec::{FramePointer, Target, TargetOptions}; use crate::spec::{FramePointer, Target, TargetOptions};
pub fn target() -> Target { pub fn target() -> Target {
let arch = Arch::Arm64; let arch = Arch::Arm64;
Target { Target {
llvm_target: "arm64-apple-tvos".into(), llvm_target: tvos_llvm_target(arch).into(),
pointer_width: 64, pointer_width: 64,
data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".into(), data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".into(),
arch: arch.target_arch(), arch: arch.target_arch(),

View file

@ -240,7 +240,10 @@ 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 // 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. // may occur when we're linking a custom build script while targeting iOS for example.
if let Ok(sdkroot) = env::var("SDKROOT") { 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")
{ {
env_remove.push("SDKROOT".into()) env_remove.push("SDKROOT".into())
} }
@ -249,6 +252,7 @@ fn link_env_remove(arch: Arch, os: &'static str) -> StaticCow<[StaticCow<str>]>
// "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld", // "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld",
// although this is apparently ignored when using the linker at "/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("IPHONEOS_DEPLOYMENT_TARGET".into());
env_remove.push("TVOS_DEPLOYMENT_TARGET".into());
env_remove.into() env_remove.into()
} else { } else {
// Otherwise if cross-compiling for a different OS/SDK, remove any part // Otherwise if cross-compiling for a different OS/SDK, remove any part
@ -279,6 +283,16 @@ pub fn ios_llvm_target(arch: Arch) -> String {
format!("{}-apple-ios{}.{}.0", arch.target_name(), major, minor) format!("{}-apple-ios{}.{}.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)
}
pub fn tvos_llvm_target(arch: Arch) -> String {
let (major, minor) = tvos_deployment_target();
format!("{}-apple-tvos{}.{}.0", arch.target_name(), major, minor)
}
fn ios_lld_platform_version() -> String { fn ios_lld_platform_version() -> String {
let (major, minor) = ios_deployment_target(); let (major, minor) = ios_deployment_target();
format!("{major}.{minor}") format!("{major}.{minor}")

View file

@ -1,10 +1,10 @@
use super::apple_base::{opts, Arch}; use super::apple_base::{opts, tvos_sim_llvm_target, Arch};
use crate::spec::{StackProbeType, Target, TargetOptions}; use crate::spec::{StackProbeType, Target, TargetOptions};
pub fn target() -> Target { pub fn target() -> Target {
let arch = Arch::X86_64_sim; let arch = Arch::X86_64_sim;
Target { Target {
llvm_target: "x86_64-apple-tvos".into(), llvm_target: tvos_sim_llvm_target(arch).into(),
pointer_width: 64, pointer_width: 64,
data_layout: "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" data_layout: "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
.into(), .into(),