refactor: Move Apple SDK names to rustc_codegen_ssa:🔙:apple
This commit is contained in:
parent
7d49ae9731
commit
713becd7da
4 changed files with 21 additions and 36 deletions
|
@ -391,8 +391,6 @@ codegen_ssa_unknown_atomic_ordering = unknown ordering in atomic intrinsic
|
||||||
|
|
||||||
codegen_ssa_unknown_reuse_kind = unknown cgu-reuse-kind `{$kind}` specified
|
codegen_ssa_unknown_reuse_kind = unknown cgu-reuse-kind `{$kind}` specified
|
||||||
|
|
||||||
codegen_ssa_unsupported_arch = unsupported arch `{$arch}` for os `{$os}`
|
|
||||||
|
|
||||||
codegen_ssa_unsupported_instruction_set = target does not support `#[instruction_set]`
|
codegen_ssa_unsupported_instruction_set = target does not support `#[instruction_set]`
|
||||||
|
|
||||||
codegen_ssa_unsupported_link_self_contained = option `-C link-self-contained` is not supported on this target
|
codegen_ssa_unsupported_link_self_contained = option `-C link-self-contained` is not supported on this target
|
||||||
|
|
|
@ -11,6 +11,24 @@ use crate::errors::AppleDeploymentTarget;
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests;
|
mod tests;
|
||||||
|
|
||||||
|
/// The canonical name of the desired SDK for a given target.
|
||||||
|
pub(super) fn sdk_name(target: &Target) -> &'static str {
|
||||||
|
match (&*target.os, &*target.abi) {
|
||||||
|
("macos", "") => "MacOSX",
|
||||||
|
("ios", "") => "iPhoneOS",
|
||||||
|
("ios", "sim") => "iPhoneSimulator",
|
||||||
|
// Mac Catalyst uses the macOS SDK
|
||||||
|
("ios", "macabi") => "MacOSX",
|
||||||
|
("tvos", "") => "AppleTVOS",
|
||||||
|
("tvos", "sim") => "AppleTVSimulator",
|
||||||
|
("visionos", "") => "XROS",
|
||||||
|
("visionos", "sim") => "XRSimulator",
|
||||||
|
("watchos", "") => "WatchOS",
|
||||||
|
("watchos", "sim") => "WatchSimulator",
|
||||||
|
(os, abi) => unreachable!("invalid os '{os}' / abi '{abi}' combination for Apple target"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub(super) fn macho_platform(target: &Target) -> u32 {
|
pub(super) fn macho_platform(target: &Target) -> u32 {
|
||||||
match (&*target.os, &*target.abi) {
|
match (&*target.os, &*target.abi) {
|
||||||
("macos", _) => object::macho::PLATFORM_MACOS,
|
("macos", _) => object::macho::PLATFORM_MACOS,
|
||||||
|
|
|
@ -3201,9 +3201,7 @@ fn add_apple_link_args(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavo
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_apple_sdk(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) -> Option<PathBuf> {
|
fn add_apple_sdk(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) -> Option<PathBuf> {
|
||||||
let arch = &sess.target.arch;
|
|
||||||
let os = &sess.target.os;
|
let os = &sess.target.os;
|
||||||
let llvm_target = &sess.target.llvm_target;
|
|
||||||
if sess.target.vendor != "apple"
|
if sess.target.vendor != "apple"
|
||||||
|| !matches!(os.as_ref(), "ios" | "tvos" | "watchos" | "visionos" | "macos")
|
|| !matches!(os.as_ref(), "ios" | "tvos" | "watchos" | "visionos" | "macos")
|
||||||
|| !matches!(flavor, LinkerFlavor::Darwin(..))
|
|| !matches!(flavor, LinkerFlavor::Darwin(..))
|
||||||
|
@ -3215,31 +3213,9 @@ fn add_apple_sdk(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) ->
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
let sdk_name = match (arch.as_ref(), os.as_ref()) {
|
let sdk_name = apple::sdk_name(&sess.target).to_lowercase();
|
||||||
("aarch64", "tvos") if llvm_target.ends_with("-simulator") => "appletvsimulator",
|
|
||||||
("aarch64", "tvos") => "appletvos",
|
let sdk_root = match get_apple_sdk_root(&sdk_name) {
|
||||||
("x86_64", "tvos") => "appletvsimulator",
|
|
||||||
("arm", "ios") => "iphoneos",
|
|
||||||
("aarch64", "ios") if llvm_target.contains("macabi") => "macosx",
|
|
||||||
("aarch64", "ios") if llvm_target.ends_with("-simulator") => "iphonesimulator",
|
|
||||||
("aarch64", "ios") => "iphoneos",
|
|
||||||
("x86", "ios") => "iphonesimulator",
|
|
||||||
("x86_64", "ios") if llvm_target.contains("macabi") => "macosx",
|
|
||||||
("x86_64", "ios") => "iphonesimulator",
|
|
||||||
("x86_64", "watchos") => "watchsimulator",
|
|
||||||
("arm64_32", "watchos") => "watchos",
|
|
||||||
("aarch64", "watchos") if llvm_target.ends_with("-simulator") => "watchsimulator",
|
|
||||||
("aarch64", "watchos") => "watchos",
|
|
||||||
("aarch64", "visionos") if llvm_target.ends_with("-simulator") => "xrsimulator",
|
|
||||||
("aarch64", "visionos") => "xros",
|
|
||||||
("arm", "watchos") => "watchos",
|
|
||||||
(_, "macos") => "macosx",
|
|
||||||
_ => {
|
|
||||||
sess.dcx().emit_err(errors::UnsupportedArch { arch, os });
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
let sdk_root = match get_apple_sdk_root(sdk_name) {
|
|
||||||
Ok(s) => s,
|
Ok(s) => s,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
sess.dcx().emit_err(e);
|
sess.dcx().emit_err(e);
|
||||||
|
|
|
@ -738,13 +738,6 @@ pub enum ExtractBundledLibsError<'a> {
|
||||||
ExtractSection { rlib: &'a Path, error: Box<dyn std::error::Error> },
|
ExtractSection { rlib: &'a Path, error: Box<dyn std::error::Error> },
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
|
||||||
#[diag(codegen_ssa_unsupported_arch)]
|
|
||||||
pub(crate) struct UnsupportedArch<'a> {
|
|
||||||
pub arch: &'a str,
|
|
||||||
pub os: &'a str,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
pub(crate) enum AppleDeploymentTarget {
|
pub(crate) enum AppleDeploymentTarget {
|
||||||
#[diag(codegen_ssa_apple_deployment_target_invalid)]
|
#[diag(codegen_ssa_apple_deployment_target_invalid)]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue