Skip to content

Commit 8f4d88c

Browse files
committed
Set the default deployment target for Macos ARM64 to 11.0.
11.0 (Big Sur) is the first version which supports ARM64 so we use that as default.
1 parent fa18030 commit 8f4d88c

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

compiler/rustc_target/src/spec/apple_base.rs

+13-6
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ pub fn opts(os: &str) -> TargetOptions {
1313
// warnings about the usage of ELF TLS.
1414
//
1515
// Here we detect what version is being requested, defaulting to 10.7. ELF
16-
// TLS is flagged as enabled if it looks to be supported.
17-
let version = macos_deployment_target();
16+
// TLS is flagged as enabled if it looks to be supported. The architecture
17+
// only matters for default deployment target which is 11.0 for ARM64 and
18+
// 10.7 for everything else.
19+
let has_elf_tls = macos_deployment_target("x86_64") >= (10, 7);
1820

1921
TargetOptions {
2022
os: os.to_string(),
@@ -31,7 +33,7 @@ pub fn opts(os: &str) -> TargetOptions {
3133
has_rpath: true,
3234
dll_suffix: ".dylib".to_string(),
3335
archive_format: "darwin".to_string(),
34-
has_elf_tls: version >= (10, 7),
36+
has_elf_tls,
3537
abi_return_struct_as_int: true,
3638
emit_debug_gdb_scripts: false,
3739
eh_frame_header: false,
@@ -63,12 +65,17 @@ fn deployment_target(var_name: &str) -> Option<(u32, u32)> {
6365
.and_then(|(a, b)| a.parse::<u32>().and_then(|a| b.parse::<u32>().map(|b| (a, b))).ok())
6466
}
6567

66-
fn macos_deployment_target() -> (u32, u32) {
67-
deployment_target("MACOSX_DEPLOYMENT_TARGET").unwrap_or((10, 7))
68+
fn macos_default_deployment_target(arch: &str) -> (u32, u32) {
69+
if arch == "arm64" { (11, 0) } else { (10, 7) }
70+
}
71+
72+
fn macos_deployment_target(arch: &str) -> (u32, u32) {
73+
deployment_target("MACOSX_DEPLOYMENT_TARGET")
74+
.unwrap_or_else(|| macos_default_deployment_target(arch))
6875
}
6976

7077
pub fn macos_llvm_target(arch: &str) -> String {
71-
let (major, minor) = macos_deployment_target();
78+
let (major, minor) = macos_deployment_target(arch);
7279
format!("{}-apple-macosx{}.{}.0", arch, major, minor)
7380
}
7481

0 commit comments

Comments
 (0)