rustc_target/spec/targets/x86_64h_apple_darwin.rs
1use crate::spec::base::apple::{Arch, TargetAbi, base};
2use crate::spec::{SanitizerSet, Target, TargetMetadata, TargetOptions};
3
4pub(crate) fn target() -> Target {
5 let (mut opts, llvm_target, arch) = base("macos", Arch::X86_64h, TargetAbi::Normal);
6 opts.max_atomic_width = Some(128);
7 opts.supported_sanitizers =
8 SanitizerSet::ADDRESS | SanitizerSet::CFI | SanitizerSet::LEAK | SanitizerSet::THREAD;
9
10 // x86_64h is core2-avx without a few of the features which would otherwise
11 // be guaranteed, so we need to disable those. This imitates clang's logic:
12 // - https://github.com/llvm/llvm-project/blob/bd1f7c417/clang/lib/Driver/ToolChains/Arch/X86.cpp#L77-L78
13 // - https://github.com/llvm/llvm-project/blob/bd1f7c417/clang/lib/Driver/ToolChains/Arch/X86.cpp#L133-L141
14 //
15 // FIXME: Sadly, turning these off here disables them in such a way that they
16 // aren't re-enabled by `-Ctarget-cpu=native` (on a machine that has them).
17 // It would be nice if this were not the case, but fixing it seems tricky
18 // (and given that the main use-case for this target is for use in universal
19 // binaries, probably not that important).
20 opts.features = "-rdrnd,-aes,-pclmul,-rtm,-fsgsbase".into();
21 // Double-check that the `cpu` is what we expect (if it's not the list above
22 // may need updating).
23 assert_eq!(
24 opts.cpu, "core-avx2",
25 "you need to adjust the feature list in x86_64h-apple-darwin if you change this",
26 );
27
28 Target {
29 llvm_target,
30 metadata: TargetMetadata {
31 description: Some("x86_64 Apple macOS with Intel Haswell+".into()),
32 tier: Some(3),
33 host_tools: Some(true),
34 std: Some(true),
35 },
36 pointer_width: 64,
37 data_layout:
38 "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(),
39 arch,
40 options: TargetOptions { mcount: "\u{1}mcount".into(), ..opts },
41 }
42}