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

default to $ARCH-apple-macosx10.7.0 LLVM triple for darwin targets #60788

Merged
merged 1 commit into from
May 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
17 changes: 5 additions & 12 deletions src/librustc_target/spec/apple_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub fn opts() -> TargetOptions {
//
// 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().unwrap_or((10, 7));
let version = macos_deployment_target();

TargetOptions {
// macOS has -dead_strip, which doesn't rely on function_sections
Expand All @@ -35,7 +35,7 @@ pub fn opts() -> TargetOptions {
}
}

fn macos_deployment_target() -> Option<(u32, u32)> {
fn macos_deployment_target() -> (u32, u32) {
let deployment_target = env::var("MACOSX_DEPLOYMENT_TARGET").ok();
let version = deployment_target.as_ref().and_then(|s| {
let mut i = s.splitn(2, '.');
Expand All @@ -44,17 +44,10 @@ fn macos_deployment_target() -> Option<(u32, u32)> {
a.parse::<u32>().and_then(|a| b.parse::<u32>().map(|b| (a, b))).ok()
});

version
version.unwrap_or((10, 7))
}

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

llvm_target
let (major, minor) = macos_deployment_target();
format!("{}-apple-macosx{}.{}.0", arch, major, minor)
}
2 changes: 1 addition & 1 deletion src/test/codegen/i686-no-macosx-deployment-target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub struct Bool {
b: bool,
}

// CHECK: target triple = "i686-apple-darwin"
// CHECK: target triple = "i686-apple-macosx10.7.0"
#[no_mangle]
pub extern "C" fn structbool() -> Bool {
Bool { b: true }
Expand Down
2 changes: 1 addition & 1 deletion src/test/codegen/x86_64-no-macosx-deployment-target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub struct Bool {
b: bool,
}

// CHECK: target triple = "x86_64-apple-darwin"
// CHECK: target triple = "x86_64-apple-macosx10.7.0"
#[no_mangle]
pub extern "C" fn structbool() -> Bool {
Bool { b: true }
Expand Down