authorbors <bors@rust-lang.org> 2025-09-04 22:51:33 UTC
committerbors <bors@rust-lang.org> 2025-09-04 22:51:33 UTC
logb3cfb8faf84c5f3b7909479a9f9b6a3290d5f4d7
tree6e291656e0d53f147359ddf2dd2a8a1e802cbdb7
parentaf00ff2ce62b6617ed19305ae39e135ac71d0b22
parent6d637dfeccd7d22523e584203e666535db878165

Auto merge of #138736 - azhogin:azhogin/sanitizers-target-modificators, r=rcvalle

Sanitizers target modificators Depends on bool flag fix: https://github.com/rust-lang/rust/pull/138483. Some sanitizers need to be target modifiers, and some do not. For now, we should mark all sanitizers as target modifiers except for these: AddressSanitizer, LeakSanitizer For kCFI, the helper flag -Zsanitizer-cfi-normalize-integers should also be a target modifier. Many test errors was with sanizer flags inconsistent with std deps. Tests are fixed with `-C unsafe-allow-abi-mismatch`.

86 files changed, 311 insertions(+), 68 deletions(-)

compiler/rustc_metadata/src/creader.rs+13-5
......@@ -412,7 +412,7 @@ impl CStore {
412412 match (&left_name_val, &right_name_val) {
413413 (Some(l), Some(r)) => match l.1.opt.cmp(&r.1.opt) {
414414 cmp::Ordering::Equal => {
415 if l.0.tech_value != r.0.tech_value {
415 if !l.1.consistent(&tcx.sess.opts, Some(&r.1)) {
416416 report_diff(
417417 &l.0.prefix,
418418 &l.0.name,
......@@ -424,20 +424,28 @@ impl CStore {
424424 right_name_val = None;
425425 }
426426 cmp::Ordering::Greater => {
427 report_diff(&r.0.prefix, &r.0.name, None, Some(&r.1.value_name));
427 if !r.1.consistent(&tcx.sess.opts, None) {
428 report_diff(&r.0.prefix, &r.0.name, None, Some(&r.1.value_name));
429 }
428430 right_name_val = None;
429431 }
430432 cmp::Ordering::Less => {
431 report_diff(&l.0.prefix, &l.0.name, Some(&l.1.value_name), None);
433 if !l.1.consistent(&tcx.sess.opts, None) {
434 report_diff(&l.0.prefix, &l.0.name, Some(&l.1.value_name), None);
435 }
432436 left_name_val = None;
433437 }
434438 },
435439 (Some(l), None) => {
436 report_diff(&l.0.prefix, &l.0.name, Some(&l.1.value_name), None);
440 if !l.1.consistent(&tcx.sess.opts, None) {
441 report_diff(&l.0.prefix, &l.0.name, Some(&l.1.value_name), None);
442 }
437443 left_name_val = None;
438444 }
439445 (None, Some(r)) => {
440 report_diff(&r.0.prefix, &r.0.name, None, Some(&r.1.value_name));
446 if !r.1.consistent(&tcx.sess.opts, None) {
447 report_diff(&r.0.prefix, &r.0.name, None, Some(&r.1.value_name));
448 }
441449 right_name_val = None;
442450 }
443451 (None, None) => break,
compiler/rustc_session/src/options.rs+69-2
......@@ -83,10 +83,77 @@ pub struct TargetModifier {
8383 pub value_name: String,
8484}
8585
86mod target_modifier_consistency_check {
87 use super::*;
88 pub(super) fn sanitizer(l: &TargetModifier, r: Option<&TargetModifier>) -> bool {
89 let mut lparsed: SanitizerSet = Default::default();
90 let lval = if l.value_name.is_empty() { None } else { Some(l.value_name.as_str()) };
91 parse::parse_sanitizers(&mut lparsed, lval);
92
93 let mut rparsed: SanitizerSet = Default::default();
94 let rval = r.filter(|v| !v.value_name.is_empty()).map(|v| v.value_name.as_str());
95 parse::parse_sanitizers(&mut rparsed, rval);
96
97 // Some sanitizers need to be target modifiers, and some do not.
98 // For now, we should mark all sanitizers as target modifiers except for these:
99 // AddressSanitizer, LeakSanitizer
100 let tmod_sanitizers = SanitizerSet::MEMORY
101 | SanitizerSet::THREAD
102 | SanitizerSet::HWADDRESS
103 | SanitizerSet::CFI
104 | SanitizerSet::MEMTAG
105 | SanitizerSet::SHADOWCALLSTACK
106 | SanitizerSet::KCFI
107 | SanitizerSet::KERNELADDRESS
108 | SanitizerSet::SAFESTACK
109 | SanitizerSet::DATAFLOW;
110
111 lparsed & tmod_sanitizers == rparsed & tmod_sanitizers
112 }
113 pub(super) fn sanitizer_cfi_normalize_integers(
114 opts: &Options,
115 l: &TargetModifier,
116 r: Option<&TargetModifier>,
117 ) -> bool {
118 // For kCFI, the helper flag -Zsanitizer-cfi-normalize-integers should also be a target modifier
119 if opts.unstable_opts.sanitizer.contains(SanitizerSet::KCFI) {
120 if let Some(r) = r {
121 return l.extend().tech_value == r.extend().tech_value;
122 } else {
123 return false;
124 }
125 }
126 true
127 }
128}
129
86130impl TargetModifier {
87131 pub fn extend(&self) -> ExtendedTargetModifierInfo {
88132 self.opt.reparse(&self.value_name)
89133 }
134 // Custom consistency check for target modifiers (or default `l.tech_value == r.tech_value`)
135 // When other is None, consistency with default value is checked
136 pub fn consistent(&self, opts: &Options, other: Option<&TargetModifier>) -> bool {
137 assert!(other.is_none() || self.opt == other.unwrap().opt);
138 match self.opt {
139 OptionsTargetModifiers::UnstableOptions(unstable) => match unstable {
140 UnstableOptionsTargetModifiers::sanitizer => {
141 return target_modifier_consistency_check::sanitizer(self, other);
142 }
143 UnstableOptionsTargetModifiers::sanitizer_cfi_normalize_integers => {
144 return target_modifier_consistency_check::sanitizer_cfi_normalize_integers(
145 opts, self, other,
146 );
147 }
148 _ => {}
149 },
150 _ => {}
151 };
152 match other {
153 Some(other) => self.extend().tech_value == other.extend().tech_value,
154 None => false,
155 }
156 }
90157}
91158
92159fn tmod_push_impl(
......@@ -2504,13 +2571,13 @@ written to standard error output)"),
25042571 retpoline_external_thunk: bool = (false, parse_bool, [TRACKED TARGET_MODIFIER],
25052572 "enables retpoline-external-thunk, retpoline-indirect-branches and retpoline-indirect-calls \
25062573 target features (default: no)"),
2507 sanitizer: SanitizerSet = (SanitizerSet::empty(), parse_sanitizers, [TRACKED],
2574 sanitizer: SanitizerSet = (SanitizerSet::empty(), parse_sanitizers, [TRACKED TARGET_MODIFIER],
25082575 "use a sanitizer"),
25092576 sanitizer_cfi_canonical_jump_tables: Option<bool> = (Some(true), parse_opt_bool, [TRACKED],
25102577 "enable canonical jump tables (default: yes)"),
25112578 sanitizer_cfi_generalize_pointers: Option<bool> = (None, parse_opt_bool, [TRACKED],
25122579 "enable generalizing pointer types (default: no)"),
2513 sanitizer_cfi_normalize_integers: Option<bool> = (None, parse_opt_bool, [TRACKED],
2580 sanitizer_cfi_normalize_integers: Option<bool> = (None, parse_opt_bool, [TRACKED TARGET_MODIFIER],
25142581 "enable normalizing integer types (default: no)"),
25152582 sanitizer_dataflow_abilist: Vec<String> = (Vec::new(), parse_comma_list, [TRACKED],
25162583 "additional ABI list files that control how shadow parameters are passed (comma separated)"),
tests/codegen-llvm/sanitizer/address-sanitizer-globals-tracking.rs+1-1
......@@ -19,7 +19,7 @@
1919//@ only-linux
2020//
2121//@ revisions:ASAN ASAN-FAT-LTO
22//@ compile-flags: -Zsanitizer=address -Ctarget-feature=-crt-static
22//@ compile-flags: -Zsanitizer=address -Ctarget-feature=-crt-static -C unsafe-allow-abi-mismatch=sanitizer
2323// [ASAN] no extra compile-flags
2424//@[ASAN-FAT-LTO] compile-flags: -Cprefer-dynamic=false -Clto=fat
2525
tests/codegen-llvm/sanitizer/cfi/add-canonical-jump-tables-flag.rs+1-1
......@@ -1,7 +1,7 @@
11// Verifies that "CFI Canonical Jump Tables" module flag is added.
22//
33//@ needs-sanitizer-cfi
4//@ compile-flags: -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi
4//@ compile-flags: -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi -C unsafe-allow-abi-mismatch=sanitizer
55
66#![crate_type = "lib"]
77
tests/codegen-llvm/sanitizer/cfi/add-cfi-normalize-integers-flag.rs+1-1
......@@ -1,7 +1,7 @@
11// Verifies that "cfi-normalize-integers" module flag is added.
22//
33//@ needs-sanitizer-cfi
4//@ compile-flags: -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-normalize-integers
4//@ compile-flags: -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-normalize-integers -C unsafe-allow-abi-mismatch=sanitizer,sanitizer-cfi-normalize-integers
55
66#![crate_type = "lib"]
77
tests/codegen-llvm/sanitizer/cfi/add-enable-split-lto-unit-flag.rs+1-1
......@@ -1,7 +1,7 @@
11// Verifies that "EnableSplitLTOUnit" module flag is added.
22//
33//@ needs-sanitizer-cfi
4//@ compile-flags: -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi
4//@ compile-flags: -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi -C unsafe-allow-abi-mismatch=sanitizer
55
66#![crate_type = "lib"]
77
tests/codegen-llvm/sanitizer/cfi/dbg-location-on-cfi-blocks.rs+1-1
......@@ -1,7 +1,7 @@
11// Verifies that the parent block's debug information are assigned to the inserted cfi block.
22//
33//@ needs-sanitizer-cfi
4//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static -Cdebuginfo=1
4//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static -Cdebuginfo=1 -C unsafe-allow-abi-mismatch=sanitizer
55
66#![crate_type = "lib"]
77
tests/codegen-llvm/sanitizer/cfi/emit-type-checks-attr-sanitize-off.rs+1-1
......@@ -1,7 +1,7 @@
11// Verifies that pointer type membership tests for indirect calls are omitted.
22//
33//@ needs-sanitizer-cfi
4//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Copt-level=0
4//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Copt-level=0 -C unsafe-allow-abi-mismatch=sanitizer
55
66#![crate_type = "lib"]
77#![feature(sanitize)]
tests/codegen-llvm/sanitizer/cfi/emit-type-checks.rs+1-1
......@@ -1,7 +1,7 @@
11// Verifies that pointer type membership tests for indirect calls are emitted.
22//
33//@ needs-sanitizer-cfi
4//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Copt-level=0
4//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Copt-level=0 -C unsafe-allow-abi-mismatch=sanitizer
55
66#![crate_type = "lib"]
77
tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-attr-cfi-encoding.rs+1-1
......@@ -1,7 +1,7 @@
11// Verifies that user-defined CFI encoding for types are emitted.
22//
33//@ needs-sanitizer-cfi
4//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Copt-level=0
4//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Copt-level=0 -C unsafe-allow-abi-mismatch=sanitizer
55
66#![crate_type = "lib"]
77#![feature(cfi_encoding, extern_types)]
tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-const-generics.rs+1-1
......@@ -2,7 +2,7 @@
22// for const generics.
33//
44//@ needs-sanitizer-cfi
5//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Copt-level=0
5//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Copt-level=0 -C unsafe-allow-abi-mismatch=sanitizer
66
77#![crate_type = "lib"]
88#![feature(type_alias_impl_trait)]
tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-drop-in-place.rs+1-1
......@@ -5,7 +5,7 @@
55// future.
66//
77//@ needs-sanitizer-cfi
8//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static
8//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static -C unsafe-allow-abi-mismatch=sanitizer
99
1010#![crate_type = "lib"]
1111
tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-function-types.rs+1-1
......@@ -2,7 +2,7 @@
22// for function types.
33//
44//@ needs-sanitizer-cfi
5//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static
5//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static -C unsafe-allow-abi-mismatch=sanitizer
66
77#![crate_type = "lib"]
88
tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-lifetimes.rs+1-1
......@@ -2,7 +2,7 @@
22// for lifetimes/regions.
33//
44//@ needs-sanitizer-cfi
5//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Copt-level=0
5//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Copt-level=0 -C unsafe-allow-abi-mismatch=sanitizer
66
77#![crate_type = "lib"]
88#![feature(type_alias_impl_trait)]
tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-method-secondary-typeid.rs+1-1
......@@ -2,7 +2,7 @@
22// self so they can be used as function pointers.
33//
44//@ needs-sanitizer-cfi
5//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static
5//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static -C unsafe-allow-abi-mismatch=sanitizer
66
77#![crate_type = "lib"]
88
tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-paths.rs+1-1
......@@ -2,7 +2,7 @@
22// for paths.
33//
44//@ needs-sanitizer-cfi
5//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static
5//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static -C unsafe-allow-abi-mismatch=sanitizer
66
77#![crate_type = "lib"]
88#![feature(type_alias_impl_trait)]
tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-pointer-types.rs+1-1
......@@ -2,7 +2,7 @@
22// for pointer types.
33//
44//@ needs-sanitizer-cfi
5//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static
5//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static -C unsafe-allow-abi-mismatch=sanitizer
66
77#![crate_type = "lib"]
88
tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-primitive-types.rs+1-1
......@@ -2,7 +2,7 @@
22// for primitive types.
33//
44//@ needs-sanitizer-cfi
5//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static
5//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static -C unsafe-allow-abi-mismatch=sanitizer
66
77#![crate_type = "lib"]
88
tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-repr-transparent-types.rs+1-1
......@@ -2,7 +2,7 @@
22// for repr transparent types.
33//
44//@ needs-sanitizer-cfi
5//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static
5//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static -C unsafe-allow-abi-mismatch=sanitizer
66
77#![crate_type = "lib"]
88
tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-sequence-types.rs+1-1
......@@ -2,7 +2,7 @@
22// for sequence types.
33//
44//@ needs-sanitizer-cfi
5//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static
5//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static -C unsafe-allow-abi-mismatch=sanitizer
66
77#![crate_type = "lib"]
88
tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-trait-types.rs+1-1
......@@ -2,7 +2,7 @@
22// for trait types.
33//
44//@ needs-sanitizer-cfi
5//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static
5//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static -C unsafe-allow-abi-mismatch=sanitizer
66
77#![crate_type = "lib"]
88
tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-user-defined-types.rs+1-1
......@@ -2,7 +2,7 @@
22// for user-defined types.
33//
44//@ needs-sanitizer-cfi
5//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static
5//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static -C unsafe-allow-abi-mismatch=sanitizer
66
77#![crate_type = "lib"]
88#![feature(extern_types)]
tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-itanium-cxx-abi-generalized.rs+1-1
......@@ -1,7 +1,7 @@
11// Verifies that generalized type metadata for functions are emitted.
22//
33//@ needs-sanitizer-cfi
4//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-generalize-pointers
4//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-generalize-pointers -C unsafe-allow-abi-mismatch=sanitizer
55
66#![crate_type = "lib"]
77
tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-itanium-cxx-abi-normalized-generalized.rs+1-1
......@@ -1,7 +1,7 @@
11// Verifies that normalized and generalized type metadata for functions are emitted.
22//
33//@ needs-sanitizer-cfi
4//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-normalize-integers -Zsanitizer-cfi-generalize-pointers
4//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-normalize-integers -Zsanitizer-cfi-generalize-pointers -C unsafe-allow-abi-mismatch=sanitizer,sanitizer-cfi-normalize-integers
55
66#![crate_type = "lib"]
77
tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-itanium-cxx-abi-normalized.rs+1-1
......@@ -1,7 +1,7 @@
11// Verifies that normalized type metadata for functions are emitted.
22//
33//@ needs-sanitizer-cfi
4//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-normalize-integers
4//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-normalize-integers -C unsafe-allow-abi-mismatch=sanitizer,sanitizer-cfi-normalize-integers
55
66#![crate_type = "lib"]
77
tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-itanium-cxx-abi.rs+1-1
......@@ -1,7 +1,7 @@
11// Verifies that type metadata for functions are emitted.
22//
33//@ needs-sanitizer-cfi
4//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi
4//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -C unsafe-allow-abi-mismatch=sanitizer
55
66#![crate_type = "lib"]
77
tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-trait-objects.rs+1-1
......@@ -1,7 +1,7 @@
11// Verifies that type metadata identifiers for trait objects are emitted correctly.
22//
33//@ needs-sanitizer-cfi
4//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Ctarget-feature=-crt-static -Zsanitizer=cfi
4//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Ctarget-feature=-crt-static -Zsanitizer=cfi -C unsafe-allow-abi-mismatch=sanitizer
55
66#![crate_type = "lib"]
77
tests/codegen-llvm/sanitizer/cfi/external_weak_symbols.rs+1-1
......@@ -2,7 +2,7 @@
22// emitted correctly.
33//
44//@ needs-sanitizer-cfi
5//@ compile-flags: -Clinker-plugin-lto -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static
5//@ compile-flags: -Clinker-plugin-lto -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static -C unsafe-allow-abi-mismatch=sanitizer
66#![crate_type = "bin"]
77#![feature(linkage)]
88
tests/codegen-llvm/sanitizer/cfi/generalize-pointers.rs+1-1
......@@ -1,7 +1,7 @@
11// Verifies that pointer types are generalized.
22//
33//@ needs-sanitizer-cfi
4//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-generalize-pointers -Copt-level=0
4//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-generalize-pointers -Copt-level=0 -C unsafe-allow-abi-mismatch=sanitizer
55
66#![crate_type = "lib"]
77
tests/codegen-llvm/sanitizer/cfi/normalize-integers.rs+1-1
......@@ -1,7 +1,7 @@
11// Verifies that integer types are normalized.
22//
33//@ needs-sanitizer-cfi
4//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-normalize-integers -Copt-level=0
4//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-normalize-integers -Copt-level=0 -C unsafe-allow-abi-mismatch=sanitizer,sanitizer-cfi-normalize-integers
55
66#![crate_type = "lib"]
77
tests/codegen-llvm/sanitizer/dataflow-instrument-functions.rs+1-1
......@@ -1,7 +1,7 @@
11// Verifies that functions are instrumented.
22//
33//@ needs-sanitizer-dataflow
4//@ compile-flags: -Copt-level=0 -Zsanitizer=dataflow
4//@ compile-flags: -Copt-level=0 -Zsanitizer=dataflow -C unsafe-allow-abi-mismatch=sanitizer
55
66#![crate_type = "lib"]
77
tests/codegen-llvm/sanitizer/memory-track-origins.rs+1-1
......@@ -4,7 +4,7 @@
44//@ needs-sanitizer-memory
55//@ revisions:MSAN-0 MSAN-1 MSAN-2 MSAN-1-LTO MSAN-2-LTO
66//
7//@ compile-flags: -Zsanitizer=memory -Ctarget-feature=-crt-static
7//@ compile-flags: -Zsanitizer=memory -Ctarget-feature=-crt-static -C unsafe-allow-abi-mismatch=sanitizer
88// [MSAN-0] no extra compile-flags
99//@[MSAN-1] compile-flags: -Zsanitizer-memory-track-origins=1
1010//@[MSAN-2] compile-flags: -Zsanitizer-memory-track-origins
tests/codegen-llvm/sanitizer/memtag-attr-check.rs+1-1
......@@ -2,7 +2,7 @@
22// applied when enabling the memtag sanitizer.
33//
44//@ needs-sanitizer-memtag
5//@ compile-flags: -Zsanitizer=memtag -Ctarget-feature=+mte -Copt-level=0
5//@ compile-flags: -C unsafe-allow-abi-mismatch=sanitizer -Zsanitizer=memtag -Ctarget-feature=+mte -Copt-level=0
66
77#![crate_type = "lib"]
88
tests/codegen-llvm/sanitizer/safestack-attr-check.rs+1-1
......@@ -1,7 +1,7 @@
11// This tests that the safestack attribute is applied when enabling the safe-stack sanitizer.
22//
33//@ needs-sanitizer-safestack
4//@ compile-flags: -Zsanitizer=safestack -Copt-level=0
4//@ compile-flags: -Zsanitizer=safestack -Copt-level=0 -C unsafe-allow-abi-mismatch=sanitizer
55
66#![crate_type = "lib"]
77
tests/codegen-llvm/sanitizer/sanitize-off-inlining.rs+1-1
......@@ -1,9 +1,9 @@
11// Verifies that sanitize(xyz = "off") attribute prevents inlining when
22// given sanitizer is enabled, but has no effect on inlining otherwise.
3//
43//@ needs-sanitizer-address
54//@ needs-sanitizer-leak
65//@ revisions: ASAN LSAN
6//@ compile-flags: -C unsafe-allow-abi-mismatch=sanitizer
77//@ compile-flags: -Copt-level=3 -Zmir-opt-level=4 -Ctarget-feature=-crt-static
88//@[ASAN] compile-flags: -Zsanitizer=address
99//@[LSAN] compile-flags: -Zsanitizer=leak
tests/codegen-llvm/sanitizer/sanitize-off-kasan-asan.rs+1-1
......@@ -2,7 +2,7 @@
22// the address sanitizer.
33//
44//@ needs-sanitizer-address
5//@ compile-flags: -Zsanitizer=address -Ctarget-feature=-crt-static -Copt-level=0
5//@ compile-flags: -Zsanitizer=address -Ctarget-feature=-crt-static -Copt-level=0 -C unsafe-allow-abi-mismatch=sanitizer
66
77#![crate_type = "lib"]
88#![feature(sanitize)]
tests/codegen-llvm/sanitizer/sanitizer-recover.rs+1-1
......@@ -5,7 +5,7 @@
55//@ needs-sanitizer-memory
66//@ revisions:ASAN ASAN-RECOVER MSAN MSAN-RECOVER MSAN-RECOVER-LTO
77//@ no-prefer-dynamic
8//
8//@ compile-flags: -C unsafe-allow-abi-mismatch=sanitizer
99//@ compile-flags: -Ctarget-feature=-crt-static
1010//@[ASAN] compile-flags: -Zsanitizer=address -Copt-level=0
1111//@[ASAN-RECOVER] compile-flags: -Zsanitizer=address -Zsanitizer-recover=address -Copt-level=0
tests/run-make/sanitizer-cdylib-link/rmake.rs+2
......@@ -8,6 +8,8 @@
88//@ needs-sanitizer-support
99//@ needs-sanitizer-address
1010
11//@ compile-flags: -C unsafe-allow-abi-mismatch=sanitizer
12
1113use run_make_support::{run_fail, rustc};
1214
1315fn main() {
tests/run-make/sanitizer-dylib-link/rmake.rs+2
......@@ -7,6 +7,8 @@
77//@ needs-sanitizer-support
88//@ needs-sanitizer-address
99
10//@ compile-flags: -C unsafe-allow-abi-mismatch=sanitizer
11
1012use run_make_support::{run_fail, rustc};
1113
1214fn main() {
tests/run-make/sanitizer-staticlib-link/rmake.rs+2
......@@ -11,6 +11,8 @@
1111//@ needs-sanitizer-support
1212//@ needs-sanitizer-address
1313
14//@ compile-flags: -C unsafe-allow-abi-mismatch=sanitizer
15
1416use run_make_support::{cc, extra_c_flags, extra_cxx_flags, run_fail, rustc, static_lib_name};
1517
1618fn main() {
tests/rustdoc/sanitizer-option.rs+1-1
......@@ -1,6 +1,6 @@
11//@ needs-sanitizer-support
22//@ needs-sanitizer-address
3//@ compile-flags: --test -Z sanitizer=address
3//@ compile-flags: --test -Z sanitizer=address -C unsafe-allow-abi-mismatch=sanitizer
44//
55// #43031: Verify that rustdoc passes `-Z` options to rustc. Use an extern
66// function that is provided by the sanitizer runtime, if flag is not passed
tests/ui/asm/global-asm-isnt-really-a-mir-body.rs+2
......@@ -1,5 +1,7 @@
11//@ revisions: emit_mir instrument cfi
22
3//@ compile-flags: -C unsafe-allow-abi-mismatch=sanitizer
4
35// Make sure we don't try to emit MIR for it.
46//@[emit_mir] compile-flags: --emit=mir
57
tests/ui/lto/issue-100772.rs+1-1
......@@ -1,6 +1,6 @@
11//@ build-pass
22//@ needs-sanitizer-cfi
3//@ compile-flags: -Ccodegen-units=1 -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi
3//@ compile-flags: -Ccodegen-units=1 -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi -C unsafe-allow-abi-mismatch=sanitizer
44//@ no-prefer-dynamic
55//@ only-x86_64-unknown-linux-gnu
66
tests/ui/sanitizer/address.rs+1-1
......@@ -2,7 +2,7 @@
22//@ needs-sanitizer-address
33//@ ignore-cross-compile
44//
5//@ compile-flags: -Z sanitizer=address -O -g
5//@ compile-flags: -Z sanitizer=address -O -g -C unsafe-allow-abi-mismatch=sanitizer
66//
77//@ run-fail-or-crash
88//@ error-pattern: AddressSanitizer: stack-buffer-overflow
tests/ui/sanitizer/asan_odr_windows.rs+1-1
......@@ -2,7 +2,7 @@
22//! See <https://github.com/rust-lang/rust/issues/124390>.
33
44//@ run-pass
5//@ compile-flags:-Zsanitizer=address
5//@ compile-flags:-Zsanitizer=address -C unsafe-allow-abi-mismatch=sanitizer
66//@ aux-build: asan_odr_win-2.rs
77//@ only-windows-msvc
88//@ needs-sanitizer-support
tests/ui/sanitizer/badfree.rs+1-1
......@@ -2,7 +2,7 @@
22//@ needs-sanitizer-address
33//@ ignore-cross-compile
44//
5//@ compile-flags: -Z sanitizer=address -O
5//@ compile-flags: -Z sanitizer=address -O -C unsafe-allow-abi-mismatch=sanitizer
66//
77//@ run-fail-or-crash
88//@ regex-error-pattern: AddressSanitizer: (SEGV|attempting free on address which was not malloc)
tests/ui/sanitizer/cfi/assoc-ty-lifetime-issue-123053.rs+1-1
......@@ -2,7 +2,7 @@
22// trait object type to fail, causing an ICE.
33//
44//@ needs-sanitizer-cfi
5//@ compile-flags: -Ccodegen-units=1 -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi
5//@ compile-flags: -Ccodegen-units=1 -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi -C unsafe-allow-abi-mismatch=sanitizer
66//@ edition: 2021
77//@ no-prefer-dynamic
88//@ only-x86_64-unknown-linux-gnu
tests/ui/sanitizer/cfi/async-closures.rs+1-1
......@@ -7,7 +7,7 @@
77//@ ignore-backends: gcc
88//@ [cfi] needs-sanitizer-cfi
99//@ [kcfi] needs-sanitizer-kcfi
10//@ compile-flags: -C target-feature=-crt-static
10//@ compile-flags: -C target-feature=-crt-static -C unsafe-allow-abi-mismatch=sanitizer
1111//@ [cfi] compile-flags: -C codegen-units=1 -C lto -C prefer-dynamic=off -C opt-level=0
1212//@ [cfi] compile-flags: -Z sanitizer=cfi
1313//@ [kcfi] compile-flags: -Z sanitizer=kcfi
tests/ui/sanitizer/cfi/can-reveal-opaques.rs+1-1
......@@ -1,5 +1,5 @@
11//@ needs-sanitizer-cfi
2//@ compile-flags: -Ccodegen-units=1 -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi
2//@ compile-flags: -Ccodegen-units=1 -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi -C unsafe-allow-abi-mismatch=sanitizer
33//@ no-prefer-dynamic
44//@ only-x86_64-unknown-linux-gnu
55//@ ignore-backends: gcc
tests/ui/sanitizer/cfi/closures.rs+1-1
......@@ -6,7 +6,7 @@
66//@ ignore-backends: gcc
77//@ [cfi] needs-sanitizer-cfi
88//@ [kcfi] needs-sanitizer-kcfi
9//@ compile-flags: -C target-feature=-crt-static
9//@ compile-flags: -C target-feature=-crt-static -C unsafe-allow-abi-mismatch=sanitizer
1010//@ [cfi] compile-flags: -C codegen-units=1 -C lto -C prefer-dynamic=off -C opt-level=0
1111//@ [cfi] compile-flags: -Z sanitizer=cfi
1212//@ [kcfi] compile-flags: -Z sanitizer=kcfi
tests/ui/sanitizer/cfi/complex-receiver.rs+1-1
......@@ -8,7 +8,7 @@
88//@ ignore-backends: gcc
99//@ [cfi] needs-sanitizer-cfi
1010//@ [kcfi] needs-sanitizer-kcfi
11//@ compile-flags: -C target-feature=-crt-static
11//@ compile-flags: -C target-feature=-crt-static -C unsafe-allow-abi-mismatch=sanitizer
1212//@ [cfi] compile-flags: -C codegen-units=1 -C lto -C prefer-dynamic=off -C opt-level=0
1313//@ [cfi] compile-flags: -Z sanitizer=cfi
1414//@ [kcfi] compile-flags: -Z sanitizer=kcfi
tests/ui/sanitizer/cfi/coroutine.rs+1
......@@ -8,6 +8,7 @@
88//@ [cfi] needs-sanitizer-cfi
99//@ [kcfi] needs-sanitizer-kcfi
1010//@ compile-flags: -C target-feature=-crt-static
11//@ compile-flags: -C unsafe-allow-abi-mismatch=sanitizer
1112//@ [cfi] compile-flags: -C codegen-units=1 -C lto -C prefer-dynamic=off -C opt-level=0
1213//@ [cfi] compile-flags: -Z sanitizer=cfi
1314//@ [kcfi] compile-flags: -Z sanitizer=kcfi
tests/ui/sanitizer/cfi/drop-in-place.rs+1
......@@ -5,6 +5,7 @@
55//@ ignore-backends: gcc
66//@ needs-sanitizer-cfi
77//@ compile-flags: -Clto -Copt-level=0 -Cprefer-dynamic=off -Ctarget-feature=-crt-static -Zsanitizer=cfi
8//@ compile-flags: -C unsafe-allow-abi-mismatch=sanitizer
89//@ run-pass
910
1011struct EmptyDrop;
tests/ui/sanitizer/cfi/drop-no-principal.rs+1-1
......@@ -4,7 +4,7 @@
44// FIXME(#122848) Remove only-linux once OSX CFI binaries works
55//@ only-linux
66//@ ignore-backends: gcc
7//@ compile-flags: --crate-type=bin -Cprefer-dynamic=off -Clto -Zsanitizer=cfi
7//@ compile-flags: --crate-type=bin -Cprefer-dynamic=off -Clto -Zsanitizer=cfi -C unsafe-allow-abi-mismatch=sanitizer
88//@ compile-flags: -C target-feature=-crt-static -C codegen-units=1 -C opt-level=0
99// FIXME(#118761) Should be run-pass once the labels on drop are compatible.
1010// This test is being landed ahead of that to test that the compiler doesn't ICE while labeling the
tests/ui/sanitizer/cfi/fn-ptr.rs+1
......@@ -7,6 +7,7 @@
77//@ [cfi] needs-sanitizer-cfi
88//@ [kcfi] needs-sanitizer-kcfi
99//@ compile-flags: -C target-feature=-crt-static
10//@ compile-flags: -C unsafe-allow-abi-mismatch=sanitizer
1011//@ [cfi] compile-flags: -C opt-level=0 -C codegen-units=1 -C lto
1112//@ [cfi] compile-flags: -C prefer-dynamic=off
1213//@ [cfi] compile-flags: -Z sanitizer=cfi
tests/ui/sanitizer/cfi/generalize-pointers-attr-cfg.rs+1
......@@ -4,6 +4,7 @@
44//@ needs-sanitizer-cfi
55//@ check-pass
66//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-generalize-pointers
7//@ compile-flags: -C unsafe-allow-abi-mismatch=sanitizer
78
89#![feature(cfg_sanitizer_cfi)]
910
tests/ui/sanitizer/cfi/normalize-integers-attr-cfg.rs+1-1
......@@ -3,7 +3,7 @@
33//
44//@ needs-sanitizer-cfi
55//@ check-pass
6//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-normalize-integers
6//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-normalize-integers -C unsafe-allow-abi-mismatch=sanitizer,sanitizer-cfi-normalize-integers
77
88#![feature(cfg_sanitizer_cfi)]
99
tests/ui/sanitizer/cfi/self-ref.rs+1-1
......@@ -6,7 +6,7 @@
66//@ ignore-backends: gcc
77//@ [cfi] needs-sanitizer-cfi
88//@ [kcfi] needs-sanitizer-kcfi
9//@ compile-flags: -C target-feature=-crt-static
9//@ compile-flags: -C target-feature=-crt-static -C unsafe-allow-abi-mismatch=sanitizer
1010//@ [cfi] compile-flags: -C codegen-units=1 -C lto -C prefer-dynamic=off -C opt-level=0
1111//@ [cfi] compile-flags: -Z sanitizer=cfi
1212//@ [kcfi] compile-flags: -Z sanitizer=kcfi
tests/ui/sanitizer/cfi/sized-associated-ty.rs+1-1
......@@ -7,7 +7,7 @@
77//@ ignore-backends: gcc
88//@ [cfi] needs-sanitizer-cfi
99//@ [kcfi] needs-sanitizer-kcfi
10//@ compile-flags: -C target-feature=-crt-static
10//@ compile-flags: -C target-feature=-crt-static -C unsafe-allow-abi-mismatch=sanitizer
1111//@ [cfi] compile-flags: -C codegen-units=1 -C lto -C prefer-dynamic=off -C opt-level=0
1212//@ [cfi] compile-flags: -Z sanitizer=cfi
1313//@ [kcfi] compile-flags: -Z sanitizer=kcfi
tests/ui/sanitizer/cfi/supertraits.rs+1-1
......@@ -6,7 +6,7 @@
66//@ ignore-backends: gcc
77//@ [cfi] needs-sanitizer-cfi
88//@ [kcfi] needs-sanitizer-kcfi
9//@ compile-flags: -C target-feature=-crt-static
9//@ compile-flags: -C target-feature=-crt-static -C unsafe-allow-abi-mismatch=sanitizer
1010//@ [cfi] compile-flags: -C codegen-units=1 -C lto -C prefer-dynamic=off -C opt-level=0
1111//@ [cfi] compile-flags: -Z sanitizer=cfi
1212//@ [kcfi] compile-flags: -Z sanitizer=kcfi
tests/ui/sanitizer/cfi/transparent-has-regions.rs+1-1
......@@ -1,5 +1,5 @@
11//@ needs-sanitizer-cfi
2//@ compile-flags: -Ccodegen-units=1 -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi
2//@ compile-flags: -Ccodegen-units=1 -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi -C unsafe-allow-abi-mismatch=sanitizer
33//@ no-prefer-dynamic
44//@ only-x86_64-unknown-linux-gnu
55//@ build-pass
tests/ui/sanitizer/cfi/virtual-auto.rs+1-1
......@@ -6,7 +6,7 @@
66//@ ignore-backends: gcc
77//@ [cfi] needs-sanitizer-cfi
88//@ [kcfi] needs-sanitizer-kcfi
9//@ compile-flags: -C target-feature=-crt-static
9//@ compile-flags: -C target-feature=-crt-static -C unsafe-allow-abi-mismatch=sanitizer
1010//@ [cfi] compile-flags: -C codegen-units=1 -C lto -C prefer-dynamic=off -C opt-level=0
1111//@ [cfi] compile-flags: -Z sanitizer=cfi
1212//@ [kcfi] compile-flags: -Z sanitizer=kcfi
tests/ui/sanitizer/dataflow.rs+1-1
......@@ -4,7 +4,7 @@
44//@ needs-sanitizer-support
55//@ needs-sanitizer-dataflow
66//@ run-pass
7//@ compile-flags: -Zsanitizer=dataflow -Zsanitizer-dataflow-abilist={{src-base}}/sanitizer/dataflow-abilist.txt
7//@ compile-flags: -Zsanitizer=dataflow -Zsanitizer-dataflow-abilist={{src-base}}/sanitizer/dataflow-abilist.txt -C unsafe-allow-abi-mismatch=sanitizer
88
99use std::mem::size_of;
1010use std::os::raw::{c_int, c_long, c_void};
tests/ui/sanitizer/hwaddress.rs+1-1
......@@ -5,7 +5,7 @@
55//@ ignore-aarch64-unknown-linux-gnu
66//
77// FIXME(#83989): codegen-units=1 triggers linker errors on aarch64-gnu
8//@ compile-flags: -Z sanitizer=hwaddress -O -g -C codegen-units=16
8//@ compile-flags: -Z sanitizer=hwaddress -O -g -C codegen-units=16 -C unsafe-allow-abi-mismatch=sanitizer
99//
1010//@ run-fail
1111//@ error-pattern: HWAddressSanitizer: tag-mismatch
tests/ui/sanitizer/issue-111184-cfi-coroutine-witness.rs+1-1
......@@ -2,7 +2,7 @@
22// encode_ty and caused the compiler to ICE.
33//
44//@ needs-sanitizer-cfi
5//@ compile-flags: -Ccodegen-units=1 -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi
5//@ compile-flags: -Ccodegen-units=1 -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi -C unsafe-allow-abi-mismatch=sanitizer
66//@ edition: 2021
77//@ no-prefer-dynamic
88//@ only-x86_64-unknown-linux-gnu
tests/ui/sanitizer/issue-114275-cfi-const-expr-in-arry-len.rs+1-1
......@@ -2,7 +2,7 @@
22// was expecting array type lengths to be evaluated, this was causing an ICE.
33//
44//@ build-pass
5//@ compile-flags: -Ccodegen-units=1 -Clto -Zsanitizer=cfi -Ctarget-feature=-crt-static
5//@ compile-flags: -Ccodegen-units=1 -Clto -Zsanitizer=cfi -Ctarget-feature=-crt-static -C unsafe-allow-abi-mismatch=sanitizer
66//@ needs-sanitizer-cfi
77
88#![crate_type = "lib"]
tests/ui/sanitizer/issue-72154-address-lifetime-markers.rs+1-1
......@@ -7,7 +7,7 @@
77//@ needs-sanitizer-address
88//@ ignore-cross-compile
99//
10//@ compile-flags: -Copt-level=0 -Zsanitizer=address
10//@ compile-flags: -Copt-level=0 -Zsanitizer=address -C unsafe-allow-abi-mismatch=sanitizer
1111//@ run-pass
1212
1313pub struct Wrap {
tests/ui/sanitizer/kcfi-mangling.rs+1-1
......@@ -2,7 +2,7 @@
22
33//@ needs-sanitizer-kcfi
44//@ no-prefer-dynamic
5//@ compile-flags: -C panic=abort -Zsanitizer=kcfi -C symbol-mangling-version=v0
5//@ compile-flags: -C panic=abort -Zsanitizer=kcfi -C symbol-mangling-version=v0 -C unsafe-allow-abi-mismatch=sanitizer
66//@ build-pass
77//@ ignore-backends: gcc
88
tests/ui/sanitizer/leak.rs+1-1
......@@ -1,7 +1,7 @@
11//@ needs-sanitizer-support
22//@ needs-sanitizer-leak
33//
4//@ compile-flags: -Z sanitizer=leak -O
4//@ compile-flags: -Z sanitizer=leak -O -C unsafe-allow-abi-mismatch=sanitizer
55//
66//@ run-fail
77//@ error-pattern: LeakSanitizer: detected memory leaks
tests/ui/sanitizer/memory-eager.rs+2
......@@ -1,6 +1,8 @@
11//@ needs-sanitizer-support
22//@ needs-sanitizer-memory
33//
4//@ compile-flags: -C unsafe-allow-abi-mismatch=sanitizer
5//
46//@ revisions: unoptimized optimized
57//
68//@ [optimized]compile-flags: -Z sanitizer=memory -Zsanitizer-memory-track-origins -O
tests/ui/sanitizer/memory-passing.rs+2
......@@ -1,6 +1,8 @@
11//@ needs-sanitizer-support
22//@ needs-sanitizer-memory
33//
4//@ compile-flags: -C unsafe-allow-abi-mismatch=sanitizer
5//
46//@ revisions: unoptimized optimized
57//
68//@ [optimized]compile-flags: -Z sanitizer=memory -Zsanitizer-memory-track-origins -O
tests/ui/sanitizer/memory.rs+2
......@@ -1,6 +1,8 @@
11//@ needs-sanitizer-support
22//@ needs-sanitizer-memory
33//
4//@ compile-flags: -C unsafe-allow-abi-mismatch=sanitizer
5//
46//@ revisions: unoptimized optimized
57//
68//@ [optimized]compile-flags: -Z sanitizer=memory -Zsanitizer-memory-track-origins -O
tests/ui/sanitizer/new-llvm-pass-manager-thin-lto.rs+2
......@@ -6,6 +6,8 @@
66//@ needs-sanitizer-address
77//@ ignore-cross-compile
88//
9//@ compile-flags: -C unsafe-allow-abi-mismatch=sanitizer
10//
911//@ no-prefer-dynamic
1012//@ revisions: opt0 opt1
1113//@ compile-flags: -Zsanitizer=address -Clto=thin
tests/ui/sanitizer/thread.rs+1-1
......@@ -13,7 +13,7 @@
1313//@ needs-sanitizer-support
1414//@ needs-sanitizer-thread
1515//
16//@ compile-flags: -Z sanitizer=thread -O
16//@ compile-flags: -Z sanitizer=thread -O -C unsafe-allow-abi-mismatch=sanitizer
1717//
1818//@ run-fail-or-crash
1919//@ error-pattern: WARNING: ThreadSanitizer: data race
tests/ui/sanitizer/use-after-scope.rs+1-1
......@@ -2,7 +2,7 @@
22//@ needs-sanitizer-address
33//@ ignore-cross-compile
44//
5//@ compile-flags: -Zsanitizer=address
5//@ compile-flags: -Zsanitizer=address -C unsafe-allow-abi-mismatch=sanitizer
66//@ run-fail-or-crash
77//@ error-pattern: ERROR: AddressSanitizer: stack-use-after-scope
88
tests/ui/target_modifiers/auxiliary/kcfi-normalize-ints.rs created+7
......@@ -0,0 +1,7 @@
1//@ no-prefer-dynamic
2//@ needs-sanitizer-kcfi
3//@ compile-flags: -C panic=abort -Zsanitizer=kcfi -Zsanitizer-cfi-normalize-integers
4
5#![feature(no_core)]
6#![crate_type = "rlib"]
7#![no_core]
tests/ui/target_modifiers/auxiliary/no-sanitizers.rs created+6
......@@ -0,0 +1,6 @@
1//@ no-prefer-dynamic
2//@ compile-flags: -C panic=abort
3
4#![feature(no_core)]
5#![crate_type = "rlib"]
6#![no_core]
tests/ui/target_modifiers/auxiliary/safestack-and-kcfi.rs created+10
......@@ -0,0 +1,10 @@
1//@ no-prefer-dynamic
2
3//@ needs-sanitizer-kcfi
4//@ needs-sanitizer-safestack
5
6//@ compile-flags: -C panic=abort -Zsanitizer=safestack,kcfi
7
8#![feature(no_core)]
9#![crate_type = "rlib"]
10#![no_core]
tests/ui/target_modifiers/sanitizer-kcfi-normalize-ints.rs created+18
......@@ -0,0 +1,18 @@
1// For kCFI, the helper flag -Zsanitizer-cfi-normalize-integers should also be a target modifier.
2
3//@ needs-sanitizer-kcfi
4//@ aux-build:kcfi-normalize-ints.rs
5//@ compile-flags: -Cpanic=abort
6
7//@ revisions: ok wrong_flag wrong_sanitizer
8//@[ok] compile-flags: -Zsanitizer=kcfi -Zsanitizer-cfi-normalize-integers
9//@[wrong_flag] compile-flags: -Zsanitizer=kcfi
10//@[ok] check-pass
11
12#![feature(no_core)]
13//[wrong_flag]~^ ERROR mixing `-Zsanitizer-cfi-normalize-integers` will cause an ABI mismatch in crate `sanitizer_kcfi_normalize_ints`
14//[wrong_sanitizer]~^^ ERROR mixing `-Zsanitizer` will cause an ABI mismatch in crate `sanitizer_kcfi_normalize_ints`
15#![crate_type = "rlib"]
16#![no_core]
17
18extern crate kcfi_normalize_ints;
tests/ui/target_modifiers/sanitizer-kcfi-normalize-ints.wrong_flag.stderr created+13
......@@ -0,0 +1,13 @@
1error: mixing `-Zsanitizer-cfi-normalize-integers` will cause an ABI mismatch in crate `sanitizer_kcfi_normalize_ints`
2 --> $DIR/sanitizer-kcfi-normalize-ints.rs:12:1
3 |
4LL | #![feature(no_core)]
5 | ^
6 |
7 = help: the `-Zsanitizer-cfi-normalize-integers` flag modifies the ABI so Rust crates compiled with different values of this flag cannot be used together safely
8 = note: unset `-Zsanitizer-cfi-normalize-integers` in this crate is incompatible with `-Zsanitizer-cfi-normalize-integers=` in dependency `kcfi_normalize_ints`
9 = help: set `-Zsanitizer-cfi-normalize-integers=` in this crate or unset `-Zsanitizer-cfi-normalize-integers` in `kcfi_normalize_ints`
10 = help: if you are sure this will not cause problems, you may use `-Cunsafe-allow-abi-mismatch=sanitizer-cfi-normalize-integers` to silence this error
11
12error: aborting due to 1 previous error
13
tests/ui/target_modifiers/sanitizer-kcfi-normalize-ints.wrong_sanitizer.stderr created+13
......@@ -0,0 +1,13 @@
1error: mixing `-Zsanitizer` will cause an ABI mismatch in crate `sanitizer_kcfi_normalize_ints`
2 --> $DIR/sanitizer-kcfi-normalize-ints.rs:12:1
3 |
4LL | #![feature(no_core)]
5 | ^
6 |
7 = help: the `-Zsanitizer` flag modifies the ABI so Rust crates compiled with different values of this flag cannot be used together safely
8 = note: unset `-Zsanitizer` in this crate is incompatible with `-Zsanitizer=kcfi` in dependency `kcfi_normalize_ints`
9 = help: set `-Zsanitizer=kcfi` in this crate or unset `-Zsanitizer` in `kcfi_normalize_ints`
10 = help: if you are sure this will not cause problems, you may use `-Cunsafe-allow-abi-mismatch=sanitizer` to silence this error
11
12error: aborting due to 1 previous error
13
tests/ui/target_modifiers/sanitizers-good-for-inconsistency.rs created+19
......@@ -0,0 +1,19 @@
1// AddressSanitizer, LeakSanitizer are good to be inconsistent (they are not a target modifiers)
2
3//@ revisions: wrong_address_san wrong_leak_san
4
5//@[wrong_address_san] needs-sanitizer-address
6//@[wrong_leak_san] needs-sanitizer-leak
7
8//@ aux-build:no-sanitizers.rs
9//@ compile-flags: -Cpanic=abort -C target-feature=-crt-static
10
11//@[wrong_address_san] compile-flags: -Zsanitizer=address
12//@[wrong_leak_san] compile-flags: -Zsanitizer=leak
13//@ check-pass
14
15#![feature(no_core)]
16#![crate_type = "rlib"]
17#![no_core]
18
19extern crate no_sanitizers;
tests/ui/target_modifiers/sanitizers-safestack-and-kcfi.missed_both.stderr created+13
......@@ -0,0 +1,13 @@
1error: mixing `-Zsanitizer` will cause an ABI mismatch in crate `sanitizers_safestack_and_kcfi`
2 --> $DIR/sanitizers-safestack-and-kcfi.rs:16:1
3 |
4LL | #![feature(no_core)]
5 | ^
6 |
7 = help: the `-Zsanitizer` flag modifies the ABI so Rust crates compiled with different values of this flag cannot be used together safely
8 = note: unset `-Zsanitizer` in this crate is incompatible with `-Zsanitizer=safestack,kcfi` in dependency `safestack_and_kcfi`
9 = help: set `-Zsanitizer=safestack,kcfi` in this crate or unset `-Zsanitizer` in `safestack_and_kcfi`
10 = help: if you are sure this will not cause problems, you may use `-Cunsafe-allow-abi-mismatch=sanitizer` to silence this error
11
12error: aborting due to 1 previous error
13
tests/ui/target_modifiers/sanitizers-safestack-and-kcfi.missed_kcfi.stderr created+13
......@@ -0,0 +1,13 @@
1error: mixing `-Zsanitizer` will cause an ABI mismatch in crate `sanitizers_safestack_and_kcfi`
2 --> $DIR/sanitizers-safestack-and-kcfi.rs:16:1
3 |
4LL | #![feature(no_core)]
5 | ^
6 |
7 = help: the `-Zsanitizer` flag modifies the ABI so Rust crates compiled with different values of this flag cannot be used together safely
8 = note: `-Zsanitizer=safestack` in this crate is incompatible with `-Zsanitizer=safestack,kcfi` in dependency `safestack_and_kcfi`
9 = help: set `-Zsanitizer=safestack,kcfi` in this crate or `-Zsanitizer=safestack` in `safestack_and_kcfi`
10 = help: if you are sure this will not cause problems, you may use `-Cunsafe-allow-abi-mismatch=sanitizer` to silence this error
11
12error: aborting due to 1 previous error
13
tests/ui/target_modifiers/sanitizers-safestack-and-kcfi.missed_safestack.stderr created+13
......@@ -0,0 +1,13 @@
1error: mixing `-Zsanitizer` will cause an ABI mismatch in crate `sanitizers_safestack_and_kcfi`
2 --> $DIR/sanitizers-safestack-and-kcfi.rs:16:1
3 |
4LL | #![feature(no_core)]
5 | ^
6 |
7 = help: the `-Zsanitizer` flag modifies the ABI so Rust crates compiled with different values of this flag cannot be used together safely
8 = note: `-Zsanitizer=kcfi` in this crate is incompatible with `-Zsanitizer=safestack,kcfi` in dependency `safestack_and_kcfi`
9 = help: set `-Zsanitizer=safestack,kcfi` in this crate or `-Zsanitizer=kcfi` in `safestack_and_kcfi`
10 = help: if you are sure this will not cause problems, you may use `-Cunsafe-allow-abi-mismatch=sanitizer` to silence this error
11
12error: aborting due to 1 previous error
13
tests/ui/target_modifiers/sanitizers-safestack-and-kcfi.rs created+23
......@@ -0,0 +1,23 @@
1//@ needs-sanitizer-kcfi
2//@ needs-sanitizer-safestack
3
4//@ aux-build:safestack-and-kcfi.rs
5//@ compile-flags: -Cpanic=abort
6
7//@ revisions: good good_reverted missed_safestack missed_kcfi missed_both
8//@[good] compile-flags: -Zsanitizer=safestack,kcfi
9//@[good_reverted] compile-flags: -Zsanitizer=kcfi,safestack
10//@[missed_safestack] compile-flags: -Zsanitizer=kcfi
11//@[missed_kcfi] compile-flags: -Zsanitizer=safestack
12// [missed_both] no additional compile-flags:
13//@[good] check-pass
14//@[good_reverted] check-pass
15
16#![feature(no_core)]
17//[missed_safestack]~^ ERROR mixing `-Zsanitizer` will cause an ABI mismatch in crate `sanitizers_safestack_and_kcfi`
18//[missed_kcfi]~^^ ERROR mixing `-Zsanitizer` will cause an ABI mismatch in crate `sanitizers_safestack_and_kcfi`
19//[missed_both]~^^^ ERROR mixing `-Zsanitizer` will cause an ABI mismatch in crate `sanitizers_safestack_and_kcfi`
20#![crate_type = "rlib"]
21#![no_core]
22
23extern crate safestack_and_kcfi;