Add sanitizer support for modern iOS platforms · rust-lang/rust@aacf321 (original) (raw)

`@@ -483,7 +483,7 @@ impl Step for Llvm {

`

483

483

` cfg.define("LLVM_VERSION_SUFFIX", suffix);

`

484

484

`}

`

485

485

``

486

``

`-

configure_cmake(builder, target, &mut cfg, true, ldflags);

`

``

486

`+

configure_cmake(builder, target, &mut cfg, true, ldflags, &[]);

`

487

487

`configure_llvm(builder, target, &mut cfg);

`

488

488

``

489

489

`for (key, val) in &builder.config.llvm_build_config {

`

`@@ -574,6 +574,7 @@ fn configure_cmake(

`

574

574

`cfg: &mut cmake::Config,

`

575

575

`use_compiler_launcher: bool,

`

576

576

`mut ldflags: LdFlags,

`

``

577

`+

extra_compiler_flags: &[&str],

`

577

578

`) {

`

578

579

`// Do not print installation messages for up-to-date files.

`

579

580

`// LLVM and LLD builds can produce a lot of those and hit CI limits on log size.

`

`@@ -714,6 +715,9 @@ fn configure_cmake(

`

714

715

`if builder.config.llvm_clang_cl.is_some() {

`

715

716

` cflags.push(&format!(" --target={}", target));

`

716

717

`}

`

``

718

`+

for flag in extra_compiler_flags {

`

``

719

`+

cflags.push(&format!(" {}", flag));

`

``

720

`+

}

`

717

721

` cfg.define("CMAKE_C_FLAGS", cflags);

`

718

722

`let mut cxxflags: OsString = builder.cflags(target, GitRepo::Llvm, CLang::Cxx).join(" ").into();

`

719

723

`if let Some(ref s) = builder.config.llvm_cxxflags {

`

`@@ -723,6 +727,9 @@ fn configure_cmake(

`

723

727

`if builder.config.llvm_clang_cl.is_some() {

`

724

728

` cxxflags.push(&format!(" --target={}", target));

`

725

729

`}

`

``

730

`+

for flag in extra_compiler_flags {

`

``

731

`+

cxxflags.push(&format!(" {}", flag));

`

``

732

`+

}

`

726

733

` cfg.define("CMAKE_CXX_FLAGS", cxxflags);

`

727

734

`if let Some(ar) = builder.ar(target) {

`

728

735

`if ar.is_absolute() {

`

`@@ -864,7 +871,7 @@ impl Step for Lld {

`

864

871

`}

`

865

872

`}

`

866

873

``

867

``

`-

configure_cmake(builder, target, &mut cfg, true, ldflags);

`

``

874

`+

configure_cmake(builder, target, &mut cfg, true, ldflags, &[]);

`

868

875

`configure_llvm(builder, target, &mut cfg);

`

869

876

``

870

877

`// Re-use the same flags as llvm to control the level of debug information

`

`@@ -1028,7 +1035,16 @@ impl Step for Sanitizers {

`

1028

1035

`// Unfortunately sccache currently lacks support to build them successfully.

`

1029

1036

`// Disable compiler launcher on Darwin targets to avoid potential issues.

`

1030

1037

`let use_compiler_launcher = !self.target.contains("apple-darwin");

`

1031

``

`-

configure_cmake(builder, self.target, &mut cfg, use_compiler_launcher, LdFlags::default());

`

``

1038

`+

let extra_compiler_flags: &[&str] =

`

``

1039

`+

if self.target.contains("apple") { &["-fembed-bitcode=off"] } else { &[] };

`

``

1040

`+

configure_cmake(

`

``

1041

`+

builder,

`

``

1042

`+

self.target,

`

``

1043

`+

&mut cfg,

`

``

1044

`+

use_compiler_launcher,

`

``

1045

`+

LdFlags::default(),

`

``

1046

`+

extra_compiler_flags,

`

``

1047

`+

);

`

1032

1048

``

1033

1049

`t!(fs::create_dir_all(&out_dir));

`

1034

1050

` cfg.out_dir(out_dir);

`

`@@ -1084,12 +1100,15 @@ fn supported_sanitizers(

`

1084

1100

``

1085

1101

`match &*target.triple {

`

1086

1102

`"aarch64-apple-darwin" => darwin_libs("osx", &["asan", "lsan", "tsan"]),

`

``

1103

`+

"aarch64-apple-ios" => darwin_libs("ios", &["asan", "tsan"]),

`

``

1104

`+

"aarch64-apple-ios-sim" => darwin_libs("iossim", &["asan", "tsan"]),

`

1087

1105

`"aarch64-unknown-fuchsia" => common_libs("fuchsia", "aarch64", &["asan"]),

`

1088

1106

`"aarch64-unknown-linux-gnu" => {

`

1089

1107

`common_libs("linux", "aarch64", &["asan", "lsan", "msan", "tsan", "hwasan"])

`

1090

1108

`}

`

1091

1109

`"x86_64-apple-darwin" => darwin_libs("osx", &["asan", "lsan", "tsan"]),

`

1092

1110

`"x86_64-unknown-fuchsia" => common_libs("fuchsia", "x86_64", &["asan"]),

`

``

1111

`+

"x86_64-apple-ios" => darwin_libs("iossim", &["asan", "tsan"]),

`

1093

1112

`"x86_64-unknown-freebsd" => common_libs("freebsd", "x86_64", &["asan", "msan", "tsan"]),

`

1094

1113

`"x86_64-unknown-netbsd" => {

`

1095

1114

`common_libs("netbsd", "x86_64", &["asan", "lsan", "msan", "tsan"])

`