refactor: Move Apple OSVersion (back) to rustc_target

Also convert OSVersion into a proper struct for better type-safety.
This commit is contained in:
Mads Marquart
2025-02-11 10:43:25 +01:00
parent a4166dabaa
commit d74ce25b65
11 changed files with 125 additions and 100 deletions

View File

@@ -3115,8 +3115,7 @@ fn add_apple_link_args(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavo
_ => bug!("invalid OS/ABI combination for Apple target: {target_os}, {target_abi}"),
};
let (major, minor, patch) = apple::deployment_target(sess);
let min_version = format!("{major}.{minor}.{patch}");
let min_version = apple::deployment_target(sess).fmt_full().to_string();
// The SDK version is used at runtime when compiling with a newer SDK / version of Xcode:
// - By dyld to give extra warnings and errors, see e.g.:
@@ -3185,10 +3184,10 @@ fn add_apple_link_args(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavo
// The presence of `-mmacosx-version-min` makes CC default to
// macOS, and it sets the deployment target.
let (major, minor, patch) = apple::deployment_target(sess);
let version = apple::deployment_target(sess).fmt_full();
// Intentionally pass this as a single argument, Clang doesn't
// seem to like it otherwise.
cmd.cc_arg(&format!("-mmacosx-version-min={major}.{minor}.{patch}"));
cmd.cc_arg(&format!("-mmacosx-version-min={version}"));
// macOS has no environment, so with these two, we've told CC the
// four desired parameters.