]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_target/src/spec/apple_sdk_base.rs
Merge commit '98e2b9f25b6db4b2680a3d388456d9f95cb28344' into clippyup
[rust.git] / compiler / rustc_target / src / spec / apple_sdk_base.rs
1 use crate::spec::TargetOptions;
2
3 use Arch::*;
4 #[allow(non_camel_case_types)]
5 #[derive(Copy, Clone)]
6 pub enum Arch {
7     Armv7,
8     Armv7s,
9     Arm64,
10     I386,
11     X86_64,
12     X86_64_macabi,
13     Arm64_macabi,
14     Arm64_sim,
15 }
16
17 fn target_cpu(arch: Arch) -> String {
18     match arch {
19         Armv7 => "cortex-a8", // iOS7 is supported on iPhone 4 and higher
20         Armv7s => "cortex-a9",
21         Arm64 => "apple-a7",
22         I386 => "yonah",
23         X86_64 => "core2",
24         X86_64_macabi => "core2",
25         Arm64_macabi => "apple-a12",
26         Arm64_sim => "apple-a12",
27     }
28     .to_string()
29 }
30
31 fn link_env_remove(arch: Arch) -> Vec<String> {
32     match arch {
33         Armv7 | Armv7s | Arm64 | I386 | X86_64 | Arm64_sim => {
34             vec!["MACOSX_DEPLOYMENT_TARGET".to_string()]
35         }
36         X86_64_macabi | Arm64_macabi => vec!["IPHONEOS_DEPLOYMENT_TARGET".to_string()],
37     }
38 }
39
40 pub fn opts(os: &str, arch: Arch) -> TargetOptions {
41     TargetOptions {
42         cpu: target_cpu(arch),
43         dynamic_linking: false,
44         executables: true,
45         link_env_remove: link_env_remove(arch),
46         has_elf_tls: false,
47         eliminate_frame_pointer: false,
48         ..super::apple_base::opts(os)
49     }
50 }