Skip to content

Commit

Permalink
Set the default deployment target for Macos ARM64 to 11.0.
Browse files Browse the repository at this point in the history
11.0 (Big Sur) is the first version which supports ARM64 so we use
that as default.
  • Loading branch information
hkratz committed Nov 25, 2021
1 parent fa18030 commit 8f4d88c
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions compiler/rustc_target/src/spec/apple_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ pub fn opts(os: &str) -> TargetOptions {
// warnings about the usage of ELF TLS.
//
// Here we detect what version is being requested, defaulting to 10.7. ELF
// TLS is flagged as enabled if it looks to be supported.
let version = macos_deployment_target();
// TLS is flagged as enabled if it looks to be supported. The architecture
// only matters for default deployment target which is 11.0 for ARM64 and
// 10.7 for everything else.
let has_elf_tls = macos_deployment_target("x86_64") >= (10, 7);

TargetOptions {
os: os.to_string(),
Expand All @@ -31,7 +33,7 @@ pub fn opts(os: &str) -> TargetOptions {
has_rpath: true,
dll_suffix: ".dylib".to_string(),
archive_format: "darwin".to_string(),
has_elf_tls: version >= (10, 7),
has_elf_tls,
abi_return_struct_as_int: true,
emit_debug_gdb_scripts: false,
eh_frame_header: false,
Expand Down Expand Up @@ -63,12 +65,17 @@ fn deployment_target(var_name: &str) -> Option<(u32, u32)> {
.and_then(|(a, b)| a.parse::<u32>().and_then(|a| b.parse::<u32>().map(|b| (a, b))).ok())
}

fn macos_deployment_target() -> (u32, u32) {
deployment_target("MACOSX_DEPLOYMENT_TARGET").unwrap_or((10, 7))
fn macos_default_deployment_target(arch: &str) -> (u32, u32) {
if arch == "arm64" { (11, 0) } else { (10, 7) }
}

fn macos_deployment_target(arch: &str) -> (u32, u32) {
deployment_target("MACOSX_DEPLOYMENT_TARGET")
.unwrap_or_else(|| macos_default_deployment_target(arch))
}

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

Expand Down

0 comments on commit 8f4d88c

Please sign in to comment.