Skip to content

Commit

Permalink
Auto merge of rust-lang#115644 - danakj:catalyst-asan, r=cjgillot,thomcc
Browse files Browse the repository at this point in the history
Enable ASAN/LSAN/TSAN for *-apple-ios-macabi

The -macabi targets are iOS running on MacOS, and they use the runtime libraries for MacOS, thus they have the same sanitizers available as the *-apple-darwin targets.

This is based on the work of rust-lang@aacf321.

Closes rust-lang#113935.
  • Loading branch information
bors committed Sep 17, 2023
2 parents db9c21f + 1365771 commit 02bd00b
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 2 deletions.
3 changes: 2 additions & 1 deletion compiler/rustc_target/src/spec/aarch64_apple_ios_macabi.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
use super::apple_base::{opts, Arch};
use crate::spec::{Cc, FramePointer, LinkerFlavor, Lld, Target, TargetOptions};
use crate::spec::{Cc, FramePointer, LinkerFlavor, Lld, SanitizerSet, Target, TargetOptions};

pub fn target() -> Target {
let llvm_target = "arm64-apple-ios14.0-macabi";

let arch = Arch::Arm64_macabi;
let mut base = opts("ios", arch);
base.add_pre_link_args(LinkerFlavor::Darwin(Cc::Yes, Lld::No), &["-target", llvm_target]);
base.supported_sanitizers = SanitizerSet::ADDRESS | SanitizerSet::LEAK | SanitizerSet::THREAD;

Target {
llvm_target: llvm_target.into(),
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_target/src/spec/x86_64_apple_ios_macabi.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
use super::apple_base::{opts, Arch};
use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetOptions};
use crate::spec::{Cc, LinkerFlavor, Lld, SanitizerSet, StackProbeType, Target, TargetOptions};

pub fn target() -> Target {
let llvm_target = "x86_64-apple-ios14.0-macabi";

let arch = Arch::X86_64_macabi;
let mut base = opts("ios", arch);
base.add_pre_link_args(LinkerFlavor::Darwin(Cc::Yes, Lld::No), &["-target", llvm_target]);
base.supported_sanitizers = SanitizerSet::ADDRESS | SanitizerSet::LEAK | SanitizerSet::THREAD;

Target {
llvm_target: llvm_target.into(),
Expand Down
3 changes: 3 additions & 0 deletions src/bootstrap/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,9 @@ fn copy_sanitizers(
let dst = libdir.join(&runtime.name);
builder.copy(&runtime.path, &dst);

// The `aarch64-apple-ios-macabi` and `x86_64-apple-ios-macabi` are also supported for
// sanitizers, but they share a sanitizer runtime with `${arch}-apple-darwin`, so we do
// not list them here to rename and sign the runtime library.
if target == "x86_64-apple-darwin"
|| target == "aarch64-apple-darwin"
|| target == "aarch64-apple-ios"
Expand Down
2 changes: 2 additions & 0 deletions src/bootstrap/llvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1063,6 +1063,7 @@ fn supported_sanitizers(
"aarch64-apple-darwin" => darwin_libs("osx", &["asan", "lsan", "tsan"]),
"aarch64-apple-ios" => darwin_libs("ios", &["asan", "tsan"]),
"aarch64-apple-ios-sim" => darwin_libs("iossim", &["asan", "tsan"]),
"aarch64-apple-ios-macabi" => darwin_libs("osx", &["asan", "lsan", "tsan"]),
"aarch64-unknown-fuchsia" => common_libs("fuchsia", "aarch64", &["asan"]),
"aarch64-unknown-linux-gnu" => {
common_libs("linux", "aarch64", &["asan", "lsan", "msan", "tsan", "hwasan"])
Expand All @@ -1073,6 +1074,7 @@ fn supported_sanitizers(
"x86_64-apple-darwin" => darwin_libs("osx", &["asan", "lsan", "tsan"]),
"x86_64-unknown-fuchsia" => common_libs("fuchsia", "x86_64", &["asan"]),
"x86_64-apple-ios" => darwin_libs("iossim", &["asan", "tsan"]),
"x86_64-apple-ios-macabi" => darwin_libs("osx", &["asan", "lsan", "tsan"]),
"x86_64-unknown-freebsd" => common_libs("freebsd", "x86_64", &["asan", "msan", "tsan"]),
"x86_64-unknown-netbsd" => {
common_libs("netbsd", "x86_64", &["asan", "lsan", "msan", "tsan"])
Expand Down
5 changes: 5 additions & 0 deletions src/tools/compiletest/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pub const ASAN_SUPPORTED_TARGETS: &[&str] = &[
"aarch64-apple-darwin",
"aarch64-apple-ios",
"aarch64-apple-ios-sim",
"aarch64-apple-ios-macabi",
"aarch64-unknown-fuchsia",
"aarch64-linux-android",
"aarch64-unknown-linux-gnu",
Expand All @@ -22,6 +23,7 @@ pub const ASAN_SUPPORTED_TARGETS: &[&str] = &[
"i686-unknown-linux-gnu",
"x86_64-apple-darwin",
"x86_64-apple-ios",
"x86_64-apple-ios-macabi",
"x86_64-unknown-fuchsia",
"x86_64-linux-android",
"x86_64-unknown-freebsd",
Expand Down Expand Up @@ -60,6 +62,7 @@ pub const LSAN_SUPPORTED_TARGETS: &[&str] = &[
// "aarch64-apple-darwin",
"aarch64-unknown-linux-gnu",
"x86_64-apple-darwin",
"x86_64-apple-ios-macabi",
"x86_64-unknown-linux-gnu",
"s390x-unknown-linux-gnu",
];
Expand All @@ -75,9 +78,11 @@ pub const TSAN_SUPPORTED_TARGETS: &[&str] = &[
"aarch64-apple-darwin",
"aarch64-apple-ios",
"aarch64-apple-ios-sim",
"aarch64-apple-ios-macabi",
"aarch64-unknown-linux-gnu",
"x86_64-apple-darwin",
"x86_64-apple-ios",
"x86_64-apple-ios-macabi",
"x86_64-unknown-freebsd",
"x86_64-unknown-linux-gnu",
"s390x-unknown-linux-gnu",
Expand Down

0 comments on commit 02bd00b

Please sign in to comment.