diff options
| author | kit <kit@hastur.io> | 2021-08-16 15:35:53 +1000 |
|---|---|---|
| committer | kit <kit@hastur.io> | 2021-08-16 17:31:37 +1000 |
| commit | 13e2f807a19398e735ca3addab19366cda133a31 (patch) | |
| tree | bb7faad05311e5676aaa49f219189b56159a2587 | |
| parent | 2a6fb9a4c0e5ca7a81999065943b211c226fe9d8 (diff) | |
| download | rust-13e2f807a19398e735ca3addab19366cda133a31.tar.gz rust-13e2f807a19398e735ca3addab19366cda133a31.zip | |
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.
| -rw-r--r-- | compiler/rustc_target/src/spec/aarch64_apple_ios.rs | 9 | ||||
| -rw-r--r-- | compiler/rustc_target/src/spec/apple_base.rs | 5 |
2 files changed, 13 insertions, 1 deletions
diff --git a/compiler/rustc_target/src/spec/aarch64_apple_ios.rs b/compiler/rustc_target/src/spec/aarch64_apple_ios.rs index e5805d9e691..6468419fce7 100644 --- a/compiler/rustc_target/src/spec/aarch64_apple_ios.rs +++ b/compiler/rustc_target/src/spec/aarch64_apple_ios.rs @@ -2,8 +2,15 @@ use super::apple_sdk_base::{opts, Arch}; use crate::spec::{FramePointer, Target, TargetOptions}; pub fn target() -> Target { + // Clang automatically chooses a more specific target based on + // IPHONEOS_DEPLOYMENT_TARGET. + // This is required for the target to pick the right + // MACH-O commands, so we do too. + let arch = "arm64"; + let llvm_target = super::apple_base::ios_llvm_target(arch); + Target { - llvm_target: "arm64-apple-ios".to_string(), + llvm_target, pointer_width: 64, data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".to_string(), arch: "aarch64".to_string(), diff --git a/compiler/rustc_target/src/spec/apple_base.rs b/compiler/rustc_target/src/spec/apple_base.rs index 0c8a89210ff..cff0b3651e1 100644 --- a/compiler/rustc_target/src/spec/apple_base.rs +++ b/compiler/rustc_target/src/spec/apple_base.rs @@ -91,6 +91,11 @@ fn ios_deployment_target() -> (u32, u32) { deployment_target("IPHONEOS_DEPLOYMENT_TARGET").unwrap_or((7, 0)) } +pub fn ios_llvm_target(arch: &str) -> String { + let (major, minor) = ios_deployment_target(); + format!("{}-apple-ios{}.{}.0", arch, major, minor) +} + pub fn ios_sim_llvm_target(arch: &str) -> String { let (major, minor) = ios_deployment_target(); format!("{}-apple-ios{}.{}.0-simulator", arch, major, minor) |
