Skip to content
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
10 changes: 9 additions & 1 deletion compiler/rustc_target/src/spec/aarch64_apple_ios_sim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,16 @@ use crate::spec::{Target, TargetOptions};

pub fn target() -> Target {
let base = opts("ios", Arch::Arm64_sim);

// Clang automatically chooses a more specific target based on
// IPHONEOS_DEPLOYMENT_TARGET.
// This is required for the simulator target to pick the right
// MACH-O commands, so we do too.
let arch = "arm64";
let llvm_target = super::apple_base::ios_sim_llvm_target(arch);

Target {
llvm_target: "arm64-apple-ios-simulator".to_string(),
llvm_target: llvm_target,
pointer_width: 64,
data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".to_string(),
arch: "aarch64".to_string(),
Expand Down
21 changes: 16 additions & 5 deletions compiler/rustc_target/src/spec/apple_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,16 @@ pub fn opts(os: &str) -> TargetOptions {
}
}

fn macos_deployment_target() -> (u32, u32) {
let deployment_target = env::var("MACOSX_DEPLOYMENT_TARGET").ok();
let version = deployment_target
fn deployment_target(var_name: &str) -> Option<(u32, u32)> {
let deployment_target = env::var(var_name).ok();
deployment_target
.as_ref()
.and_then(|s| s.split_once('.'))
.and_then(|(a, b)| a.parse::<u32>().and_then(|a| b.parse::<u32>().map(|b| (a, b))).ok());
.and_then(|(a, b)| a.parse::<u32>().and_then(|a| b.parse::<u32>().map(|b| (a, b))).ok())
}

version.unwrap_or((10, 7))
fn macos_deployment_target() -> (u32, u32) {
deployment_target("MACOSX_DEPLOYMENT_TARGET").unwrap_or((10, 7))
}

pub fn macos_llvm_target(arch: &str) -> String {
Expand All @@ -84,3 +86,12 @@ pub fn macos_link_env_remove() -> Vec<String> {
env_remove.push("IPHONEOS_DEPLOYMENT_TARGET".to_string());
env_remove
}

fn ios_deployment_target() -> (u32, u32) {
deployment_target("IPHONEOS_DEPLOYMENT_TARGET").unwrap_or((7, 0))
}

pub fn ios_sim_llvm_target(arch: &str) -> String {
let (major, minor) = ios_deployment_target();
format!("{}-apple-ios{}.{}.0-simulator", arch, major, minor)
}