Skip to content

Commit abb1911

Browse files
committed
Fix the tvOS targets to use the right LLVM target and respect the deployment target environment variables
1 parent 3785a17 commit abb1911

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

compiler/rustc_target/src/spec/aarch64_apple_tvos.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
use super::apple_base::{opts, Arch};
1+
use super::apple_base::{opts, tvos_llvm_target, Arch};
22
use crate::spec::{FramePointer, Target, TargetOptions};
33

44
pub fn target() -> Target {
55
let arch = Arch::Arm64;
66
Target {
7-
llvm_target: "arm64-apple-tvos".into(),
7+
llvm_target: tvos_llvm_target(arch).into(),
88
pointer_width: 64,
99
data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".into(),
1010
arch: arch.target_arch(),

compiler/rustc_target/src/spec/apple_base.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,10 @@ fn link_env_remove(arch: Arch, os: &'static str) -> StaticCow<[StaticCow<str>]>
240240
// Remove the `SDKROOT` environment variable if it's clearly set for the wrong platform, which
241241
// may occur when we're linking a custom build script while targeting iOS for example.
242242
if let Ok(sdkroot) = env::var("SDKROOT") {
243-
if sdkroot.contains("iPhoneOS.platform") || sdkroot.contains("iPhoneSimulator.platform")
243+
if sdkroot.contains("iPhoneOS.platform")
244+
|| sdkroot.contains("iPhoneSimulator.platform")
245+
|| sdkroot.contains("AppleTVOS.platform")
246+
|| sdkroot.contains("AppleTVSimulator.platform")
244247
{
245248
env_remove.push("SDKROOT".into())
246249
}
@@ -249,6 +252,7 @@ fn link_env_remove(arch: Arch, os: &'static str) -> StaticCow<[StaticCow<str>]>
249252
// "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld",
250253
// although this is apparently ignored when using the linker at "/usr/bin/ld".
251254
env_remove.push("IPHONEOS_DEPLOYMENT_TARGET".into());
255+
env_remove.push("TVOS_DEPLOYMENT_TARGET".into());
252256
env_remove.into()
253257
} else {
254258
// Otherwise if cross-compiling for a different OS/SDK, remove any part
@@ -279,6 +283,16 @@ pub fn ios_llvm_target(arch: Arch) -> String {
279283
format!("{}-apple-ios{}.{}.0", arch.target_name(), major, minor)
280284
}
281285

286+
pub fn tvos_sim_llvm_target(arch: Arch) -> String {
287+
let (major, minor) = tvos_deployment_target();
288+
format!("{}-apple-tvos{}.{}.0-simulator", arch.target_name(), major, minor)
289+
}
290+
291+
pub fn tvos_llvm_target(arch: Arch) -> String {
292+
let (major, minor) = tvos_deployment_target();
293+
format!("{}-apple-tvos{}.{}.0", arch.target_name(), major, minor)
294+
}
295+
282296
fn ios_lld_platform_version() -> String {
283297
let (major, minor) = ios_deployment_target();
284298
format!("{major}.{minor}")

compiler/rustc_target/src/spec/x86_64_apple_tvos.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
use super::apple_base::{opts, Arch};
1+
use super::apple_base::{opts, tvos_sim_llvm_target, Arch};
22
use crate::spec::{StackProbeType, Target, TargetOptions};
33

44
pub fn target() -> Target {
55
let arch = Arch::X86_64_sim;
66
Target {
7-
llvm_target: "x86_64-apple-tvos".into(),
7+
llvm_target: tvos_sim_llvm_target(arch).into(),
88
pointer_width: 64,
99
data_layout: "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
1010
.into(),

0 commit comments

Comments
 (0)