Skip to content

Commit 3fda19e

Browse files
committed
sanitizers: Stabilize AddressSanitizer and LeakSanitizer
Stabilize AddressSanitizer and LeakSanitizer for the Tier 1 targets that support them.
1 parent 8dbc916 commit 3fda19e

11 files changed

+49
-3
lines changed

compiler/rustc_target/src/spec/targets/aarch64_unknown_linux_gnu.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@ pub(crate) fn target() -> Target {
1919
stack_probes: StackProbeType::Inline,
2020
supported_sanitizers: SanitizerSet::ADDRESS
2121
| SanitizerSet::CFI
22+
| SanitizerSet::HWADDRESS
2223
| SanitizerSet::KCFI
2324
| SanitizerSet::LEAK
2425
| SanitizerSet::MEMORY
2526
| SanitizerSet::MEMTAG
26-
| SanitizerSet::THREAD
27-
| SanitizerSet::HWADDRESS,
27+
| SanitizerSet::THREAD,
28+
stable_sanitizers: SanitizerSet::ADDRESS | SanitizerSet::LEAK,
2829
supports_xray: true,
2930
..base::linux_gnu::opts()
3031
},

compiler/rustc_target/src/spec/targets/i686_pc_windows_msvc.rs

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ pub(crate) fn target() -> Target {
55
base.cpu = "pentium4".into();
66
base.max_atomic_width = Some(64);
77
base.supported_sanitizers = SanitizerSet::ADDRESS;
8+
base.stable_sanitizers = SanitizerSet::ADDRESS;
89

910
base.add_pre_link_args(LinkerFlavor::Msvc(Lld::No), &[
1011
// Mark all dynamic libraries and executables as compatible with the larger 4GiB address

compiler/rustc_target/src/spec/targets/i686_unknown_linux_gnu.rs

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ pub(crate) fn target() -> Target {
55
base.cpu = "pentium4".into();
66
base.max_atomic_width = Some(64);
77
base.supported_sanitizers = SanitizerSet::ADDRESS;
8+
base.stable_sanitizers = SanitizerSet::ADDRESS;
89
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32"]);
910
base.stack_probes = StackProbeType::Inline;
1011

compiler/rustc_target/src/spec/targets/x86_64_apple_darwin.rs

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ pub(crate) fn target() -> Target {
2323
| SanitizerSet::CFI
2424
| SanitizerSet::LEAK
2525
| SanitizerSet::THREAD,
26+
stable_sanitizers: SanitizerSet::ADDRESS | SanitizerSet::LEAK,
2627
..opts
2728
},
2829
}

compiler/rustc_target/src/spec/targets/x86_64_pc_windows_msvc.rs

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ pub(crate) fn target() -> Target {
77
base.plt_by_default = false;
88
base.max_atomic_width = Some(128);
99
base.supported_sanitizers = SanitizerSet::ADDRESS;
10+
base.stable_sanitizers = SanitizerSet::ADDRESS;
1011

1112
Target {
1213
llvm_target: "x86_64-pc-windows-msvc".into(),

compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_gnu.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@ pub(crate) fn target() -> Target {
1010
base.static_position_independent_executables = true;
1111
base.supported_sanitizers = SanitizerSet::ADDRESS
1212
| SanitizerSet::CFI
13-
| SanitizerSet::KCFI
1413
| SanitizerSet::DATAFLOW
14+
| SanitizerSet::KCFI
1515
| SanitizerSet::LEAK
1616
| SanitizerSet::MEMORY
1717
| SanitizerSet::SAFESTACK
1818
| SanitizerSet::THREAD;
19+
base.stable_sanitizers = SanitizerSet::ADDRESS | SanitizerSet::LEAK;
1920
base.supports_xray = true;
2021

2122
// When we're asked to use the `rust-lld` linker by default, set the appropriate lld-using
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Verifies that stable and unstable supported sanitizers can be used with `-Zunstable-options`.
2+
//
3+
//@ needs-llvm-components: x86
4+
//@ needs-sanitizer-support
5+
//@ build-pass
6+
//@ compile-flags: -Zunstable-options -Clto -Csanitize=address,cfi --target x86_64-unknown-linux-gnu
7+
8+
#![crate_type = "rlib"]
9+
#![feature(no_core)]
10+
#![no_core]
11+
#![no_main]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Verifies that stable and unstable supported sanitizers cannot be used without
2+
// `-Zunstable-options`.
3+
//
4+
//@ needs-llvm-components: x86
5+
//@ needs-sanitizer-support
6+
//@ compile-flags: -Clto -Csanitize=address,cfi --target x86_64-unknown-linux-gnu
7+
//@ error-pattern: error: cfi sanitizer is not supported for this target
8+
9+
fn main() { }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
error: cfi sanitizer is not supported for this target
2+
3+
error: aborting due to 1 previous error
4+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Verifies that stable supported sanitizers can be used with `-Zunstable-options`.
2+
//
3+
//@ needs-llvm-components: x86
4+
//@ needs-sanitizer-support
5+
//@ build-pass
6+
//@ compile-flags: -Zunstable-options -Csanitize=address --target x86_64-unknown-linux-gnu
7+
8+
fn main() { }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Verifies that stable supported sanitizers can be used without `-Zunstable-options`.
2+
//
3+
//@ needs-llvm-components: x86
4+
//@ needs-sanitizer-support
5+
//@ build-pass
6+
//@ compile-flags: -Csanitize=address --target x86_64-unknown-linux-gnu
7+
8+
fn main() { }

0 commit comments

Comments
 (0)