]> git.proxmox.com Git - rustc.git/blob - compiler/rustc_target/src/spec/apple_sdk_base.rs
New upstream version 1.61.0+dfsg1
[rustc.git] / compiler / rustc_target / src / spec / apple_sdk_base.rs
1 use crate::{spec::cvs, spec::TargetOptions};
2 use std::borrow::Cow;
3
4 use Arch::*;
5 #[allow(non_camel_case_types)]
6 #[derive(Copy, Clone)]
7 pub enum Arch {
8 Armv7,
9 Armv7s,
10 Arm64,
11 I386,
12 X86_64,
13 X86_64_macabi,
14 Arm64_macabi,
15 Arm64_sim,
16 }
17
18 fn target_abi(arch: Arch) -> &'static str {
19 match arch {
20 Armv7 | Armv7s | Arm64 | I386 | X86_64 => "",
21 X86_64_macabi | Arm64_macabi => "macabi",
22 Arm64_sim => "sim",
23 }
24 }
25
26 fn target_cpu(arch: Arch) -> &'static str {
27 match arch {
28 Armv7 => "cortex-a8", // iOS7 is supported on iPhone 4 and higher
29 Armv7s => "cortex-a9",
30 Arm64 => "apple-a7",
31 I386 => "yonah",
32 X86_64 => "core2",
33 X86_64_macabi => "core2",
34 Arm64_macabi => "apple-a12",
35 Arm64_sim => "apple-a12",
36 }
37 }
38
39 fn link_env_remove(arch: Arch) -> Cow<'static, [Cow<'static, str>]> {
40 match arch {
41 Armv7 | Armv7s | Arm64 | I386 | X86_64 | Arm64_sim => {
42 cvs!["MACOSX_DEPLOYMENT_TARGET"]
43 }
44 X86_64_macabi | Arm64_macabi => cvs!["IPHONEOS_DEPLOYMENT_TARGET"],
45 }
46 }
47
48 pub fn opts(os: &'static str, arch: Arch) -> TargetOptions {
49 TargetOptions {
50 abi: target_abi(arch).into(),
51 cpu: target_cpu(arch).into(),
52 dynamic_linking: false,
53 executables: true,
54 link_env_remove: link_env_remove(arch),
55 has_thread_local: false,
56 ..super::apple_base::opts(os)
57 }
58 }