Skip to content

Commit cd530fc

Browse files
committed
Merge deployment target variable loading on iOS and Mac Catalyst
1 parent 3cb4e34 commit cd530fc

File tree

1 file changed

+21
-26
lines changed
  • compiler/rustc_target/src/spec/base/apple

1 file changed

+21
-26
lines changed

compiler/rustc_target/src/spec/base/apple/mod.rs

+21-26
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,11 @@ fn pre_link_args(os: &'static str, arch: Arch, abi: &'static str) -> LinkArgs {
9898
};
9999

100100
let min_version: StaticCow<str> = {
101-
let (major, minor) = match (os, abi) {
102-
("ios", "macabi") => mac_catalyst_deployment_target(),
103-
("ios", _) => ios_deployment_target(arch),
104-
("tvos", _) => tvos_deployment_target(),
105-
("watchos", _) => watchos_deployment_target(),
106-
("macos", _) => macos_deployment_target(arch),
101+
let (major, minor) = match os {
102+
"ios" => ios_deployment_target(arch, abi),
103+
"tvos" => tvos_deployment_target(),
104+
"watchos" => watchos_deployment_target(),
105+
"macos" => macos_deployment_target(arch),
107106
_ => unreachable!(),
108107
};
109108
format!("{major}.{minor}").into()
@@ -232,16 +231,13 @@ pub fn deployment_target(target: &Target) -> Option<(u32, u32)> {
232231
};
233232
macos_deployment_target(arch)
234233
}
235-
"ios" => match &*target.abi {
236-
"macabi" => mac_catalyst_deployment_target(),
237-
_ => {
238-
let arch = match target.arch.as_ref() {
239-
"arm64e" => Arm64e,
240-
_ => Arm64,
241-
};
242-
ios_deployment_target(arch)
243-
}
244-
},
234+
"ios" => {
235+
let arch = match target.arch.as_ref() {
236+
"arm64e" => Arm64e,
237+
_ => Arm64,
238+
};
239+
ios_deployment_target(arch, &target.abi)
240+
}
245241
"watchos" => watchos_deployment_target(),
246242
"tvos" => tvos_deployment_target(),
247243
_ => return None,
@@ -311,35 +307,34 @@ fn link_env_remove(os: &'static str) -> StaticCow<[StaticCow<str>]> {
311307
}
312308
}
313309

314-
fn ios_deployment_target(arch: Arch) -> (u32, u32) {
310+
fn ios_deployment_target(arch: Arch, abi: &str) -> (u32, u32) {
315311
// If you are looking for the default deployment target, prefer `rustc --print deployment-target`.
316-
let (major, minor) = if arch == Arm64e { (14, 0) } else { (10, 0) };
312+
let (major, minor) = match (arch, abi) {
313+
(Arm64e, _) => (14, 0),
314+
(_, "macabi") => (14, 0),
315+
_ => (10, 0),
316+
};
317317
from_set_deployment_target("IPHONEOS_DEPLOYMENT_TARGET").unwrap_or((major, minor))
318318
}
319319

320-
fn mac_catalyst_deployment_target() -> (u32, u32) {
321-
// If you are looking for the default deployment target, prefer `rustc --print deployment-target`.
322-
from_set_deployment_target("IPHONEOS_DEPLOYMENT_TARGET").unwrap_or((14, 0))
323-
}
324-
325320
pub fn ios_llvm_target(arch: Arch) -> String {
326321
// Modern iOS tooling extracts information about deployment target
327322
// from LC_BUILD_VERSION. This load command will only be emitted when
328323
// we build with a version specific `llvm_target`, with the version
329324
// set high enough. Luckily one LC_BUILD_VERSION is enough, for Xcode
330325
// to pick it up (since std and core are still built with the fallback
331326
// of version 7.0 and hence emit the old LC_IPHONE_MIN_VERSION).
332-
let (major, minor) = ios_deployment_target(arch);
327+
let (major, minor) = ios_deployment_target(arch, "");
333328
format!("{}-apple-ios{}.{}.0", arch.target_name(), major, minor)
334329
}
335330

336331
pub fn mac_catalyst_llvm_target(arch: Arch) -> String {
337-
let (major, minor) = mac_catalyst_deployment_target();
332+
let (major, minor) = ios_deployment_target(arch, "macabi");
338333
format!("{}-apple-ios{}.{}.0-macabi", arch.target_name(), major, minor)
339334
}
340335

341336
pub fn ios_sim_llvm_target(arch: Arch) -> String {
342-
let (major, minor) = ios_deployment_target(arch);
337+
let (major, minor) = ios_deployment_target(arch, "sim");
343338
format!("{}-apple-ios{}.{}.0-simulator", arch.target_name(), major, minor)
344339
}
345340

0 commit comments

Comments
 (0)