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

Fix IPHONEOS_DEPLOYMENT_TARGET on Mac Catalyst #121296

Merged
merged 5 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions compiler/rustc_target/src/spec/base/apple/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,19 +106,27 @@ fn pre_link_args(os: &'static str, arch: Arch, abi: &'static str) -> LinkArgs {
}
.into();

let arch = arch.target_name();

let mut args = TargetOptions::link_args(
LinkerFlavor::Darwin(Cc::No, Lld::No),
&["-arch", arch, "-platform_version"],
&["-arch", arch.target_name(), "-platform_version"],
);
add_link_args_iter(
&mut args,
LinkerFlavor::Darwin(Cc::No, Lld::No),
[platform_name, platform_version.clone(), platform_version].into_iter(),
);
if abi != "macabi" {
add_link_args(&mut args, LinkerFlavor::Darwin(Cc::Yes, Lld::No), &["-arch", arch]);
add_link_args(
&mut args,
LinkerFlavor::Darwin(Cc::Yes, Lld::No),
&["-arch", arch.target_name()],
);
} else {
add_link_args_iter(
&mut args,
LinkerFlavor::Darwin(Cc::Yes, Lld::No),
["-target".into(), mac_catalyst_llvm_target(arch).into()].into_iter(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know it's not your code, but I wish this function took impl IntoIterator. Maybe a future cleanup.

);
}

args
Expand Down Expand Up @@ -326,6 +334,11 @@ pub fn ios_llvm_target(arch: Arch) -> String {
format!("{}-apple-ios{}.{}.0", arch.target_name(), major, minor)
}

pub fn mac_catalyst_llvm_target(arch: Arch) -> String {
let (major, minor) = mac_catalyst_deployment_target();
format!("{}-apple-ios{}.{}.0-macabi", arch.target_name(), major, minor)
}

fn ios_lld_platform_version(arch: Arch) -> String {
let (major, minor) = ios_deployment_target(arch);
format!("{major}.{minor}")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
use crate::spec::base::apple::{opts, Arch};
use crate::spec::{Cc, FramePointer, LinkerFlavor, Lld, SanitizerSet, Target, TargetOptions};
use crate::spec::base::apple::{mac_catalyst_llvm_target, opts, Arch};
use crate::spec::{FramePointer, SanitizerSet, Target, TargetOptions};

pub fn target() -> Target {
let llvm_target = "arm64-apple-ios14.0-macabi";

let arch = Arch::Arm64_macabi;
let mut base = opts("ios", arch);
base.add_pre_link_args(LinkerFlavor::Darwin(Cc::Yes, Lld::No), &["-target", llvm_target]);
base.supported_sanitizers = SanitizerSet::ADDRESS | SanitizerSet::LEAK | SanitizerSet::THREAD;

Target {
llvm_target: llvm_target.into(),
llvm_target: mac_catalyst_llvm_target(arch).into(),
pointer_width: 64,
data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".into(),
arch: arch.target_arch(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
use crate::spec::base::apple::{opts, Arch};
use crate::spec::{Cc, LinkerFlavor, Lld, SanitizerSet, Target, TargetOptions};
use crate::spec::base::apple::{mac_catalyst_llvm_target, opts, Arch};
use crate::spec::{SanitizerSet, Target, TargetOptions};

pub fn target() -> Target {
let llvm_target = "x86_64-apple-ios14.0-macabi";

let arch = Arch::X86_64_macabi;
let mut base = opts("ios", arch);
base.add_pre_link_args(LinkerFlavor::Darwin(Cc::Yes, Lld::No), &["-target", llvm_target]);
base.supported_sanitizers = SanitizerSet::ADDRESS | SanitizerSet::LEAK | SanitizerSet::THREAD;

Target {
llvm_target: llvm_target.into(),
llvm_target: mac_catalyst_llvm_target(arch).into(),
pointer_width: 64,
data_layout:
"e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(),
Expand Down