mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
Auto merge of #106476 - keith:ks/add-sanitizer-support-for-modern-ios-platforms, r=badboy
Add sanitizer support for modern iOS platforms asan and tsan generally support iOS, but that previously wasn't configured in rust. This only adds support for the simulator architectures, and arm64 device architecture, not the older 32 bit architectures.
This commit is contained in:
commit
6d819a4b8f
@ -1,8 +1,11 @@
|
||||
use super::apple_base::{ios_llvm_target, opts, Arch};
|
||||
use crate::spec::{FramePointer, Target, TargetOptions};
|
||||
use crate::spec::{FramePointer, SanitizerSet, Target, TargetOptions};
|
||||
|
||||
pub fn target() -> Target {
|
||||
let arch = Arch::Arm64;
|
||||
let mut base = opts("ios", arch);
|
||||
base.supported_sanitizers = SanitizerSet::ADDRESS | SanitizerSet::THREAD;
|
||||
|
||||
Target {
|
||||
// Clang automatically chooses a more specific target based on
|
||||
// IPHONEOS_DEPLOYMENT_TARGET.
|
||||
@ -28,7 +31,7 @@ pub fn target() -> Target {
|
||||
darwinpcs\0\
|
||||
-Os\0"
|
||||
.into(),
|
||||
..opts("ios", arch)
|
||||
..base
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,11 @@
|
||||
use super::apple_base::{ios_sim_llvm_target, opts, Arch};
|
||||
use crate::spec::{FramePointer, Target, TargetOptions};
|
||||
use crate::spec::{FramePointer, SanitizerSet, Target, TargetOptions};
|
||||
|
||||
pub fn target() -> Target {
|
||||
let arch = Arch::Arm64_sim;
|
||||
let mut base = opts("ios", arch);
|
||||
base.supported_sanitizers = SanitizerSet::ADDRESS | SanitizerSet::THREAD;
|
||||
|
||||
Target {
|
||||
// Clang automatically chooses a more specific target based on
|
||||
// IPHONEOS_DEPLOYMENT_TARGET.
|
||||
@ -28,7 +31,7 @@ pub fn target() -> Target {
|
||||
darwinpcs\0\
|
||||
-Os\0"
|
||||
.into(),
|
||||
..opts("ios", arch)
|
||||
..base
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,11 @@
|
||||
use super::apple_base::{ios_sim_llvm_target, opts, Arch};
|
||||
use crate::spec::{StackProbeType, Target, TargetOptions};
|
||||
use crate::spec::{SanitizerSet, StackProbeType, Target, TargetOptions};
|
||||
|
||||
pub fn target() -> Target {
|
||||
let arch = Arch::X86_64_sim;
|
||||
let mut base = opts("ios", arch);
|
||||
base.supported_sanitizers = SanitizerSet::ADDRESS | SanitizerSet::THREAD;
|
||||
|
||||
Target {
|
||||
llvm_target: ios_sim_llvm_target(arch).into(),
|
||||
pointer_width: 64,
|
||||
@ -12,7 +15,7 @@ pub fn target() -> Target {
|
||||
options: TargetOptions {
|
||||
max_atomic_width: Some(64),
|
||||
stack_probes: StackProbeType::X86,
|
||||
..opts("ios", arch)
|
||||
..base
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -533,7 +533,12 @@ fn copy_sanitizers(
|
||||
let dst = libdir.join(&runtime.name);
|
||||
builder.copy(&runtime.path, &dst);
|
||||
|
||||
if target == "x86_64-apple-darwin" || target == "aarch64-apple-darwin" {
|
||||
if target == "x86_64-apple-darwin"
|
||||
|| target == "aarch64-apple-darwin"
|
||||
|| target == "aarch64-apple-ios"
|
||||
|| target == "aarch64-apple-ios-sim"
|
||||
|| target == "x86_64-apple-ios"
|
||||
{
|
||||
// Update the library’s install name to reflect that it has been renamed.
|
||||
apple_darwin_update_library_name(&dst, &format!("@rpath/{}", &runtime.name));
|
||||
// Upon renaming the install name, the code signature of the file will invalidate,
|
||||
|
@ -483,7 +483,7 @@ impl Step for Llvm {
|
||||
cfg.define("LLVM_VERSION_SUFFIX", suffix);
|
||||
}
|
||||
|
||||
configure_cmake(builder, target, &mut cfg, true, ldflags);
|
||||
configure_cmake(builder, target, &mut cfg, true, ldflags, &[]);
|
||||
configure_llvm(builder, target, &mut cfg);
|
||||
|
||||
for (key, val) in &builder.config.llvm_build_config {
|
||||
@ -574,6 +574,7 @@ fn configure_cmake(
|
||||
cfg: &mut cmake::Config,
|
||||
use_compiler_launcher: bool,
|
||||
mut ldflags: LdFlags,
|
||||
extra_compiler_flags: &[&str],
|
||||
) {
|
||||
// Do not print installation messages for up-to-date files.
|
||||
// LLVM and LLD builds can produce a lot of those and hit CI limits on log size.
|
||||
@ -714,6 +715,9 @@ fn configure_cmake(
|
||||
if builder.config.llvm_clang_cl.is_some() {
|
||||
cflags.push(&format!(" --target={}", target));
|
||||
}
|
||||
for flag in extra_compiler_flags {
|
||||
cflags.push(&format!(" {}", flag));
|
||||
}
|
||||
cfg.define("CMAKE_C_FLAGS", cflags);
|
||||
let mut cxxflags: OsString = builder.cflags(target, GitRepo::Llvm, CLang::Cxx).join(" ").into();
|
||||
if let Some(ref s) = builder.config.llvm_cxxflags {
|
||||
@ -723,6 +727,9 @@ fn configure_cmake(
|
||||
if builder.config.llvm_clang_cl.is_some() {
|
||||
cxxflags.push(&format!(" --target={}", target));
|
||||
}
|
||||
for flag in extra_compiler_flags {
|
||||
cxxflags.push(&format!(" {}", flag));
|
||||
}
|
||||
cfg.define("CMAKE_CXX_FLAGS", cxxflags);
|
||||
if let Some(ar) = builder.ar(target) {
|
||||
if ar.is_absolute() {
|
||||
@ -864,7 +871,7 @@ impl Step for Lld {
|
||||
}
|
||||
}
|
||||
|
||||
configure_cmake(builder, target, &mut cfg, true, ldflags);
|
||||
configure_cmake(builder, target, &mut cfg, true, ldflags, &[]);
|
||||
configure_llvm(builder, target, &mut cfg);
|
||||
|
||||
// Re-use the same flags as llvm to control the level of debug information
|
||||
@ -1028,7 +1035,16 @@ impl Step for Sanitizers {
|
||||
// Unfortunately sccache currently lacks support to build them successfully.
|
||||
// Disable compiler launcher on Darwin targets to avoid potential issues.
|
||||
let use_compiler_launcher = !self.target.contains("apple-darwin");
|
||||
configure_cmake(builder, self.target, &mut cfg, use_compiler_launcher, LdFlags::default());
|
||||
let extra_compiler_flags: &[&str] =
|
||||
if self.target.contains("apple") { &["-fembed-bitcode=off"] } else { &[] };
|
||||
configure_cmake(
|
||||
builder,
|
||||
self.target,
|
||||
&mut cfg,
|
||||
use_compiler_launcher,
|
||||
LdFlags::default(),
|
||||
extra_compiler_flags,
|
||||
);
|
||||
|
||||
t!(fs::create_dir_all(&out_dir));
|
||||
cfg.out_dir(out_dir);
|
||||
@ -1084,12 +1100,15 @@ fn supported_sanitizers(
|
||||
|
||||
match &*target.triple {
|
||||
"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-unknown-fuchsia" => common_libs("fuchsia", "aarch64", &["asan"]),
|
||||
"aarch64-unknown-linux-gnu" => {
|
||||
common_libs("linux", "aarch64", &["asan", "lsan", "msan", "tsan", "hwasan"])
|
||||
}
|
||||
"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-unknown-freebsd" => common_libs("freebsd", "x86_64", &["asan", "msan", "tsan"]),
|
||||
"x86_64-unknown-netbsd" => {
|
||||
common_libs("netbsd", "x86_64", &["asan", "lsan", "msan", "tsan"])
|
||||
|
@ -11,6 +11,8 @@ mod tests;
|
||||
|
||||
pub const ASAN_SUPPORTED_TARGETS: &[&str] = &[
|
||||
"aarch64-apple-darwin",
|
||||
"aarch64-apple-ios",
|
||||
"aarch64-apple-ios-sim",
|
||||
"aarch64-unknown-fuchsia",
|
||||
"aarch64-linux-android",
|
||||
"aarch64-unknown-linux-gnu",
|
||||
@ -19,6 +21,7 @@ pub const ASAN_SUPPORTED_TARGETS: &[&str] = &[
|
||||
"i686-linux-android",
|
||||
"i686-unknown-linux-gnu",
|
||||
"x86_64-apple-darwin",
|
||||
"x86_64-apple-ios",
|
||||
"x86_64-unknown-fuchsia",
|
||||
"x86_64-linux-android",
|
||||
"x86_64-unknown-freebsd",
|
||||
@ -70,8 +73,11 @@ pub const MSAN_SUPPORTED_TARGETS: &[&str] = &[
|
||||
|
||||
pub const TSAN_SUPPORTED_TARGETS: &[&str] = &[
|
||||
"aarch64-apple-darwin",
|
||||
"aarch64-apple-ios",
|
||||
"aarch64-apple-ios-sim",
|
||||
"aarch64-unknown-linux-gnu",
|
||||
"x86_64-apple-darwin",
|
||||
"x86_64-apple-ios",
|
||||
"x86_64-unknown-freebsd",
|
||||
"x86_64-unknown-linux-gnu",
|
||||
"s390x-unknown-linux-gnu",
|
||||
|
Loading…
Reference in New Issue
Block a user