未验证 提交 c6da5b08 编写于 作者: G Guillaume Gomez 提交者: GitHub

Rollup merge of #88077 - kit-981:feature/fix-minimum-os-version-in-header, r=petrochenkov

Generate an iOS LLVM target with a specific version

This commit adds the `LC_VERSION_MIN_IPHONEOS` load command to the Mach-O header generated for `aarch64-apple-ios` binaries. The operating system will look for this load command to determine the minimum supported operating system version and will not allow the binary to run if it's absent. This logic already exists for the simulator toolchain.

I've been using `otool` from a [cctools](https://github.com/tpoechtrager/cctools-port) toolchain to parse the header and validate that this change adds the required load command.

This change appears to be enough to build Rust binaries that can run on a jailbroken iPhone.
...@@ -2,8 +2,15 @@ ...@@ -2,8 +2,15 @@
use crate::spec::{FramePointer, Target, TargetOptions}; use crate::spec::{FramePointer, Target, TargetOptions};
pub fn target() -> Target { 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 { Target {
llvm_target: "arm64-apple-ios".to_string(), llvm_target,
pointer_width: 64, pointer_width: 64,
data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".to_string(), data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".to_string(),
arch: "aarch64".to_string(), arch: "aarch64".to_string(),
......
...@@ -91,6 +91,11 @@ fn ios_deployment_target() -> (u32, u32) { ...@@ -91,6 +91,11 @@ fn ios_deployment_target() -> (u32, u32) {
deployment_target("IPHONEOS_DEPLOYMENT_TARGET").unwrap_or((7, 0)) 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 { pub fn ios_sim_llvm_target(arch: &str) -> String {
let (major, minor) = ios_deployment_target(); let (major, minor) = ios_deployment_target();
format!("{}-apple-ios{}.{}.0-simulator", arch, major, minor) format!("{}-apple-ios{}.{}.0-simulator", arch, major, minor)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册