From 7f51a73aa1be3a0ad8ca7444f0247cc4f92c38c4 Mon Sep 17 00:00:00 2001 From: Ramon de C Valle Date: Sat, 6 Apr 2024 14:07:49 -0700 Subject: [PATCH 1/5] 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 | 8 +-- .../src/back/symbol_export.rs | 8 +-- compiler/rustc_codegen_ssa/src/back/write.rs | 2 +- compiler/rustc_interface/src/tests.rs | 2 +- compiler/rustc_metadata/src/native_libs.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 | 57 +++++++++++++++---- compiler/rustc_target/src/spec/json.rs | 38 ++++--------- compiler/rustc_target/src/spec/mod.rs | 35 ++++++++++++ src/tools/compiletest/src/common.rs | 4 +- src/tools/compiletest/src/header/needs.rs | 14 +++-- tests/codegen/naked-asan.rs | 2 +- ...arch64-shadow-call-stack-with-fixed-x18.rs | 4 +- .../address-sanitizer-globals-tracking.rs | 3 +- .../cfi/add-canonical-jump-tables-flag.rs | 2 +- .../cfi/add-cfi-normalize-integers-flag.rs | 2 +- .../cfi/add-enable-split-lto-unit-flag.rs | 2 +- .../cfi/dbg-location-on-cfi-blocks.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 +- .../kcfi/add-cfi-normalize-integers-flag.rs | 2 +- tests/codegen/sanitizer/kcfi/add-kcfi-flag.rs | 2 +- .../sanitizer/kcfi/add-kcfi-offset-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 +- .../sanitizer/riscv64-shadow-call-stack.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 ------ .../shadow-call-stack-without-fixed-x18.rs | 2 +- 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 +- tests/ui/sanitizer/cfi/can-reveal-opaques.rs | 2 +- .../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 +- .../generalize-pointers-requires-cfi.stderr | 2 +- .../ui/sanitizer/cfi/invalid-attr-encoding.rs | 2 +- .../is-incompatible-with-kcfi.aarch64.stderr | 2 +- .../cfi/is-incompatible-with-kcfi.rs | 4 +- .../is-incompatible-with-kcfi.x86_64.stderr | 2 +- .../cfi/normalize-integers-attr-cfg.rs | 2 +- .../cfi/normalize-integers-requires-cfi.rs | 4 +- .../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 +- .../sanitizer/cfi/transparent-has-regions.rs | 2 +- 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 | 2 +- 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.stderr | 4 -- tests/ui/sanitizer/use-after-scope.rs | 2 +- 123 files changed, 323 insertions(+), 247 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.stderr diff --git a/compiler/rustc_codegen_llvm/src/abi.rs b/compiler/rustc_codegen_llvm/src/abi.rs index 8294e29d07df6..e101f426e1f60 100644 --- a/compiler/rustc_codegen_llvm/src/abi.rs +++ b/compiler/rustc_codegen_llvm/src/abi.rs @@ -14,7 +14,6 @@ use rustc_session::config; use rustc_target::callconv::{ ArgAbi, ArgAttribute, ArgAttributes, ArgExtension, CastTarget, Conv, FnAbi, PassMode, }; -use rustc_target::spec::SanitizerSet; use smallvec::SmallVec; use crate::attributes::{self, llfn_attrs_from_instance}; @@ -82,7 +81,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 e8c42d16733ec..912206a440d28 100644 --- a/compiler/rustc_codegen_llvm/src/attributes.rs +++ b/compiler/rustc_codegen_llvm/src/attributes.rs @@ -86,7 +86,7 @@ pub(crate) 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)); } @@ -219,13 +219,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 8de68925cabbc..2b4024f77c6d4 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -1250,7 +1250,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"); } @@ -2480,11 +2480,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 fd06c50eb8145..519ddf0abcb2d 100644 --- a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs +++ b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs @@ -15,7 +15,7 @@ use rustc_middle::util::Providers; use rustc_session::config::{CrateType, OomStrategy}; use rustc_symbol_mangling::mangle_internal_symbol; use rustc_target::callconv::Conv; -use rustc_target::spec::{SanitizerSet, TlsModel}; +use rustc_target::spec::TlsModel; use tracing::debug; use crate::base::allocator_kind_for_codegen; @@ -267,15 +267,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 0fd4ed8475b49..2b713bafe1207 100644 --- a/compiler/rustc_codegen_ssa/src/back/write.rs +++ b/compiler/rustc_codegen_ssa/src/back/write.rs @@ -186,7 +186,7 @@ impl ModuleConfig { debug_info_for_profiling: sess.opts.unstable_opts.debug_info_for_profiling, instrument_coverage: if_regular!(sess.instrument_coverage(), 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 5c8c51c8bbcc2..a59938e51578c 100644 --- a/compiler/rustc_interface/src/tests.rs +++ b/compiler/rustc_interface/src/tests.rs @@ -637,6 +637,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)); @@ -849,7 +850,6 @@ fn test_unstable_options_tracking_hash() { tracked!(regparm, Some(3)); 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_metadata/src/native_libs.rs b/compiler/rustc_metadata/src/native_libs.rs index cee9cff077503..0e136b3360ae2 100644 --- a/compiler/rustc_metadata/src/native_libs.rs +++ b/compiler/rustc_metadata/src/native_libs.rs @@ -73,7 +73,7 @@ pub fn walk_native_lib_search_dirs( || sess.target.os == "linux" || sess.target.os == "fuchsia" || sess.target.is_like_aix - || sess.target.is_like_darwin && !sess.opts.unstable_opts.sanitizer.is_empty() + || sess.target.is_like_darwin && !sess.opts.cg.sanitize.is_empty() { f(&sess.target_tlib_path.dir, false)?; } diff --git a/compiler/rustc_session/messages.ftl b/compiler/rustc_session/messages.ftl index 528c52eace7cb..4df4fdf748e3b 100644 --- a/compiler/rustc_session/messages.ftl +++ b/compiler/rustc_session/messages.ftl @@ -9,7 +9,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 @@ -90,15 +90,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_arity_requires_kcfi = `-Zsanitizer-kcfi-arity` requires `-Zsanitizer=kcfi` diff --git a/compiler/rustc_session/src/config/cfg.rs b/compiler/rustc_session/src/config/cfg.rs index 231ca434962e6..41b6e9b1c65af 100644 --- a/compiler/rustc_session/src/config/cfg.rs +++ b/compiler/rustc_session/src/config/cfg.rs @@ -212,7 +212,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 36eee5f308656..bab9deb573d46 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -1156,25 +1156,14 @@ pub 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 } @@ -2043,6 +2032,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], @@ -2440,8 +2431,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 010ae42c2802d..83b4808d752f2 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -371,8 +371,12 @@ impl Session { self.opts.unstable_opts.coverage_options.discard_all_spans_in_codegen } + 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 { @@ -391,12 +395,36 @@ 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_arity_enabled(&self) -> bool { self.opts.unstable_opts.sanitizer_kcfi_arity == Some(true) } 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 { @@ -578,7 +606,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 { @@ -714,7 +745,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 } } @@ -1211,14 +1242,19 @@ 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 mut 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 mut unsupported_sanitizers = sess.opts.cg.sanitize - supported_sanitizers; + // Niche: if `fixed-x18`, or effectively switching on `reserved-x18` flag, is enabled // we should allow Shadow Call Stack sanitizer. if sess.opts.unstable_opts.fixed_x18 && sess.target.arch == "aarch64" { unsupported_sanitizers -= SanitizerSet::SHADOWCALLSTACK; } + match unsupported_sanitizers.into_iter().count() { 0 => {} 1 => { @@ -1233,7 +1269,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(), @@ -1241,10 +1277,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/json.rs b/compiler/rustc_target/src/spec/json.rs index be71da76b4a35..584d1fc367708 100644 --- a/compiler/rustc_target/src/spec/json.rs +++ b/compiler/rustc_target/src/spec/json.rs @@ -6,6 +6,7 @@ use serde_json::Value; use super::{Target, TargetKind, TargetOptions, TargetWarnings}; use crate::json::{Json, ToJson}; +use crate::spec::SanitizerSet; impl Target { /// Loads a target descriptor from a JSON object. @@ -357,32 +358,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 { - use super::SanitizerSet; - 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: @@ -656,6 +640,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!(small_data_threshold_support, SmallDataThresholdSupport)?; @@ -835,6 +820,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/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index 3c769dad630a1..debf305cbb58e 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -1508,6 +1508,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() @@ -2639,6 +2670,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, @@ -2882,6 +2916,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, diff --git a/src/tools/compiletest/src/common.rs b/src/tools/compiletest/src/common.rs index de93e2b99eede..811cf35155b27 100644 --- a/src/tools/compiletest/src/common.rs +++ b/src/tools/compiletest/src/common.rs @@ -707,7 +707,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 2ace40c490bf3..9675272dd8f71 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 { @@ -314,7 +314,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, @@ -333,14 +333,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/naked-asan.rs b/tests/codegen/naked-asan.rs index 223c41b15bb35..ffbd84e3012b7 100644 --- a/tests/codegen/naked-asan.rs +++ b/tests/codegen/naked-asan.rs @@ -2,7 +2,7 @@ //@ only-x86_64 //@ needs-sanitizer-address -//@ compile-flags: -Zsanitizer=address -Ctarget-feature=-crt-static +//@ compile-flags: -Zunstable-options -Csanitize=address -Ctarget-feature=-crt-static #![crate_type = "lib"] #![no_std] diff --git a/tests/codegen/sanitizer/aarch64-shadow-call-stack-with-fixed-x18.rs b/tests/codegen/sanitizer/aarch64-shadow-call-stack-with-fixed-x18.rs index e1d7dc2d631f0..d3752dc8aaa0b 100644 --- a/tests/codegen/sanitizer/aarch64-shadow-call-stack-with-fixed-x18.rs +++ b/tests/codegen/sanitizer/aarch64-shadow-call-stack-with-fixed-x18.rs @@ -1,8 +1,8 @@ //@ add-core-stubs //@ revisions: aarch64 android -//@[aarch64] compile-flags: --target aarch64-unknown-none -Zfixed-x18 -Zsanitizer=shadow-call-stack +//@[aarch64] compile-flags: --target aarch64-unknown-none -Zfixed-x18 -Zunstable-options -Csanitize=shadow-call-stack //@[aarch64] needs-llvm-components: aarch64 -//@[android] compile-flags: --target aarch64-linux-android -Zsanitizer=shadow-call-stack +//@[android] compile-flags: --target aarch64-linux-android -Zunstable-options -Csanitize=shadow-call-stack //@[android] needs-llvm-components: aarch64 #![allow(internal_features)] 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-cfi-normalize-integers-flag.rs b/tests/codegen/sanitizer/cfi/add-cfi-normalize-integers-flag.rs index a54a6d84a8073..da122c533807d 100644 --- a/tests/codegen/sanitizer/cfi/add-cfi-normalize-integers-flag.rs +++ b/tests/codegen/sanitizer/cfi/add-cfi-normalize-integers-flag.rs @@ -1,7 +1,7 @@ // Verifies that "cfi-normalize-integers" module flag is added. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-normalize-integers +//@ compile-flags: -Clto -Ctarget-feature=-crt-static -Zunstable-options -Csanitize=cfi -Zsanitizer-cfi-normalize-integers #![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/dbg-location-on-cfi-blocks.rs b/tests/codegen/sanitizer/cfi/dbg-location-on-cfi-blocks.rs index df65960dfe0be..7f06a4d98d2f9 100644 --- a/tests/codegen/sanitizer/cfi/dbg-location-on-cfi-blocks.rs +++ b/tests/codegen/sanitizer/cfi/dbg-location-on-cfi-blocks.rs @@ -1,7 +1,7 @@ // Verifies that the parent block's debug information are assigned to the inserted cfi block. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static -Cdebuginfo=1 +//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zunstable-options -Csanitize=cfi -Ctarget-feature=-crt-static -Cdebuginfo=1 #![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 71ccdc8ca624f..b897f6e18293e 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 ebc66a015df69..6056e82fccccf 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 9048c6a1f1838..31ad2cde559ef 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 36d2e8c9f25a2..da933ab4c67a5 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 a8ba8db1be3b4..1abf49fbf7250 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 774c9ab53f1e7..a594a73522fda 100644 --- a/tests/codegen/sanitizer/kasan-emits-instrumentation.rs +++ b/tests/codegen/sanitizer/kasan-emits-instrumentation.rs @@ -1,7 +1,7 @@ -// Verifies that `-Zsanitizer=kernel-address` emits sanitizer instrumentation. +// Verifies that `-Csanitize=kernel-address` emits sanitizer instrumentation. //@ add-core-stubs -//@ compile-flags: -Zsanitizer=kernel-address -Copt-level=0 +//@ compile-flags: -Zunstable-options -Zsanitizer=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-cfi-normalize-integers-flag.rs b/tests/codegen/sanitizer/kcfi/add-cfi-normalize-integers-flag.rs index 0be1ff1977492..c0f1346668a19 100644 --- a/tests/codegen/sanitizer/kcfi/add-cfi-normalize-integers-flag.rs +++ b/tests/codegen/sanitizer/kcfi/add-cfi-normalize-integers-flag.rs @@ -6,7 +6,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 -Zsanitizer-cfi-normalize-integers +//@ compile-flags: -Ctarget-feature=-crt-static -Zunstable-options -Csanitize=kcfi -Zsanitizer-cfi-normalize-integers #![feature(no_core, lang_items)] #![crate_type = "lib"] diff --git a/tests/codegen/sanitizer/kcfi/add-kcfi-flag.rs b/tests/codegen/sanitizer/kcfi/add-kcfi-flag.rs index eabe0409c9a33..7d7e895072bb6 100644 --- a/tests/codegen/sanitizer/kcfi/add-kcfi-flag.rs +++ b/tests/codegen/sanitizer/kcfi/add-kcfi-flag.rs @@ -6,7 +6,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/add-kcfi-offset-flag.rs b/tests/codegen/sanitizer/kcfi/add-kcfi-offset-flag.rs index 2f18c9d84b90f..00c6eed31a3bf 100644 --- a/tests/codegen/sanitizer/kcfi/add-kcfi-offset-flag.rs +++ b/tests/codegen/sanitizer/kcfi/add-kcfi-offset-flag.rs @@ -6,7 +6,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 -Z patchable-function-entry=4,3 +//@ compile-flags: -Ctarget-feature=-crt-static -Zunstable-options -Csanitize=kcfi -Z patchable-function-entry=4,3 #![feature(no_core, lang_items, patchable_function_entry)] #![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 6b40918dd3af1..8741b106b99a5 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 @@ -6,7 +6,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 942b50deb0284..84df1298fc288 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 @@ -6,7 +6,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 c89d9bdd12176..e1489ce0015c6 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 @@ -6,7 +6,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 220cae1a4fa37..ca81bacb5d6d5 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 @@ -6,7 +6,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 bb9a000590302..37b7c044b6348 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 @@ -6,7 +6,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 8b844b991429b..a3def302ebcb4 100644 --- a/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle.rs +++ b/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle.rs @@ -6,7 +6,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 15c107bea158b..ad70d77fa751b 100644 --- a/tests/codegen/sanitizer/kcfi/emit-type-metadata-trait-objects.rs +++ b/tests/codegen/sanitizer/kcfi/emit-type-metadata-trait-objects.rs @@ -6,7 +6,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 2a309f6b9c696..d1d15cdf89ad3 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/riscv64-shadow-call-stack.rs b/tests/codegen/sanitizer/riscv64-shadow-call-stack.rs index 945e46218d04a..d0f3e9a3bd4a7 100644 --- a/tests/codegen/sanitizer/riscv64-shadow-call-stack.rs +++ b/tests/codegen/sanitizer/riscv64-shadow-call-stack.rs @@ -1,5 +1,5 @@ //@ add-core-stubs -//@ compile-flags: --target riscv64imac-unknown-none-elf -Zsanitizer=shadow-call-stack +//@ compile-flags: --target riscv64imac-unknown-none-elf -Zunstable-options -Zsanitizer=shadow-call-stack //@ needs-llvm-components: riscv #![allow(internal_features)] 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/abi/shadow-call-stack-without-fixed-x18.rs b/tests/ui/abi/shadow-call-stack-without-fixed-x18.rs index 74882fb5c55ce..df0ee60db6352 100644 --- a/tests/ui/abi/shadow-call-stack-without-fixed-x18.rs +++ b/tests/ui/abi/shadow-call-stack-without-fixed-x18.rs @@ -1,4 +1,4 @@ -//@ compile-flags: --target aarch64-unknown-none -Zsanitizer=shadow-call-stack +//@ compile-flags: --target aarch64-unknown-none -Zunstable-options -Csanitize=shadow-call-stack //@ dont-check-compiler-stderr //@ needs-llvm-components: aarch64 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 ba0abf605707a..63bd456a1f4b5 100644 --- a/tests/ui/sanitizer/cfg-kasan.rs +++ b/tests/ui/sanitizer/cfg-kasan.rs @@ -1,9 +1,9 @@ -// Verifies that when compiling with -Zsanitizer=kernel-address, +// Verifies that when compiling with -Csanitize=kernel-address, // the `#[cfg(sanitize = "address")]` attribute is configured. //@ add-core-stubs //@ 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 a43813c04469f..e13192ecb1a04 100644 --- a/tests/ui/sanitizer/cfg.rs +++ b/tests/ui/sanitizer/cfg.rs @@ -1,4 +1,4 @@ -// Verifies that when compiling with -Zsanitizer=option, +// Verifies that when compiling with -Csanitize=option, // the `#[cfg(sanitize = "option")]` attribute is configured. //@ add-core-stubs @@ -6,19 +6,19 @@ //@ revisions: address cfi kcfi leak memory thread //@compile-flags: -Ctarget-feature=-crt-static //@[address]needs-sanitizer-address -//@[address]compile-flags: -Zsanitizer=address +//@[address]compile-flags: -Zunstable-options -Csanitize=address //@[cfi]needs-sanitizer-cfi -//@[cfi]compile-flags: -Zsanitizer=cfi +//@[cfi]compile-flags: -Zunstable-options -Csanitize=cfi //@[cfi]compile-flags: -Clto -Ccodegen-units=1 //@[kcfi]needs-llvm-components: x86 -//@[kcfi]compile-flags: -Zsanitizer=kcfi --target x86_64-unknown-none -//@[kcfi]compile-flags: -C panic=abort +//@[kcfi]compile-flags: -Zunstable-options -Csanitize=kcfi +//@[kcfi]compile-flags: --target x86_64-unknown-none -C panic=abort //@[leak]needs-sanitizer-leak -//@[leak]compile-flags: -Zsanitizer=leak +//@[leak]compile-flags: -Zunstable-options -Csanitize=leak //@[memory]needs-sanitizer-memory -//@[memory]compile-flags: -Zsanitizer=memory +//@[memory]compile-flags: -Zunstable-options -Csanitize=memory //@[thread]needs-sanitizer-thread -//@[thread]compile-flags: -Zsanitizer=thread +//@[thread]compile-flags: -Zunstable-options -Csanitize=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 f4f383e008a08..d8921fd4238ce 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 +//@ 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 diff --git a/tests/ui/sanitizer/cfi/async-closures.rs b/tests/ui/sanitizer/cfi/async-closures.rs index 351853ab1a710..1244a5151ccc3 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/can-reveal-opaques.rs b/tests/ui/sanitizer/cfi/can-reveal-opaques.rs index 99c12d72eb524..0475b3b5755fd 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/cfi/canonical-jump-tables-requires-cfi.rs b/tests/ui/sanitizer/cfi/canonical-jump-tables-requires-cfi.rs index 36f6e3bc95e18..c3adfcd9befef 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 39a754f103637..c90d5f7ac854b 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 //@ 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 83277da528c96..43032944f070a 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-encoding.rs b/tests/ui/sanitizer/cfi/invalid-attr-encoding.rs index 7ef6bd2f0acc3..153182f6895b5 100644 --- a/tests/ui/sanitizer/cfi/invalid-attr-encoding.rs +++ b/tests/ui/sanitizer/cfi/invalid-attr-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 db8d11616440d..9341370f12ac1 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 b9d5b9623d5f0..656178e8e8737 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 db83f5f6bf020..49138c1f261c3 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 f80b316918804..722d1963e7dbc 100644 --- a/tests/ui/sanitizer/cfi/supertraits.rs +++ b/tests/ui/sanitizer/cfi/supertraits.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/transparent-has-regions.rs b/tests/ui/sanitizer/cfi/transparent-has-regions.rs index b70e1ea179121..069708d15d141 100644 --- a/tests/ui/sanitizer/cfi/transparent-has-regions.rs +++ b/tests/ui/sanitizer/cfi/transparent-has-regions.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/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 4ef5b6756a495..b8476402be72b 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 b8bdf28351c3d..be989436c8fe9 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 c706a5a2e4e7b..418ba67162812 100644 --- a/tests/ui/sanitizer/incompatible.rs +++ b/tests/ui/sanitizer/incompatible.rs @@ -1,4 +1,4 @@ -//@ 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 #![feature(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 7d0c73c2841e8..780bffae966a0 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 +//@ 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 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 532d7b308f63d..3a573787c3c3d 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 96a4cd909c7c2..4e6e4aaff3070 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 a91fefe4d16da..69f92b9b397d0 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 566774d6b1d64..2a071712f8fef 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..4d7ca813793ff --- /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: -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.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 0b4d96064cefca4daea0eb596316d6b5788dbaf6 Mon Sep 17 00:00:00 2001 From: Ramon de C Valle Date: Sat, 6 Apr 2024 14:43:39 -0700 Subject: [PATCH 2/5] 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 | 1 + .../src/spec/targets/x86_64_pc_windows_msvc.rs | 1 + .../src/spec/targets/x86_64_unknown_linux_gnu.rs | 3 ++- tests/codegen/sanitizer/cfi/external_weak_symbols.rs | 2 +- .../codegen/sanitizer/kasan-emits-instrumentation.rs | 2 +- tests/codegen/sanitizer/riscv64-shadow-call-stack.rs | 2 +- tests/ui/asm/global-asm-isnt-really-a-mir-body.rs | 2 +- .../cfi/canonical-jump-tables-requires-cfi.rs | 2 +- .../sanitizer/cfi/generalize-pointers-requires-cfi.rs | 2 +- tests/ui/sanitizer/cfi/is-incompatible-with-kcfi.rs | 2 +- .../sanitizer/cfi/normalize-integers-requires-cfi.rs | 2 +- tests/ui/sanitizer/cfi/requires-lto.rs | 2 +- .../with-rustc-lto-requires-single-codegen-unit.rs | 2 +- tests/ui/sanitizer/incompatible.rs | 2 +- tests/ui/sanitizer/kcfi-arity-requires-llvm-21-0-0.rs | 5 +++-- ...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 ++++++++ ...pported-cannot-be-used-without-unstable-options.rs | 3 ++- ...nsupported-cannot-be-used-with-unstable-options.rs | 2 ++ ...pported-cannot-be-used-without-unstable-options.rs | 3 ++- tests/ui/sanitizer/unsupported-target.rs | 8 -------- 27 files changed, 69 insertions(+), 26 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 delete mode 100644 tests/ui/sanitizer/unsupported-target.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 c6be2c20ea233..bf95a16f6605a 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(crate) 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 6a95afa1d0d3c..816ab03a3fc6e 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 @@ -6,6 +6,7 @@ pub(crate) 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 c70c026f9f71e..53f53a098e9f0 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 @@ -19,6 +19,7 @@ pub(crate) 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 2f868e38f1a51..23713857be611 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 @@ -23,6 +23,7 @@ pub(crate) fn target() -> Target { | SanitizerSet::CFI | SanitizerSet::LEAK | SanitizerSet::THREAD, + stable_sanitizers: SanitizerSet::ADDRESS | SanitizerSet::LEAK, ..opts }, } 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 d88aabaa6d336..b73ee3d2781d1 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(crate) 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 0c8353fad182f..cd9542ecafbb8 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 @@ -12,12 +12,13 @@ pub(crate) 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/codegen/sanitizer/cfi/external_weak_symbols.rs b/tests/codegen/sanitizer/cfi/external_weak_symbols.rs index 00e9b5029af8c..e04f6055915a2 100644 --- a/tests/codegen/sanitizer/cfi/external_weak_symbols.rs +++ b/tests/codegen/sanitizer/cfi/external_weak_symbols.rs @@ -2,7 +2,7 @@ // emitted correctly. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clinker-plugin-lto -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static +//@ compile-flags: -Clinker-plugin-lto -Copt-level=0 -Zunstable-options -Csanitize=cfi -Ctarget-feature=-crt-static #![crate_type = "bin"] #![feature(linkage)] diff --git a/tests/codegen/sanitizer/kasan-emits-instrumentation.rs b/tests/codegen/sanitizer/kasan-emits-instrumentation.rs index a594a73522fda..ec86e6537f1cc 100644 --- a/tests/codegen/sanitizer/kasan-emits-instrumentation.rs +++ b/tests/codegen/sanitizer/kasan-emits-instrumentation.rs @@ -1,7 +1,7 @@ // Verifies that `-Csanitize=kernel-address` emits sanitizer instrumentation. //@ add-core-stubs -//@ compile-flags: -Zunstable-options -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/riscv64-shadow-call-stack.rs b/tests/codegen/sanitizer/riscv64-shadow-call-stack.rs index d0f3e9a3bd4a7..13b90d8681156 100644 --- a/tests/codegen/sanitizer/riscv64-shadow-call-stack.rs +++ b/tests/codegen/sanitizer/riscv64-shadow-call-stack.rs @@ -1,5 +1,5 @@ //@ add-core-stubs -//@ compile-flags: --target riscv64imac-unknown-none-elf -Zunstable-options -Zsanitizer=shadow-call-stack +//@ compile-flags: --target riscv64imac-unknown-none-elf -Zunstable-options -Csanitize=shadow-call-stack //@ needs-llvm-components: riscv #![allow(internal_features)] diff --git a/tests/ui/asm/global-asm-isnt-really-a-mir-body.rs b/tests/ui/asm/global-asm-isnt-really-a-mir-body.rs index b7636d116ec6c..5e28971d14727 100644 --- a/tests/ui/asm/global-asm-isnt-really-a-mir-body.rs +++ b/tests/ui/asm/global-asm-isnt-really-a-mir-body.rs @@ -8,7 +8,7 @@ //@[instrument] only-linux // Make sure we don't try to CFI encode it. -//@[cfi] compile-flags: -Zsanitizer=cfi -Ccodegen-units=1 -Clto -Ctarget-feature=-crt-static -Clink-dead-code=true +//@[cfi] compile-flags: -Zunstable-options -Csanitize=cfi -Ccodegen-units=1 -Clto -Ctarget-feature=-crt-static -Clink-dead-code=true //@[cfi] needs-sanitizer-cfi //@[cfi] no-prefer-dynamic // FIXME(#122848) Remove only-linux once OSX CFI binaries work 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 c3adfcd9befef..fa66222983175 100644 --- a/tests/ui/sanitizer/cfi/canonical-jump-tables-requires-cfi.rs +++ b/tests/ui/sanitizer/cfi/canonical-jump-tables-requires-cfi.rs @@ -7,4 +7,4 @@ #![no_core] #![no_main] -//~? ERROR `-Zsanitizer-cfi-canonical-jump-tables` requires `-Zsanitizer=cfi` +//~? ERROR `-Zsanitizer-cfi-canonical-jump-tables` requires `-Csanitize=cfi` diff --git a/tests/ui/sanitizer/cfi/generalize-pointers-requires-cfi.rs b/tests/ui/sanitizer/cfi/generalize-pointers-requires-cfi.rs index 43032944f070a..3bb723513ed8b 100644 --- a/tests/ui/sanitizer/cfi/generalize-pointers-requires-cfi.rs +++ b/tests/ui/sanitizer/cfi/generalize-pointers-requires-cfi.rs @@ -8,4 +8,4 @@ #![no_core] #![no_main] -//~? ERROR `-Zsanitizer-cfi-generalize-pointers` requires `-Zsanitizer=cfi` or `-Zsanitizer=kcfi` +//~? ERROR `-Zsanitizer-cfi-generalize-pointers` requires `-Csanitize=cfi` or `-Csanitize=kcfi` diff --git a/tests/ui/sanitizer/cfi/is-incompatible-with-kcfi.rs b/tests/ui/sanitizer/cfi/is-incompatible-with-kcfi.rs index 9341370f12ac1..8c3b4bc5e1b94 100644 --- a/tests/ui/sanitizer/cfi/is-incompatible-with-kcfi.rs +++ b/tests/ui/sanitizer/cfi/is-incompatible-with-kcfi.rs @@ -12,4 +12,4 @@ #![no_main] //~? 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` diff --git a/tests/ui/sanitizer/cfi/normalize-integers-requires-cfi.rs b/tests/ui/sanitizer/cfi/normalize-integers-requires-cfi.rs index 656178e8e8737..ff56b18eb8951 100644 --- a/tests/ui/sanitizer/cfi/normalize-integers-requires-cfi.rs +++ b/tests/ui/sanitizer/cfi/normalize-integers-requires-cfi.rs @@ -8,4 +8,4 @@ #![no_core] #![no_main] -//~? ERROR `-Zsanitizer-cfi-normalize-integers` requires `-Zsanitizer=cfi` or `-Zsanitizer=kcfi` +//~? ERROR `-Zsanitizer-cfi-normalize-integers` requires `-Csanitize=cfi` or `-Csanitize=kcfi` diff --git a/tests/ui/sanitizer/cfi/requires-lto.rs b/tests/ui/sanitizer/cfi/requires-lto.rs index 49138c1f261c3..0e338a43eb5f2 100644 --- a/tests/ui/sanitizer/cfi/requires-lto.rs +++ b/tests/ui/sanitizer/cfi/requires-lto.rs @@ -7,4 +7,4 @@ #![no_core] #![no_main] -//~? ERROR `-Zsanitizer=cfi` requires `-Clto` or `-Clinker-plugin-lto` +//~? ERROR `-Csanitize=cfi` requires `-Clto` or `-Clinker-plugin-lto` 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 b8476402be72b..1f24234da5ad8 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 @@ -7,4 +7,4 @@ #![no_core] #![no_main] -//~? ERROR `-Zsanitizer=cfi` with `-Clto` requires `-Ccodegen-units=1` +//~? ERROR `-Csanitize=cfi` with `-Clto` requires `-Ccodegen-units=1` diff --git a/tests/ui/sanitizer/incompatible.rs b/tests/ui/sanitizer/incompatible.rs index 418ba67162812..c3b247f379904 100644 --- a/tests/ui/sanitizer/incompatible.rs +++ b/tests/ui/sanitizer/incompatible.rs @@ -5,4 +5,4 @@ #![no_core] #![no_main] -//~? ERROR `-Zsanitizer=address` is incompatible with `-Zsanitizer=memory` +//~? ERROR `-Csanitize=address` is incompatible with `-Csanitize=memory` diff --git a/tests/ui/sanitizer/kcfi-arity-requires-llvm-21-0-0.rs b/tests/ui/sanitizer/kcfi-arity-requires-llvm-21-0-0.rs index 8a724b853e13a..c8dbbba86b896 100644 --- a/tests/ui/sanitizer/kcfi-arity-requires-llvm-21-0-0.rs +++ b/tests/ui/sanitizer/kcfi-arity-requires-llvm-21-0-0.rs @@ -1,11 +1,12 @@ // Verifies that `-Zsanitizer-kcfi-arity` requires LLVM 21.0.0 or later. // //@ needs-sanitizer-kcfi -//@ compile-flags: -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Cpanic=abort -Zsanitizer=kcfi -Zsanitizer-kcfi-arity +//@ compile-flags: -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Cpanic=abort -Zunstable-options -Csanitize=kcfi -Zsanitizer-kcfi-arity //@ build-fail //@ max-llvm-major-version: 20 -//~? ERROR `-Zsanitizer-kcfi-arity` requires LLVM 21.0.0 or later. #![feature(no_core)] #![no_core] #![no_main] + +//~? ERROR `-Zsanitizer-kcfi-arity` requires LLVM 21.0.0 or later. 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() { } 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 index 4d7ca813793ff..a18f5619c5e6b 100644 --- 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 @@ -2,8 +2,9 @@ // //@ needs-llvm-components: x86 //@ compile-flags: -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] + +//~? ERROR kernel-address sanitizer is not supported for this target 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 index b1c141824b92d..f121cf67ac95a 100644 --- a/tests/ui/sanitizer/unsupported-cannot-be-used-with-unstable-options.rs +++ b/tests/ui/sanitizer/unsupported-cannot-be-used-with-unstable-options.rs @@ -7,3 +7,5 @@ #![feature(no_core)] #![no_core] #![no_main] + +//~? ERROR kernel-address sanitizer is not supported for this target 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 index b5e206e83af13..2e34b51f47872 100644 --- a/tests/ui/sanitizer/unsupported-cannot-be-used-without-unstable-options.rs +++ b/tests/ui/sanitizer/unsupported-cannot-be-used-without-unstable-options.rs @@ -2,8 +2,9 @@ // //@ 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] + +//~? ERROR kernel-address sanitizer is not supported for this target diff --git a/tests/ui/sanitizer/unsupported-target.rs b/tests/ui/sanitizer/unsupported-target.rs deleted file mode 100644 index 14925548e9271..0000000000000 --- a/tests/ui/sanitizer/unsupported-target.rs +++ /dev/null @@ -1,8 +0,0 @@ -//@ compile-flags: -Z sanitizer=leak --target i686-unknown-linux-gnu -//@ needs-llvm-components: x86 - -#![feature(no_core)] -#![no_core] -#![no_main] - -//~? ERROR leak sanitizer is not supported for this target From 896b3486c573284a825e18ead725e8306ea9da4a Mon Sep 17 00:00:00 2001 From: Ramon de C Valle Date: Thu, 16 May 2024 20:05:34 -0700 Subject: [PATCH 3/5] sanitizers: Add documentation for stable sanitizers --- src/doc/rustc/src/SUMMARY.md | 1 + src/doc/rustc/src/codegen-options/index.md | 42 ++++++++++ src/doc/rustc/src/sanitizers.md | 95 ++++++++++++++++++++++ 3 files changed, 138 insertions(+) create mode 100644 src/doc/rustc/src/sanitizers.md diff --git a/src/doc/rustc/src/SUMMARY.md b/src/doc/rustc/src/SUMMARY.md index cf41f5b86a85c..ddc056146926f 100644 --- a/src/doc/rustc/src/SUMMARY.md +++ b/src/doc/rustc/src/SUMMARY.md @@ -24,6 +24,7 @@ - [Checking Conditional Configurations](check-cfg.md) - [Cargo Specifics](check-cfg/cargo-specifics.md) - [Exploit Mitigations](exploit-mitigations.md) +- [Sanitizers](sanitizers.md) - [Symbol Mangling](symbol-mangling/index.md) - [v0 Symbol Format](symbol-mangling/v0.md) - [Contributing to `rustc`](contributing.md) diff --git a/src/doc/rustc/src/codegen-options/index.md b/src/doc/rustc/src/codegen-options/index.md index a3b70e7f97711..658f68f53b7dc 100644 --- a/src/doc/rustc/src/codegen-options/index.md +++ b/src/doc/rustc/src/codegen-options/index.md @@ -529,6 +529,48 @@ 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 a set of compiler-based runtime error detection tools that +instrument programs to detect bugs during execution. They work by instrumenting +code at compile time and runtime to monitor program behavior and detect specific +classes of errors at runtime. Sanitizers enable precise, low-overhead runtime +bug detection, improving software reliability and security. + +This option allows for use of one or more of these sanitizers: + + * [AddressSanitizer + (ASan)](../sanitizers.md#addresssanitizer): + Detects memory errors (e.g., buffer overflows, use after free). + * [LeakSanitizer + (LSan)](../sanitizers.md#leaksanitizer): + Detects memory leaks either as part of AddressSanitizer or as a standalone + tool. + +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 | +| 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 | + +The quality of the Sanitizers implementation and support varies across operating +systems and architectures, and relies heavily on LLVM implementation--they are +mostly implemented in and supported by LLVM. + +Using a different LLVM or runtime version than the one used by the Rust compiler +is not supported. Using Sanitizers in mixed-language binaries (also known as +“mixed binaries”) is supported when the same LLVM and runtime version is used by +all languages. + +For more information about the available sanitizers, see the [Sanitizers +chapter](../sanitizers.md). + ## save-temps This flag controls whether temporary files generated during compilation are diff --git a/src/doc/rustc/src/sanitizers.md b/src/doc/rustc/src/sanitizers.md new file mode 100644 index 0000000000000..fc5bce90bc0e4 --- /dev/null +++ b/src/doc/rustc/src/sanitizers.md @@ -0,0 +1,95 @@ +# Sanitizers + +## Introduction + +Sanitizers are a set of compiler-based runtime error detection tools that +instrument programs to detect bugs during execution. They work by instrumenting +code at compile time and runtime to monitor program behavior and detect specific +classes of errors at runtime. Sanitizers enable precise, low-overhead runtime +bug detection, improving software reliability and security. + +This option allows for use of one or more of these sanitizers: + + * [AddressSanitizer (ASan)](#addresssanitizer): Detects memory errors (e.g., + buffer overflows, use after free). + * [LeakSanitizer (LSan)](#leaksanitizer): Detects memory leaks either as part + of AddressSanitizer or as a standalone tool. + +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 | +| 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 | + +## AddressSanitizer + +AddressSanitizer (ASan) detects memory errors by instrumenting code at compile +time and runtime to mark regions around allocated memory (i.e., red zones) as +unaddressable (i.e., poisoned), quarantine and mark deallocated memory as +unaddressable, and add checks before memory accesses. It uses a shadow memory +mapping to store metadata information about whether a memory region is +addressable. It can detect: + +* Heap-based buffer overflows, Stack-based buffer overflows, and other variants + of out-of-bounds reads and writes. +* Use after free, double free, and other variants of expired pointer dereference + (also known as “dangling pointer”). +* Initialization order bugs (such as [“Static Initialization Order + Fiasco”](https://en.cppreference.com/w/cpp/language/siof)). +* Memory leaks. + +AddressSanitizer uses both instrumentation at compile time and runtime. It is +recommended to recompile all code using AddressSanitizer for best results. If +parts of the compiled code are not instrumented, AddressSanitizer may not detect +certain memory errors or detect false positives. + +AddressSanitizer increases memory usage and also impacts performance due to the +red zones and shadow memory mapping, and the added checks before memory +accesses. AddressSanitizer and its runtime are not suitable for production use. + +For more information, see the [AddressSanitizer +documentation](https://clang.llvm.org/docs/AddressSanitizer.html). + +## LeakSanitizer + +LeakSanitizer (LSan) detects memory leaks either as part of AddressSanitizer or +as a standalone tool by instrumenting code at runtime to track all memory and +thread management functions (i.e., interceptors), and searching for memory that +remain allocated but are no longer reachable by any references in the program, +at program termination or during specific checkpoints. + +LeakSanitizer can detect: + +* Memory allocated dynamically (e.g., via `malloc`, `new`) that are not freed or + deleted and is no longer referenced in the program (i.e., directly leaked + memory). +* Memory allocated dynamically that is referenced by another memory that are not + freed or deleted and is no longer referenced in the program (i.e., indirectly + leaked memory). + +LeakSanitizer does not use instrumentation at compile time and works without +recompiling all code using LeakSanitizer. + +LeakSanitizer impacts performance due to the interceptors and the checks for +memory leaks at program termination. LeakSanitizer and its runtime are not +suitable for production use. + +For more information, see the [LeakSanitizer +documentation](https://clang.llvm.org/docs/LeakSanitizer.html). + +## Disclaimer + +The quality of the Sanitizers implementation and support varies across operating +systems and architectures, and relies heavily on LLVM implementation--they are +mostly implemented in and supported by LLVM. + +Using a different LLVM or runtime version than the one used by the Rust compiler +is not supported. Using Sanitizers in mixed-language binaries (also known as +“mixed binaries”) is supported when the same LLVM and runtime version is used by +all languages. From 7ec002b55687893fe5c13986b9d2bcc6a194cdd0 Mon Sep 17 00:00:00 2001 From: Ramon de C Valle Date: Tue, 6 Aug 2024 15:42:33 -0700 Subject: [PATCH 4/5] 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 | 3 ++ library/std/src/lib.rs | 1 + .../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/scs-attr-check.rs | 2 -- tests/mir-opt/inline/inline_compatibility.rs | 1 + tests/ui/attributes/no-sanitize.rs | 1 - tests/ui/attributes/no-sanitize.stderr | 14 ++++----- .../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 +-- triagebot.toml | 4 --- 20 files changed, 19 insertions(+), 76 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 e3e4eefe5e10a..145ed451fce54 100644 --- a/compiler/rustc_feature/src/accepted.rs +++ b/compiler/rustc_feature/src/accepted.rs @@ -312,6 +312,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 76270cad48f39..a2a0a30aa4dc8 100644 --- a/compiler/rustc_feature/src/builtin_attrs.rs +++ b/compiler/rustc_feature/src/builtin_attrs.rs @@ -486,10 +486,10 @@ pub static 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 cbc121e3632a6..8982008ccf236 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -581,8 +581,6 @@ declare_features! ( (unstable, new_range, "1.86.0", Some(123741)), /// 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 b25d2a30681c0..89a08655ee3b2 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -2403,8 +2403,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 9625475e617ea..10442d6c37168 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -131,6 +131,9 @@ #![feature(variant_count)] // tidy-alphabetical-end // +// Features: +#![cfg_attr(bootstrap, feature(no_sanitize))] +// // Language features: // tidy-alphabetical-start #![feature(abi_unadjusted)] diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index 3a52b7790376c..d531f891424dd 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -263,6 +263,7 @@ #![allow(unused_features)] // // Features: +#![cfg_attr(bootstrap, feature(no_sanitize))] #![cfg_attr(test, feature(internal_output_capture, print_internals, update_panic_count, rt))] #![cfg_attr( all(target_vendor = "fortanix", target_env = "sgx"), 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 b897f6e18293e..df61765bc2fac 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/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 1bb102ccda58a..13f28aaacd6a7 100644 --- a/tests/mir-opt/inline/inline_compatibility.rs +++ b/tests/mir-opt/inline/inline_compatibility.rs @@ -4,6 +4,7 @@ #![crate_type = "lib"] #![feature(no_sanitize)] +#![feature(target_feature_11)] #![feature(c_variadic)] #[inline] diff --git a/tests/ui/attributes/no-sanitize.rs b/tests/ui/attributes/no-sanitize.rs index ddf909be63a8a..602ffe60e80c6 100644 --- a/tests/ui/attributes/no-sanitize.rs +++ b/tests/ui/attributes/no-sanitize.rs @@ -1,4 +1,3 @@ -#![feature(no_sanitize)] #![feature(stmt_expr_attributes)] #![deny(unused_attributes)] #![allow(dead_code)] diff --git a/tests/ui/attributes/no-sanitize.stderr b/tests/ui/attributes/no-sanitize.stderr index 8d5fbb109eadb..668cec62391b2 100644 --- a/tests/ui/attributes/no-sanitize.stderr +++ b/tests/ui/attributes/no-sanitize.stderr @@ -1,5 +1,5 @@ error: `#[no_sanitize(memory)]` should be applied to a function - --> $DIR/no-sanitize.rs:7:19 + --> $DIR/no-sanitize.rs:6:19 | LL | #[no_sanitize(memory)] | ^^^^^^ @@ -9,7 +9,7 @@ LL | | }; | |_____- not a function error: `#[no_sanitize(memory)]` should be applied to a function - --> $DIR/no-sanitize.rs:13:15 + --> $DIR/no-sanitize.rs:12:15 | LL | #[no_sanitize(memory)] | ^^^^^^ @@ -17,7 +17,7 @@ LL | type InvalidTy = (); | -------------------- not a function error: `#[no_sanitize(memory)]` should be applied to a function - --> $DIR/no-sanitize.rs:16:15 + --> $DIR/no-sanitize.rs:15:15 | LL | #[no_sanitize(memory)] | ^^^^^^ @@ -25,7 +25,7 @@ LL | mod invalid_module {} | --------------------- not a function error: `#[no_sanitize(memory)]` should be applied to a function - --> $DIR/no-sanitize.rs:20:27 + --> $DIR/no-sanitize.rs:19:27 | LL | let _ = #[no_sanitize(memory)] | ^^^^^^ @@ -33,7 +33,7 @@ LL | (|| 1); | ------ not a function error: `#[no_sanitize(memory)]` should be applied to a function - --> $DIR/no-sanitize.rs:24:15 + --> $DIR/no-sanitize.rs:23:15 | LL | #[no_sanitize(memory)] | ^^^^^^ @@ -41,7 +41,7 @@ LL | struct F; | --------- not a function error: `#[no_sanitize(memory)]` should be applied to a function - --> $DIR/no-sanitize.rs:27:15 + --> $DIR/no-sanitize.rs:26:15 | LL | #[no_sanitize(memory)] | ^^^^^^ @@ -52,7 +52,7 @@ LL | | } | |_- not a function error: `#[no_sanitize(memory)]` should be applied to a function - --> $DIR/no-sanitize.rs:33:24 + --> $DIR/no-sanitize.rs:32:24 | LL | #[no_sanitize(address, memory)] | ^^^^^^ 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 5ac014f1c5bf4..0000000000000 --- a/tests/ui/feature-gates/feature-gate-no_sanitize.rs +++ /dev/null @@ -1,4 +0,0 @@ -#[no_sanitize(address)] -//~^ ERROR 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)] | ^^^^^^^^^^^^^^^^^ diff --git a/triagebot.toml b/triagebot.toml index 189223f2feba1..99e462cfff22e 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -565,7 +565,6 @@ trigger_files = [ "src/doc/unstable-book/src/compiler-flags/sanitizer.md", "src/doc/unstable-book/src/language-features/cfg-sanitize.md", "src/doc/unstable-book/src/language-features/cfi-encoding.md", - "src/doc/unstable-book/src/language-features/no-sanitize.md", "tests/codegen/sanitizer", "tests/codegen/split-lto-unit.rs", "tests/codegen/stack-probes-inline.rs", @@ -1026,9 +1025,6 @@ cc = ["@rust-lang/project-exploit-mitigations", "@rcvalle"] [mentions."src/doc/unstable-book/src/language-features/cfi-encoding.md"] cc = ["@rust-lang/project-exploit-mitigations", "@rcvalle"] -[mentions."src/doc/unstable-book/src/language-features/no-sanitize.md"] -cc = ["@rust-lang/project-exploit-mitigations", "@rcvalle"] - [mentions."src/doc/rustc/src/check-cfg.md"] cc = ["@Urgau"] From 32b81ee7c35409e513787ae838d4cacdaf64034a Mon Sep 17 00:00:00 2001 From: Ramon de C Valle Date: Tue, 19 Nov 2024 21:11:13 +0000 Subject: [PATCH 5/5] sanitizers: Stabilize AddressSanitizer for aarch64-apple-darwin Stabilize AddressSanitizer for aarch64-apple-darwin since it was promoted to Tier 1 in #128592. --- compiler/rustc_target/src/spec/targets/aarch64_apple_darwin.rs | 1 + src/doc/rustc/src/codegen-options/index.md | 1 + src/doc/rustc/src/sanitizers.md | 1 + 3 files changed, 3 insertions(+) diff --git a/compiler/rustc_target/src/spec/targets/aarch64_apple_darwin.rs b/compiler/rustc_target/src/spec/targets/aarch64_apple_darwin.rs index d3e0a32c8b8fa..8bf22b5338f6e 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_apple_darwin.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_apple_darwin.rs @@ -22,6 +22,7 @@ pub(crate) fn target() -> Target { max_atomic_width: Some(128), // FIXME: The leak sanitizer currently fails the tests, see #88132. supported_sanitizers: SanitizerSet::ADDRESS | SanitizerSet::CFI | SanitizerSet::THREAD, + stable_sanitizers: SanitizerSet::ADDRESS, ..opts }, } diff --git a/src/doc/rustc/src/codegen-options/index.md b/src/doc/rustc/src/codegen-options/index.md index 658f68f53b7dc..2b96a242c1ff9 100644 --- a/src/doc/rustc/src/codegen-options/index.md +++ b/src/doc/rustc/src/codegen-options/index.md @@ -552,6 +552,7 @@ of these sanitizers: | Target | Sanitizers | |-----------------------------|-----------------| +| aarch64-apple-darwin | address | | aarch64-unknown-linux-gnu | address, leak | | i686-pc-windows-msvc | address | | i686-unknown-linux-gnu | address | diff --git a/src/doc/rustc/src/sanitizers.md b/src/doc/rustc/src/sanitizers.md index fc5bce90bc0e4..80e085a17132d 100644 --- a/src/doc/rustc/src/sanitizers.md +++ b/src/doc/rustc/src/sanitizers.md @@ -20,6 +20,7 @@ of these sanitizers: | Target | Sanitizers | |-----------------------------|-----------------| +| aarch64-apple-darwin | address | | aarch64-unknown-linux-gnu | address, leak | | i686-pc-windows-msvc | address | | i686-unknown-linux-gnu | address |