From 9e2cc8aa3d98854f0802952288f160122b0e4ad2 Mon Sep 17 00:00:00 2001 From: Ramon de C Valle Date: Sat, 6 Apr 2024 14:07:49 -0700 Subject: [PATCH 1/4] sanitizers: Add support for stable sanitizers Add suppport for specifying stable sanitizers in addition to the existing supported sanitizers. --- compiler/rustc_codegen_llvm/src/abi.rs | 3 +- compiler/rustc_codegen_llvm/src/attributes.rs | 10 +-- compiler/rustc_codegen_ssa/src/back/link.rs | 10 +-- .../src/back/symbol_export.rs | 8 +-- compiler/rustc_codegen_ssa/src/back/write.rs | 2 +- compiler/rustc_interface/src/tests.rs | 2 +- compiler/rustc_session/messages.ftl | 12 ++-- compiler/rustc_session/src/config/cfg.rs | 2 +- compiler/rustc_session/src/options.rs | 29 +++----- compiler/rustc_session/src/session.rs | 54 +++++++++++--- compiler/rustc_target/src/spec/mod.rs | 71 ++++++++++++------- src/tools/compiletest/src/common.rs | 4 +- src/tools/compiletest/src/header/needs.rs | 14 ++-- .../address-sanitizer-globals-tracking.rs | 3 +- .../cfi/add-canonical-jump-tables-flag.rs | 2 +- .../cfi/add-enable-split-lto-unit-flag.rs | 2 +- .../cfi/emit-type-checks-attr-no-sanitize.rs | 2 +- .../codegen/sanitizer/cfi/emit-type-checks.rs | 2 +- .../emit-type-metadata-attr-cfi-encoding.rs | 2 +- ...adata-id-itanium-cxx-abi-const-generics.rs | 2 +- ...tadata-id-itanium-cxx-abi-drop-in-place.rs | 2 +- ...adata-id-itanium-cxx-abi-function-types.rs | 2 +- ...e-metadata-id-itanium-cxx-abi-lifetimes.rs | 2 +- ...itanium-cxx-abi-method-secondary-typeid.rs | 2 +- ...-type-metadata-id-itanium-cxx-abi-paths.rs | 2 +- ...tadata-id-itanium-cxx-abi-pointer-types.rs | 2 +- ...data-id-itanium-cxx-abi-primitive-types.rs | 2 +- ...-itanium-cxx-abi-repr-transparent-types.rs | 2 +- ...adata-id-itanium-cxx-abi-sequence-types.rs | 2 +- ...metadata-id-itanium-cxx-abi-trait-types.rs | 2 +- ...a-id-itanium-cxx-abi-user-defined-types.rs | 2 +- ...pe-metadata-itanium-cxx-abi-generalized.rs | 2 +- ...-itanium-cxx-abi-normalized-generalized.rs | 2 +- ...ype-metadata-itanium-cxx-abi-normalized.rs | 2 +- .../cfi/emit-type-metadata-itanium-cxx-abi.rs | 2 +- .../cfi/emit-type-metadata-trait-objects.rs | 2 +- .../sanitizer/cfi/generalize-pointers.rs | 2 +- .../sanitizer/cfi/normalize-integers.rs | 2 +- .../dataflow-instrument-functions.rs | 2 +- .../sanitizer/kasan-emits-instrumentation.rs | 4 +- tests/codegen/sanitizer/kcfi/add-kcfi-flag.rs | 2 +- ...it-kcfi-operand-bundle-attr-no-sanitize.rs | 2 +- ...rand-bundle-itanium-cxx-abi-generalized.rs | 2 +- ...-itanium-cxx-abi-normalized-generalized.rs | 2 +- ...erand-bundle-itanium-cxx-abi-normalized.rs | 2 +- ...mit-kcfi-operand-bundle-itanium-cxx-abi.rs | 2 +- .../kcfi/emit-kcfi-operand-bundle.rs | 2 +- .../kcfi/emit-type-metadata-trait-objects.rs | 2 +- .../codegen/sanitizer/memory-track-origins.rs | 2 +- tests/codegen/sanitizer/memtag-attr-check.rs | 2 +- .../codegen/sanitizer/no-sanitize-inlining.rs | 4 +- tests/codegen/sanitizer/no-sanitize.rs | 2 +- .../codegen/sanitizer/safestack-attr-check.rs | 2 +- tests/codegen/sanitizer/sanitizer-recover.rs | 14 ++-- tests/codegen/sanitizer/scs-attr-check.rs | 2 +- tests/rustdoc/sanitizer-option.rs | 18 ----- tests/ui/lto/issue-100772.rs | 2 +- tests/ui/sanitizer/badfree.rs | 2 +- tests/ui/sanitizer/cfg-kasan.rs | 4 +- tests/ui/sanitizer/cfg.rs | 16 ++--- .../cfi-assoc-ty-lifetime-issue-123053.rs | 2 +- tests/ui/sanitizer/cfi-async-closures.rs | 4 +- .../cfi-canonical-jump-tables-requires-cfi.rs | 2 +- ...-canonical-jump-tables-requires-cfi.stderr | 2 +- tests/ui/sanitizer/cfi-closures.rs | 4 +- tests/ui/sanitizer/cfi-complex-receiver.rs | 4 +- tests/ui/sanitizer/cfi-coroutine.rs | 4 +- tests/ui/sanitizer/cfi-drop-in-place.rs | 2 +- tests/ui/sanitizer/cfi-drop-no-principal.rs | 2 +- tests/ui/sanitizer/cfi-fn-ptr.rs | 4 +- .../cfi-generalize-pointers-attr-cfg.rs | 2 +- .../cfi-generalize-pointers-requires-cfi.rs | 4 +- ...fi-generalize-pointers-requires-cfi.stderr | 2 +- .../cfi-invalid-attr-cfi-encoding.rs | 2 +- ...i-is-incompatible-with-kcfi.aarch64.stderr | 2 +- .../cfi-is-incompatible-with-kcfi.rs | 4 +- ...fi-is-incompatible-with-kcfi.x86_64.stderr | 2 +- .../cfi-normalize-integers-attr-cfg.rs | 2 +- .../cfi-normalize-integers-requires-cfi.rs | 4 +- ...cfi-normalize-integers-requires-cfi.stderr | 2 +- tests/ui/sanitizer/cfi-requires-lto.rs | 4 +- tests/ui/sanitizer/cfi-requires-lto.stderr | 2 +- tests/ui/sanitizer/cfi-self-ref.rs | 4 +- tests/ui/sanitizer/cfi-sized-associated-ty.rs | 4 +- tests/ui/sanitizer/cfi-supertraits.rs | 4 +- tests/ui/sanitizer/cfi-virtual-auto.rs | 4 +- ...-rustc-lto-requires-single-codegen-unit.rs | 4 +- ...tc-lto-requires-single-codegen-unit.stderr | 2 +- tests/ui/sanitizer/crt-static.rs | 2 +- tests/ui/sanitizer/dataflow.rs | 2 +- tests/ui/sanitizer/incompatible.rs | 4 +- tests/ui/sanitizer/incompatible.stderr | 2 +- .../issue-111184-cfi-coroutine-witness.rs | 2 +- ...issue-114275-cfi-const-expr-in-arry-len.rs | 2 +- .../issue-72154-address-lifetime-markers.rs | 2 +- tests/ui/sanitizer/kcfi-mangling.rs | 2 +- tests/ui/sanitizer/leak.rs | 2 +- tests/ui/sanitizer/memory-eager.rs | 6 +- tests/ui/sanitizer/memory-passing.rs | 6 +- tests/ui/sanitizer/memory.rs | 6 +- .../new-llvm-pass-manager-thin-lto.rs | 2 +- tests/ui/sanitizer/thread.rs | 2 +- ...orted-can-be-used-with-unstable-options.rs | 10 +++ ...cannot-be-used-without-unstable-options.rs | 9 +++ ...ot-be-used-without-unstable-options.stderr | 4 ++ ...ed-cannot-be-used-with-unstable-options.rs | 9 +++ ...annot-be-used-with-unstable-options.stderr | 4 ++ ...cannot-be-used-without-unstable-options.rs | 9 +++ ...ot-be-used-without-unstable-options.stderr | 4 ++ tests/ui/sanitizer/unsupported-target.rs | 6 -- tests/ui/sanitizer/unsupported-target.stderr | 4 -- tests/ui/sanitizer/use-after-scope.rs | 2 +- 112 files changed, 310 insertions(+), 241 deletions(-) delete mode 100644 tests/rustdoc/sanitizer-option.rs create mode 100644 tests/ui/sanitizer/unstable-supported-can-be-used-with-unstable-options.rs create mode 100644 tests/ui/sanitizer/unstable-supported-cannot-be-used-without-unstable-options.rs create mode 100644 tests/ui/sanitizer/unstable-supported-cannot-be-used-without-unstable-options.stderr create mode 100644 tests/ui/sanitizer/unsupported-cannot-be-used-with-unstable-options.rs create mode 100644 tests/ui/sanitizer/unsupported-cannot-be-used-with-unstable-options.stderr create mode 100644 tests/ui/sanitizer/unsupported-cannot-be-used-without-unstable-options.rs create mode 100644 tests/ui/sanitizer/unsupported-cannot-be-used-without-unstable-options.stderr delete mode 100644 tests/ui/sanitizer/unsupported-target.rs delete mode 100644 tests/ui/sanitizer/unsupported-target.stderr diff --git a/compiler/rustc_codegen_llvm/src/abi.rs b/compiler/rustc_codegen_llvm/src/abi.rs index b8f4203126381..3f4b8453c22fb 100644 --- a/compiler/rustc_codegen_llvm/src/abi.rs +++ b/compiler/rustc_codegen_llvm/src/abi.rs @@ -13,7 +13,6 @@ use rustc_session::config; pub use rustc_target::abi::call::*; use rustc_target::abi::{self, HasDataLayout, Int, Size}; pub use rustc_target::spec::abi::Abi; -use rustc_target::spec::SanitizerSet; use smallvec::SmallVec; use crate::builder::Builder; @@ -81,7 +80,7 @@ fn get_attrs<'ll>(this: &ArgAttributes, cx: &CodegenCx<'ll, '_>) -> SmallVec<[&' attrs.push(llattr.create_attr(cx.llcx)); } } - } else if cx.tcx.sess.opts.unstable_opts.sanitizer.contains(SanitizerSet::MEMORY) { + } else if cx.tcx.sess.is_sanitizer_memory_enabled() { // If we're not optimising, *but* memory sanitizer is on, emit noundef, since it affects // memory sanitizer's behavior. diff --git a/compiler/rustc_codegen_llvm/src/attributes.rs b/compiler/rustc_codegen_llvm/src/attributes.rs index ad38814a68b6d..e3e84f9657819 100644 --- a/compiler/rustc_codegen_llvm/src/attributes.rs +++ b/compiler/rustc_codegen_llvm/src/attributes.rs @@ -85,7 +85,7 @@ pub fn sanitize_attrs<'ll>( no_sanitize: SanitizerSet, ) -> SmallVec<[&'ll Attribute; 4]> { let mut attrs = SmallVec::new(); - let enabled = cx.tcx.sess.opts.unstable_opts.sanitizer - no_sanitize; + let enabled = cx.tcx.sess.opts.cg.sanitize - no_sanitize; if enabled.contains(SanitizerSet::ADDRESS) || enabled.contains(SanitizerSet::KERNELADDRESS) { attrs.push(llvm::AttributeKind::SanitizeAddress.create_attr(cx.llcx)); } @@ -218,13 +218,7 @@ fn probestack_attr<'ll>(cx: &CodegenCx<'ll, '_>) -> Option<&'ll Attribute> { // Currently stack probes seem somewhat incompatible with the address // sanitizer and thread sanitizer. With asan we're already protected from // stack overflow anyway so we don't really need stack probes regardless. - if cx - .sess() - .opts - .unstable_opts - .sanitizer - .intersects(SanitizerSet::ADDRESS | SanitizerSet::THREAD) - { + if cx.sess().is_sanitizer_address_enabled() || cx.sess().is_sanitizer_thread_enabled() { return None; } diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index 45a92fd03d547..e1e371ba41775 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -1283,7 +1283,7 @@ fn add_sanitizer_libraries( return; } - let sanitizer = sess.opts.unstable_opts.sanitizer; + let sanitizer = sess.opts.cg.sanitize; if sanitizer.contains(SanitizerSet::ADDRESS) { link_sanitizer_runtime(sess, flavor, linker, "asan"); } @@ -2144,7 +2144,7 @@ fn add_library_search_dirs( if sess.target.vendor == "fortanix" || sess.target.os == "linux" || sess.target.os == "fuchsia" - || sess.target.is_like_osx && !sess.opts.unstable_opts.sanitizer.is_empty() + || sess.target.is_like_osx && !sess.opts.cg.sanitize.is_empty() { let lib_path = sess.target_filesearch(PathKind::Native).get_lib_path(); cmd.include_path(&fix_windows_verbatim_for_gcc(&lib_path)); @@ -2453,11 +2453,7 @@ fn add_order_independent_options( && crate_type == CrateType::Executable && !matches!(flavor, LinkerFlavor::Gnu(Cc::Yes, _)) { - let prefix = if sess.opts.unstable_opts.sanitizer.contains(SanitizerSet::ADDRESS) { - "asan/" - } else { - "" - }; + let prefix = if sess.is_sanitizer_address_enabled() { "asan/" } else { "" }; cmd.link_arg(format!("--dynamic-linker={prefix}ld.so.1")); } diff --git a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs index d2f11d48140c9..683549367f069 100644 --- a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs +++ b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs @@ -13,7 +13,7 @@ use rustc_middle::query::LocalCrate; use rustc_middle::ty::{self, GenericArgKind, GenericArgsRef, Instance, SymbolName, TyCtxt}; use rustc_middle::util::Providers; use rustc_session::config::{CrateType, OomStrategy}; -use rustc_target::spec::{SanitizerSet, TlsModel}; +use rustc_target::spec::TlsModel; use tracing::debug; use crate::base::allocator_kind_for_codegen; @@ -265,15 +265,15 @@ fn exported_symbols_provider_local( })); } - if tcx.sess.opts.unstable_opts.sanitizer.contains(SanitizerSet::MEMORY) { + if tcx.sess.is_sanitizer_memory_enabled() { let mut msan_weak_symbols = Vec::new(); // Similar to profiling, preserve weak msan symbol during LTO. - if tcx.sess.opts.unstable_opts.sanitizer_recover.contains(SanitizerSet::MEMORY) { + if tcx.sess.is_sanitizer_memory_recover_enabled() { msan_weak_symbols.push("__msan_keep_going"); } - if tcx.sess.opts.unstable_opts.sanitizer_memory_track_origins != 0 { + if tcx.sess.is_sanitizer_memory_track_origins_enabled() { msan_weak_symbols.push("__msan_track_origins"); } diff --git a/compiler/rustc_codegen_ssa/src/back/write.rs b/compiler/rustc_codegen_ssa/src/back/write.rs index bea12747a5199..e80bef6239981 100644 --- a/compiler/rustc_codegen_ssa/src/back/write.rs +++ b/compiler/rustc_codegen_ssa/src/back/write.rs @@ -196,7 +196,7 @@ impl ModuleConfig { false ), - sanitizer: if_regular!(sess.opts.unstable_opts.sanitizer, SanitizerSet::empty()), + sanitizer: if_regular!(sess.opts.cg.sanitize, SanitizerSet::empty()), sanitizer_dataflow_abilist: if_regular!( sess.opts.unstable_opts.sanitizer_dataflow_abilist.clone(), Vec::new() diff --git a/compiler/rustc_interface/src/tests.rs b/compiler/rustc_interface/src/tests.rs index ce3b2f77f210a..2e9614dbb064a 100644 --- a/compiler/rustc_interface/src/tests.rs +++ b/compiler/rustc_interface/src/tests.rs @@ -630,6 +630,7 @@ fn test_codegen_options_tracking_hash() { tracked!(profile_use, Some(PathBuf::from("abc"))); tracked!(relocation_model, Some(RelocModel::Pic)); tracked!(relro_level, Some(RelroLevel::Full)); + tracked!(sanitize, SanitizerSet::ADDRESS); tracked!(soft_float, true); tracked!(split_debuginfo, Some(SplitDebuginfo::Packed)); tracked!(symbol_mangling_version, Some(SymbolManglingVersion::V0)); @@ -831,7 +832,6 @@ fn test_unstable_options_tracking_hash() { tracked!(profiler_runtime, "abc".to_string()); tracked!(relax_elf_relocations, Some(true)); tracked!(remap_cwd_prefix, Some(PathBuf::from("abc"))); - tracked!(sanitizer, SanitizerSet::ADDRESS); tracked!(sanitizer_cfi_canonical_jump_tables, None); tracked!(sanitizer_cfi_generalize_pointers, Some(true)); tracked!(sanitizer_cfi_normalize_integers, Some(true)); diff --git a/compiler/rustc_session/messages.ftl b/compiler/rustc_session/messages.ftl index b84280a3ccf3f..e6e513358d1c7 100644 --- a/compiler/rustc_session/messages.ftl +++ b/compiler/rustc_session/messages.ftl @@ -3,7 +3,7 @@ session_branch_protection_requires_aarch64 = `-Zbranch-protection` is only suppo session_cannot_enable_crt_static_linux = sanitizer is incompatible with statically linked libc, disable it using `-C target-feature=-crt-static` -session_cannot_mix_and_match_sanitizers = `-Zsanitizer={$first}` is incompatible with `-Zsanitizer={$second}` +session_cannot_mix_and_match_sanitizers = `-Csanitize={$first}` is incompatible with `-Csanitize={$second}` session_cli_feature_diagnostic_help = add `-Zcrate-attr="feature({$feature})"` to the command-line options to enable @@ -86,15 +86,15 @@ session_profile_sample_use_file_does_not_exist = file `{$path}` passed to `-C pr session_profile_use_file_does_not_exist = file `{$path}` passed to `-C profile-use` does not exist -session_sanitizer_cfi_canonical_jump_tables_requires_cfi = `-Zsanitizer-cfi-canonical-jump-tables` requires `-Zsanitizer=cfi` +session_sanitizer_cfi_canonical_jump_tables_requires_cfi = `-Zsanitizer-cfi-canonical-jump-tables` requires `-Csanitize=cfi` -session_sanitizer_cfi_generalize_pointers_requires_cfi = `-Zsanitizer-cfi-generalize-pointers` requires `-Zsanitizer=cfi` or `-Zsanitizer=kcfi` +session_sanitizer_cfi_generalize_pointers_requires_cfi = `-Zsanitizer-cfi-generalize-pointers` requires `-Csanitize=cfi` or `-Csanitize=kcfi` -session_sanitizer_cfi_normalize_integers_requires_cfi = `-Zsanitizer-cfi-normalize-integers` requires `-Zsanitizer=cfi` or `-Zsanitizer=kcfi` +session_sanitizer_cfi_normalize_integers_requires_cfi = `-Zsanitizer-cfi-normalize-integers` requires `-Csanitize=cfi` or `-Csanitize=kcfi` -session_sanitizer_cfi_requires_lto = `-Zsanitizer=cfi` requires `-Clto` or `-Clinker-plugin-lto` +session_sanitizer_cfi_requires_lto = `-Csanitize=cfi` requires `-Clto` or `-Clinker-plugin-lto` -session_sanitizer_cfi_requires_single_codegen_unit = `-Zsanitizer=cfi` with `-Clto` requires `-Ccodegen-units=1` +session_sanitizer_cfi_requires_single_codegen_unit = `-Csanitize=cfi` with `-Clto` requires `-Ccodegen-units=1` session_sanitizer_kcfi_requires_panic_abort = `-Z sanitizer=kcfi` requires `-C panic=abort` diff --git a/compiler/rustc_session/src/config/cfg.rs b/compiler/rustc_session/src/config/cfg.rs index 4109ebb6d340a..232d36981feaf 100644 --- a/compiler/rustc_session/src/config/cfg.rs +++ b/compiler/rustc_session/src/config/cfg.rs @@ -130,7 +130,7 @@ pub(crate) fn default_configuration(sess: &Session) -> Cfg { ins_sym!(sym::relocation_model, sess.target.relocation_model.desc_symbol()); } - for mut s in sess.opts.unstable_opts.sanitizer { + for mut s in sess.opts.cg.sanitize { // KASAN is still ASAN under the hood, so it uses the same attribute. if s == SanitizerSet::KERNELADDRESS { s = SanitizerSet::ADDRESS; diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index bf54aae1cfeb0..7c8b48a7dab49 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -783,25 +783,14 @@ mod parse { } pub(crate) fn parse_sanitizers(slot: &mut SanitizerSet, v: Option<&str>) -> bool { - if let Some(v) = v { - for s in v.split(',') { - *slot |= match s { - "address" => SanitizerSet::ADDRESS, - "cfi" => SanitizerSet::CFI, - "dataflow" => SanitizerSet::DATAFLOW, - "kcfi" => SanitizerSet::KCFI, - "kernel-address" => SanitizerSet::KERNELADDRESS, - "leak" => SanitizerSet::LEAK, - "memory" => SanitizerSet::MEMORY, - "memtag" => SanitizerSet::MEMTAG, - "shadow-call-stack" => SanitizerSet::SHADOWCALLSTACK, - "thread" => SanitizerSet::THREAD, - "hwaddress" => SanitizerSet::HWADDRESS, - "safestack" => SanitizerSet::SAFESTACK, - _ => return false, - } + if let Some(s) = v { + let sanitizer_set = SanitizerSet::from_comma_list(s); + if sanitizer_set.is_ok() { + *slot |= sanitizer_set.unwrap(); + true + } else { + false } - true } else { false } @@ -1595,6 +1584,8 @@ options! { "output remarks for these optimization passes (space separated, or \"all\")"), rpath: bool = (false, parse_bool, [UNTRACKED], "set rpath values in libs/exes (default: no)"), + sanitize: SanitizerSet = (SanitizerSet::empty(), parse_sanitizers, [TRACKED], + "use one or multiple sanitizers"), save_temps: bool = (false, parse_bool, [UNTRACKED], "save all temporary output files during compilation (default: no)"), soft_float: bool = (false, parse_bool, [TRACKED], @@ -1953,8 +1944,6 @@ options! { remark_dir: Option = (None, parse_opt_pathbuf, [UNTRACKED], "directory into which to write optimization remarks (if not specified, they will be \ written to standard error output)"), - sanitizer: SanitizerSet = (SanitizerSet::empty(), parse_sanitizers, [TRACKED], - "use a sanitizer"), sanitizer_cfi_canonical_jump_tables: Option = (Some(true), parse_opt_bool, [TRACKED], "enable canonical jump tables (default: yes)"), sanitizer_cfi_generalize_pointers: Option = (None, parse_opt_bool, [TRACKED], diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index be67baf57f6dc..4b3470ba8f59c 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -366,8 +366,12 @@ impl Session { self.opts.unstable_opts.coverage_options.no_mir_spans } + pub fn is_sanitizer_address_enabled(&self) -> bool { + self.opts.cg.sanitize.contains(SanitizerSet::ADDRESS) + } + pub fn is_sanitizer_cfi_enabled(&self) -> bool { - self.opts.unstable_opts.sanitizer.contains(SanitizerSet::CFI) + self.opts.cg.sanitize.contains(SanitizerSet::CFI) } pub fn is_sanitizer_cfi_canonical_jump_tables_disabled(&self) -> bool { @@ -386,8 +390,32 @@ impl Session { self.opts.unstable_opts.sanitizer_cfi_normalize_integers == Some(true) } + pub fn is_sanitizer_hwaddress_enabled(&self) -> bool { + self.opts.cg.sanitize.contains(SanitizerSet::HWADDRESS) + } + pub fn is_sanitizer_kcfi_enabled(&self) -> bool { - self.opts.unstable_opts.sanitizer.contains(SanitizerSet::KCFI) + self.opts.cg.sanitize.contains(SanitizerSet::KCFI) + } + + pub fn is_sanitizer_kernel_address_enabled(&self) -> bool { + self.opts.cg.sanitize.contains(SanitizerSet::KERNELADDRESS) + } + + pub fn is_sanitizer_memory_enabled(&self) -> bool { + self.opts.cg.sanitize.contains(SanitizerSet::MEMORY) + } + + pub fn is_sanitizer_memory_recover_enabled(&self) -> bool { + self.opts.unstable_opts.sanitizer_recover.contains(SanitizerSet::MEMORY) + } + + pub fn is_sanitizer_memory_track_origins_enabled(&self) -> bool { + self.opts.unstable_opts.sanitizer_memory_track_origins != 0 + } + + pub fn is_sanitizer_thread_enabled(&self) -> bool { + self.opts.cg.sanitize.contains(SanitizerSet::THREAD) } pub fn is_split_lto_unit_enabled(&self) -> bool { @@ -614,7 +642,10 @@ impl Session { // AddressSanitizer and KernelAddressSanitizer uses lifetimes to detect use after scope bugs. // MemorySanitizer uses lifetimes to detect use of uninitialized stack variables. // HWAddressSanitizer will use lifetimes to detect use after scope bugs in the future. - || self.opts.unstable_opts.sanitizer.intersects(SanitizerSet::ADDRESS | SanitizerSet::KERNELADDRESS | SanitizerSet::MEMORY | SanitizerSet::HWADDRESS) + || self.is_sanitizer_address_enabled() + || self.is_sanitizer_kernel_address_enabled() + || self.is_sanitizer_memory_enabled() + || self.is_sanitizer_hwaddress_enabled() } pub fn diagnostic_width(&self) -> usize { @@ -741,7 +772,7 @@ impl Session { let more_names = self.opts.output_types.contains_key(&OutputType::LlvmAssembly) || self.opts.output_types.contains_key(&OutputType::Bitcode) // AddressSanitizer and MemorySanitizer use alloca name when reporting an issue. - || self.opts.unstable_opts.sanitizer.intersects(SanitizerSet::ADDRESS | SanitizerSet::MEMORY); + || self.is_sanitizer_address_enabled() || self.is_sanitizer_memory_enabled(); !more_names } } @@ -1186,8 +1217,12 @@ fn validate_commandline_args_with_session_available(sess: &Session) { } // Sanitizers can only be used on platforms that we know have working sanitizer codegen. - let supported_sanitizers = sess.target.options.supported_sanitizers; - let unsupported_sanitizers = sess.opts.unstable_opts.sanitizer - supported_sanitizers; + let supported_sanitizers = if sess.unstable_options() { + sess.target.options.supported_sanitizers | sess.target.options.stable_sanitizers + } else { + sess.target.options.stable_sanitizers + }; + let unsupported_sanitizers = sess.opts.cg.sanitize - supported_sanitizers; match unsupported_sanitizers.into_iter().count() { 0 => {} 1 => { @@ -1202,7 +1237,7 @@ fn validate_commandline_args_with_session_available(sess: &Session) { } // Cannot mix and match mutually-exclusive sanitizers. - if let Some((first, second)) = sess.opts.unstable_opts.sanitizer.mutually_exclusive() { + if let Some((first, second)) = sess.opts.cg.sanitize.mutually_exclusive() { sess.dcx().emit_err(errors::CannotMixAndMatchSanitizers { first: first.to_string(), second: second.to_string(), @@ -1210,10 +1245,7 @@ fn validate_commandline_args_with_session_available(sess: &Session) { } // Cannot enable crt-static with sanitizers on Linux - if sess.crt_static(None) - && !sess.opts.unstable_opts.sanitizer.is_empty() - && !sess.target.is_like_msvc - { + if sess.crt_static(None) && !sess.opts.cg.sanitize.is_empty() && !sess.target.is_like_msvc { sess.dcx().emit_err(errors::CannotEnableCrtStaticLinux); } diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index 946947124c6eb..20b09542870aa 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -1369,6 +1369,37 @@ impl SanitizerSet { }) } + pub fn from_comma_list(s: &str) -> Result { + let mut sanitizer_set = SanitizerSet::empty(); + for name in s.split(',') { + sanitizer_set |= match name { + "address" => SanitizerSet::ADDRESS, + "cfi" => SanitizerSet::CFI, + "dataflow" => SanitizerSet::DATAFLOW, + "kcfi" => SanitizerSet::KCFI, + "kernel-address" => SanitizerSet::KERNELADDRESS, + "leak" => SanitizerSet::LEAK, + "memory" => SanitizerSet::MEMORY, + "memtag" => SanitizerSet::MEMTAG, + "safestack" => SanitizerSet::SAFESTACK, + "shadow-call-stack" => SanitizerSet::SHADOWCALLSTACK, + "thread" => SanitizerSet::THREAD, + "hwaddress" => SanitizerSet::HWADDRESS, + _ => return Err(format!("Unknown sanitizer {}", name)), + }; + } + return Ok(sanitizer_set); + } + + fn from_json(json: &Json) -> Result { + if let Some(array) = json.as_array() { + let s: String = array.iter().filter_map(|v| v.as_str()).collect::>().join(","); + return Self::from_comma_list(&s); + } else { + return Err("Expected a list of sanitizers".to_string()); + } + } + pub fn mutually_exclusive(self) -> Option<(SanitizerSet, SanitizerSet)> { Self::MUTUALLY_EXCLUSIVE .into_iter() @@ -2363,6 +2394,9 @@ pub struct TargetOptions { /// distributed with the target, the sanitizer should still appear in this list for the target. pub supported_sanitizers: SanitizerSet, + /// The stable sanitizers supported by this target + pub stable_sanitizers: SanitizerSet, + /// Minimum number of bits in #[repr(C)] enum. Defaults to the size of c_int pub c_enum_min_bits: Option, @@ -2594,6 +2628,7 @@ impl Default for TargetOptions { // `Off` is supported by default, but targets can remove this manually, e.g. Windows. supported_split_debuginfo: Cow::Borrowed(&[SplitDebuginfo::Off]), supported_sanitizers: SanitizerSet::empty(), + stable_sanitizers: SanitizerSet::empty(), c_enum_min_bits: None, generate_arange_section: true, supports_stack_protector: true, @@ -3015,31 +3050,15 @@ impl Target { } ); ($key_name:ident, SanitizerSet) => ( { let name = (stringify!($key_name)).replace("_", "-"); - if let Some(o) = obj.remove(&name) { - if let Some(a) = o.as_array() { - for s in a { - base.$key_name |= match s.as_str() { - Some("address") => SanitizerSet::ADDRESS, - Some("cfi") => SanitizerSet::CFI, - Some("dataflow") => SanitizerSet::DATAFLOW, - Some("kcfi") => SanitizerSet::KCFI, - Some("kernel-address") => SanitizerSet::KERNELADDRESS, - Some("leak") => SanitizerSet::LEAK, - Some("memory") => SanitizerSet::MEMORY, - Some("memtag") => SanitizerSet::MEMTAG, - Some("safestack") => SanitizerSet::SAFESTACK, - Some("shadow-call-stack") => SanitizerSet::SHADOWCALLSTACK, - Some("thread") => SanitizerSet::THREAD, - Some("hwaddress") => SanitizerSet::HWADDRESS, - Some(s) => return Err(format!("unknown sanitizer {}", s)), - _ => return Err(format!("not a string: {:?}", s)), - }; - } - } else { - incorrect_type.push(name) - } - } - Ok::<(), String>(()) + obj.remove(&name).and_then(|o| match SanitizerSet::from_json(&o) { + Ok(v) => { + base.$key_name = v; + Some(Ok(())) + }, + Err(s) => Some(Err( + format!("`{:?}` is not a valid value for `{}`: {}", o, name, s) + )), + }).unwrap_or(Ok(())) } ); ($key_name:ident, link_self_contained_components) => ( { // Skeleton of what needs to be parsed: @@ -3311,6 +3330,7 @@ impl Target { key!(split_debuginfo, SplitDebuginfo)?; key!(supported_split_debuginfo, fallible_list)?; key!(supported_sanitizers, SanitizerSet)?; + key!(stable_sanitizers, SanitizerSet)?; key!(generate_arange_section, bool); key!(supports_stack_protector, bool); key!(entry_name); @@ -3566,6 +3586,7 @@ impl ToJson for Target { target_option_val!(split_debuginfo); target_option_val!(supported_split_debuginfo); target_option_val!(supported_sanitizers); + target_option_val!(stable_sanitizers); target_option_val!(c_enum_min_bits); target_option_val!(generate_arange_section); target_option_val!(supports_stack_protector); diff --git a/src/tools/compiletest/src/common.rs b/src/tools/compiletest/src/common.rs index 70ebefe3f417f..54b64d41c063e 100644 --- a/src/tools/compiletest/src/common.rs +++ b/src/tools/compiletest/src/common.rs @@ -622,7 +622,9 @@ pub struct TargetCfg { #[serde(default)] pub(crate) dynamic_linking: bool, #[serde(rename = "supported-sanitizers", default)] - pub(crate) sanitizers: Vec, + pub(crate) supported_sanitizers: Vec, + #[serde(rename = "stable-sanitizers", default)] + pub(crate) stable_sanitizers: Vec, #[serde(rename = "supports-xray", default)] pub(crate) xray: bool, #[serde(default = "default_reloc_model")] diff --git a/src/tools/compiletest/src/header/needs.rs b/src/tools/compiletest/src/header/needs.rs index 5b2665f7d0ba7..6dfcdf55ccaa1 100644 --- a/src/tools/compiletest/src/header/needs.rs +++ b/src/tools/compiletest/src/header/needs.rs @@ -40,8 +40,8 @@ pub(super) fn handle_needs( ignore_reason: "ignored on targets without kernel CFI sanitizer", }, Need { - name: "needs-sanitizer-kasan", - condition: cache.sanitizer_kasan, + name: "needs-sanitizer-kernel-address", + condition: cache.sanitizer_kernel_address, ignore_reason: "ignored on targets without kernel address sanitizer", }, Need { @@ -202,7 +202,7 @@ pub(super) struct CachedNeedsConditions { sanitizer_cfi: bool, sanitizer_dataflow: bool, sanitizer_kcfi: bool, - sanitizer_kasan: bool, + sanitizer_kernel_address: bool, sanitizer_leak: bool, sanitizer_memory: bool, sanitizer_thread: bool, @@ -220,14 +220,18 @@ pub(super) struct CachedNeedsConditions { impl CachedNeedsConditions { pub(super) fn load(config: &Config) -> Self { let target = &&*config.target; - let sanitizers = &config.target_cfg().sanitizers; + let sanitizers = [ + config.target_cfg().supported_sanitizers.clone(), + config.target_cfg().stable_sanitizers.clone(), + ] + .concat(); Self { sanitizer_support: std::env::var_os("RUSTC_SANITIZER_SUPPORT").is_some(), sanitizer_address: sanitizers.contains(&Sanitizer::Address), sanitizer_cfi: sanitizers.contains(&Sanitizer::Cfi), sanitizer_dataflow: sanitizers.contains(&Sanitizer::Dataflow), sanitizer_kcfi: sanitizers.contains(&Sanitizer::Kcfi), - sanitizer_kasan: sanitizers.contains(&Sanitizer::KernelAddress), + sanitizer_kernel_address: sanitizers.contains(&Sanitizer::KernelAddress), sanitizer_leak: sanitizers.contains(&Sanitizer::Leak), sanitizer_memory: sanitizers.contains(&Sanitizer::Memory), sanitizer_thread: sanitizers.contains(&Sanitizer::Thread), diff --git a/tests/codegen/sanitizer/address-sanitizer-globals-tracking.rs b/tests/codegen/sanitizer/address-sanitizer-globals-tracking.rs index f319306f93fd8..6f1717fa0c70a 100644 --- a/tests/codegen/sanitizer/address-sanitizer-globals-tracking.rs +++ b/tests/codegen/sanitizer/address-sanitizer-globals-tracking.rs @@ -19,7 +19,8 @@ //@ only-linux // //@ revisions:ASAN ASAN-FAT-LTO -//@ compile-flags: -Zsanitizer=address -Ctarget-feature=-crt-static +//@ compile-flags: -Zunstable-options -Csanitize=address +//@ compile-flags: -Ctarget-feature=-crt-static //@[ASAN] compile-flags: //@[ASAN-FAT-LTO] compile-flags: -Cprefer-dynamic=false -Clto=fat diff --git a/tests/codegen/sanitizer/cfi/add-canonical-jump-tables-flag.rs b/tests/codegen/sanitizer/cfi/add-canonical-jump-tables-flag.rs index 22577e2a3c46b..2e74f96dbb58f 100644 --- a/tests/codegen/sanitizer/cfi/add-canonical-jump-tables-flag.rs +++ b/tests/codegen/sanitizer/cfi/add-canonical-jump-tables-flag.rs @@ -1,7 +1,7 @@ // Verifies that "CFI Canonical Jump Tables" module flag is added. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi +//@ compile-flags: -Clto -Ctarget-feature=-crt-static -Zunstable-options -Csanitize=cfi #![crate_type = "lib"] diff --git a/tests/codegen/sanitizer/cfi/add-enable-split-lto-unit-flag.rs b/tests/codegen/sanitizer/cfi/add-enable-split-lto-unit-flag.rs index 283b8f2610294..a11879c689b9b 100644 --- a/tests/codegen/sanitizer/cfi/add-enable-split-lto-unit-flag.rs +++ b/tests/codegen/sanitizer/cfi/add-enable-split-lto-unit-flag.rs @@ -1,7 +1,7 @@ // Verifies that "EnableSplitLTOUnit" module flag is added. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi +//@ compile-flags: -Clto -Ctarget-feature=-crt-static -Zunstable-options -Csanitize=cfi #![crate_type = "lib"] diff --git a/tests/codegen/sanitizer/cfi/emit-type-checks-attr-no-sanitize.rs b/tests/codegen/sanitizer/cfi/emit-type-checks-attr-no-sanitize.rs index 259967e89181a..7b50ee77679da 100644 --- a/tests/codegen/sanitizer/cfi/emit-type-checks-attr-no-sanitize.rs +++ b/tests/codegen/sanitizer/cfi/emit-type-checks-attr-no-sanitize.rs @@ -1,7 +1,7 @@ // Verifies that pointer type membership tests for indirect calls are omitted. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Copt-level=0 +//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zunstable-options -Csanitize=cfi -Copt-level=0 #![crate_type = "lib"] #![feature(no_sanitize)] diff --git a/tests/codegen/sanitizer/cfi/emit-type-checks.rs b/tests/codegen/sanitizer/cfi/emit-type-checks.rs index 37edbefee56ad..7f0801df2db7c 100644 --- a/tests/codegen/sanitizer/cfi/emit-type-checks.rs +++ b/tests/codegen/sanitizer/cfi/emit-type-checks.rs @@ -1,7 +1,7 @@ // Verifies that pointer type membership tests for indirect calls are emitted. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Copt-level=0 +//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zunstable-options -Csanitize=cfi -Copt-level=0 #![crate_type = "lib"] diff --git a/tests/codegen/sanitizer/cfi/emit-type-metadata-attr-cfi-encoding.rs b/tests/codegen/sanitizer/cfi/emit-type-metadata-attr-cfi-encoding.rs index 9bc2e42db0f61..0a992cdda502c 100644 --- a/tests/codegen/sanitizer/cfi/emit-type-metadata-attr-cfi-encoding.rs +++ b/tests/codegen/sanitizer/cfi/emit-type-metadata-attr-cfi-encoding.rs @@ -1,7 +1,7 @@ // Verifies that user-defined CFI encoding for types are emitted. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Copt-level=0 +//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zunstable-options -Csanitize=cfi -Copt-level=0 #![crate_type = "lib"] #![feature(cfi_encoding, extern_types)] diff --git a/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-const-generics.rs b/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-const-generics.rs index 3edc68e134740..f3f95af439bd9 100644 --- a/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-const-generics.rs +++ b/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-const-generics.rs @@ -2,7 +2,7 @@ // for const generics. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Copt-level=0 +//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zunstable-options -Csanitize=cfi -Copt-level=0 #![crate_type = "lib"] #![feature(type_alias_impl_trait)] diff --git a/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-drop-in-place.rs b/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-drop-in-place.rs index 2a7eca6fc1963..716062c94dc60 100644 --- a/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-drop-in-place.rs +++ b/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-drop-in-place.rs @@ -1,7 +1,7 @@ // Verifies that type metadata identifiers for drop functions are emitted correctly. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static +//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zunstable-options -Csanitize=cfi -Ctarget-feature=-crt-static #![crate_type = "lib"] diff --git a/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-function-types.rs b/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-function-types.rs index 7e60aafff6802..c8e72ab806fe2 100644 --- a/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-function-types.rs +++ b/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-function-types.rs @@ -2,7 +2,7 @@ // for function types. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static +//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zunstable-options -Csanitize=cfi -Ctarget-feature=-crt-static #![crate_type = "lib"] diff --git a/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-lifetimes.rs b/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-lifetimes.rs index 09cfd2e10d6e7..f35a60f641ce6 100644 --- a/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-lifetimes.rs +++ b/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-lifetimes.rs @@ -2,7 +2,7 @@ // for lifetimes/regions. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Copt-level=0 +//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zunstable-options -Csanitize=cfi -Copt-level=0 #![crate_type = "lib"] #![feature(type_alias_impl_trait)] diff --git a/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-method-secondary-typeid.rs b/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-method-secondary-typeid.rs index 9d611777ff0ba..7b88d9956da7c 100644 --- a/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-method-secondary-typeid.rs +++ b/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-method-secondary-typeid.rs @@ -2,7 +2,7 @@ // self so they can be used as function pointers. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static +//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zunstable-options -Csanitize=cfi -Ctarget-feature=-crt-static #![crate_type = "lib"] diff --git a/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-paths.rs b/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-paths.rs index ffbfe021ba3eb..c3878d8ae6539 100644 --- a/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-paths.rs +++ b/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-paths.rs @@ -2,7 +2,7 @@ // for paths. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static +//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zunstable-options -Csanitize=cfi -Ctarget-feature=-crt-static #![crate_type = "lib"] #![feature(type_alias_impl_trait)] diff --git a/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-pointer-types.rs b/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-pointer-types.rs index d37bb740f5505..42d717f8ae5cd 100644 --- a/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-pointer-types.rs +++ b/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-pointer-types.rs @@ -2,7 +2,7 @@ // for pointer types. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static +//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zunstable-options -Csanitize=cfi -Ctarget-feature=-crt-static #![crate_type = "lib"] diff --git a/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-primitive-types.rs b/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-primitive-types.rs index 7d9e4d0587276..fe00a9738a0e5 100644 --- a/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-primitive-types.rs +++ b/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-primitive-types.rs @@ -2,7 +2,7 @@ // for primitive types. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static +//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zunstable-options -Csanitize=cfi -Ctarget-feature=-crt-static #![crate_type = "lib"] diff --git a/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-repr-transparent-types.rs b/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-repr-transparent-types.rs index 0f97c70f3f923..f35a72739fc2b 100644 --- a/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-repr-transparent-types.rs +++ b/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-repr-transparent-types.rs @@ -2,7 +2,7 @@ // for repr transparent types. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static +//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zunstable-options -Csanitize=cfi -Ctarget-feature=-crt-static #![crate_type = "lib"] diff --git a/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-sequence-types.rs b/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-sequence-types.rs index bdee3f47a837d..ac7dbc3ed4b3a 100644 --- a/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-sequence-types.rs +++ b/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-sequence-types.rs @@ -2,7 +2,7 @@ // for sequence types. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static +//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zunstable-options -Csanitize=cfi -Ctarget-feature=-crt-static #![crate_type = "lib"] diff --git a/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-trait-types.rs b/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-trait-types.rs index 55e816178f8fc..36d0ff8b8746d 100644 --- a/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-trait-types.rs +++ b/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-trait-types.rs @@ -2,7 +2,7 @@ // for trait types. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static +//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zunstable-options -Csanitize=cfi -Ctarget-feature=-crt-static #![crate_type = "lib"] diff --git a/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-user-defined-types.rs b/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-user-defined-types.rs index c1f3ca61afeb1..1a0d370f2a056 100644 --- a/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-user-defined-types.rs +++ b/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-user-defined-types.rs @@ -2,7 +2,7 @@ // for user-defined types. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static +//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zunstable-options -Csanitize=cfi -Ctarget-feature=-crt-static #![crate_type = "lib"] #![feature(extern_types)] diff --git a/tests/codegen/sanitizer/cfi/emit-type-metadata-itanium-cxx-abi-generalized.rs b/tests/codegen/sanitizer/cfi/emit-type-metadata-itanium-cxx-abi-generalized.rs index 32637b64b3ea8..ac540445fd329 100644 --- a/tests/codegen/sanitizer/cfi/emit-type-metadata-itanium-cxx-abi-generalized.rs +++ b/tests/codegen/sanitizer/cfi/emit-type-metadata-itanium-cxx-abi-generalized.rs @@ -1,7 +1,7 @@ // Verifies that generalized type metadata for functions are emitted. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-generalize-pointers +//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zunstable-options -Csanitize=cfi -Zsanitizer-cfi-generalize-pointers #![crate_type = "lib"] diff --git a/tests/codegen/sanitizer/cfi/emit-type-metadata-itanium-cxx-abi-normalized-generalized.rs b/tests/codegen/sanitizer/cfi/emit-type-metadata-itanium-cxx-abi-normalized-generalized.rs index 51121b0aef1aa..751c09c1b64c8 100644 --- a/tests/codegen/sanitizer/cfi/emit-type-metadata-itanium-cxx-abi-normalized-generalized.rs +++ b/tests/codegen/sanitizer/cfi/emit-type-metadata-itanium-cxx-abi-normalized-generalized.rs @@ -1,7 +1,7 @@ // Verifies that normalized and generalized type metadata for functions are emitted. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-normalize-integers -Zsanitizer-cfi-generalize-pointers +//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zunstable-options -Csanitize=cfi -Zsanitizer-cfi-normalize-integers -Zsanitizer-cfi-generalize-pointers #![crate_type = "lib"] diff --git a/tests/codegen/sanitizer/cfi/emit-type-metadata-itanium-cxx-abi-normalized.rs b/tests/codegen/sanitizer/cfi/emit-type-metadata-itanium-cxx-abi-normalized.rs index 1cfdd23006e3a..a59e652494787 100644 --- a/tests/codegen/sanitizer/cfi/emit-type-metadata-itanium-cxx-abi-normalized.rs +++ b/tests/codegen/sanitizer/cfi/emit-type-metadata-itanium-cxx-abi-normalized.rs @@ -1,7 +1,7 @@ // Verifies that normalized type metadata for functions are emitted. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-normalize-integers +//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zunstable-options -Csanitize=cfi -Zsanitizer-cfi-normalize-integers #![crate_type = "lib"] diff --git a/tests/codegen/sanitizer/cfi/emit-type-metadata-itanium-cxx-abi.rs b/tests/codegen/sanitizer/cfi/emit-type-metadata-itanium-cxx-abi.rs index 56ab1ce4b3582..a813a12827c0d 100644 --- a/tests/codegen/sanitizer/cfi/emit-type-metadata-itanium-cxx-abi.rs +++ b/tests/codegen/sanitizer/cfi/emit-type-metadata-itanium-cxx-abi.rs @@ -1,7 +1,7 @@ // Verifies that type metadata for functions are emitted. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi +//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zunstable-options -Csanitize=cfi #![crate_type = "lib"] diff --git a/tests/codegen/sanitizer/cfi/emit-type-metadata-trait-objects.rs b/tests/codegen/sanitizer/cfi/emit-type-metadata-trait-objects.rs index 0e57ce322d127..02b1323e282bc 100644 --- a/tests/codegen/sanitizer/cfi/emit-type-metadata-trait-objects.rs +++ b/tests/codegen/sanitizer/cfi/emit-type-metadata-trait-objects.rs @@ -1,7 +1,7 @@ // Verifies that type metadata identifiers for trait objects are emitted correctly. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Ctarget-feature=-crt-static -Zsanitizer=cfi +//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Ctarget-feature=-crt-static -Zunstable-options -Csanitize=cfi #![crate_type = "lib"] diff --git a/tests/codegen/sanitizer/cfi/generalize-pointers.rs b/tests/codegen/sanitizer/cfi/generalize-pointers.rs index 57004da6f8e06..0069632c46bf0 100644 --- a/tests/codegen/sanitizer/cfi/generalize-pointers.rs +++ b/tests/codegen/sanitizer/cfi/generalize-pointers.rs @@ -1,7 +1,7 @@ // Verifies that pointer types are generalized. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-generalize-pointers -Copt-level=0 +//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zunstable-options -Csanitize=cfi -Zsanitizer-cfi-generalize-pointers -Copt-level=0 #![crate_type = "lib"] diff --git a/tests/codegen/sanitizer/cfi/normalize-integers.rs b/tests/codegen/sanitizer/cfi/normalize-integers.rs index 770ee4e64e089..8f812e17e85f6 100644 --- a/tests/codegen/sanitizer/cfi/normalize-integers.rs +++ b/tests/codegen/sanitizer/cfi/normalize-integers.rs @@ -1,7 +1,7 @@ // Verifies that integer types are normalized. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-normalize-integers -Copt-level=0 +//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zunstable-options -Csanitize=cfi -Zsanitizer-cfi-normalize-integers -Copt-level=0 #![crate_type = "lib"] diff --git a/tests/codegen/sanitizer/dataflow-instrument-functions.rs b/tests/codegen/sanitizer/dataflow-instrument-functions.rs index a2d0d63cc1754..550d2160c55de 100644 --- a/tests/codegen/sanitizer/dataflow-instrument-functions.rs +++ b/tests/codegen/sanitizer/dataflow-instrument-functions.rs @@ -1,7 +1,7 @@ // Verifies that functions are instrumented. // //@ needs-sanitizer-dataflow -//@ compile-flags: -Copt-level=0 -Zsanitizer=dataflow +//@ compile-flags: -Copt-level=0 -Zunstable-options -Csanitize=dataflow #![crate_type = "lib"] diff --git a/tests/codegen/sanitizer/kasan-emits-instrumentation.rs b/tests/codegen/sanitizer/kasan-emits-instrumentation.rs index 56ee875286a22..c2568049b10e9 100644 --- a/tests/codegen/sanitizer/kasan-emits-instrumentation.rs +++ b/tests/codegen/sanitizer/kasan-emits-instrumentation.rs @@ -1,6 +1,6 @@ -// Verifies that `-Zsanitizer=kernel-address` emits sanitizer instrumentation. +// Verifies that `-Csanitize=kernel-address` emits sanitizer instrumentation. -//@ compile-flags: -Zsanitizer=kernel-address -Copt-level=0 +//@ compile-flags: -Zunstable-options -Csanitize=kernel-address -Copt-level=0 //@ revisions: aarch64 riscv64imac riscv64gc x86_64 //@[aarch64] compile-flags: --target aarch64-unknown-none //@[aarch64] needs-llvm-components: aarch64 diff --git a/tests/codegen/sanitizer/kcfi/add-kcfi-flag.rs b/tests/codegen/sanitizer/kcfi/add-kcfi-flag.rs index 013de74f8d689..2d253739cf8fd 100644 --- a/tests/codegen/sanitizer/kcfi/add-kcfi-flag.rs +++ b/tests/codegen/sanitizer/kcfi/add-kcfi-flag.rs @@ -5,7 +5,7 @@ //@ [aarch64] needs-llvm-components: aarch64 //@ [x86_64] compile-flags: --target x86_64-unknown-none //@ [x86_64] needs-llvm-components: x86 -//@ compile-flags: -Ctarget-feature=-crt-static -Zsanitizer=kcfi +//@ compile-flags: -Ctarget-feature=-crt-static -Zunstable-options -Csanitize=kcfi #![feature(no_core, lang_items)] #![crate_type = "lib"] diff --git a/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle-attr-no-sanitize.rs b/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle-attr-no-sanitize.rs index ba2e397f6daa5..02a3da82a8a04 100644 --- a/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle-attr-no-sanitize.rs +++ b/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle-attr-no-sanitize.rs @@ -5,7 +5,7 @@ //@ [aarch64] needs-llvm-components: aarch64 //@ [x86_64] compile-flags: --target x86_64-unknown-none //@ [x86_64] needs-llvm-components: -//@ compile-flags: -Cno-prepopulate-passes -Zsanitizer=kcfi -Copt-level=0 +//@ compile-flags: -Cno-prepopulate-passes -Zunstable-options -Csanitize=kcfi -Copt-level=0 #![crate_type = "lib"] #![feature(no_core, no_sanitize, lang_items)] diff --git a/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi-generalized.rs b/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi-generalized.rs index 4e95bdf4d7c41..386ea02cce391 100644 --- a/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi-generalized.rs +++ b/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi-generalized.rs @@ -5,7 +5,7 @@ //@ [aarch64] needs-llvm-components: aarch64 //@ [x86_64] compile-flags: --target x86_64-unknown-none //@ [x86_64] needs-llvm-components: -//@ compile-flags: -Cno-prepopulate-passes -Zsanitizer=kcfi -Zsanitizer-cfi-generalize-pointers +//@ compile-flags: -Cno-prepopulate-passes -Zunstable-options -Csanitize=kcfi -Zsanitizer-cfi-generalize-pointers #![crate_type = "lib"] #![feature(no_core, lang_items)] diff --git a/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi-normalized-generalized.rs b/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi-normalized-generalized.rs index 31b43b5098806..87288e98938d4 100644 --- a/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi-normalized-generalized.rs +++ b/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi-normalized-generalized.rs @@ -5,7 +5,7 @@ //@ [aarch64] needs-llvm-components: aarch64 //@ [x86_64] compile-flags: --target x86_64-unknown-none //@ [x86_64] needs-llvm-components: -//@ compile-flags: -Cno-prepopulate-passes -Zsanitizer=kcfi -Zsanitizer-cfi-normalize-integers -Zsanitizer-cfi-generalize-pointers +//@ compile-flags: -Cno-prepopulate-passes -Zunstable-options -Csanitize=kcfi -Zsanitizer-cfi-normalize-integers -Zsanitizer-cfi-generalize-pointers #![crate_type = "lib"] #![feature(no_core, lang_items)] diff --git a/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi-normalized.rs b/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi-normalized.rs index 4755f6062aaab..50286ab4e0edf 100644 --- a/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi-normalized.rs +++ b/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi-normalized.rs @@ -5,7 +5,7 @@ //@ [aarch64] needs-llvm-components: aarch64 //@ [x86_64] compile-flags: --target x86_64-unknown-none //@ [x86_64] needs-llvm-components: -//@ compile-flags: -Cno-prepopulate-passes -Zsanitizer=kcfi -Zsanitizer-cfi-normalize-integers +//@ compile-flags: -Cno-prepopulate-passes -Zunstable-options -Csanitize=kcfi -Zsanitizer-cfi-normalize-integers #![crate_type = "lib"] #![feature(no_core, lang_items)] diff --git a/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi.rs b/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi.rs index be9760bd9afa4..2189cdc0d811d 100644 --- a/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi.rs +++ b/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi.rs @@ -5,7 +5,7 @@ //@ [aarch64] needs-llvm-components: aarch64 //@ [x86_64] compile-flags: --target x86_64-unknown-none //@ [x86_64] needs-llvm-components: -//@ compile-flags: -Cno-prepopulate-passes -Zsanitizer=kcfi -Copt-level=0 +//@ compile-flags: -Cno-prepopulate-passes -Zunstable-options -Csanitize=kcfi -Copt-level=0 #![crate_type = "lib"] #![feature(no_core, lang_items)] diff --git a/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle.rs b/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle.rs index c9c94cdb32926..57bcf4c45a2cc 100644 --- a/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle.rs +++ b/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle.rs @@ -5,7 +5,7 @@ //@ [aarch64] needs-llvm-components: aarch64 //@ [x86_64] compile-flags: --target x86_64-unknown-none //@ [x86_64] needs-llvm-components: -//@ compile-flags: -Cno-prepopulate-passes -Zsanitizer=kcfi -Copt-level=0 +//@ compile-flags: -Cno-prepopulate-passes -Zunstable-options -Csanitize=kcfi -Copt-level=0 #![crate_type = "lib"] #![feature(no_core, lang_items)] diff --git a/tests/codegen/sanitizer/kcfi/emit-type-metadata-trait-objects.rs b/tests/codegen/sanitizer/kcfi/emit-type-metadata-trait-objects.rs index c1967e55e75b4..386367d5c1e1e 100644 --- a/tests/codegen/sanitizer/kcfi/emit-type-metadata-trait-objects.rs +++ b/tests/codegen/sanitizer/kcfi/emit-type-metadata-trait-objects.rs @@ -5,7 +5,7 @@ //@ [aarch64] needs-llvm-components: aarch64 //@ [x86_64] compile-flags: --target x86_64-unknown-none //@ [x86_64] needs-llvm-components: -//@ compile-flags: -Cno-prepopulate-passes -Zsanitizer=kcfi -Copt-level=0 +//@ compile-flags: -Cno-prepopulate-passes -Zunstable-options -Csanitize=kcfi -Copt-level=0 #![crate_type = "lib"] #![feature(arbitrary_self_types, no_core, lang_items)] diff --git a/tests/codegen/sanitizer/memory-track-origins.rs b/tests/codegen/sanitizer/memory-track-origins.rs index 318c277e10cba..b7f9ed021410e 100644 --- a/tests/codegen/sanitizer/memory-track-origins.rs +++ b/tests/codegen/sanitizer/memory-track-origins.rs @@ -4,7 +4,7 @@ //@ needs-sanitizer-memory //@ revisions:MSAN-0 MSAN-1 MSAN-2 MSAN-1-LTO MSAN-2-LTO // -//@ compile-flags: -Zsanitizer=memory -Ctarget-feature=-crt-static +//@ compile-flags: -Zunstable-options -Csanitize=memory -Ctarget-feature=-crt-static //@[MSAN-0] compile-flags: //@[MSAN-1] compile-flags: -Zsanitizer-memory-track-origins=1 //@[MSAN-2] compile-flags: -Zsanitizer-memory-track-origins diff --git a/tests/codegen/sanitizer/memtag-attr-check.rs b/tests/codegen/sanitizer/memtag-attr-check.rs index ffe3a2322a20e..a567edf9a6f96 100644 --- a/tests/codegen/sanitizer/memtag-attr-check.rs +++ b/tests/codegen/sanitizer/memtag-attr-check.rs @@ -2,7 +2,7 @@ // applied when enabling the memtag sanitizer. // //@ needs-sanitizer-memtag -//@ compile-flags: -Zsanitizer=memtag -Ctarget-feature=+mte -Copt-level=0 +//@ compile-flags: -Zunstable-options -Csanitize=memtag -Ctarget-feature=+mte -Copt-level=0 #![crate_type = "lib"] diff --git a/tests/codegen/sanitizer/no-sanitize-inlining.rs b/tests/codegen/sanitizer/no-sanitize-inlining.rs index 4bd832d2ab195..55689a2d6d31e 100644 --- a/tests/codegen/sanitizer/no-sanitize-inlining.rs +++ b/tests/codegen/sanitizer/no-sanitize-inlining.rs @@ -5,8 +5,8 @@ //@ needs-sanitizer-leak //@ revisions: ASAN LSAN //@ compile-flags: -Copt-level=3 -Zmir-opt-level=4 -Ctarget-feature=-crt-static -//@[ASAN] compile-flags: -Zsanitizer=address -//@[LSAN] compile-flags: -Zsanitizer=leak +//@[ASAN] compile-flags: -Zunstable-options -Csanitize=address +//@[LSAN] compile-flags: -Zunstable-options -Csanitize=leak #![crate_type = "lib"] #![feature(no_sanitize)] diff --git a/tests/codegen/sanitizer/no-sanitize.rs b/tests/codegen/sanitizer/no-sanitize.rs index 47d3fd83f1127..477418d35db73 100644 --- a/tests/codegen/sanitizer/no-sanitize.rs +++ b/tests/codegen/sanitizer/no-sanitize.rs @@ -2,7 +2,7 @@ // selectively disable sanitizer instrumentation. // //@ needs-sanitizer-address -//@ compile-flags: -Zsanitizer=address -Ctarget-feature=-crt-static -Copt-level=0 +//@ compile-flags: -Zunstable-options -Csanitize=address -Ctarget-feature=-crt-static -Copt-level=0 #![crate_type = "lib"] #![feature(no_sanitize)] diff --git a/tests/codegen/sanitizer/safestack-attr-check.rs b/tests/codegen/sanitizer/safestack-attr-check.rs index 050a60333afa1..01cf8b44076c9 100644 --- a/tests/codegen/sanitizer/safestack-attr-check.rs +++ b/tests/codegen/sanitizer/safestack-attr-check.rs @@ -1,7 +1,7 @@ // This tests that the safestack attribute is applied when enabling the safe-stack sanitizer. // //@ needs-sanitizer-safestack -//@ compile-flags: -Zsanitizer=safestack -Copt-level=0 +//@ compile-flags: -Zunstable-options -Csanitize=safestack -Copt-level=0 #![crate_type = "lib"] diff --git a/tests/codegen/sanitizer/sanitizer-recover.rs b/tests/codegen/sanitizer/sanitizer-recover.rs index 6b65932048184..b0646dce3c9b7 100644 --- a/tests/codegen/sanitizer/sanitizer-recover.rs +++ b/tests/codegen/sanitizer/sanitizer-recover.rs @@ -7,11 +7,15 @@ //@ no-prefer-dynamic // //@ compile-flags: -Ctarget-feature=-crt-static -//@[ASAN] compile-flags: -Zsanitizer=address -Copt-level=0 -//@[ASAN-RECOVER] compile-flags: -Zsanitizer=address -Zsanitizer-recover=address -Copt-level=0 -//@[MSAN] compile-flags: -Zsanitizer=memory -//@[MSAN-RECOVER] compile-flags: -Zsanitizer=memory -Zsanitizer-recover=memory -//@[MSAN-RECOVER-LTO] compile-flags: -Zsanitizer=memory -Zsanitizer-recover=memory -C lto=fat +//@[ASAN] compile-flags: -Zunstable-options -Csanitize=address +//@[ASAN] compile-flags: -Copt-level=0 +//@[ASAN-RECOVER] compile-flags: -Zunstable-options -Csanitize=address +//@[ASAN-RECOVER] compile-flags: -Zsanitizer-recover=address -Copt-level=0 +//@[MSAN] compile-flags: -Zunstable-options -Csanitize=memory +//@[MSAN-RECOVER] compile-flags: -Zunstable-options -Csanitize=memory +//@[MSAN-RECOVER] compile-flags: -Zsanitizer-recover=memory +//@[MSAN-RECOVER-LTO] compile-flags: -Zunstable-options -Csanitize=memory +//@[MSAN-RECOVER-LTO] compile-flags: -Zsanitizer-recover=memory -C lto=fat // // MSAN-NOT: @__msan_keep_going // MSAN-RECOVER: @__msan_keep_going = weak_odr {{.*}}constant i32 1 diff --git a/tests/codegen/sanitizer/scs-attr-check.rs b/tests/codegen/sanitizer/scs-attr-check.rs index 6f4cbc2c0a6bc..4c23dab7a5360 100644 --- a/tests/codegen/sanitizer/scs-attr-check.rs +++ b/tests/codegen/sanitizer/scs-attr-check.rs @@ -2,7 +2,7 @@ // applied when enabling the shadow-call-stack sanitizer. // //@ needs-sanitizer-shadow-call-stack -//@ compile-flags: -Zsanitizer=shadow-call-stack +//@ compile-flags: -Zunstable-options -Csanitize=shadow-call-stack #![crate_type = "lib"] #![feature(no_sanitize)] diff --git a/tests/rustdoc/sanitizer-option.rs b/tests/rustdoc/sanitizer-option.rs deleted file mode 100644 index 2adf1be51fd7f..0000000000000 --- a/tests/rustdoc/sanitizer-option.rs +++ /dev/null @@ -1,18 +0,0 @@ -//@ needs-sanitizer-support -//@ needs-sanitizer-address -//@ compile-flags: --test -Z sanitizer=address -// -// #43031: Verify that rustdoc passes `-Z` options to rustc. Use an extern -// function that is provided by the sanitizer runtime, if flag is not passed -// correctly, then linking will fail. - -/// ``` -/// extern "C" { -/// fn __sanitizer_print_stack_trace(); -/// } -/// -/// fn main() { -/// unsafe { __sanitizer_print_stack_trace() }; -/// } -/// ``` -pub fn z_flag_is_passed_to_rustc() {} diff --git a/tests/ui/lto/issue-100772.rs b/tests/ui/lto/issue-100772.rs index 29ec5b9bf9647..5666389f1208f 100644 --- a/tests/ui/lto/issue-100772.rs +++ b/tests/ui/lto/issue-100772.rs @@ -1,6 +1,6 @@ //@ build-pass //@ needs-sanitizer-cfi -//@ compile-flags: -Ccodegen-units=1 -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi +//@ compile-flags: -Ccodegen-units=1 -Clto -Ctarget-feature=-crt-static -Zunstable-options -Csanitize=cfi //@ no-prefer-dynamic //@ only-x86_64-unknown-linux-gnu diff --git a/tests/ui/sanitizer/badfree.rs b/tests/ui/sanitizer/badfree.rs index ecbb58eba00d4..54592c703a193 100644 --- a/tests/ui/sanitizer/badfree.rs +++ b/tests/ui/sanitizer/badfree.rs @@ -2,7 +2,7 @@ //@ needs-sanitizer-address //@ ignore-cross-compile // -//@ compile-flags: -Z sanitizer=address -O +//@ compile-flags: -Zunstable-options -Csanitize=address -O // //@ run-fail //@ regex-error-pattern: AddressSanitizer: (SEGV|attempting free on address which was not malloc) diff --git a/tests/ui/sanitizer/cfg-kasan.rs b/tests/ui/sanitizer/cfg-kasan.rs index 491eaf3acc173..e3569ec5411b5 100644 --- a/tests/ui/sanitizer/cfg-kasan.rs +++ b/tests/ui/sanitizer/cfg-kasan.rs @@ -1,8 +1,8 @@ -// Verifies that when compiling with -Zsanitizer=kernel-address, +// Verifies that when compiling with -Csanitize=kernel-address, // the `#[cfg(sanitize = "address")]` attribute is configured. //@ check-pass -//@ compile-flags: -Zsanitizer=kernel-address +//@ compile-flags: -Zunstable-options -Csanitize=kernel-address //@ revisions: aarch64 riscv64imac riscv64gc x86_64 //@[aarch64] compile-flags: --target aarch64-unknown-none //@[aarch64] needs-llvm-components: aarch64 diff --git a/tests/ui/sanitizer/cfg.rs b/tests/ui/sanitizer/cfg.rs index b1ba17d57139c..26d485529d275 100644 --- a/tests/ui/sanitizer/cfg.rs +++ b/tests/ui/sanitizer/cfg.rs @@ -1,23 +1,23 @@ -// Verifies that when compiling with -Zsanitizer=option, +// Verifies that when compiling with -Csanitize=option, // the `#[cfg(sanitize = "option")]` attribute is configured. //@ check-pass //@ revisions: address cfi kcfi leak memory thread //@compile-flags: -Ctarget-feature=-crt-static //@[address]needs-sanitizer-address -//@[address]compile-flags: -Zsanitizer=address --cfg address +//@[address]compile-flags: -Zunstable-options -Csanitize=address --cfg address //@[cfi]needs-sanitizer-cfi -//@[cfi]compile-flags: -Zsanitizer=cfi --cfg cfi +//@[cfi]compile-flags: -Zunstable-options -Csanitize=cfi --cfg cfi //@[cfi]compile-flags: -Clto -Ccodegen-units=1 //@[kcfi]needs-llvm-components: x86 -//@[kcfi]compile-flags: -Zsanitizer=kcfi --cfg kcfi --target x86_64-unknown-none -//@[kcfi]compile-flags: -C panic=abort +//@[kcfi]compile-flags: -Zunstable-options -Csanitize=kcfi --cfg kcfi +//@[kcfi]compile-flags: --target x86_64-unknown-none -C panic=abort //@[leak]needs-sanitizer-leak -//@[leak]compile-flags: -Zsanitizer=leak --cfg leak +//@[leak]compile-flags: -Zunstable-options -Csanitize=leak --cfg leak //@[memory]needs-sanitizer-memory -//@[memory]compile-flags: -Zsanitizer=memory --cfg memory +//@[memory]compile-flags: -Zunstable-options -Csanitize=memory --cfg memory //@[thread]needs-sanitizer-thread -//@[thread]compile-flags: -Zsanitizer=thread --cfg thread +//@[thread]compile-flags: -Zunstable-options -Csanitize=thread --cfg thread #![feature(cfg_sanitize, no_core, lang_items)] #![crate_type="lib"] diff --git a/tests/ui/sanitizer/cfi-assoc-ty-lifetime-issue-123053.rs b/tests/ui/sanitizer/cfi-assoc-ty-lifetime-issue-123053.rs index dd604b6bf7dcd..4c1defd8370bf 100644 --- a/tests/ui/sanitizer/cfi-assoc-ty-lifetime-issue-123053.rs +++ b/tests/ui/sanitizer/cfi-assoc-ty-lifetime-issue-123053.rs @@ -2,7 +2,7 @@ // trait object type to fail, causing an ICE. // //@ needs-sanitizer-cfi -//@ compile-flags: -Ccodegen-units=1 -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi --edition=2021 +//@ compile-flags: -Ccodegen-units=1 -Clto -Ctarget-feature=-crt-static -Zunstable-options -Csanitize=cfi --edition=2021 //@ no-prefer-dynamic //@ only-x86_64-unknown-linux-gnu //@ build-pass diff --git a/tests/ui/sanitizer/cfi-async-closures.rs b/tests/ui/sanitizer/cfi-async-closures.rs index d94f2992d8428..3de24a010ce65 100644 --- a/tests/ui/sanitizer/cfi-async-closures.rs +++ b/tests/ui/sanitizer/cfi-async-closures.rs @@ -8,8 +8,8 @@ //@ [kcfi] needs-sanitizer-kcfi //@ compile-flags: -C target-feature=-crt-static //@ [cfi] compile-flags: -C codegen-units=1 -C lto -C prefer-dynamic=off -C opt-level=0 -//@ [cfi] compile-flags: -Z sanitizer=cfi -//@ [kcfi] compile-flags: -Z sanitizer=kcfi +//@ [cfi] compile-flags: -Zunstable-options -Csanitize=cfi +//@ [kcfi] compile-flags: -Zunstable-options -Csanitize=kcfi //@ [kcfi] compile-flags: -C panic=abort -Z panic-abort-tests -C prefer-dynamic=off //@ run-pass diff --git a/tests/ui/sanitizer/cfi-canonical-jump-tables-requires-cfi.rs b/tests/ui/sanitizer/cfi-canonical-jump-tables-requires-cfi.rs index 10c5bf6ea5e14..01ca498dcc1ed 100644 --- a/tests/ui/sanitizer/cfi-canonical-jump-tables-requires-cfi.rs +++ b/tests/ui/sanitizer/cfi-canonical-jump-tables-requires-cfi.rs @@ -1,4 +1,4 @@ -// Verifies that `-Zsanitizer-cfi-canonical-jump-tables` requires `-Zsanitizer=cfi`. +// Verifies that `-Zsanitizer-cfi-canonical-jump-tables` requires `-Csanitize=cfi`. // //@ needs-sanitizer-cfi //@ compile-flags: -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer-cfi-canonical-jump-tables=false diff --git a/tests/ui/sanitizer/cfi-canonical-jump-tables-requires-cfi.stderr b/tests/ui/sanitizer/cfi-canonical-jump-tables-requires-cfi.stderr index de67d6a6b7f06..95f120c360b7c 100644 --- a/tests/ui/sanitizer/cfi-canonical-jump-tables-requires-cfi.stderr +++ b/tests/ui/sanitizer/cfi-canonical-jump-tables-requires-cfi.stderr @@ -1,4 +1,4 @@ -error: `-Zsanitizer-cfi-canonical-jump-tables` requires `-Zsanitizer=cfi` +error: `-Zsanitizer-cfi-canonical-jump-tables` requires `-Csanitize=cfi` error: aborting due to 1 previous error diff --git a/tests/ui/sanitizer/cfi-closures.rs b/tests/ui/sanitizer/cfi-closures.rs index 9f9002da674f5..ccc17c96a9854 100644 --- a/tests/ui/sanitizer/cfi-closures.rs +++ b/tests/ui/sanitizer/cfi-closures.rs @@ -7,8 +7,8 @@ //@ [kcfi] needs-sanitizer-kcfi //@ compile-flags: -C target-feature=-crt-static //@ [cfi] compile-flags: -C codegen-units=1 -C lto -C prefer-dynamic=off -C opt-level=0 -//@ [cfi] compile-flags: -Z sanitizer=cfi -//@ [kcfi] compile-flags: -Z sanitizer=kcfi +//@ [cfi] compile-flags: -Zunstable-options -Csanitize=cfi +//@ [kcfi] compile-flags: -Zunstable-options -Csanitize=kcfi //@ [kcfi] compile-flags: -C panic=abort -Z panic-abort-tests -C prefer-dynamic=off //@ compile-flags: --test //@ run-pass diff --git a/tests/ui/sanitizer/cfi-complex-receiver.rs b/tests/ui/sanitizer/cfi-complex-receiver.rs index c7b45a775ca1d..d54cebf1fe743 100644 --- a/tests/ui/sanitizer/cfi-complex-receiver.rs +++ b/tests/ui/sanitizer/cfi-complex-receiver.rs @@ -9,8 +9,8 @@ //@ [kcfi] needs-sanitizer-kcfi //@ compile-flags: -C target-feature=-crt-static //@ [cfi] compile-flags: -C codegen-units=1 -C lto -C prefer-dynamic=off -C opt-level=0 -//@ [cfi] compile-flags: -Z sanitizer=cfi -//@ [kcfi] compile-flags: -Z sanitizer=kcfi +//@ [cfi] compile-flags: -Zunstable-options -Csanitize=cfi +//@ [kcfi] compile-flags: -Zunstable-options -Csanitize=kcfi //@ [kcfi] compile-flags: -C panic=abort -C prefer-dynamic=off //@ run-pass diff --git a/tests/ui/sanitizer/cfi-coroutine.rs b/tests/ui/sanitizer/cfi-coroutine.rs index ad994fcf73700..4de1048ed238d 100644 --- a/tests/ui/sanitizer/cfi-coroutine.rs +++ b/tests/ui/sanitizer/cfi-coroutine.rs @@ -8,8 +8,8 @@ //@ [kcfi] needs-sanitizer-kcfi //@ compile-flags: -C target-feature=-crt-static //@ [cfi] compile-flags: -C codegen-units=1 -C lto -C prefer-dynamic=off -C opt-level=0 -//@ [cfi] compile-flags: -Z sanitizer=cfi -//@ [kcfi] compile-flags: -Z sanitizer=kcfi +//@ [cfi] compile-flags: -Zunstable-options -Csanitize=cfi +//@ [kcfi] compile-flags: -Zunstable-options -Csanitize=kcfi //@ [kcfi] compile-flags: -C panic=abort -Z panic-abort-tests -C prefer-dynamic=off //@ compile-flags: --test -Z unstable-options //@ run-pass diff --git a/tests/ui/sanitizer/cfi-drop-in-place.rs b/tests/ui/sanitizer/cfi-drop-in-place.rs index 8ce2c43260261..eee036348d37d 100644 --- a/tests/ui/sanitizer/cfi-drop-in-place.rs +++ b/tests/ui/sanitizer/cfi-drop-in-place.rs @@ -3,7 +3,7 @@ // FIXME(#122848): Remove only-linux when fixed. //@ only-linux //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Copt-level=0 -Cprefer-dynamic=off -Ctarget-feature=-crt-static -Zsanitizer=cfi +//@ compile-flags: -Clto -Copt-level=0 -Cprefer-dynamic=off -Ctarget-feature=-crt-static -Zunstable-options -Csanitize=cfi //@ run-pass struct EmptyDrop; diff --git a/tests/ui/sanitizer/cfi-drop-no-principal.rs b/tests/ui/sanitizer/cfi-drop-no-principal.rs index c1c88c8c71c73..4bdb690697686 100644 --- a/tests/ui/sanitizer/cfi-drop-no-principal.rs +++ b/tests/ui/sanitizer/cfi-drop-no-principal.rs @@ -3,7 +3,7 @@ //@ needs-sanitizer-cfi // FIXME(#122848) Remove only-linux once OSX CFI binaries works //@ only-linux -//@ compile-flags: --crate-type=bin -Cprefer-dynamic=off -Clto -Zsanitizer=cfi +//@ compile-flags: --crate-type=bin -Cprefer-dynamic=off -Clto -Zunstable-options -Csanitize=cfi //@ compile-flags: -C target-feature=-crt-static -C codegen-units=1 -C opt-level=0 // FIXME(#118761) Should be run-pass once the labels on drop are compatible. // This test is being landed ahead of that to test that the compiler doesn't ICE while labeling the diff --git a/tests/ui/sanitizer/cfi-fn-ptr.rs b/tests/ui/sanitizer/cfi-fn-ptr.rs index 505b4b8e7f032..95a160c05731b 100644 --- a/tests/ui/sanitizer/cfi-fn-ptr.rs +++ b/tests/ui/sanitizer/cfi-fn-ptr.rs @@ -8,8 +8,8 @@ //@ compile-flags: -C target-feature=-crt-static //@ [cfi] compile-flags: -C opt-level=0 -C codegen-units=1 -C lto //@ [cfi] compile-flags: -C prefer-dynamic=off -//@ [cfi] compile-flags: -Z sanitizer=cfi -//@ [kcfi] compile-flags: -Z sanitizer=kcfi +//@ [cfi] compile-flags: -Zunstable-options -Csanitize=cfi +//@ [kcfi] compile-flags: -Zunstable-options -Csanitize=kcfi //@ [kcfi] compile-flags: -C panic=abort -C prefer-dynamic=off //@ run-pass diff --git a/tests/ui/sanitizer/cfi-generalize-pointers-attr-cfg.rs b/tests/ui/sanitizer/cfi-generalize-pointers-attr-cfg.rs index d46002c69fda0..a57afbf184efe 100644 --- a/tests/ui/sanitizer/cfi-generalize-pointers-attr-cfg.rs +++ b/tests/ui/sanitizer/cfi-generalize-pointers-attr-cfg.rs @@ -3,7 +3,7 @@ // //@ needs-sanitizer-cfi //@ check-pass -//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-generalize-pointers +//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zunstable-options -Csanitize=cfi -Zsanitizer-cfi-generalize-pointers #![feature(cfg_sanitizer_cfi)] diff --git a/tests/ui/sanitizer/cfi-generalize-pointers-requires-cfi.rs b/tests/ui/sanitizer/cfi-generalize-pointers-requires-cfi.rs index 8ba13bd3639b1..3e2f3ef565359 100644 --- a/tests/ui/sanitizer/cfi-generalize-pointers-requires-cfi.rs +++ b/tests/ui/sanitizer/cfi-generalize-pointers-requires-cfi.rs @@ -1,5 +1,5 @@ -// Verifies that `-Zsanitizer-cfi-generalize-pointers` requires `-Zsanitizer=cfi` or -// `-Zsanitizer=kcfi`. +// Verifies that `-Zsanitizer-cfi-generalize-pointers` requires `-Csanitize=cfi` or +// `-Csanitize=kcfi`. // //@ needs-sanitizer-cfi //@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer-cfi-generalize-pointers diff --git a/tests/ui/sanitizer/cfi-generalize-pointers-requires-cfi.stderr b/tests/ui/sanitizer/cfi-generalize-pointers-requires-cfi.stderr index 621708de241c2..4c76d27b879e2 100644 --- a/tests/ui/sanitizer/cfi-generalize-pointers-requires-cfi.stderr +++ b/tests/ui/sanitizer/cfi-generalize-pointers-requires-cfi.stderr @@ -1,4 +1,4 @@ -error: `-Zsanitizer-cfi-generalize-pointers` requires `-Zsanitizer=cfi` or `-Zsanitizer=kcfi` +error: `-Zsanitizer-cfi-generalize-pointers` requires `-Csanitize=cfi` or `-Csanitize=kcfi` error: aborting due to 1 previous error diff --git a/tests/ui/sanitizer/cfi-invalid-attr-cfi-encoding.rs b/tests/ui/sanitizer/cfi-invalid-attr-cfi-encoding.rs index 7ef6bd2f0acc3..153182f6895b5 100644 --- a/tests/ui/sanitizer/cfi-invalid-attr-cfi-encoding.rs +++ b/tests/ui/sanitizer/cfi-invalid-attr-cfi-encoding.rs @@ -1,7 +1,7 @@ // Verifies that invalid user-defined CFI encodings can't be used. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi +//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zunstable-options -Csanitize=cfi #![feature(cfi_encoding, no_core)] #![no_core] diff --git a/tests/ui/sanitizer/cfi-is-incompatible-with-kcfi.aarch64.stderr b/tests/ui/sanitizer/cfi-is-incompatible-with-kcfi.aarch64.stderr index 7f596a19104e6..8a9544f6c6afc 100644 --- a/tests/ui/sanitizer/cfi-is-incompatible-with-kcfi.aarch64.stderr +++ b/tests/ui/sanitizer/cfi-is-incompatible-with-kcfi.aarch64.stderr @@ -1,6 +1,6 @@ error: cfi sanitizer is not supported for this target -error: `-Zsanitizer=cfi` is incompatible with `-Zsanitizer=kcfi` +error: `-Csanitize=cfi` is incompatible with `-Csanitize=kcfi` error: aborting due to 2 previous errors diff --git a/tests/ui/sanitizer/cfi-is-incompatible-with-kcfi.rs b/tests/ui/sanitizer/cfi-is-incompatible-with-kcfi.rs index c628709d7a1ce..9e2416f4299af 100644 --- a/tests/ui/sanitizer/cfi-is-incompatible-with-kcfi.rs +++ b/tests/ui/sanitizer/cfi-is-incompatible-with-kcfi.rs @@ -1,11 +1,11 @@ -// Verifies that `-Zsanitizer=cfi` is incompatible with `-Zsanitizer=kcfi`. +// Verifies that `-Csanitize=cfi` is incompatible with `-Csanitize=kcfi`. // //@ revisions: aarch64 x86_64 //@ [aarch64] compile-flags: --target aarch64-unknown-none //@ [aarch64] needs-llvm-components: aarch64 //@ [x86_64] compile-flags: --target x86_64-unknown-none //@ [x86_64] needs-llvm-components: x86 -//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer=kcfi +//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zunstable-options -Csanitize=cfi -Csanitize=kcfi #![feature(no_core)] #![no_core] diff --git a/tests/ui/sanitizer/cfi-is-incompatible-with-kcfi.x86_64.stderr b/tests/ui/sanitizer/cfi-is-incompatible-with-kcfi.x86_64.stderr index 7f596a19104e6..8a9544f6c6afc 100644 --- a/tests/ui/sanitizer/cfi-is-incompatible-with-kcfi.x86_64.stderr +++ b/tests/ui/sanitizer/cfi-is-incompatible-with-kcfi.x86_64.stderr @@ -1,6 +1,6 @@ error: cfi sanitizer is not supported for this target -error: `-Zsanitizer=cfi` is incompatible with `-Zsanitizer=kcfi` +error: `-Csanitize=cfi` is incompatible with `-Csanitize=kcfi` error: aborting due to 2 previous errors diff --git a/tests/ui/sanitizer/cfi-normalize-integers-attr-cfg.rs b/tests/ui/sanitizer/cfi-normalize-integers-attr-cfg.rs index 24c2c2c13da75..1c30dc9162524 100644 --- a/tests/ui/sanitizer/cfi-normalize-integers-attr-cfg.rs +++ b/tests/ui/sanitizer/cfi-normalize-integers-attr-cfg.rs @@ -3,7 +3,7 @@ // //@ needs-sanitizer-cfi //@ check-pass -//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-normalize-integers +//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zunstable-options -Csanitize=cfi -Zsanitizer-cfi-normalize-integers #![feature(cfg_sanitizer_cfi)] diff --git a/tests/ui/sanitizer/cfi-normalize-integers-requires-cfi.rs b/tests/ui/sanitizer/cfi-normalize-integers-requires-cfi.rs index a7ecefbf7efb7..5ba849531ea6f 100644 --- a/tests/ui/sanitizer/cfi-normalize-integers-requires-cfi.rs +++ b/tests/ui/sanitizer/cfi-normalize-integers-requires-cfi.rs @@ -1,5 +1,5 @@ -// Verifies that `-Zsanitizer-cfi-normalize-integers` requires `-Zsanitizer=cfi` or -// `-Zsanitizer=kcfi` +// Verifies that `-Zsanitizer-cfi-normalize-integers` requires `-Csanitize=cfi` or +// `-Csanitize=kcfi` // //@ needs-sanitizer-cfi //@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer-cfi-normalize-integers diff --git a/tests/ui/sanitizer/cfi-normalize-integers-requires-cfi.stderr b/tests/ui/sanitizer/cfi-normalize-integers-requires-cfi.stderr index 748fb60dad92e..32e9c9f2cf67d 100644 --- a/tests/ui/sanitizer/cfi-normalize-integers-requires-cfi.stderr +++ b/tests/ui/sanitizer/cfi-normalize-integers-requires-cfi.stderr @@ -1,4 +1,4 @@ -error: `-Zsanitizer-cfi-normalize-integers` requires `-Zsanitizer=cfi` or `-Zsanitizer=kcfi` +error: `-Zsanitizer-cfi-normalize-integers` requires `-Csanitize=cfi` or `-Csanitize=kcfi` error: aborting due to 1 previous error diff --git a/tests/ui/sanitizer/cfi-requires-lto.rs b/tests/ui/sanitizer/cfi-requires-lto.rs index 5a34f696e0546..f0b67bcfa3f45 100644 --- a/tests/ui/sanitizer/cfi-requires-lto.rs +++ b/tests/ui/sanitizer/cfi-requires-lto.rs @@ -1,7 +1,7 @@ -// Verifies that `-Zsanitizer=cfi` requires `-Clto` or `-Clinker-plugin-lto`. +// Verifies that `-Csanitize=cfi` requires `-Clto` or `-Clinker-plugin-lto`. // //@ needs-sanitizer-cfi -//@ compile-flags: -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi +//@ compile-flags: -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zunstable-options -Csanitize=cfi #![feature(no_core)] #![no_core] diff --git a/tests/ui/sanitizer/cfi-requires-lto.stderr b/tests/ui/sanitizer/cfi-requires-lto.stderr index efc0c43138e12..13d539e7c706b 100644 --- a/tests/ui/sanitizer/cfi-requires-lto.stderr +++ b/tests/ui/sanitizer/cfi-requires-lto.stderr @@ -1,4 +1,4 @@ -error: `-Zsanitizer=cfi` requires `-Clto` or `-Clinker-plugin-lto` +error: `-Csanitize=cfi` requires `-Clto` or `-Clinker-plugin-lto` error: aborting due to 1 previous error diff --git a/tests/ui/sanitizer/cfi-self-ref.rs b/tests/ui/sanitizer/cfi-self-ref.rs index 3b524ac661cf8..b9b1b5c382f96 100644 --- a/tests/ui/sanitizer/cfi-self-ref.rs +++ b/tests/ui/sanitizer/cfi-self-ref.rs @@ -7,8 +7,8 @@ //@ [kcfi] needs-sanitizer-kcfi //@ compile-flags: -C target-feature=-crt-static //@ [cfi] compile-flags: -C codegen-units=1 -C lto -C prefer-dynamic=off -C opt-level=0 -//@ [cfi] compile-flags: -Z sanitizer=cfi -//@ [kcfi] compile-flags: -Z sanitizer=kcfi +//@ [cfi] compile-flags: -Zunstable-options -Csanitize=cfi +//@ [kcfi] compile-flags: -Zunstable-options -Csanitize=kcfi //@ [kcfi] compile-flags: -C panic=abort -C prefer-dynamic=off //@ run-pass diff --git a/tests/ui/sanitizer/cfi-sized-associated-ty.rs b/tests/ui/sanitizer/cfi-sized-associated-ty.rs index f5b4e22e9d99b..7ae53dd0a7c03 100644 --- a/tests/ui/sanitizer/cfi-sized-associated-ty.rs +++ b/tests/ui/sanitizer/cfi-sized-associated-ty.rs @@ -8,8 +8,8 @@ //@ [kcfi] needs-sanitizer-kcfi //@ compile-flags: -C target-feature=-crt-static //@ [cfi] compile-flags: -C codegen-units=1 -C lto -C prefer-dynamic=off -C opt-level=0 -//@ [cfi] compile-flags: -Z sanitizer=cfi -//@ [kcfi] compile-flags: -Z sanitizer=kcfi +//@ [cfi] compile-flags: -Zunstable-options -Csanitize=cfi +//@ [kcfi] compile-flags: -Zunstable-options -Csanitize=kcfi //@ [kcfi] compile-flags: -C panic=abort -C prefer-dynamic=off //@ run-pass diff --git a/tests/ui/sanitizer/cfi-supertraits.rs b/tests/ui/sanitizer/cfi-supertraits.rs index 4bb6177577f7c..29512933210a9 100644 --- a/tests/ui/sanitizer/cfi-supertraits.rs +++ b/tests/ui/sanitizer/cfi-supertraits.rs @@ -8,8 +8,8 @@ //@ [kcfi] needs-sanitizer-kcfi //@ compile-flags: -C target-feature=-crt-static //@ [cfi] compile-flags: -C codegen-units=1 -C lto -C prefer-dynamic=off -C opt-level=0 -//@ [cfi] compile-flags: -Z sanitizer=cfi -//@ [kcfi] compile-flags: -Z sanitizer=kcfi +//@ [cfi] compile-flags: -Zunstable-options -Csanitize=cfi +//@ [kcfi] compile-flags: -Zunstable-options -Csanitize=kcfi //@ [kcfi] compile-flags: -C panic=abort -C prefer-dynamic=off //@ run-pass diff --git a/tests/ui/sanitizer/cfi-virtual-auto.rs b/tests/ui/sanitizer/cfi-virtual-auto.rs index 6971d516a2057..cb3e71218dff1 100644 --- a/tests/ui/sanitizer/cfi-virtual-auto.rs +++ b/tests/ui/sanitizer/cfi-virtual-auto.rs @@ -7,8 +7,8 @@ //@ [kcfi] needs-sanitizer-kcfi //@ compile-flags: -C target-feature=-crt-static //@ [cfi] compile-flags: -C codegen-units=1 -C lto -C prefer-dynamic=off -C opt-level=0 -//@ [cfi] compile-flags: -Z sanitizer=cfi -//@ [kcfi] compile-flags: -Z sanitizer=kcfi +//@ [cfi] compile-flags: -Zunstable-options -Csanitize=cfi +//@ [kcfi] compile-flags: -Zunstable-options -Csanitize=kcfi //@ [kcfi] compile-flags: -C panic=abort -C prefer-dynamic=off //@ run-pass diff --git a/tests/ui/sanitizer/cfi-with-rustc-lto-requires-single-codegen-unit.rs b/tests/ui/sanitizer/cfi-with-rustc-lto-requires-single-codegen-unit.rs index 954e4ec3b8538..af0048d1df824 100644 --- a/tests/ui/sanitizer/cfi-with-rustc-lto-requires-single-codegen-unit.rs +++ b/tests/ui/sanitizer/cfi-with-rustc-lto-requires-single-codegen-unit.rs @@ -1,7 +1,7 @@ -// Verifies that `-Zsanitizer=cfi` with `-Clto` or `-Clto=thin` requires `-Ccodegen-units=1`. +// Verifies that `-Csanitize=cfi` with `-Clto` or `-Clto=thin` requires `-Ccodegen-units=1`. // //@ needs-sanitizer-cfi -//@ compile-flags: -Ccodegen-units=2 -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi +//@ compile-flags: -Ccodegen-units=2 -Clto -Ctarget-feature=-crt-static -Zunstable-options -Csanitize=cfi #![feature(no_core)] #![no_core] diff --git a/tests/ui/sanitizer/cfi-with-rustc-lto-requires-single-codegen-unit.stderr b/tests/ui/sanitizer/cfi-with-rustc-lto-requires-single-codegen-unit.stderr index 8d6dc1d8f1ea4..76673871f6e13 100644 --- a/tests/ui/sanitizer/cfi-with-rustc-lto-requires-single-codegen-unit.stderr +++ b/tests/ui/sanitizer/cfi-with-rustc-lto-requires-single-codegen-unit.stderr @@ -1,4 +1,4 @@ -error: `-Zsanitizer=cfi` with `-Clto` requires `-Ccodegen-units=1` +error: `-Csanitize=cfi` with `-Clto` requires `-Ccodegen-units=1` error: aborting due to 1 previous error diff --git a/tests/ui/sanitizer/crt-static.rs b/tests/ui/sanitizer/crt-static.rs index c24faeca3dc85..e690b9f394dfd 100644 --- a/tests/ui/sanitizer/crt-static.rs +++ b/tests/ui/sanitizer/crt-static.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -Z sanitizer=address -C target-feature=+crt-static --target x86_64-unknown-linux-gnu +//@ compile-flags: -Zunstable-options -Csanitize=address -C target-feature=+crt-static --target x86_64-unknown-linux-gnu //@ needs-llvm-components: x86 #![feature(no_core)] diff --git a/tests/ui/sanitizer/dataflow.rs b/tests/ui/sanitizer/dataflow.rs index 658a9e4808664..7bf54db87c63d 100644 --- a/tests/ui/sanitizer/dataflow.rs +++ b/tests/ui/sanitizer/dataflow.rs @@ -4,7 +4,7 @@ //@ needs-sanitizer-support //@ needs-sanitizer-dataflow //@ run-pass -//@ compile-flags: -Zsanitizer=dataflow -Zsanitizer-dataflow-abilist={{src-base}}/sanitizer/dataflow-abilist.txt +//@ compile-flags: -Zunstable-options -Csanitize=dataflow -Zsanitizer-dataflow-abilist={{src-base}}/sanitizer/dataflow-abilist.txt use std::mem::size_of; use std::os::raw::{c_int, c_long, c_void}; diff --git a/tests/ui/sanitizer/incompatible.rs b/tests/ui/sanitizer/incompatible.rs index d000abb26ac74..94a6bac95e198 100644 --- a/tests/ui/sanitizer/incompatible.rs +++ b/tests/ui/sanitizer/incompatible.rs @@ -1,6 +1,6 @@ -//@ compile-flags: -Z sanitizer=address -Z sanitizer=memory --target x86_64-unknown-linux-gnu +//@ compile-flags: -Zunstable-options -Csanitize=address -Csanitize=memory --target x86_64-unknown-linux-gnu //@ needs-llvm-components: x86 -//@ error-pattern: error: `-Zsanitizer=address` is incompatible with `-Zsanitizer=memory` +//@ error-pattern: error: `-Csanitize=address` is incompatible with `-Csanitize=memory` #![feature(no_core)] #![no_core] diff --git a/tests/ui/sanitizer/incompatible.stderr b/tests/ui/sanitizer/incompatible.stderr index 4dff813ee1be6..9995fb36abfa6 100644 --- a/tests/ui/sanitizer/incompatible.stderr +++ b/tests/ui/sanitizer/incompatible.stderr @@ -1,4 +1,4 @@ -error: `-Zsanitizer=address` is incompatible with `-Zsanitizer=memory` +error: `-Csanitize=address` is incompatible with `-Csanitize=memory` error: aborting due to 1 previous error diff --git a/tests/ui/sanitizer/issue-111184-cfi-coroutine-witness.rs b/tests/ui/sanitizer/issue-111184-cfi-coroutine-witness.rs index e5b1e0322575c..76e9b1395ba17 100644 --- a/tests/ui/sanitizer/issue-111184-cfi-coroutine-witness.rs +++ b/tests/ui/sanitizer/issue-111184-cfi-coroutine-witness.rs @@ -2,7 +2,7 @@ // encode_ty and caused the compiler to ICE. // //@ needs-sanitizer-cfi -//@ compile-flags: -Ccodegen-units=1 -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi --edition=2021 +//@ compile-flags: -Ccodegen-units=1 -Clto -Ctarget-feature=-crt-static -Zunstable-options -Csanitize=cfi --edition=2021 //@ no-prefer-dynamic //@ only-x86_64-unknown-linux-gnu //@ build-pass diff --git a/tests/ui/sanitizer/issue-114275-cfi-const-expr-in-arry-len.rs b/tests/ui/sanitizer/issue-114275-cfi-const-expr-in-arry-len.rs index b1b7487fa2a4d..dad91975aeaa3 100644 --- a/tests/ui/sanitizer/issue-114275-cfi-const-expr-in-arry-len.rs +++ b/tests/ui/sanitizer/issue-114275-cfi-const-expr-in-arry-len.rs @@ -2,7 +2,7 @@ // was expecting array type lengths to be evaluated, this was causing an ICE. // //@ build-pass -//@ compile-flags: -Ccodegen-units=1 -Clto -Zsanitizer=cfi -Ctarget-feature=-crt-static +//@ compile-flags: -Ccodegen-units=1 -Clto -Zunstable-options -Csanitize=cfi -Ctarget-feature=-crt-static //@ needs-sanitizer-cfi #![crate_type = "lib"] diff --git a/tests/ui/sanitizer/issue-72154-address-lifetime-markers.rs b/tests/ui/sanitizer/issue-72154-address-lifetime-markers.rs index aa0c19db9a12b..9ff3c7f3129a8 100644 --- a/tests/ui/sanitizer/issue-72154-address-lifetime-markers.rs +++ b/tests/ui/sanitizer/issue-72154-address-lifetime-markers.rs @@ -7,7 +7,7 @@ //@ needs-sanitizer-address //@ ignore-cross-compile // -//@ compile-flags: -Copt-level=0 -Zsanitizer=address +//@ compile-flags: -Copt-level=0 -Zunstable-options -Csanitize=address //@ run-pass pub struct Wrap { diff --git a/tests/ui/sanitizer/kcfi-mangling.rs b/tests/ui/sanitizer/kcfi-mangling.rs index fde7b5451b6e2..96f14734f63fc 100644 --- a/tests/ui/sanitizer/kcfi-mangling.rs +++ b/tests/ui/sanitizer/kcfi-mangling.rs @@ -2,7 +2,7 @@ //@ needs-sanitizer-kcfi //@ no-prefer-dynamic -//@ compile-flags: -C panic=abort -Zsanitizer=kcfi -C symbol-mangling-version=v0 +//@ compile-flags: -C panic=abort -Zunstable-options -Csanitize=kcfi -C symbol-mangling-version=v0 //@ build-pass trait Foo { diff --git a/tests/ui/sanitizer/leak.rs b/tests/ui/sanitizer/leak.rs index 65915ec24b723..fe1c1bfd083f3 100644 --- a/tests/ui/sanitizer/leak.rs +++ b/tests/ui/sanitizer/leak.rs @@ -1,7 +1,7 @@ //@ needs-sanitizer-support //@ needs-sanitizer-leak // -//@ compile-flags: -Z sanitizer=leak -O +//@ compile-flags: -Zunstable-options -Csanitize=leak -O // //@ run-fail //@ error-pattern: LeakSanitizer: detected memory leaks diff --git a/tests/ui/sanitizer/memory-eager.rs b/tests/ui/sanitizer/memory-eager.rs index 9e7889fa1bc09..cfd7d66ab2afa 100644 --- a/tests/ui/sanitizer/memory-eager.rs +++ b/tests/ui/sanitizer/memory-eager.rs @@ -3,8 +3,10 @@ // //@ revisions: unoptimized optimized // -//@ [optimized]compile-flags: -Z sanitizer=memory -Zsanitizer-memory-track-origins -O -//@ [unoptimized]compile-flags: -Z sanitizer=memory -Zsanitizer-memory-track-origins +//@ [optimized]compile-flags: -Zunstable-options -Csanitize=memory +//@ [optimized]compile-flags: -Zsanitizer-memory-track-origins -O +//@ [unoptimized]compile-flags: -Zunstable-options -Csanitize=memory +//@ [unoptimized]compile-flags: -Zsanitizer-memory-track-origins // //@ run-fail //@ error-pattern: MemorySanitizer: use-of-uninitialized-value diff --git a/tests/ui/sanitizer/memory-passing.rs b/tests/ui/sanitizer/memory-passing.rs index c8ab64bfaf833..78c04f10ae127 100644 --- a/tests/ui/sanitizer/memory-passing.rs +++ b/tests/ui/sanitizer/memory-passing.rs @@ -3,8 +3,10 @@ // //@ revisions: unoptimized optimized // -//@ [optimized]compile-flags: -Z sanitizer=memory -Zsanitizer-memory-track-origins -O -//@ [unoptimized]compile-flags: -Z sanitizer=memory -Zsanitizer-memory-track-origins +//@ [optimized]compile-flags: -Zunstable-options -Csanitize=memory +//@ [optimized]compile-flags: -Zsanitizer-memory-track-origins -O +//@ [unoptimized]compile-flags: -Zunstable-options -Csanitize=memory +//@ [unoptimized]compile-flags: -Zsanitizer-memory-track-origins // //@ run-pass // diff --git a/tests/ui/sanitizer/memory.rs b/tests/ui/sanitizer/memory.rs index bd2d67717495f..ee9c9fbc904dd 100644 --- a/tests/ui/sanitizer/memory.rs +++ b/tests/ui/sanitizer/memory.rs @@ -3,8 +3,10 @@ // //@ revisions: unoptimized optimized // -//@ [optimized]compile-flags: -Z sanitizer=memory -Zsanitizer-memory-track-origins -O -//@ [unoptimized]compile-flags: -Z sanitizer=memory -Zsanitizer-memory-track-origins +//@ [optimized]compile-flags: -Zunstable-options -Csanitize=memory +//@ [optimized]compile-flags: -Zsanitizer-memory-track-origins -O +//@ [unoptimized]compile-flags: -Zunstable-options -Csanitize=memory +//@ [unoptimized]compile-flags: -Zsanitizer-memory-track-origins // //@ run-fail //@ error-pattern: MemorySanitizer: use-of-uninitialized-value diff --git a/tests/ui/sanitizer/new-llvm-pass-manager-thin-lto.rs b/tests/ui/sanitizer/new-llvm-pass-manager-thin-lto.rs index b7dd4a437821a..b1bcd5554f7dd 100644 --- a/tests/ui/sanitizer/new-llvm-pass-manager-thin-lto.rs +++ b/tests/ui/sanitizer/new-llvm-pass-manager-thin-lto.rs @@ -8,7 +8,7 @@ // //@ no-prefer-dynamic //@ revisions: opt0 opt1 -//@ compile-flags: -Zsanitizer=address -Clto=thin +//@ compile-flags: -Zunstable-options -Csanitize=address -Clto=thin //@[opt0]compile-flags: -Copt-level=0 //@[opt1]compile-flags: -Copt-level=1 //@ run-fail diff --git a/tests/ui/sanitizer/thread.rs b/tests/ui/sanitizer/thread.rs index 9d9ad6ee51867..a0107689f09ab 100644 --- a/tests/ui/sanitizer/thread.rs +++ b/tests/ui/sanitizer/thread.rs @@ -13,7 +13,7 @@ //@ needs-sanitizer-support //@ needs-sanitizer-thread // -//@ compile-flags: -Z sanitizer=thread -O +//@ compile-flags: -Zunstable-options -Csanitize=thread -O // //@ run-fail //@ error-pattern: WARNING: ThreadSanitizer: data race diff --git a/tests/ui/sanitizer/unstable-supported-can-be-used-with-unstable-options.rs b/tests/ui/sanitizer/unstable-supported-can-be-used-with-unstable-options.rs new file mode 100644 index 0000000000000..df25d2c58371f --- /dev/null +++ b/tests/ui/sanitizer/unstable-supported-can-be-used-with-unstable-options.rs @@ -0,0 +1,10 @@ +// Verifies that unstable supported sanitizers can be used with `-Zunstable-options`. +// +//@ needs-llvm-components: x86 +//@ compile-flags: -Zunstable-options -Csanitize=kernel-address --target x86_64-unknown-none +//@ build-pass + +#![crate_type = "rlib"] +#![feature(no_core)] +#![no_core] +#![no_main] diff --git a/tests/ui/sanitizer/unstable-supported-cannot-be-used-without-unstable-options.rs b/tests/ui/sanitizer/unstable-supported-cannot-be-used-without-unstable-options.rs new file mode 100644 index 0000000000000..a28b33c83c471 --- /dev/null +++ b/tests/ui/sanitizer/unstable-supported-cannot-be-used-without-unstable-options.rs @@ -0,0 +1,9 @@ +// Verifies that unstable supported sanitizers cannot be used without `-Zunstable-options`. +// +//@ needs-llvm-components: x86 +//@ compile-flags: -Zunstable-options=false -Csanitize=kernel-address --target x86_64-unknown-none +//@ error-pattern: error: kernel-address sanitizer is not supported for this target + +#![feature(no_core)] +#![no_core] +#![no_main] diff --git a/tests/ui/sanitizer/unstable-supported-cannot-be-used-without-unstable-options.stderr b/tests/ui/sanitizer/unstable-supported-cannot-be-used-without-unstable-options.stderr new file mode 100644 index 0000000000000..9c04afbb32a5f --- /dev/null +++ b/tests/ui/sanitizer/unstable-supported-cannot-be-used-without-unstable-options.stderr @@ -0,0 +1,4 @@ +error: kernel-address sanitizer is not supported for this target + +error: aborting due to 1 previous error + diff --git a/tests/ui/sanitizer/unsupported-cannot-be-used-with-unstable-options.rs b/tests/ui/sanitizer/unsupported-cannot-be-used-with-unstable-options.rs new file mode 100644 index 0000000000000..b1c141824b92d --- /dev/null +++ b/tests/ui/sanitizer/unsupported-cannot-be-used-with-unstable-options.rs @@ -0,0 +1,9 @@ +// Verifies that unsupported sanitizers cannot be used with `-Zunstable-options`. +// +//@ needs-llvm-components: x86 +//@ compile-flags: -Zunstable-options -Csanitize=kernel-address --target x86_64-unknown-linux-gnu +//@ error-pattern: error: kernel-address sanitizer is not supported for this target + +#![feature(no_core)] +#![no_core] +#![no_main] diff --git a/tests/ui/sanitizer/unsupported-cannot-be-used-with-unstable-options.stderr b/tests/ui/sanitizer/unsupported-cannot-be-used-with-unstable-options.stderr new file mode 100644 index 0000000000000..9c04afbb32a5f --- /dev/null +++ b/tests/ui/sanitizer/unsupported-cannot-be-used-with-unstable-options.stderr @@ -0,0 +1,4 @@ +error: kernel-address sanitizer is not supported for this target + +error: aborting due to 1 previous error + diff --git a/tests/ui/sanitizer/unsupported-cannot-be-used-without-unstable-options.rs b/tests/ui/sanitizer/unsupported-cannot-be-used-without-unstable-options.rs new file mode 100644 index 0000000000000..b5e206e83af13 --- /dev/null +++ b/tests/ui/sanitizer/unsupported-cannot-be-used-without-unstable-options.rs @@ -0,0 +1,9 @@ +// Verifies that unsupported sanitizers cannot be used without `-Zunstable-options`. +// +//@ needs-llvm-components: x86 +//@ compile-flags: -Csanitize=kernel-address --target x86_64-unknown-linux-gnu +//@ error-pattern: error: kernel-address sanitizer is not supported for this target + +#![feature(no_core)] +#![no_core] +#![no_main] diff --git a/tests/ui/sanitizer/unsupported-cannot-be-used-without-unstable-options.stderr b/tests/ui/sanitizer/unsupported-cannot-be-used-without-unstable-options.stderr new file mode 100644 index 0000000000000..9c04afbb32a5f --- /dev/null +++ b/tests/ui/sanitizer/unsupported-cannot-be-used-without-unstable-options.stderr @@ -0,0 +1,4 @@ +error: kernel-address sanitizer is not supported for this target + +error: aborting due to 1 previous error + diff --git a/tests/ui/sanitizer/unsupported-target.rs b/tests/ui/sanitizer/unsupported-target.rs deleted file mode 100644 index 7c7dc24b5d9a5..0000000000000 --- a/tests/ui/sanitizer/unsupported-target.rs +++ /dev/null @@ -1,6 +0,0 @@ -//@ compile-flags: -Z sanitizer=leak --target i686-unknown-linux-gnu -//@ needs-llvm-components: x86 -//@ error-pattern: error: leak sanitizer is not supported for this target -#![feature(no_core)] -#![no_core] -#![no_main] diff --git a/tests/ui/sanitizer/unsupported-target.stderr b/tests/ui/sanitizer/unsupported-target.stderr deleted file mode 100644 index bebbf3884ae67..0000000000000 --- a/tests/ui/sanitizer/unsupported-target.stderr +++ /dev/null @@ -1,4 +0,0 @@ -error: leak sanitizer is not supported for this target - -error: aborting due to 1 previous error - diff --git a/tests/ui/sanitizer/use-after-scope.rs b/tests/ui/sanitizer/use-after-scope.rs index 4d7f6f6c2f2b5..ffcb079118d97 100644 --- a/tests/ui/sanitizer/use-after-scope.rs +++ b/tests/ui/sanitizer/use-after-scope.rs @@ -2,7 +2,7 @@ //@ needs-sanitizer-address //@ ignore-cross-compile // -//@ compile-flags: -Zsanitizer=address +//@ compile-flags: -Zunstable-options -Csanitize=address //@ run-fail //@ error-pattern: ERROR: AddressSanitizer: stack-use-after-scope From 8d114eaf2437caca2afe57b7e286fc60ce81f43f Mon Sep 17 00:00:00 2001 From: Ramon de C Valle Date: Sat, 6 Apr 2024 14:43:39 -0700 Subject: [PATCH 2/4] sanitizers: Stabilize AddressSanitizer and LeakSanitizer Stabilize AddressSanitizer and LeakSanitizer for the Tier 1 targets that support them. --- .../src/spec/targets/aarch64_unknown_linux_gnu.rs | 5 +++-- .../src/spec/targets/i686_pc_windows_msvc.rs | 1 + .../src/spec/targets/i686_unknown_linux_gnu.rs | 1 + .../src/spec/targets/x86_64_apple_darwin.rs | 3 ++- .../src/spec/targets/x86_64_pc_windows_msvc.rs | 1 + .../src/spec/targets/x86_64_unknown_linux_gnu.rs | 3 ++- tests/ui/sanitizer/cfi-can-reveal-opaques.rs | 2 +- ...ble-supported-can-be-used-with-unstable-options.rs | 11 +++++++++++ ...pported-cannot-be-used-without-unstable-options.rs | 9 +++++++++ ...ted-cannot-be-used-without-unstable-options.stderr | 4 ++++ ...ble-supported-can-be-used-with-unstable-options.rs | 8 ++++++++ ...-supported-can-be-used-without-unstable-options.rs | 8 ++++++++ 12 files changed, 51 insertions(+), 5 deletions(-) create mode 100644 tests/ui/sanitizer/stable-and-unstable-supported-can-be-used-with-unstable-options.rs create mode 100644 tests/ui/sanitizer/stable-and-unstable-supported-cannot-be-used-without-unstable-options.rs create mode 100644 tests/ui/sanitizer/stable-and-unstable-supported-cannot-be-used-without-unstable-options.stderr create mode 100644 tests/ui/sanitizer/stable-supported-can-be-used-with-unstable-options.rs create mode 100644 tests/ui/sanitizer/stable-supported-can-be-used-without-unstable-options.rs diff --git a/compiler/rustc_target/src/spec/targets/aarch64_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/targets/aarch64_unknown_linux_gnu.rs index 1a45c2c5c05ef..3c36ddf616859 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_unknown_linux_gnu.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_unknown_linux_gnu.rs @@ -19,12 +19,13 @@ pub fn target() -> Target { stack_probes: StackProbeType::Inline, supported_sanitizers: SanitizerSet::ADDRESS | SanitizerSet::CFI + | SanitizerSet::HWADDRESS | SanitizerSet::KCFI | SanitizerSet::LEAK | SanitizerSet::MEMORY | SanitizerSet::MEMTAG - | SanitizerSet::THREAD - | SanitizerSet::HWADDRESS, + | SanitizerSet::THREAD, + stable_sanitizers: SanitizerSet::ADDRESS | SanitizerSet::LEAK, supports_xray: true, ..base::linux_gnu::opts() }, diff --git a/compiler/rustc_target/src/spec/targets/i686_pc_windows_msvc.rs b/compiler/rustc_target/src/spec/targets/i686_pc_windows_msvc.rs index 970b43ad109ba..bd2865a0ed580 100644 --- a/compiler/rustc_target/src/spec/targets/i686_pc_windows_msvc.rs +++ b/compiler/rustc_target/src/spec/targets/i686_pc_windows_msvc.rs @@ -5,6 +5,7 @@ pub fn target() -> Target { base.cpu = "pentium4".into(); base.max_atomic_width = Some(64); base.supported_sanitizers = SanitizerSet::ADDRESS; + base.stable_sanitizers = SanitizerSet::ADDRESS; base.add_pre_link_args( LinkerFlavor::Msvc(Lld::No), diff --git a/compiler/rustc_target/src/spec/targets/i686_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/targets/i686_unknown_linux_gnu.rs index 5584435a0ad9d..2d86fa2a475e4 100644 --- a/compiler/rustc_target/src/spec/targets/i686_unknown_linux_gnu.rs +++ b/compiler/rustc_target/src/spec/targets/i686_unknown_linux_gnu.rs @@ -5,6 +5,7 @@ pub fn target() -> Target { base.cpu = "pentium4".into(); base.max_atomic_width = Some(64); base.supported_sanitizers = SanitizerSet::ADDRESS; + base.stable_sanitizers = SanitizerSet::ADDRESS; base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32"]); base.stack_probes = StackProbeType::Inline; diff --git a/compiler/rustc_target/src/spec/targets/x86_64_apple_darwin.rs b/compiler/rustc_target/src/spec/targets/x86_64_apple_darwin.rs index c3a52a506bc9d..7729d1ce045b5 100644 --- a/compiler/rustc_target/src/spec/targets/x86_64_apple_darwin.rs +++ b/compiler/rustc_target/src/spec/targets/x86_64_apple_darwin.rs @@ -8,7 +8,8 @@ pub fn target() -> Target { base.frame_pointer = FramePointer::Always; base.add_pre_link_args(LinkerFlavor::Darwin(Cc::Yes, Lld::No), &["-m64"]); base.supported_sanitizers = - SanitizerSet::ADDRESS | SanitizerSet::CFI | SanitizerSet::LEAK | SanitizerSet::THREAD; + SanitizerSet::ADDRESS | SanitizerSet::LEAK | SanitizerSet::THREAD | SanitizerSet::CFI; + base.stable_sanitizers = SanitizerSet::ADDRESS | SanitizerSet::LEAK; Target { // Clang automatically chooses a more specific target based on diff --git a/compiler/rustc_target/src/spec/targets/x86_64_pc_windows_msvc.rs b/compiler/rustc_target/src/spec/targets/x86_64_pc_windows_msvc.rs index 3ef3e5114e682..cd2a717ce8b11 100644 --- a/compiler/rustc_target/src/spec/targets/x86_64_pc_windows_msvc.rs +++ b/compiler/rustc_target/src/spec/targets/x86_64_pc_windows_msvc.rs @@ -7,6 +7,7 @@ pub fn target() -> Target { base.plt_by_default = false; base.max_atomic_width = Some(128); base.supported_sanitizers = SanitizerSet::ADDRESS; + base.stable_sanitizers = SanitizerSet::ADDRESS; Target { llvm_target: "x86_64-pc-windows-msvc".into(), diff --git a/compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_gnu.rs index 4a92d4ef9d5ca..1c1b98b2adcbd 100644 --- a/compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_gnu.rs +++ b/compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_gnu.rs @@ -10,12 +10,13 @@ pub fn target() -> Target { base.static_position_independent_executables = true; base.supported_sanitizers = SanitizerSet::ADDRESS | SanitizerSet::CFI - | SanitizerSet::KCFI | SanitizerSet::DATAFLOW + | SanitizerSet::KCFI | SanitizerSet::LEAK | SanitizerSet::MEMORY | SanitizerSet::SAFESTACK | SanitizerSet::THREAD; + base.stable_sanitizers = SanitizerSet::ADDRESS | SanitizerSet::LEAK; base.supports_xray = true; // When we're asked to use the `rust-lld` linker by default, set the appropriate lld-using diff --git a/tests/ui/sanitizer/cfi-can-reveal-opaques.rs b/tests/ui/sanitizer/cfi-can-reveal-opaques.rs index 55988a62a8cdf..9d77830ef9338 100644 --- a/tests/ui/sanitizer/cfi-can-reveal-opaques.rs +++ b/tests/ui/sanitizer/cfi-can-reveal-opaques.rs @@ -1,5 +1,5 @@ //@ needs-sanitizer-cfi -//@ compile-flags: -Ccodegen-units=1 -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi +//@ compile-flags: -Ccodegen-units=1 -Clto -Ctarget-feature=-crt-static -Zunstable-options -Csanitize=cfi //@ no-prefer-dynamic //@ only-x86_64-unknown-linux-gnu //@ build-pass diff --git a/tests/ui/sanitizer/stable-and-unstable-supported-can-be-used-with-unstable-options.rs b/tests/ui/sanitizer/stable-and-unstable-supported-can-be-used-with-unstable-options.rs new file mode 100644 index 0000000000000..2678d8904011a --- /dev/null +++ b/tests/ui/sanitizer/stable-and-unstable-supported-can-be-used-with-unstable-options.rs @@ -0,0 +1,11 @@ +// Verifies that stable and unstable supported sanitizers can be used with `-Zunstable-options`. +// +//@ needs-llvm-components: x86 +//@ needs-sanitizer-support +//@ build-pass +//@ compile-flags: -Zunstable-options -Clto -Csanitize=address,cfi --target x86_64-unknown-linux-gnu + +#![crate_type = "rlib"] +#![feature(no_core)] +#![no_core] +#![no_main] diff --git a/tests/ui/sanitizer/stable-and-unstable-supported-cannot-be-used-without-unstable-options.rs b/tests/ui/sanitizer/stable-and-unstable-supported-cannot-be-used-without-unstable-options.rs new file mode 100644 index 0000000000000..da15546055ad9 --- /dev/null +++ b/tests/ui/sanitizer/stable-and-unstable-supported-cannot-be-used-without-unstable-options.rs @@ -0,0 +1,9 @@ +// Verifies that stable and unstable supported sanitizers cannot be used without +// `-Zunstable-options`. +// +//@ needs-llvm-components: x86 +//@ needs-sanitizer-support +//@ compile-flags: -Clto -Csanitize=address,cfi --target x86_64-unknown-linux-gnu +//@ error-pattern: error: cfi sanitizer is not supported for this target + +fn main() { } diff --git a/tests/ui/sanitizer/stable-and-unstable-supported-cannot-be-used-without-unstable-options.stderr b/tests/ui/sanitizer/stable-and-unstable-supported-cannot-be-used-without-unstable-options.stderr new file mode 100644 index 0000000000000..b423f8e9eec72 --- /dev/null +++ b/tests/ui/sanitizer/stable-and-unstable-supported-cannot-be-used-without-unstable-options.stderr @@ -0,0 +1,4 @@ +error: cfi sanitizer is not supported for this target + +error: aborting due to 1 previous error + diff --git a/tests/ui/sanitizer/stable-supported-can-be-used-with-unstable-options.rs b/tests/ui/sanitizer/stable-supported-can-be-used-with-unstable-options.rs new file mode 100644 index 0000000000000..1928c26dcbd5d --- /dev/null +++ b/tests/ui/sanitizer/stable-supported-can-be-used-with-unstable-options.rs @@ -0,0 +1,8 @@ +// Verifies that stable supported sanitizers can be used with `-Zunstable-options`. +// +//@ needs-llvm-components: x86 +//@ needs-sanitizer-support +//@ build-pass +//@ compile-flags: -Zunstable-options -Csanitize=address --target x86_64-unknown-linux-gnu + +fn main() { } diff --git a/tests/ui/sanitizer/stable-supported-can-be-used-without-unstable-options.rs b/tests/ui/sanitizer/stable-supported-can-be-used-without-unstable-options.rs new file mode 100644 index 0000000000000..0a3d79365b5fe --- /dev/null +++ b/tests/ui/sanitizer/stable-supported-can-be-used-without-unstable-options.rs @@ -0,0 +1,8 @@ +// Verifies that stable supported sanitizers can be used without `-Zunstable-options`. +// +//@ needs-llvm-components: x86 +//@ needs-sanitizer-support +//@ build-pass +//@ compile-flags: -Csanitize=address --target x86_64-unknown-linux-gnu + +fn main() { } From 9ee702b6f529485f54887476d6a70b50a5c76730 Mon Sep 17 00:00:00 2001 From: Ramon de C Valle Date: Thu, 16 May 2024 20:05:34 -0700 Subject: [PATCH 3/4] sanitizers: Add documentation for stable sanitizers --- src/doc/rustc/src/codegen-options/index.md | 40 ++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/doc/rustc/src/codegen-options/index.md b/src/doc/rustc/src/codegen-options/index.md index cb43feca758df..d263359724bd7 100644 --- a/src/doc/rustc/src/codegen-options/index.md +++ b/src/doc/rustc/src/codegen-options/index.md @@ -519,6 +519,46 @@ enabled. It takes one of the following values: * `y`, `yes`, `on`, `true` or no value: enable rpath. * `n`, `no`, `off` or `false`: disable rpath (the default). +## sanitize + +Sanitizers are tools that help detect and prevent various types of bugs and +vulnerabilities in software. They are available in compilers and work by +instrumenting the code to add additional runtime checks. While they provide +powerful tools for identifying bugs or security issues, it's important to note +that using sanitizers can introduce runtime overhead and might not catch all +possible issues. Therefore, they are typically used alongside other best +practices in software development, such as testing and fuzzing, to ensure the +highest level of software quality and security. + +This option allows for use of one or more of these sanitizers: + +* [AddressSanitizer](https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/sanitizer.html#addresssanitizer) + a fast memory error detector. +* [LeakSanitizer](https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/sanitizer.html#leaksanitizer) + a run-time memory leak detector. + +These are the valid values for this option for targets that support one or more +of these sanitizers: + +| Target | Sanitizers | +|--------|------------| +| aarch64-unknown-linux-gnu | address, leak | +| i586-pc-windows-msvc | address | +| i586-unknown-linux-gnu | address | +| i686-pc-windows-msvc | address | +| i686-unknown-linux-gnu | address | +| x86_64-apple-darwin | address, leak | +| x86_64-pc-windows-msvc | address | +| x86_64-unknown-linux-gnu | address, leak | + +For more information on sanitizers, see the +[sanitizer +feature](https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/sanitizer.html) +in the [The Rust Unstable +Book](https://doc.rust-lang.org/nightly/unstable-book/). For more information on +stable and supported sanitizers, see the [supported sanitizers +table](https://github.com/rust-lang/rust/issues/123615#issuecomment-2041791236). + ## save-temps This flag controls whether temporary files generated during compilation are From 8af3b93cfc48e2f5391a2079649b75aeb15cf809 Mon Sep 17 00:00:00 2001 From: Ramon de C Valle Date: Tue, 6 Aug 2024 15:42:33 -0700 Subject: [PATCH 4/4] sanitizers: Stabilize the `no_sanitize` attribute Stabilize the `no_sanitize` attribute so stable sanitizers can also be selectively disabled for annotated functions. --- compiler/rustc_feature/src/accepted.rs | 2 ++ compiler/rustc_feature/src/builtin_attrs.rs | 4 +-- compiler/rustc_feature/src/unstable.rs | 2 -- compiler/rustc_lint_defs/src/builtin.rs | 2 -- library/core/src/lib.rs | 2 ++ library/std/src/lib.rs | 2 ++ .../src/language-features/no-sanitize.md | 29 ------------------- .../cfi/emit-type-checks-attr-no-sanitize.rs | 1 - .../codegen/sanitizer/no-sanitize-inlining.rs | 2 -- tests/codegen/sanitizer/no-sanitize.rs | 2 -- tests/codegen/sanitizer/scs-attr-check.rs | 2 -- tests/mir-opt/inline/inline_compatibility.rs | 1 - .../feature-gates/feature-gate-no_sanitize.rs | 4 --- .../feature-gate-no_sanitize.stderr | 13 --------- tests/ui/invalid/invalid-no-sanitize.rs | 2 -- tests/ui/invalid/invalid-no-sanitize.stderr | 2 +- tests/ui/sanitizer/inline-always.rs | 2 -- tests/ui/sanitizer/inline-always.stderr | 4 +-- 18 files changed, 11 insertions(+), 67 deletions(-) delete mode 100644 src/doc/unstable-book/src/language-features/no-sanitize.md delete mode 100644 tests/ui/feature-gates/feature-gate-no_sanitize.rs delete mode 100644 tests/ui/feature-gates/feature-gate-no_sanitize.stderr diff --git a/compiler/rustc_feature/src/accepted.rs b/compiler/rustc_feature/src/accepted.rs index e42a655531b5d..49f558344c87e 100644 --- a/compiler/rustc_feature/src/accepted.rs +++ b/compiler/rustc_feature/src/accepted.rs @@ -284,6 +284,8 @@ declare_features! ( (accepted, native_link_modifiers_whole_archive, "1.61.0", Some(81490)), /// Allows using non lexical lifetimes (RFC 2094). (accepted, nll, "1.63.0", Some(43234)), + /// Allows the use of `no_sanitize` attribute. + (accepted, no_sanitize, "CURRENT_RUSTC_VERSION", Some(39699)), /// Allows using `#![no_std]`. (accepted, no_std, "1.6.0", None), /// Allows defining identifiers beyond ASCII. diff --git a/compiler/rustc_feature/src/builtin_attrs.rs b/compiler/rustc_feature/src/builtin_attrs.rs index 72ea55d5999a2..2182d3b5f0033 100644 --- a/compiler/rustc_feature/src/builtin_attrs.rs +++ b/compiler/rustc_feature/src/builtin_attrs.rs @@ -475,10 +475,10 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ ), ungated!(track_caller, Normal, template!(Word), WarnFollowing, EncodeCrossCrate::Yes), ungated!(instruction_set, Normal, template!(List: "set"), ErrorPreceding, EncodeCrossCrate::No), - gated!( + ungated!( no_sanitize, Normal, template!(List: "address, kcfi, memory, thread"), DuplicatesOk, - EncodeCrossCrate::No, experimental!(no_sanitize) + EncodeCrossCrate::No ), gated!( coverage, Normal, template!(OneOf: &[sym::off, sym::on]), diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index 88a4b5a838246..ad859e13c5832 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -546,8 +546,6 @@ declare_features! ( (unstable, never_type_fallback, "1.41.0", Some(65992)), /// Allows `#![no_core]`. (unstable, no_core, "1.3.0", Some(29639)), - /// Allows the use of `no_sanitize` attribute. - (unstable, no_sanitize, "1.42.0", Some(39699)), /// Allows using the `non_exhaustive_omitted_patterns` lint. (unstable, non_exhaustive_omitted_patterns_lint, "1.57.0", Some(89554)), /// Allows `for` binders in where-clauses diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index ff0bdfcc9d261..23afc05a25823 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -2457,8 +2457,6 @@ declare_lint! { /// ### Example /// /// ```rust - /// #![feature(no_sanitize)] - /// /// #[inline(always)] /// #[no_sanitize(address)] /// fn x() {} diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index e74900ff7471b..b6483292ef80b 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -104,6 +104,8 @@ // Do not check link redundancy on bootstraping phase #![allow(rustdoc::redundant_explicit_links)] #![warn(rustdoc::unescaped_backticks)] +// FIXME: Remove after `no_sanitize` stabilization (along with `#![feature(no_sanitize)]`) +#![allow(stable_features)] // // Library features: // tidy-alphabetical-start diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index 67405d788bd9b..0c6c237df9adb 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -259,6 +259,8 @@ #![deny(ffi_unwind_calls)] // std may use features in a platform-specific way #![allow(unused_features)] +// FIXME: Remove after `no_sanitize` stabilization (along with `#![feature(no_sanitize)]`) +#![allow(stable_features)] // // Features: #![cfg_attr(test, feature(internal_output_capture, print_internals, update_panic_count, rt))] diff --git a/src/doc/unstable-book/src/language-features/no-sanitize.md b/src/doc/unstable-book/src/language-features/no-sanitize.md deleted file mode 100644 index 28c683934d4ed..0000000000000 --- a/src/doc/unstable-book/src/language-features/no-sanitize.md +++ /dev/null @@ -1,29 +0,0 @@ -# `no_sanitize` - -The tracking issue for this feature is: [#39699] - -[#39699]: https://github.com/rust-lang/rust/issues/39699 - ------------------------- - -The `no_sanitize` attribute can be used to selectively disable sanitizer -instrumentation in an annotated function. This might be useful to: avoid -instrumentation overhead in a performance critical function, or avoid -instrumenting code that contains constructs unsupported by given sanitizer. - -The precise effect of this annotation depends on particular sanitizer in use. -For example, with `no_sanitize(thread)`, the thread sanitizer will no longer -instrument non-atomic store / load operations, but it will instrument atomic -operations to avoid reporting false positives and provide meaning full stack -traces. - -## Examples - -``` rust -#![feature(no_sanitize)] - -#[no_sanitize(address)] -fn foo() { - // ... -} -``` diff --git a/tests/codegen/sanitizer/cfi/emit-type-checks-attr-no-sanitize.rs b/tests/codegen/sanitizer/cfi/emit-type-checks-attr-no-sanitize.rs index 7b50ee77679da..a9a91339795b4 100644 --- a/tests/codegen/sanitizer/cfi/emit-type-checks-attr-no-sanitize.rs +++ b/tests/codegen/sanitizer/cfi/emit-type-checks-attr-no-sanitize.rs @@ -4,7 +4,6 @@ //@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zunstable-options -Csanitize=cfi -Copt-level=0 #![crate_type = "lib"] -#![feature(no_sanitize)] #[no_sanitize(cfi)] pub fn foo(f: fn(i32) -> i32, arg: i32) -> i32 { diff --git a/tests/codegen/sanitizer/no-sanitize-inlining.rs b/tests/codegen/sanitizer/no-sanitize-inlining.rs index 55689a2d6d31e..b813ff584a8f0 100644 --- a/tests/codegen/sanitizer/no-sanitize-inlining.rs +++ b/tests/codegen/sanitizer/no-sanitize-inlining.rs @@ -9,8 +9,6 @@ //@[LSAN] compile-flags: -Zunstable-options -Csanitize=leak #![crate_type = "lib"] -#![feature(no_sanitize)] - // ASAN-LABEL: define void @test // ASAN: call {{.*}} @random_inline // ASAN: } diff --git a/tests/codegen/sanitizer/no-sanitize.rs b/tests/codegen/sanitizer/no-sanitize.rs index 477418d35db73..e5b8bb4c9120e 100644 --- a/tests/codegen/sanitizer/no-sanitize.rs +++ b/tests/codegen/sanitizer/no-sanitize.rs @@ -5,8 +5,6 @@ //@ compile-flags: -Zunstable-options -Csanitize=address -Ctarget-feature=-crt-static -Copt-level=0 #![crate_type = "lib"] -#![feature(no_sanitize)] - // CHECK-LABEL: ; no_sanitize::unsanitized // CHECK-NEXT: ; Function Attrs: // CHECK-NOT: sanitize_address diff --git a/tests/codegen/sanitizer/scs-attr-check.rs b/tests/codegen/sanitizer/scs-attr-check.rs index 4c23dab7a5360..f0f593e810fb8 100644 --- a/tests/codegen/sanitizer/scs-attr-check.rs +++ b/tests/codegen/sanitizer/scs-attr-check.rs @@ -5,8 +5,6 @@ //@ compile-flags: -Zunstable-options -Csanitize=shadow-call-stack #![crate_type = "lib"] -#![feature(no_sanitize)] - // CHECK: ; sanitizer_scs_attr_check::scs // CHECK-NEXT: ; Function Attrs:{{.*}}shadowcallstack pub fn scs() {} diff --git a/tests/mir-opt/inline/inline_compatibility.rs b/tests/mir-opt/inline/inline_compatibility.rs index 13f28aaacd6a7..d7d7bc773a2ed 100644 --- a/tests/mir-opt/inline/inline_compatibility.rs +++ b/tests/mir-opt/inline/inline_compatibility.rs @@ -3,7 +3,6 @@ //@ compile-flags: -Cpanic=abort #![crate_type = "lib"] -#![feature(no_sanitize)] #![feature(target_feature_11)] #![feature(c_variadic)] diff --git a/tests/ui/feature-gates/feature-gate-no_sanitize.rs b/tests/ui/feature-gates/feature-gate-no_sanitize.rs deleted file mode 100644 index 66a9263e13a53..0000000000000 --- a/tests/ui/feature-gates/feature-gate-no_sanitize.rs +++ /dev/null @@ -1,4 +0,0 @@ -#[no_sanitize(address)] -//~^ the `#[no_sanitize]` attribute is an experimental feature -fn main() { -} diff --git a/tests/ui/feature-gates/feature-gate-no_sanitize.stderr b/tests/ui/feature-gates/feature-gate-no_sanitize.stderr deleted file mode 100644 index a33bf6a9e40c1..0000000000000 --- a/tests/ui/feature-gates/feature-gate-no_sanitize.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0658]: the `#[no_sanitize]` attribute is an experimental feature - --> $DIR/feature-gate-no_sanitize.rs:1:1 - | -LL | #[no_sanitize(address)] - | ^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #39699 for more information - = help: add `#![feature(no_sanitize)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/invalid/invalid-no-sanitize.rs b/tests/ui/invalid/invalid-no-sanitize.rs index b52e3cc83fab2..14e4e797d2f4b 100644 --- a/tests/ui/invalid/invalid-no-sanitize.rs +++ b/tests/ui/invalid/invalid-no-sanitize.rs @@ -1,5 +1,3 @@ -#![feature(no_sanitize)] - #[no_sanitize(brontosaurus)] //~ ERROR invalid argument fn main() { } diff --git a/tests/ui/invalid/invalid-no-sanitize.stderr b/tests/ui/invalid/invalid-no-sanitize.stderr index b1c80438b318d..630282290e903 100644 --- a/tests/ui/invalid/invalid-no-sanitize.stderr +++ b/tests/ui/invalid/invalid-no-sanitize.stderr @@ -1,5 +1,5 @@ error: invalid argument for `no_sanitize` - --> $DIR/invalid-no-sanitize.rs:3:15 + --> $DIR/invalid-no-sanitize.rs:1:15 | LL | #[no_sanitize(brontosaurus)] | ^^^^^^^^^^^^ diff --git a/tests/ui/sanitizer/inline-always.rs b/tests/ui/sanitizer/inline-always.rs index d92daee3026a6..6480f43e51c04 100644 --- a/tests/ui/sanitizer/inline-always.rs +++ b/tests/ui/sanitizer/inline-always.rs @@ -1,7 +1,5 @@ //@ check-pass -#![feature(no_sanitize)] - #[inline(always)] //~^ NOTE inlining requested here #[no_sanitize(address)] diff --git a/tests/ui/sanitizer/inline-always.stderr b/tests/ui/sanitizer/inline-always.stderr index 74fba3c0e0e59..aeb5933773bd1 100644 --- a/tests/ui/sanitizer/inline-always.stderr +++ b/tests/ui/sanitizer/inline-always.stderr @@ -1,11 +1,11 @@ warning: `no_sanitize` will have no effect after inlining - --> $DIR/inline-always.rs:7:1 + --> $DIR/inline-always.rs:5:1 | LL | #[no_sanitize(address)] | ^^^^^^^^^^^^^^^^^^^^^^^ | note: inlining requested here - --> $DIR/inline-always.rs:5:1 + --> $DIR/inline-always.rs:3:1 | LL | #[inline(always)] | ^^^^^^^^^^^^^^^^^