Skip to content

Commit

Permalink
Set the StackProbeType in apple::opts
Browse files Browse the repository at this point in the history
  • Loading branch information
cuviper committed Dec 13, 2023
1 parent b99b5e5 commit 233de9d
Show file tree
Hide file tree
Showing 17 changed files with 32 additions and 56 deletions.
13 changes: 11 additions & 2 deletions compiler/rustc_target/src/spec/base/apple/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::{borrow::Cow, env};

use crate::spec::{add_link_args, add_link_args_iter};
use crate::spec::{cvs, Cc, DebuginfoKind, FramePointer, LinkArgs};
use crate::spec::{LinkerFlavor, Lld, SplitDebuginfo, StaticCow, Target, TargetOptions};
use crate::spec::{cvs, Cc, DebuginfoKind, FramePointer, LinkArgs, LinkerFlavor, Lld};
use crate::spec::{SplitDebuginfo, StackProbeType, StaticCow, Target, TargetOptions};

#[cfg(test)]
mod tests;
Expand Down Expand Up @@ -81,6 +81,14 @@ impl Arch {
Arm64_sim => "apple-a12",
}
}

fn stack_probes(self) -> StackProbeType {
match self {
Armv7k | Armv7s => StackProbeType::None,
Arm64 | Arm64e | Arm64_32 | I386 | I686 | X86_64 | X86_64h | X86_64_sim
| X86_64_macabi | Arm64_macabi | Arm64_sim => StackProbeType::Inline,
}
}
}

fn pre_link_args(os: &'static str, arch: Arch, abi: &'static str) -> LinkArgs {
Expand Down Expand Up @@ -147,6 +155,7 @@ pub fn opts(os: &'static str, arch: Arch) -> TargetOptions {
abi_return_struct_as_int: true,
emit_debug_gdb_scripts: false,
eh_frame_header: false,
stack_probes: arch.stack_probes(),

debuginfo_kind: DebuginfoKind::DwarfDsym,
// The historical default for macOS targets is to run `dsymutil` which
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
use crate::spec::base::apple::{macos_llvm_target, opts, Arch};
use crate::spec::{FramePointer, SanitizerSet, StackProbeType, Target, TargetOptions};
use crate::spec::{FramePointer, SanitizerSet, Target, TargetOptions};

pub fn target() -> Target {
let arch = Arch::Arm64;
let mut base = opts("macos", arch);
base.cpu = "apple-m1".into();
base.max_atomic_width = Some(128);
base.stack_probes = StackProbeType::Inline;

// FIXME: The leak sanitizer currently fails the tests, see #88132.
base.supported_sanitizers = SanitizerSet::ADDRESS | SanitizerSet::CFI | SanitizerSet::THREAD;
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_target/src/spec/targets/aarch64_apple_ios.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::spec::base::apple::{ios_llvm_target, opts, Arch};
use crate::spec::{FramePointer, SanitizerSet, StackProbeType, Target, TargetOptions};
use crate::spec::{FramePointer, SanitizerSet, Target, TargetOptions};

pub fn target() -> Target {
let arch = Arch::Arm64;
Expand All @@ -18,7 +18,6 @@ pub fn target() -> Target {
options: TargetOptions {
features: "+neon,+fp-armv8,+apple-a7".into(),
max_atomic_width: Some(128),
stack_probes: StackProbeType::Inline,
frame_pointer: FramePointer::NonLeaf,
..base
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use crate::spec::base::apple::{opts, Arch};
use crate::spec::{
Cc, FramePointer, LinkerFlavor, Lld, SanitizerSet, StackProbeType, Target, TargetOptions,
};
use crate::spec::{Cc, FramePointer, LinkerFlavor, Lld, SanitizerSet, Target, TargetOptions};

pub fn target() -> Target {
let llvm_target = "arm64-apple-ios14.0-macabi";
Expand All @@ -19,7 +17,6 @@ pub fn target() -> Target {
options: TargetOptions {
features: "+neon,+fp-armv8,+apple-a12".into(),
max_atomic_width: Some(128),
stack_probes: StackProbeType::Inline,
frame_pointer: FramePointer::NonLeaf,
..base
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::spec::base::apple::{ios_sim_llvm_target, opts, Arch};
use crate::spec::{FramePointer, SanitizerSet, StackProbeType, Target, TargetOptions};
use crate::spec::{FramePointer, SanitizerSet, Target, TargetOptions};

pub fn target() -> Target {
let arch = Arch::Arm64_sim;
Expand All @@ -18,7 +18,6 @@ pub fn target() -> Target {
options: TargetOptions {
features: "+neon,+fp-armv8,+apple-a7".into(),
max_atomic_width: Some(128),
stack_probes: StackProbeType::Inline,
frame_pointer: FramePointer::NonLeaf,
..base
},
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_target/src/spec/targets/aarch64_apple_tvos.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::spec::base::apple::{opts, tvos_llvm_target, Arch};
use crate::spec::{FramePointer, StackProbeType, Target, TargetOptions};
use crate::spec::{FramePointer, Target, TargetOptions};

pub fn target() -> Target {
let arch = Arch::Arm64;
Expand All @@ -11,7 +11,6 @@ pub fn target() -> Target {
options: TargetOptions {
features: "+neon,+fp-armv8,+apple-a7".into(),
max_atomic_width: Some(128),
stack_probes: StackProbeType::Inline,
frame_pointer: FramePointer::NonLeaf,
..opts("tvos", arch)
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::spec::base::apple::{opts, tvos_sim_llvm_target, Arch};
use crate::spec::{FramePointer, StackProbeType, Target, TargetOptions};
use crate::spec::{FramePointer, Target, TargetOptions};

pub fn target() -> Target {
let arch = Arch::Arm64_sim;
Expand All @@ -11,7 +11,6 @@ pub fn target() -> Target {
options: TargetOptions {
features: "+neon,+fp-armv8,+apple-a7".into(),
max_atomic_width: Some(128),
stack_probes: StackProbeType::Inline,
frame_pointer: FramePointer::NonLeaf,
..opts("tvos", arch)
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::spec::base::apple::{opts, watchos_sim_llvm_target, Arch};
use crate::spec::{FramePointer, StackProbeType, Target, TargetOptions};
use crate::spec::{FramePointer, Target, TargetOptions};

pub fn target() -> Target {
let arch = Arch::Arm64_sim;
Expand All @@ -15,7 +15,6 @@ pub fn target() -> Target {
options: TargetOptions {
features: "+neon,+fp-armv8,+apple-a7".into(),
max_atomic_width: Some(128),
stack_probes: StackProbeType::Inline,
frame_pointer: FramePointer::NonLeaf,
..opts("watchos", arch)
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::spec::base::apple::{opts, Arch};
use crate::spec::{StackProbeType, Target, TargetOptions};
use crate::spec::{Target, TargetOptions};

pub fn target() -> Target {
let base = opts("watchos", Arch::Arm64_32);
Expand All @@ -11,7 +11,6 @@ pub fn target() -> Target {
options: TargetOptions {
features: "+v8a,+neon,+fp-armv8,+apple-a7".into(),
max_atomic_width: Some(128),
stack_probes: StackProbeType::Inline,
dynamic_linking: false,
position_independent_executables: true,
..base
Expand Down
8 changes: 2 additions & 6 deletions compiler/rustc_target/src/spec/targets/i386_apple_ios.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::spec::base::apple::{ios_sim_llvm_target, opts, Arch};
use crate::spec::{StackProbeType, Target, TargetOptions};
use crate::spec::{Target, TargetOptions};

pub fn target() -> Target {
let arch = Arch::I386;
Expand All @@ -14,10 +14,6 @@ pub fn target() -> Target {
f64:32:64-f80:128-n8:16:32-S128"
.into(),
arch: arch.target_arch(),
options: TargetOptions {
max_atomic_width: Some(64),
stack_probes: StackProbeType::Inline,
..opts("ios", arch)
},
options: TargetOptions { max_atomic_width: Some(64), ..opts("ios", arch) },
}
}
3 changes: 1 addition & 2 deletions compiler/rustc_target/src/spec/targets/i686_apple_darwin.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
use crate::spec::base::apple::{macos_llvm_target, opts, Arch};
use crate::spec::{Cc, FramePointer, LinkerFlavor, Lld, StackProbeType, Target, TargetOptions};
use crate::spec::{Cc, FramePointer, LinkerFlavor, Lld, Target, TargetOptions};

pub fn target() -> Target {
// ld64 only understands i386 and not i686
let arch = Arch::I386;
let mut base = opts("macos", arch);
base.max_atomic_width = Some(64);
base.add_pre_link_args(LinkerFlavor::Darwin(Cc::Yes, Lld::No), &["-m32"]);
base.stack_probes = StackProbeType::Inline;
base.frame_pointer = FramePointer::Always;

Target {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
use crate::spec::base::apple::{macos_llvm_target, opts, Arch};
use crate::spec::{Cc, FramePointer, LinkerFlavor, Lld, SanitizerSet};
use crate::spec::{StackProbeType, Target, TargetOptions};
use crate::spec::{Target, TargetOptions};

pub fn target() -> Target {
let arch = Arch::X86_64;
let mut base = opts("macos", arch);
base.max_atomic_width = Some(128); // penryn+ supports cmpxchg16b
base.frame_pointer = FramePointer::Always;
base.add_pre_link_args(LinkerFlavor::Darwin(Cc::Yes, Lld::No), &["-m64"]);
base.stack_probes = StackProbeType::Inline;
base.supported_sanitizers =
SanitizerSet::ADDRESS | SanitizerSet::CFI | SanitizerSet::LEAK | SanitizerSet::THREAD;

Expand Down
8 changes: 2 additions & 6 deletions compiler/rustc_target/src/spec/targets/x86_64_apple_ios.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::spec::base::apple::{ios_sim_llvm_target, opts, Arch};
use crate::spec::{SanitizerSet, StackProbeType, Target, TargetOptions};
use crate::spec::{SanitizerSet, Target, TargetOptions};

pub fn target() -> Target {
let arch = Arch::X86_64_sim;
Expand All @@ -12,10 +12,6 @@ pub fn target() -> Target {
data_layout: "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
.into(),
arch: arch.target_arch(),
options: TargetOptions {
max_atomic_width: Some(128),
stack_probes: StackProbeType::Inline,
..base
},
options: TargetOptions { max_atomic_width: Some(128), ..base },
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::spec::base::apple::{opts, Arch};
use crate::spec::{Cc, LinkerFlavor, Lld, SanitizerSet, StackProbeType, Target, TargetOptions};
use crate::spec::{Cc, LinkerFlavor, Lld, SanitizerSet, Target, TargetOptions};

pub fn target() -> Target {
let llvm_target = "x86_64-apple-ios14.0-macabi";
Expand All @@ -15,10 +15,6 @@ pub fn target() -> Target {
data_layout: "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
.into(),
arch: arch.target_arch(),
options: TargetOptions {
max_atomic_width: Some(128),
stack_probes: StackProbeType::Inline,
..base
},
options: TargetOptions { max_atomic_width: Some(128), ..base },
}
}
8 changes: 2 additions & 6 deletions compiler/rustc_target/src/spec/targets/x86_64_apple_tvos.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::spec::base::apple::{opts, tvos_sim_llvm_target, Arch};
use crate::spec::{StackProbeType, Target, TargetOptions};
use crate::spec::{Target, TargetOptions};

pub fn target() -> Target {
let arch = Arch::X86_64_sim;
Expand All @@ -9,10 +9,6 @@ pub fn target() -> Target {
data_layout: "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
.into(),
arch: arch.target_arch(),
options: TargetOptions {
max_atomic_width: Some(128),
stack_probes: StackProbeType::Inline,
..opts("tvos", arch)
},
options: TargetOptions { max_atomic_width: Some(128), ..opts("tvos", arch) },
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::spec::base::apple::{opts, watchos_sim_llvm_target, Arch};
use crate::spec::{StackProbeType, Target, TargetOptions};
use crate::spec::{Target, TargetOptions};

pub fn target() -> Target {
let arch = Arch::X86_64_sim;
Expand All @@ -9,10 +9,6 @@ pub fn target() -> Target {
data_layout: "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
.into(),
arch: arch.target_arch(),
options: TargetOptions {
max_atomic_width: Some(128),
stack_probes: StackProbeType::Inline,
..opts("watchos", arch)
},
options: TargetOptions { max_atomic_width: Some(128), ..opts("watchos", arch) },
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
use crate::spec::base::apple::{macos_llvm_target, opts, Arch};
use crate::spec::{Cc, FramePointer, LinkerFlavor, Lld, SanitizerSet};
use crate::spec::{StackProbeType, Target, TargetOptions};
use crate::spec::{Target, TargetOptions};

pub fn target() -> Target {
let arch = Arch::X86_64h;
let mut base = opts("macos", arch);
base.max_atomic_width = Some(128);
base.frame_pointer = FramePointer::Always;
base.add_pre_link_args(LinkerFlavor::Darwin(Cc::Yes, Lld::No), &["-m64"]);
base.stack_probes = StackProbeType::Inline;
base.supported_sanitizers =
SanitizerSet::ADDRESS | SanitizerSet::CFI | SanitizerSet::LEAK | SanitizerSet::THREAD;

Expand Down

0 comments on commit 233de9d

Please sign in to comment.