-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Always add LC_BUILD_VERSION for metadata object files #114114
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -179,20 +179,52 @@ pub fn opts(os: &'static str, arch: Arch) -> TargetOptions { | |
} | ||
} | ||
|
||
pub fn deployment_target(target: &Target) -> Option<String> { | ||
pub fn sdk_version(platform: u32) -> Option<(u32, u32)> { | ||
// NOTE: These values are from an arbitrary point in time but shouldn't make it into the final | ||
// binary since the final link command will have the current SDK version passed to it. | ||
match platform { | ||
object::macho::PLATFORM_MACOS => Some((13, 1)), | ||
object::macho::PLATFORM_IOS | ||
| object::macho::PLATFORM_IOSSIMULATOR | ||
| object::macho::PLATFORM_TVOS | ||
| object::macho::PLATFORM_TVOSSIMULATOR | ||
| object::macho::PLATFORM_MACCATALYST => Some((16, 2)), | ||
object::macho::PLATFORM_WATCHOS | object::macho::PLATFORM_WATCHOSSIMULATOR => Some((9, 1)), | ||
_ => None, | ||
} | ||
} | ||
|
||
pub fn platform(target: &Target) -> Option<u32> { | ||
Some(match (&*target.os, &*target.abi) { | ||
("macos", _) => object::macho::PLATFORM_MACOS, | ||
("ios", "macabi") => object::macho::PLATFORM_MACCATALYST, | ||
("ios", "sim") => object::macho::PLATFORM_IOSSIMULATOR, | ||
("ios", _) => object::macho::PLATFORM_IOS, | ||
("watchos", "sim") => object::macho::PLATFORM_WATCHOSSIMULATOR, | ||
("watchos", _) => object::macho::PLATFORM_WATCHOS, | ||
("tvos", "sim") => object::macho::PLATFORM_TVOSSIMULATOR, | ||
("tvos", _) => object::macho::PLATFORM_TVOS, | ||
_ => return None, | ||
}) | ||
} | ||
|
||
pub fn deployment_target(target: &Target) -> Option<(u32, u32)> { | ||
let (major, minor) = match &*target.os { | ||
"macos" => { | ||
// This does not need to be specific. It just needs to handle x86 vs M1. | ||
let arch = if target.arch == "x86" || target.arch == "x86_64" { X86_64 } else { Arm64 }; | ||
macos_deployment_target(arch) | ||
} | ||
"ios" => ios_deployment_target(), | ||
"ios" => match &*target.abi { | ||
"macabi" => mac_catalyst_deployment_target(), | ||
_ => ios_deployment_target(), | ||
}, | ||
"watchos" => watchos_deployment_target(), | ||
"tvos" => tvos_deployment_target(), | ||
_ => return None, | ||
}; | ||
|
||
Some(format!("{major}.{minor}")) | ||
Some((major, minor)) | ||
} | ||
|
||
fn from_set_deployment_target(var_name: &str) -> Option<(u32, u32)> { | ||
|
@@ -274,6 +306,11 @@ fn ios_deployment_target() -> (u32, u32) { | |
from_set_deployment_target("IPHONEOS_DEPLOYMENT_TARGET").unwrap_or((7, 0)) | ||
} | ||
|
||
fn mac_catalyst_deployment_target() -> (u32, u32) { | ||
// If you are looking for the default deployment target, prefer `rustc --print deployment-target`. | ||
from_set_deployment_target("IPHONEOS_DEPLOYMENT_TARGET").unwrap_or((14, 0)) | ||
|
||
} | ||
|
||
pub fn ios_llvm_target(arch: Arch) -> String { | ||
// Modern iOS tooling extracts information about deployment target | ||
// from LC_BUILD_VERSION. This load command will only be emitted when | ||
|
Uh oh!
There was an error while loading. Please reload this page.