-
Notifications
You must be signed in to change notification settings - Fork 13.4k
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)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where did 14.0 come from here? Was it just because that's the current assumed target in the other spec files? IMO (not the reviewer here) its fine to do this but in some followup the hardcoded versions in the current catalyst target specs should get nuked. This would match what users would expect now that were reading this variable. Definitely doesn't need to be done here though I think. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I pulled it from the original implementation of this behavior that only applied to catalyst https://github.com/rust-lang/rust/pull/114114/files#diff-6bbf6edd930f26d3b180eb5c250b0e48d8f3c5eb474e3274909ef6ae6f0d1e61L343 I agree having it configurable makes sense, at least in this case if you set There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I missed the lines removed in the diff, oops. That answers the immediate question then.
Do you want to take that to a followup PR or shall I? Fixing the mess that's Catalyst has been on my list forever. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can send that one after! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah it looks like using the triple for this case 78bbe57#diff-f2aa7189f140501f7d0d283ef503e1980a9449ef0292b48b650f6e0c87bb8d6b complicates things slightly There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. iiuc it should just be making another of the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok sounds good I can try it after this one There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems like to make this work I would need to change |
||
} | ||
|
||
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.