Skip to content

Commit 13e2f80

Browse files
committed
Generate an iOS LLVM target with a specific version
Without the specific version, the mach-o header will be missing the minimum supported operating system version. This is mandatory for running Rust binaries on iOS devices.
1 parent 2a6fb9a commit 13e2f80

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

compiler/rustc_target/src/spec/aarch64_apple_ios.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,15 @@ use super::apple_sdk_base::{opts, Arch};
22
use crate::spec::{FramePointer, Target, TargetOptions};
33

44
pub fn target() -> Target {
5+
// Clang automatically chooses a more specific target based on
6+
// IPHONEOS_DEPLOYMENT_TARGET.
7+
// This is required for the target to pick the right
8+
// MACH-O commands, so we do too.
9+
let arch = "arm64";
10+
let llvm_target = super::apple_base::ios_llvm_target(arch);
11+
512
Target {
6-
llvm_target: "arm64-apple-ios".to_string(),
13+
llvm_target,
714
pointer_width: 64,
815
data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".to_string(),
916
arch: "aarch64".to_string(),

compiler/rustc_target/src/spec/apple_base.rs

+5
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ fn ios_deployment_target() -> (u32, u32) {
9191
deployment_target("IPHONEOS_DEPLOYMENT_TARGET").unwrap_or((7, 0))
9292
}
9393

94+
pub fn ios_llvm_target(arch: &str) -> String {
95+
let (major, minor) = ios_deployment_target();
96+
format!("{}-apple-ios{}.{}.0", arch, major, minor)
97+
}
98+
9499
pub fn ios_sim_llvm_target(arch: &str) -> String {
95100
let (major, minor) = ios_deployment_target();
96101
format!("{}-apple-ios{}.{}.0-simulator", arch, major, minor)

0 commit comments

Comments
 (0)