diff --git a/compiler/rustc_codegen_llvm/src/abi.rs b/compiler/rustc_codegen_llvm/src/abi.rs index 1d35138b01348..fa22cbd430ef9 100644 --- a/compiler/rustc_codegen_llvm/src/abi.rs +++ b/compiler/rustc_codegen_llvm/src/abi.rs @@ -15,7 +15,6 @@ pub(crate) use rustc_middle::ty::layout::{WIDE_PTR_ADDR, WIDE_PTR_EXTRA}; use rustc_middle::{bug, ty}; use rustc_session::config; pub(crate) use rustc_target::callconv::*; -use rustc_target::spec::SanitizerSet; use smallvec::SmallVec; use crate::attributes::llfn_attrs_from_instance; @@ -84,7 +83,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 f8454fd9960b6..044981e538947 100644 --- a/compiler/rustc_codegen_llvm/src/attributes.rs +++ b/compiler/rustc_codegen_llvm/src/attributes.rs @@ -84,7 +84,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)); } @@ -217,13 +217,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 f4f6161ebbccd..e9fdf3232e909 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -1315,7 +1315,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"); } @@ -2447,11 +2447,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 60ab291935256..2ffafa04d829b 100644 --- a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs +++ b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs @@ -13,7 +13,7 @@ use rustc_middle::query::LocalCrate; use rustc_middle::ty::{self, GenericArgKind, GenericArgsRef, Instance, SymbolName, TyCtxt}; use rustc_middle::util::Providers; use rustc_session::config::{CrateType, OomStrategy}; -use rustc_target::spec::{SanitizerSet, TlsModel}; +use rustc_target::spec::TlsModel; use tracing::debug; use crate::base::allocator_kind_for_codegen; @@ -247,15 +247,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 b40bb4ed5d2ac..b5ba7cc6b5212 100644 --- a/compiler/rustc_codegen_ssa/src/back/write.rs +++ b/compiler/rustc_codegen_ssa/src/back/write.rs @@ -183,7 +183,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_feature/src/accepted.rs b/compiler/rustc_feature/src/accepted.rs index 5a9b8c43e7468..7a14634ee8605 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 4b9f62fa764c0..5fbb7ac521f7d 100644 --- a/compiler/rustc_feature/src/builtin_attrs.rs +++ b/compiler/rustc_feature/src/builtin_attrs.rs @@ -475,10 +475,10 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ ), ungated!(track_caller, Normal, template!(Word), WarnFollowing, EncodeCrossCrate::Yes), ungated!(instruction_set, Normal, template!(List: "set"), ErrorPreceding, EncodeCrossCrate::No), - gated!( + ungated!( no_sanitize, Normal, template!(List: "address, kcfi, memory, thread"), DuplicatesOk, - EncodeCrossCrate::No, experimental!(no_sanitize) + EncodeCrossCrate::No ), ungated!( 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 ebb07195a2850..c17acb6a379a5 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -563,8 +563,6 @@ declare_features! ( (unstable, never_type_fallback, "1.41.0", Some(65992)), /// Allows `#![no_core]`. (unstable, no_core, "1.3.0", Some(29639)), - /// Allows the use of `no_sanitize` attribute. - (unstable, no_sanitize, "1.42.0", Some(39699)), /// Allows using the `non_exhaustive_omitted_patterns` lint. (unstable, non_exhaustive_omitted_patterns_lint, "1.57.0", Some(89554)), /// Allows `for` binders in where-clauses diff --git a/compiler/rustc_interface/src/tests.rs b/compiler/rustc_interface/src/tests.rs index 9ad690399140e..fd3e1e43b575a 100644 --- a/compiler/rustc_interface/src/tests.rs +++ b/compiler/rustc_interface/src/tests.rs @@ -633,6 +633,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)); @@ -839,7 +840,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_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index 2f23ab27492ca..553508000ec81 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -2440,8 +2440,6 @@ declare_lint! { /// ### Example /// /// ```rust - /// #![feature(no_sanitize)] - /// /// #[inline(always)] /// #[no_sanitize(address)] /// fn x() {} diff --git a/compiler/rustc_metadata/src/native_libs.rs b/compiler/rustc_metadata/src/native_libs.rs index 2a1e4b261e737..fa3d3a94e32a7 100644 --- a/compiler/rustc_metadata/src/native_libs.rs +++ b/compiler/rustc_metadata/src/native_libs.rs @@ -61,7 +61,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_osx && !sess.opts.unstable_opts.sanitizer.is_empty() + || sess.target.is_like_osx && !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 eb14b78a0030b..8c89e50beecfb 100644 --- a/compiler/rustc_session/messages.ftl +++ b/compiler/rustc_session/messages.ftl @@ -3,7 +3,7 @@ session_branch_protection_requires_aarch64 = `-Zbranch-protection` is only suppo session_cannot_enable_crt_static_linux = sanitizer is incompatible with statically linked libc, disable it using `-C target-feature=-crt-static` -session_cannot_mix_and_match_sanitizers = `-Zsanitizer={$first}` is incompatible with `-Zsanitizer={$second}` +session_cannot_mix_and_match_sanitizers = `-Csanitize={$first}` is incompatible with `-Csanitize={$second}` session_cli_feature_diagnostic_help = add `-Zcrate-attr="feature({$feature})"` to the command-line options to enable @@ -88,15 +88,15 @@ session_profile_sample_use_file_does_not_exist = file `{$path}` passed to `-C pr session_profile_use_file_does_not_exist = file `{$path}` passed to `-C profile-use` does not exist -session_sanitizer_cfi_canonical_jump_tables_requires_cfi = `-Zsanitizer-cfi-canonical-jump-tables` requires `-Zsanitizer=cfi` +session_sanitizer_cfi_canonical_jump_tables_requires_cfi = `-Zsanitizer-cfi-canonical-jump-tables` requires `-Csanitize=cfi` -session_sanitizer_cfi_generalize_pointers_requires_cfi = `-Zsanitizer-cfi-generalize-pointers` requires `-Zsanitizer=cfi` or `-Zsanitizer=kcfi` +session_sanitizer_cfi_generalize_pointers_requires_cfi = `-Zsanitizer-cfi-generalize-pointers` requires `-Csanitize=cfi` or `-Csanitize=kcfi` -session_sanitizer_cfi_normalize_integers_requires_cfi = `-Zsanitizer-cfi-normalize-integers` requires `-Zsanitizer=cfi` or `-Zsanitizer=kcfi` +session_sanitizer_cfi_normalize_integers_requires_cfi = `-Zsanitizer-cfi-normalize-integers` requires `-Csanitize=cfi` or `-Csanitize=kcfi` -session_sanitizer_cfi_requires_lto = `-Zsanitizer=cfi` requires `-Clto` or `-Clinker-plugin-lto` +session_sanitizer_cfi_requires_lto = `-Csanitize=cfi` requires `-Clto` or `-Clinker-plugin-lto` -session_sanitizer_cfi_requires_single_codegen_unit = `-Zsanitizer=cfi` with `-Clto` requires `-Ccodegen-units=1` +session_sanitizer_cfi_requires_single_codegen_unit = `-Csanitize=cfi` with `-Clto` requires `-Ccodegen-units=1` session_sanitizer_kcfi_requires_panic_abort = `-Z sanitizer=kcfi` requires `-C panic=abort` diff --git a/compiler/rustc_session/src/config/cfg.rs b/compiler/rustc_session/src/config/cfg.rs index 3426858495b71..2dff073be4e11 100644 --- a/compiler/rustc_session/src/config/cfg.rs +++ b/compiler/rustc_session/src/config/cfg.rs @@ -210,7 +210,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 3772a4a08af01..85a0cbb2e0c1b 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -813,25 +813,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 } @@ -1648,6 +1637,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], @@ -2018,8 +2009,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 54bb462296358..613ee0f165c5b 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -357,8 +357,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 { @@ -377,8 +381,32 @@ impl Session { self.opts.unstable_opts.sanitizer_cfi_normalize_integers == Some(true) } + pub fn is_sanitizer_hwaddress_enabled(&self) -> bool { + self.opts.cg.sanitize.contains(SanitizerSet::HWADDRESS) + } + pub fn is_sanitizer_kcfi_enabled(&self) -> bool { - self.opts.unstable_opts.sanitizer.contains(SanitizerSet::KCFI) + self.opts.cg.sanitize.contains(SanitizerSet::KCFI) + } + + pub fn is_sanitizer_kernel_address_enabled(&self) -> bool { + self.opts.cg.sanitize.contains(SanitizerSet::KERNELADDRESS) + } + + pub fn is_sanitizer_memory_enabled(&self) -> bool { + self.opts.cg.sanitize.contains(SanitizerSet::MEMORY) + } + + pub fn is_sanitizer_memory_recover_enabled(&self) -> bool { + self.opts.unstable_opts.sanitizer_recover.contains(SanitizerSet::MEMORY) + } + + pub fn is_sanitizer_memory_track_origins_enabled(&self) -> bool { + self.opts.unstable_opts.sanitizer_memory_track_origins != 0 + } + + pub fn is_sanitizer_thread_enabled(&self) -> bool { + self.opts.cg.sanitize.contains(SanitizerSet::THREAD) } pub fn is_split_lto_unit_enabled(&self) -> bool { @@ -560,7 +588,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 { @@ -688,7 +719,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 } } @@ -1131,14 +1162,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 => { @@ -1153,7 +1189,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(), @@ -1161,10 +1197,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 206766325aa16..514ecea167a5a 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. @@ -313,32 +314,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: @@ -607,6 +591,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)?; @@ -781,6 +766,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 ad746d3f26b85..2f5c67c6feb7f 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -1451,6 +1451,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() @@ -2482,6 +2513,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, @@ -2729,6 +2763,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/compiler/rustc_target/src/spec/targets/aarch64_apple_darwin.rs b/compiler/rustc_target/src/spec/targets/aarch64_apple_darwin.rs index adee6f5fe9943..8c7bce449715c 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/compiler/rustc_target/src/spec/targets/aarch64_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/targets/aarch64_unknown_linux_gnu.rs index 18711cb399d73..2cc2068f0d319 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 aacad26686315..e07d70ea3d822 100644 --- a/compiler/rustc_target/src/spec/targets/i686_pc_windows_msvc.rs +++ b/compiler/rustc_target/src/spec/targets/i686_pc_windows_msvc.rs @@ -5,6 +5,7 @@ pub(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), &[ // Mark all dynamic libraries and executables as compatible with the larger 4GiB address 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 c95cb308d7f5c..147065b1175b3 100644 --- a/compiler/rustc_target/src/spec/targets/i686_unknown_linux_gnu.rs +++ b/compiler/rustc_target/src/spec/targets/i686_unknown_linux_gnu.rs @@ -5,6 +5,7 @@ pub(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 52ef3fc88fd7e..5a3239785560f 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 baf0d8b0c8b31..7da68d1f11422 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 59ec6c7f9d5fb..dfc4089dfbb5b 100644 --- a/compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_gnu.rs +++ b/compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_gnu.rs @@ -10,12 +10,13 @@ pub(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/library/core/src/lib.rs b/library/core/src/lib.rs index 18bd9bb811836..5a0fc7255418e 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -138,6 +138,9 @@ #![feature(variant_count)] // tidy-alphabetical-end // +// Features: +#![cfg_attr(bootstrap, feature(no_sanitize))] +// // Language features: // tidy-alphabetical-start #![feature(abi_unadjusted)] @@ -176,7 +179,6 @@ #![feature(negative_impls)] #![feature(never_type)] #![feature(no_core)] -#![feature(no_sanitize)] #![feature(optimize_attribute)] #![feature(prelude_import)] #![feature(repr_simd)] diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index 1c80694ca8f24..b02f5bcf2c4f2 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -261,6 +261,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"), @@ -304,7 +305,6 @@ #![feature(needs_panic_runtime)] #![feature(negative_impls)] #![feature(never_type)] -#![feature(no_sanitize)] #![feature(optimize_attribute)] #![feature(prelude_import)] #![feature(rustc_attrs)] diff --git a/src/doc/rustc/src/SUMMARY.md b/src/doc/rustc/src/SUMMARY.md index 1e9f5a33fc792..6bf0998b5b403 100644 --- a/src/doc/rustc/src/SUMMARY.md +++ b/src/doc/rustc/src/SUMMARY.md @@ -110,6 +110,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 e987d06b0f31f..acf7eaf5b6eb5 100644 --- a/src/doc/rustc/src/codegen-options/index.md +++ b/src/doc/rustc/src/codegen-options/index.md @@ -516,6 +516,50 @@ 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)](https://doc.rust-lang.org/rustc/sanitizers.html#addresssanitizer): + Detects memory errors (e.g., buffer overflows, use after free). + * [LeakSanitizer + (LSan)](https://doc.rust-lang.org/rustc/sanitizers.html#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-apple-darwin | address | +| 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 Sanitizers, see the [Sanitizers +chapter](https://doc.rust-lang.org/rustc/sanitizers.html) of [The rustc +book](https://doc.rust-lang.org/rustc/). + ## 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..80e085a17132d --- /dev/null +++ b/src/doc/rustc/src/sanitizers.md @@ -0,0 +1,96 @@ +# 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-apple-darwin | address | +| 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. 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/src/tools/compiletest/src/common.rs b/src/tools/compiletest/src/common.rs index 36f876bcdc604..2cb6911783c32 100644 --- a/src/tools/compiletest/src/common.rs +++ b/src/tools/compiletest/src/common.rs @@ -654,7 +654,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 e19dcd992fc2e..21104370b8aae 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 { @@ -265,7 +265,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, @@ -284,14 +284,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 8efedab6ea55d..4dfb87dd9653e 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 e2e14ab14a801..d23b5d3dd4399 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,7 +1,7 @@ //@ 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..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 @@ -1,10 +1,9 @@ // 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)] #[no_sanitize(cfi)] pub fn foo(f: fn(i32) -> i32, arg: i32) -> i32 { 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 3edc68e134740..f3f95af439bd9 100644 --- a/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-const-generics.rs +++ b/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-const-generics.rs @@ -2,7 +2,7 @@ // for const generics. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Copt-level=0 +//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zunstable-options -Csanitize=cfi -Copt-level=0 #![crate_type = "lib"] #![feature(type_alias_impl_trait)] diff --git a/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-drop-in-place.rs b/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-drop-in-place.rs index 2a7eca6fc1963..716062c94dc60 100644 --- a/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-drop-in-place.rs +++ b/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-drop-in-place.rs @@ -1,7 +1,7 @@ // Verifies that type metadata identifiers for drop functions are emitted correctly. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static +//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zunstable-options -Csanitize=cfi -Ctarget-feature=-crt-static #![crate_type = "lib"] diff --git a/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-function-types.rs b/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-function-types.rs index 7e60aafff6802..c8e72ab806fe2 100644 --- a/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-function-types.rs +++ b/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-function-types.rs @@ -2,7 +2,7 @@ // for function types. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static +//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zunstable-options -Csanitize=cfi -Ctarget-feature=-crt-static #![crate_type = "lib"] diff --git a/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-lifetimes.rs b/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-lifetimes.rs index 09cfd2e10d6e7..f35a60f641ce6 100644 --- a/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-lifetimes.rs +++ b/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-lifetimes.rs @@ -2,7 +2,7 @@ // for lifetimes/regions. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Copt-level=0 +//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zunstable-options -Csanitize=cfi -Copt-level=0 #![crate_type = "lib"] #![feature(type_alias_impl_trait)] diff --git a/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-method-secondary-typeid.rs b/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-method-secondary-typeid.rs index 9d611777ff0ba..7b88d9956da7c 100644 --- a/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-method-secondary-typeid.rs +++ b/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-method-secondary-typeid.rs @@ -2,7 +2,7 @@ // self so they can be used as function pointers. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static +//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zunstable-options -Csanitize=cfi -Ctarget-feature=-crt-static #![crate_type = "lib"] diff --git a/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-paths.rs b/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-paths.rs index ffbfe021ba3eb..c3878d8ae6539 100644 --- a/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-paths.rs +++ b/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-paths.rs @@ -2,7 +2,7 @@ // for paths. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static +//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zunstable-options -Csanitize=cfi -Ctarget-feature=-crt-static #![crate_type = "lib"] #![feature(type_alias_impl_trait)] diff --git a/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-pointer-types.rs b/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-pointer-types.rs index d37bb740f5505..42d717f8ae5cd 100644 --- a/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-pointer-types.rs +++ b/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-pointer-types.rs @@ -2,7 +2,7 @@ // for pointer types. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static +//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zunstable-options -Csanitize=cfi -Ctarget-feature=-crt-static #![crate_type = "lib"] diff --git a/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-primitive-types.rs b/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-primitive-types.rs index 7d9e4d0587276..fe00a9738a0e5 100644 --- a/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-primitive-types.rs +++ b/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-primitive-types.rs @@ -2,7 +2,7 @@ // for primitive types. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static +//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zunstable-options -Csanitize=cfi -Ctarget-feature=-crt-static #![crate_type = "lib"] diff --git a/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-repr-transparent-types.rs b/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-repr-transparent-types.rs index 0f97c70f3f923..f35a72739fc2b 100644 --- a/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-repr-transparent-types.rs +++ b/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-repr-transparent-types.rs @@ -2,7 +2,7 @@ // for repr transparent types. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static +//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zunstable-options -Csanitize=cfi -Ctarget-feature=-crt-static #![crate_type = "lib"] diff --git a/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-sequence-types.rs b/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-sequence-types.rs index bdee3f47a837d..ac7dbc3ed4b3a 100644 --- a/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-sequence-types.rs +++ b/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-sequence-types.rs @@ -2,7 +2,7 @@ // for sequence types. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static +//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zunstable-options -Csanitize=cfi -Ctarget-feature=-crt-static #![crate_type = "lib"] diff --git a/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-trait-types.rs b/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-trait-types.rs index 55e816178f8fc..36d0ff8b8746d 100644 --- a/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-trait-types.rs +++ b/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-trait-types.rs @@ -2,7 +2,7 @@ // for trait types. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static +//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zunstable-options -Csanitize=cfi -Ctarget-feature=-crt-static #![crate_type = "lib"] diff --git a/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-user-defined-types.rs b/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-user-defined-types.rs index c1f3ca61afeb1..1a0d370f2a056 100644 --- a/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-user-defined-types.rs +++ b/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-user-defined-types.rs @@ -2,7 +2,7 @@ // for user-defined types. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static +//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zunstable-options -Csanitize=cfi -Ctarget-feature=-crt-static #![crate_type = "lib"] #![feature(extern_types)] diff --git a/tests/codegen/sanitizer/cfi/emit-type-metadata-itanium-cxx-abi-generalized.rs b/tests/codegen/sanitizer/cfi/emit-type-metadata-itanium-cxx-abi-generalized.rs index 32637b64b3ea8..ac540445fd329 100644 --- a/tests/codegen/sanitizer/cfi/emit-type-metadata-itanium-cxx-abi-generalized.rs +++ b/tests/codegen/sanitizer/cfi/emit-type-metadata-itanium-cxx-abi-generalized.rs @@ -1,7 +1,7 @@ // Verifies that generalized type metadata for functions are emitted. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-generalize-pointers +//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zunstable-options -Csanitize=cfi -Zsanitizer-cfi-generalize-pointers #![crate_type = "lib"] diff --git a/tests/codegen/sanitizer/cfi/emit-type-metadata-itanium-cxx-abi-normalized-generalized.rs b/tests/codegen/sanitizer/cfi/emit-type-metadata-itanium-cxx-abi-normalized-generalized.rs index 51121b0aef1aa..751c09c1b64c8 100644 --- a/tests/codegen/sanitizer/cfi/emit-type-metadata-itanium-cxx-abi-normalized-generalized.rs +++ b/tests/codegen/sanitizer/cfi/emit-type-metadata-itanium-cxx-abi-normalized-generalized.rs @@ -1,7 +1,7 @@ // Verifies that normalized and generalized type metadata for functions are emitted. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-normalize-integers -Zsanitizer-cfi-generalize-pointers +//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zunstable-options -Csanitize=cfi -Zsanitizer-cfi-normalize-integers -Zsanitizer-cfi-generalize-pointers #![crate_type = "lib"] diff --git a/tests/codegen/sanitizer/cfi/emit-type-metadata-itanium-cxx-abi-normalized.rs b/tests/codegen/sanitizer/cfi/emit-type-metadata-itanium-cxx-abi-normalized.rs index 1cfdd23006e3a..a59e652494787 100644 --- a/tests/codegen/sanitizer/cfi/emit-type-metadata-itanium-cxx-abi-normalized.rs +++ b/tests/codegen/sanitizer/cfi/emit-type-metadata-itanium-cxx-abi-normalized.rs @@ -1,7 +1,7 @@ // Verifies that normalized type metadata for functions are emitted. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-normalize-integers +//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zunstable-options -Csanitize=cfi -Zsanitizer-cfi-normalize-integers #![crate_type = "lib"] diff --git a/tests/codegen/sanitizer/cfi/emit-type-metadata-itanium-cxx-abi.rs b/tests/codegen/sanitizer/cfi/emit-type-metadata-itanium-cxx-abi.rs index 56ab1ce4b3582..a813a12827c0d 100644 --- a/tests/codegen/sanitizer/cfi/emit-type-metadata-itanium-cxx-abi.rs +++ b/tests/codegen/sanitizer/cfi/emit-type-metadata-itanium-cxx-abi.rs @@ -1,7 +1,7 @@ // Verifies that type metadata for functions are emitted. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi +//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zunstable-options -Csanitize=cfi #![crate_type = "lib"] diff --git a/tests/codegen/sanitizer/cfi/emit-type-metadata-trait-objects.rs b/tests/codegen/sanitizer/cfi/emit-type-metadata-trait-objects.rs index 0e57ce322d127..02b1323e282bc 100644 --- a/tests/codegen/sanitizer/cfi/emit-type-metadata-trait-objects.rs +++ b/tests/codegen/sanitizer/cfi/emit-type-metadata-trait-objects.rs @@ -1,7 +1,7 @@ // Verifies that type metadata identifiers for trait objects are emitted correctly. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Ctarget-feature=-crt-static -Zsanitizer=cfi +//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Ctarget-feature=-crt-static -Zunstable-options -Csanitize=cfi #![crate_type = "lib"] diff --git a/tests/codegen/sanitizer/cfi/generalize-pointers.rs b/tests/codegen/sanitizer/cfi/generalize-pointers.rs index 57004da6f8e06..0069632c46bf0 100644 --- a/tests/codegen/sanitizer/cfi/generalize-pointers.rs +++ b/tests/codegen/sanitizer/cfi/generalize-pointers.rs @@ -1,7 +1,7 @@ // Verifies that pointer types are generalized. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-generalize-pointers -Copt-level=0 +//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zunstable-options -Csanitize=cfi -Zsanitizer-cfi-generalize-pointers -Copt-level=0 #![crate_type = "lib"] diff --git a/tests/codegen/sanitizer/cfi/normalize-integers.rs b/tests/codegen/sanitizer/cfi/normalize-integers.rs index 770ee4e64e089..8f812e17e85f6 100644 --- a/tests/codegen/sanitizer/cfi/normalize-integers.rs +++ b/tests/codegen/sanitizer/cfi/normalize-integers.rs @@ -1,7 +1,7 @@ // Verifies that integer types are normalized. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-normalize-integers -Copt-level=0 +//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zunstable-options -Csanitize=cfi -Zsanitizer-cfi-normalize-integers -Copt-level=0 #![crate_type = "lib"] diff --git a/tests/codegen/sanitizer/dataflow-instrument-functions.rs b/tests/codegen/sanitizer/dataflow-instrument-functions.rs index a2d0d63cc1754..550d2160c55de 100644 --- a/tests/codegen/sanitizer/dataflow-instrument-functions.rs +++ b/tests/codegen/sanitizer/dataflow-instrument-functions.rs @@ -1,7 +1,7 @@ // Verifies that functions are instrumented. // //@ needs-sanitizer-dataflow -//@ compile-flags: -Copt-level=0 -Zsanitizer=dataflow +//@ compile-flags: -Copt-level=0 -Zunstable-options -Csanitize=dataflow #![crate_type = "lib"] diff --git a/tests/codegen/sanitizer/kasan-emits-instrumentation.rs b/tests/codegen/sanitizer/kasan-emits-instrumentation.rs index 56ee875286a22..c2568049b10e9 100644 --- a/tests/codegen/sanitizer/kasan-emits-instrumentation.rs +++ b/tests/codegen/sanitizer/kasan-emits-instrumentation.rs @@ -1,6 +1,6 @@ -// Verifies that `-Zsanitizer=kernel-address` emits sanitizer instrumentation. +// Verifies that `-Csanitize=kernel-address` emits sanitizer instrumentation. -//@ compile-flags: -Zsanitizer=kernel-address -Copt-level=0 +//@ compile-flags: -Zunstable-options -Csanitize=kernel-address -Copt-level=0 //@ revisions: aarch64 riscv64imac riscv64gc x86_64 //@[aarch64] compile-flags: --target aarch64-unknown-none //@[aarch64] needs-llvm-components: aarch64 diff --git a/tests/codegen/sanitizer/kcfi/add-cfi-normalize-integers-flag.rs b/tests/codegen/sanitizer/kcfi/add-cfi-normalize-integers-flag.rs index d48e4016a16ce..b82ff16acc658 100644 --- a/tests/codegen/sanitizer/kcfi/add-cfi-normalize-integers-flag.rs +++ b/tests/codegen/sanitizer/kcfi/add-cfi-normalize-integers-flag.rs @@ -5,7 +5,7 @@ //@ [aarch64] needs-llvm-components: aarch64 //@ [x86_64] compile-flags: --target x86_64-unknown-none //@ [x86_64] needs-llvm-components: x86 -//@ compile-flags: -Ctarget-feature=-crt-static -Zsanitizer=kcfi -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 013de74f8d689..2d253739cf8fd 100644 --- a/tests/codegen/sanitizer/kcfi/add-kcfi-flag.rs +++ b/tests/codegen/sanitizer/kcfi/add-kcfi-flag.rs @@ -5,7 +5,7 @@ //@ [aarch64] needs-llvm-components: aarch64 //@ [x86_64] compile-flags: --target x86_64-unknown-none //@ [x86_64] needs-llvm-components: x86 -//@ compile-flags: -Ctarget-feature=-crt-static -Zsanitizer=kcfi +//@ compile-flags: -Ctarget-feature=-crt-static -Zunstable-options -Csanitize=kcfi #![feature(no_core, lang_items)] #![crate_type = "lib"] diff --git a/tests/codegen/sanitizer/kcfi/add-kcfi-offset-flag.rs b/tests/codegen/sanitizer/kcfi/add-kcfi-offset-flag.rs index b4924719f4c15..502920220f08b 100644 --- a/tests/codegen/sanitizer/kcfi/add-kcfi-offset-flag.rs +++ b/tests/codegen/sanitizer/kcfi/add-kcfi-offset-flag.rs @@ -5,7 +5,7 @@ //@ [aarch64] needs-llvm-components: aarch64 //@ [x86_64] compile-flags: --target x86_64-unknown-none //@ [x86_64] needs-llvm-components: x86 -//@ compile-flags: -Ctarget-feature=-crt-static -Zsanitizer=kcfi -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 ba2e397f6daa5..02a3da82a8a04 100644 --- a/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle-attr-no-sanitize.rs +++ b/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle-attr-no-sanitize.rs @@ -5,7 +5,7 @@ //@ [aarch64] needs-llvm-components: aarch64 //@ [x86_64] compile-flags: --target x86_64-unknown-none //@ [x86_64] needs-llvm-components: -//@ compile-flags: -Cno-prepopulate-passes -Zsanitizer=kcfi -Copt-level=0 +//@ compile-flags: -Cno-prepopulate-passes -Zunstable-options -Csanitize=kcfi -Copt-level=0 #![crate_type = "lib"] #![feature(no_core, no_sanitize, lang_items)] diff --git a/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi-generalized.rs b/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi-generalized.rs index 4e95bdf4d7c41..386ea02cce391 100644 --- a/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi-generalized.rs +++ b/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi-generalized.rs @@ -5,7 +5,7 @@ //@ [aarch64] needs-llvm-components: aarch64 //@ [x86_64] compile-flags: --target x86_64-unknown-none //@ [x86_64] needs-llvm-components: -//@ compile-flags: -Cno-prepopulate-passes -Zsanitizer=kcfi -Zsanitizer-cfi-generalize-pointers +//@ compile-flags: -Cno-prepopulate-passes -Zunstable-options -Csanitize=kcfi -Zsanitizer-cfi-generalize-pointers #![crate_type = "lib"] #![feature(no_core, lang_items)] diff --git a/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi-normalized-generalized.rs b/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi-normalized-generalized.rs index 31b43b5098806..87288e98938d4 100644 --- a/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi-normalized-generalized.rs +++ b/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi-normalized-generalized.rs @@ -5,7 +5,7 @@ //@ [aarch64] needs-llvm-components: aarch64 //@ [x86_64] compile-flags: --target x86_64-unknown-none //@ [x86_64] needs-llvm-components: -//@ compile-flags: -Cno-prepopulate-passes -Zsanitizer=kcfi -Zsanitizer-cfi-normalize-integers -Zsanitizer-cfi-generalize-pointers +//@ compile-flags: -Cno-prepopulate-passes -Zunstable-options -Csanitize=kcfi -Zsanitizer-cfi-normalize-integers -Zsanitizer-cfi-generalize-pointers #![crate_type = "lib"] #![feature(no_core, lang_items)] diff --git a/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi-normalized.rs b/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi-normalized.rs index 4755f6062aaab..50286ab4e0edf 100644 --- a/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi-normalized.rs +++ b/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi-normalized.rs @@ -5,7 +5,7 @@ //@ [aarch64] needs-llvm-components: aarch64 //@ [x86_64] compile-flags: --target x86_64-unknown-none //@ [x86_64] needs-llvm-components: -//@ compile-flags: -Cno-prepopulate-passes -Zsanitizer=kcfi -Zsanitizer-cfi-normalize-integers +//@ compile-flags: -Cno-prepopulate-passes -Zunstable-options -Csanitize=kcfi -Zsanitizer-cfi-normalize-integers #![crate_type = "lib"] #![feature(no_core, lang_items)] diff --git a/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi.rs b/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi.rs index be9760bd9afa4..2189cdc0d811d 100644 --- a/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi.rs +++ b/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi.rs @@ -5,7 +5,7 @@ //@ [aarch64] needs-llvm-components: aarch64 //@ [x86_64] compile-flags: --target x86_64-unknown-none //@ [x86_64] needs-llvm-components: -//@ compile-flags: -Cno-prepopulate-passes -Zsanitizer=kcfi -Copt-level=0 +//@ compile-flags: -Cno-prepopulate-passes -Zunstable-options -Csanitize=kcfi -Copt-level=0 #![crate_type = "lib"] #![feature(no_core, lang_items)] diff --git a/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle.rs b/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle.rs index c9c94cdb32926..57bcf4c45a2cc 100644 --- a/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle.rs +++ b/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle.rs @@ -5,7 +5,7 @@ //@ [aarch64] needs-llvm-components: aarch64 //@ [x86_64] compile-flags: --target x86_64-unknown-none //@ [x86_64] needs-llvm-components: -//@ compile-flags: -Cno-prepopulate-passes -Zsanitizer=kcfi -Copt-level=0 +//@ compile-flags: -Cno-prepopulate-passes -Zunstable-options -Csanitize=kcfi -Copt-level=0 #![crate_type = "lib"] #![feature(no_core, lang_items)] diff --git a/tests/codegen/sanitizer/kcfi/emit-type-metadata-trait-objects.rs b/tests/codegen/sanitizer/kcfi/emit-type-metadata-trait-objects.rs index 5ab55a467268b..8cbd5780bdb75 100644 --- a/tests/codegen/sanitizer/kcfi/emit-type-metadata-trait-objects.rs +++ b/tests/codegen/sanitizer/kcfi/emit-type-metadata-trait-objects.rs @@ -5,7 +5,7 @@ //@ [aarch64] needs-llvm-components: aarch64 //@ [x86_64] compile-flags: --target x86_64-unknown-none //@ [x86_64] needs-llvm-components: -//@ compile-flags: -Cno-prepopulate-passes -Zsanitizer=kcfi -Copt-level=0 +//@ compile-flags: -Cno-prepopulate-passes -Zunstable-options -Csanitize=kcfi -Copt-level=0 #![crate_type = "lib"] #![feature(arbitrary_self_types, no_core, lang_items)] diff --git a/tests/codegen/sanitizer/memory-track-origins.rs b/tests/codegen/sanitizer/memory-track-origins.rs index 318c277e10cba..b7f9ed021410e 100644 --- a/tests/codegen/sanitizer/memory-track-origins.rs +++ b/tests/codegen/sanitizer/memory-track-origins.rs @@ -4,7 +4,7 @@ //@ needs-sanitizer-memory //@ revisions:MSAN-0 MSAN-1 MSAN-2 MSAN-1-LTO MSAN-2-LTO // -//@ compile-flags: -Zsanitizer=memory -Ctarget-feature=-crt-static +//@ compile-flags: -Zunstable-options -Csanitize=memory -Ctarget-feature=-crt-static //@[MSAN-0] compile-flags: //@[MSAN-1] compile-flags: -Zsanitizer-memory-track-origins=1 //@[MSAN-2] compile-flags: -Zsanitizer-memory-track-origins diff --git a/tests/codegen/sanitizer/memtag-attr-check.rs b/tests/codegen/sanitizer/memtag-attr-check.rs index ffe3a2322a20e..a567edf9a6f96 100644 --- a/tests/codegen/sanitizer/memtag-attr-check.rs +++ b/tests/codegen/sanitizer/memtag-attr-check.rs @@ -2,7 +2,7 @@ // applied when enabling the memtag sanitizer. // //@ needs-sanitizer-memtag -//@ compile-flags: -Zsanitizer=memtag -Ctarget-feature=+mte -Copt-level=0 +//@ compile-flags: -Zunstable-options -Csanitize=memtag -Ctarget-feature=+mte -Copt-level=0 #![crate_type = "lib"] diff --git a/tests/codegen/sanitizer/no-sanitize-inlining.rs b/tests/codegen/sanitizer/no-sanitize-inlining.rs index 4bd832d2ab195..b813ff584a8f0 100644 --- a/tests/codegen/sanitizer/no-sanitize-inlining.rs +++ b/tests/codegen/sanitizer/no-sanitize-inlining.rs @@ -5,12 +5,10 @@ //@ 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)] - // ASAN-LABEL: define void @test // ASAN: call {{.*}} @random_inline // ASAN: } diff --git a/tests/codegen/sanitizer/no-sanitize.rs b/tests/codegen/sanitizer/no-sanitize.rs index 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 5833b832ba403..edce512aab3d8 100644 --- a/tests/codegen/sanitizer/riscv64-shadow-call-stack.rs +++ b/tests/codegen/sanitizer/riscv64-shadow-call-stack.rs @@ -1,4 +1,4 @@ -//@ compile-flags: --target riscv64imac-unknown-none-elf -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/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..f0f593e810fb8 100644 --- a/tests/codegen/sanitizer/scs-attr-check.rs +++ b/tests/codegen/sanitizer/scs-attr-check.rs @@ -2,11 +2,9 @@ // 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)] - // CHECK: ; sanitizer_scs_attr_check::scs // CHECK-NEXT: ; Function Attrs:{{.*}}shadowcallstack pub fn scs() {} diff --git a/tests/mir-opt/inline/inline_compatibility.rs b/tests/mir-opt/inline/inline_compatibility.rs index 13f28aaacd6a7..d7d7bc773a2ed 100644 --- a/tests/mir-opt/inline/inline_compatibility.rs +++ b/tests/mir-opt/inline/inline_compatibility.rs @@ -3,7 +3,6 @@ //@ compile-flags: -Cpanic=abort #![crate_type = "lib"] -#![feature(no_sanitize)] #![feature(target_feature_11)] #![feature(c_variadic)] diff --git a/tests/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 d758c903087b6..7e830f51bad3f 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 //@ error-pattern: shadow-call-stack sanitizer is not supported for this target //@ dont-check-compiler-stderr //@ needs-llvm-components: aarch64 diff --git a/tests/ui/attributes/no-sanitize.rs b/tests/ui/attributes/no-sanitize.rs index 8c79866d5aa31..6a63affe7ac63 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 9b0b76e3f4eba..08772624bd309 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 66a9263e13a53..0000000000000 --- a/tests/ui/feature-gates/feature-gate-no_sanitize.rs +++ /dev/null @@ -1,4 +0,0 @@ -#[no_sanitize(address)] -//~^ the `#[no_sanitize]` attribute is an experimental feature -fn main() { -} diff --git a/tests/ui/feature-gates/feature-gate-no_sanitize.stderr b/tests/ui/feature-gates/feature-gate-no_sanitize.stderr deleted file mode 100644 index a33bf6a9e40c1..0000000000000 --- a/tests/ui/feature-gates/feature-gate-no_sanitize.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0658]: the `#[no_sanitize]` attribute is an experimental feature - --> $DIR/feature-gate-no_sanitize.rs:1:1 - | -LL | #[no_sanitize(address)] - | ^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #39699 for more information - = help: add `#![feature(no_sanitize)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/invalid/invalid-no-sanitize.rs b/tests/ui/invalid/invalid-no-sanitize.rs index b52e3cc83fab2..14e4e797d2f4b 100644 --- a/tests/ui/invalid/invalid-no-sanitize.rs +++ b/tests/ui/invalid/invalid-no-sanitize.rs @@ -1,5 +1,3 @@ -#![feature(no_sanitize)] - #[no_sanitize(brontosaurus)] //~ ERROR invalid argument fn main() { } diff --git a/tests/ui/invalid/invalid-no-sanitize.stderr b/tests/ui/invalid/invalid-no-sanitize.stderr index b1c80438b318d..630282290e903 100644 --- a/tests/ui/invalid/invalid-no-sanitize.stderr +++ b/tests/ui/invalid/invalid-no-sanitize.stderr @@ -1,5 +1,5 @@ error: invalid argument for `no_sanitize` - --> $DIR/invalid-no-sanitize.rs:3:15 + --> $DIR/invalid-no-sanitize.rs:1:15 | LL | #[no_sanitize(brontosaurus)] | ^^^^^^^^^^^^ diff --git a/tests/ui/lto/issue-100772.rs b/tests/ui/lto/issue-100772.rs index 29ec5b9bf9647..5666389f1208f 100644 --- a/tests/ui/lto/issue-100772.rs +++ b/tests/ui/lto/issue-100772.rs @@ -1,6 +1,6 @@ //@ build-pass //@ needs-sanitizer-cfi -//@ compile-flags: -Ccodegen-units=1 -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi +//@ compile-flags: -Ccodegen-units=1 -Clto -Ctarget-feature=-crt-static -Zunstable-options -Csanitize=cfi //@ no-prefer-dynamic //@ only-x86_64-unknown-linux-gnu diff --git a/tests/ui/sanitizer/badfree.rs b/tests/ui/sanitizer/badfree.rs index ecbb58eba00d4..54592c703a193 100644 --- a/tests/ui/sanitizer/badfree.rs +++ b/tests/ui/sanitizer/badfree.rs @@ -2,7 +2,7 @@ //@ needs-sanitizer-address //@ ignore-cross-compile // -//@ compile-flags: -Z sanitizer=address -O +//@ compile-flags: -Zunstable-options -Csanitize=address -O // //@ run-fail //@ regex-error-pattern: AddressSanitizer: (SEGV|attempting free on address which was not malloc) diff --git a/tests/ui/sanitizer/cfg-kasan.rs b/tests/ui/sanitizer/cfg-kasan.rs index 491eaf3acc173..e3569ec5411b5 100644 --- a/tests/ui/sanitizer/cfg-kasan.rs +++ b/tests/ui/sanitizer/cfg-kasan.rs @@ -1,8 +1,8 @@ -// Verifies that when compiling with -Zsanitizer=kernel-address, +// Verifies that when compiling with -Csanitize=kernel-address, // the `#[cfg(sanitize = "address")]` attribute is configured. //@ check-pass -//@ compile-flags: -Zsanitizer=kernel-address +//@ compile-flags: -Zunstable-options -Csanitize=kernel-address //@ revisions: aarch64 riscv64imac riscv64gc x86_64 //@[aarch64] compile-flags: --target aarch64-unknown-none //@[aarch64] needs-llvm-components: aarch64 diff --git a/tests/ui/sanitizer/cfg.rs b/tests/ui/sanitizer/cfg.rs index 7b8f285e41a8a..750706681eba4 100644 --- a/tests/ui/sanitizer/cfg.rs +++ b/tests/ui/sanitizer/cfg.rs @@ -1,23 +1,23 @@ -// Verifies that when compiling with -Zsanitizer=option, +// Verifies that when compiling with -Csanitize=option, // the `#[cfg(sanitize = "option")]` attribute is configured. //@ check-pass //@ revisions: address cfi kcfi leak memory thread //@compile-flags: -Ctarget-feature=-crt-static //@[address]needs-sanitizer-address -//@[address]compile-flags: -Zsanitizer=address +//@[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 dd604b6bf7dcd..4c1defd8370bf 100644 --- a/tests/ui/sanitizer/cfi/assoc-ty-lifetime-issue-123053.rs +++ b/tests/ui/sanitizer/cfi/assoc-ty-lifetime-issue-123053.rs @@ -2,7 +2,7 @@ // trait object type to fail, causing an ICE. // //@ needs-sanitizer-cfi -//@ compile-flags: -Ccodegen-units=1 -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi --edition=2021 +//@ compile-flags: -Ccodegen-units=1 -Clto -Ctarget-feature=-crt-static -Zunstable-options -Csanitize=cfi --edition=2021 //@ no-prefer-dynamic //@ only-x86_64-unknown-linux-gnu //@ build-pass diff --git a/tests/ui/sanitizer/cfi/async-closures.rs b/tests/ui/sanitizer/cfi/async-closures.rs index 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 10c5bf6ea5e14..01ca498dcc1ed 100644 --- a/tests/ui/sanitizer/cfi/canonical-jump-tables-requires-cfi.rs +++ b/tests/ui/sanitizer/cfi/canonical-jump-tables-requires-cfi.rs @@ -1,4 +1,4 @@ -// Verifies that `-Zsanitizer-cfi-canonical-jump-tables` requires `-Zsanitizer=cfi`. +// Verifies that `-Zsanitizer-cfi-canonical-jump-tables` requires `-Csanitize=cfi`. // //@ needs-sanitizer-cfi //@ compile-flags: -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer-cfi-canonical-jump-tables=false diff --git a/tests/ui/sanitizer/cfi/canonical-jump-tables-requires-cfi.stderr b/tests/ui/sanitizer/cfi/canonical-jump-tables-requires-cfi.stderr index de67d6a6b7f06..95f120c360b7c 100644 --- a/tests/ui/sanitizer/cfi/canonical-jump-tables-requires-cfi.stderr +++ b/tests/ui/sanitizer/cfi/canonical-jump-tables-requires-cfi.stderr @@ -1,4 +1,4 @@ -error: `-Zsanitizer-cfi-canonical-jump-tables` requires `-Zsanitizer=cfi` +error: `-Zsanitizer-cfi-canonical-jump-tables` requires `-Csanitize=cfi` error: aborting due to 1 previous error diff --git a/tests/ui/sanitizer/cfi/closures.rs b/tests/ui/sanitizer/cfi/closures.rs index 9f9002da674f5..ccc17c96a9854 100644 --- a/tests/ui/sanitizer/cfi/closures.rs +++ b/tests/ui/sanitizer/cfi/closures.rs @@ -7,8 +7,8 @@ //@ [kcfi] needs-sanitizer-kcfi //@ compile-flags: -C target-feature=-crt-static //@ [cfi] compile-flags: -C codegen-units=1 -C lto -C prefer-dynamic=off -C opt-level=0 -//@ [cfi] compile-flags: -Z sanitizer=cfi -//@ [kcfi] compile-flags: -Z sanitizer=kcfi +//@ [cfi] compile-flags: -Zunstable-options -Csanitize=cfi +//@ [kcfi] compile-flags: -Zunstable-options -Csanitize=kcfi //@ [kcfi] compile-flags: -C panic=abort -Z panic-abort-tests -C prefer-dynamic=off //@ compile-flags: --test //@ run-pass diff --git a/tests/ui/sanitizer/cfi/complex-receiver.rs b/tests/ui/sanitizer/cfi/complex-receiver.rs index c7b45a775ca1d..d54cebf1fe743 100644 --- a/tests/ui/sanitizer/cfi/complex-receiver.rs +++ b/tests/ui/sanitizer/cfi/complex-receiver.rs @@ -9,8 +9,8 @@ //@ [kcfi] needs-sanitizer-kcfi //@ compile-flags: -C target-feature=-crt-static //@ [cfi] compile-flags: -C codegen-units=1 -C lto -C prefer-dynamic=off -C opt-level=0 -//@ [cfi] compile-flags: -Z sanitizer=cfi -//@ [kcfi] compile-flags: -Z sanitizer=kcfi +//@ [cfi] compile-flags: -Zunstable-options -Csanitize=cfi +//@ [kcfi] compile-flags: -Zunstable-options -Csanitize=kcfi //@ [kcfi] compile-flags: -C panic=abort -C prefer-dynamic=off //@ run-pass diff --git a/tests/ui/sanitizer/cfi/coroutine.rs b/tests/ui/sanitizer/cfi/coroutine.rs index 3ad896afd00b0..88ed5acd28889 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 8ba13bd3639b1..3e2f3ef565359 100644 --- a/tests/ui/sanitizer/cfi/generalize-pointers-requires-cfi.rs +++ b/tests/ui/sanitizer/cfi/generalize-pointers-requires-cfi.rs @@ -1,5 +1,5 @@ -// Verifies that `-Zsanitizer-cfi-generalize-pointers` requires `-Zsanitizer=cfi` or -// `-Zsanitizer=kcfi`. +// Verifies that `-Zsanitizer-cfi-generalize-pointers` requires `-Csanitize=cfi` or +// `-Csanitize=kcfi`. // //@ needs-sanitizer-cfi //@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer-cfi-generalize-pointers diff --git a/tests/ui/sanitizer/cfi/generalize-pointers-requires-cfi.stderr b/tests/ui/sanitizer/cfi/generalize-pointers-requires-cfi.stderr index 621708de241c2..4c76d27b879e2 100644 --- a/tests/ui/sanitizer/cfi/generalize-pointers-requires-cfi.stderr +++ b/tests/ui/sanitizer/cfi/generalize-pointers-requires-cfi.stderr @@ -1,4 +1,4 @@ -error: `-Zsanitizer-cfi-generalize-pointers` requires `-Zsanitizer=cfi` or `-Zsanitizer=kcfi` +error: `-Zsanitizer-cfi-generalize-pointers` requires `-Csanitize=cfi` or `-Csanitize=kcfi` error: aborting due to 1 previous error diff --git a/tests/ui/sanitizer/cfi/invalid-attr-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 c628709d7a1ce..9e2416f4299af 100644 --- a/tests/ui/sanitizer/cfi/is-incompatible-with-kcfi.rs +++ b/tests/ui/sanitizer/cfi/is-incompatible-with-kcfi.rs @@ -1,11 +1,11 @@ -// Verifies that `-Zsanitizer=cfi` is incompatible with `-Zsanitizer=kcfi`. +// Verifies that `-Csanitize=cfi` is incompatible with `-Csanitize=kcfi`. // //@ revisions: aarch64 x86_64 //@ [aarch64] compile-flags: --target aarch64-unknown-none //@ [aarch64] needs-llvm-components: aarch64 //@ [x86_64] compile-flags: --target x86_64-unknown-none //@ [x86_64] needs-llvm-components: x86 -//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer=kcfi +//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zunstable-options -Csanitize=cfi -Csanitize=kcfi #![feature(no_core)] #![no_core] diff --git a/tests/ui/sanitizer/cfi/is-incompatible-with-kcfi.x86_64.stderr b/tests/ui/sanitizer/cfi/is-incompatible-with-kcfi.x86_64.stderr index 7f596a19104e6..8a9544f6c6afc 100644 --- a/tests/ui/sanitizer/cfi/is-incompatible-with-kcfi.x86_64.stderr +++ b/tests/ui/sanitizer/cfi/is-incompatible-with-kcfi.x86_64.stderr @@ -1,6 +1,6 @@ error: cfi sanitizer is not supported for this target -error: `-Zsanitizer=cfi` is incompatible with `-Zsanitizer=kcfi` +error: `-Csanitize=cfi` is incompatible with `-Csanitize=kcfi` error: aborting due to 2 previous errors diff --git a/tests/ui/sanitizer/cfi/normalize-integers-attr-cfg.rs b/tests/ui/sanitizer/cfi/normalize-integers-attr-cfg.rs index 24c2c2c13da75..1c30dc9162524 100644 --- a/tests/ui/sanitizer/cfi/normalize-integers-attr-cfg.rs +++ b/tests/ui/sanitizer/cfi/normalize-integers-attr-cfg.rs @@ -3,7 +3,7 @@ // //@ needs-sanitizer-cfi //@ check-pass -//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-normalize-integers +//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zunstable-options -Csanitize=cfi -Zsanitizer-cfi-normalize-integers #![feature(cfg_sanitizer_cfi)] diff --git a/tests/ui/sanitizer/cfi/normalize-integers-requires-cfi.rs b/tests/ui/sanitizer/cfi/normalize-integers-requires-cfi.rs index a7ecefbf7efb7..5ba849531ea6f 100644 --- a/tests/ui/sanitizer/cfi/normalize-integers-requires-cfi.rs +++ b/tests/ui/sanitizer/cfi/normalize-integers-requires-cfi.rs @@ -1,5 +1,5 @@ -// Verifies that `-Zsanitizer-cfi-normalize-integers` requires `-Zsanitizer=cfi` or -// `-Zsanitizer=kcfi` +// Verifies that `-Zsanitizer-cfi-normalize-integers` requires `-Csanitize=cfi` or +// `-Csanitize=kcfi` // //@ needs-sanitizer-cfi //@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer-cfi-normalize-integers diff --git a/tests/ui/sanitizer/cfi/normalize-integers-requires-cfi.stderr b/tests/ui/sanitizer/cfi/normalize-integers-requires-cfi.stderr index 748fb60dad92e..32e9c9f2cf67d 100644 --- a/tests/ui/sanitizer/cfi/normalize-integers-requires-cfi.stderr +++ b/tests/ui/sanitizer/cfi/normalize-integers-requires-cfi.stderr @@ -1,4 +1,4 @@ -error: `-Zsanitizer-cfi-normalize-integers` requires `-Zsanitizer=cfi` or `-Zsanitizer=kcfi` +error: `-Zsanitizer-cfi-normalize-integers` requires `-Csanitize=cfi` or `-Csanitize=kcfi` error: aborting due to 1 previous error diff --git a/tests/ui/sanitizer/cfi/requires-lto.rs b/tests/ui/sanitizer/cfi/requires-lto.rs index 5a34f696e0546..f0b67bcfa3f45 100644 --- a/tests/ui/sanitizer/cfi/requires-lto.rs +++ b/tests/ui/sanitizer/cfi/requires-lto.rs @@ -1,7 +1,7 @@ -// Verifies that `-Zsanitizer=cfi` requires `-Clto` or `-Clinker-plugin-lto`. +// Verifies that `-Csanitize=cfi` requires `-Clto` or `-Clinker-plugin-lto`. // //@ needs-sanitizer-cfi -//@ compile-flags: -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi +//@ compile-flags: -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zunstable-options -Csanitize=cfi #![feature(no_core)] #![no_core] diff --git a/tests/ui/sanitizer/cfi/requires-lto.stderr b/tests/ui/sanitizer/cfi/requires-lto.stderr index efc0c43138e12..13d539e7c706b 100644 --- a/tests/ui/sanitizer/cfi/requires-lto.stderr +++ b/tests/ui/sanitizer/cfi/requires-lto.stderr @@ -1,4 +1,4 @@ -error: `-Zsanitizer=cfi` requires `-Clto` or `-Clinker-plugin-lto` +error: `-Csanitize=cfi` requires `-Clto` or `-Clinker-plugin-lto` error: aborting due to 1 previous error diff --git a/tests/ui/sanitizer/cfi/self-ref.rs b/tests/ui/sanitizer/cfi/self-ref.rs index 3b524ac661cf8..b9b1b5c382f96 100644 --- a/tests/ui/sanitizer/cfi/self-ref.rs +++ b/tests/ui/sanitizer/cfi/self-ref.rs @@ -7,8 +7,8 @@ //@ [kcfi] needs-sanitizer-kcfi //@ compile-flags: -C target-feature=-crt-static //@ [cfi] compile-flags: -C codegen-units=1 -C lto -C prefer-dynamic=off -C opt-level=0 -//@ [cfi] compile-flags: -Z sanitizer=cfi -//@ [kcfi] compile-flags: -Z sanitizer=kcfi +//@ [cfi] compile-flags: -Zunstable-options -Csanitize=cfi +//@ [kcfi] compile-flags: -Zunstable-options -Csanitize=kcfi //@ [kcfi] compile-flags: -C panic=abort -C prefer-dynamic=off //@ run-pass diff --git a/tests/ui/sanitizer/cfi/sized-associated-ty.rs b/tests/ui/sanitizer/cfi/sized-associated-ty.rs index f5b4e22e9d99b..7ae53dd0a7c03 100644 --- a/tests/ui/sanitizer/cfi/sized-associated-ty.rs +++ b/tests/ui/sanitizer/cfi/sized-associated-ty.rs @@ -8,8 +8,8 @@ //@ [kcfi] needs-sanitizer-kcfi //@ compile-flags: -C target-feature=-crt-static //@ [cfi] compile-flags: -C codegen-units=1 -C lto -C prefer-dynamic=off -C opt-level=0 -//@ [cfi] compile-flags: -Z sanitizer=cfi -//@ [kcfi] compile-flags: -Z sanitizer=kcfi +//@ [cfi] compile-flags: -Zunstable-options -Csanitize=cfi +//@ [kcfi] compile-flags: -Zunstable-options -Csanitize=kcfi //@ [kcfi] compile-flags: -C panic=abort -C prefer-dynamic=off //@ run-pass diff --git a/tests/ui/sanitizer/cfi/supertraits.rs b/tests/ui/sanitizer/cfi/supertraits.rs index 4bb6177577f7c..29512933210a9 100644 --- a/tests/ui/sanitizer/cfi/supertraits.rs +++ b/tests/ui/sanitizer/cfi/supertraits.rs @@ -8,8 +8,8 @@ //@ [kcfi] needs-sanitizer-kcfi //@ compile-flags: -C target-feature=-crt-static //@ [cfi] compile-flags: -C codegen-units=1 -C lto -C prefer-dynamic=off -C opt-level=0 -//@ [cfi] compile-flags: -Z sanitizer=cfi -//@ [kcfi] compile-flags: -Z sanitizer=kcfi +//@ [cfi] compile-flags: -Zunstable-options -Csanitize=cfi +//@ [kcfi] compile-flags: -Zunstable-options -Csanitize=kcfi //@ [kcfi] compile-flags: -C panic=abort -C prefer-dynamic=off //@ run-pass diff --git a/tests/ui/sanitizer/cfi/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 954e4ec3b8538..af0048d1df824 100644 --- a/tests/ui/sanitizer/cfi/with-rustc-lto-requires-single-codegen-unit.rs +++ b/tests/ui/sanitizer/cfi/with-rustc-lto-requires-single-codegen-unit.rs @@ -1,7 +1,7 @@ -// Verifies that `-Zsanitizer=cfi` with `-Clto` or `-Clto=thin` requires `-Ccodegen-units=1`. +// Verifies that `-Csanitize=cfi` with `-Clto` or `-Clto=thin` requires `-Ccodegen-units=1`. // //@ needs-sanitizer-cfi -//@ compile-flags: -Ccodegen-units=2 -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi +//@ compile-flags: -Ccodegen-units=2 -Clto -Ctarget-feature=-crt-static -Zunstable-options -Csanitize=cfi #![feature(no_core)] #![no_core] diff --git a/tests/ui/sanitizer/cfi/with-rustc-lto-requires-single-codegen-unit.stderr b/tests/ui/sanitizer/cfi/with-rustc-lto-requires-single-codegen-unit.stderr index 8d6dc1d8f1ea4..76673871f6e13 100644 --- a/tests/ui/sanitizer/cfi/with-rustc-lto-requires-single-codegen-unit.stderr +++ b/tests/ui/sanitizer/cfi/with-rustc-lto-requires-single-codegen-unit.stderr @@ -1,4 +1,4 @@ -error: `-Zsanitizer=cfi` with `-Clto` requires `-Ccodegen-units=1` +error: `-Csanitize=cfi` with `-Clto` requires `-Ccodegen-units=1` error: aborting due to 1 previous error diff --git a/tests/ui/sanitizer/crt-static.rs b/tests/ui/sanitizer/crt-static.rs index c24faeca3dc85..e690b9f394dfd 100644 --- a/tests/ui/sanitizer/crt-static.rs +++ b/tests/ui/sanitizer/crt-static.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -Z sanitizer=address -C target-feature=+crt-static --target x86_64-unknown-linux-gnu +//@ compile-flags: -Zunstable-options -Csanitize=address -C target-feature=+crt-static --target x86_64-unknown-linux-gnu //@ needs-llvm-components: x86 #![feature(no_core)] diff --git a/tests/ui/sanitizer/dataflow.rs b/tests/ui/sanitizer/dataflow.rs index 658a9e4808664..7bf54db87c63d 100644 --- a/tests/ui/sanitizer/dataflow.rs +++ b/tests/ui/sanitizer/dataflow.rs @@ -4,7 +4,7 @@ //@ needs-sanitizer-support //@ needs-sanitizer-dataflow //@ run-pass -//@ compile-flags: -Zsanitizer=dataflow -Zsanitizer-dataflow-abilist={{src-base}}/sanitizer/dataflow-abilist.txt +//@ compile-flags: -Zunstable-options -Csanitize=dataflow -Zsanitizer-dataflow-abilist={{src-base}}/sanitizer/dataflow-abilist.txt use std::mem::size_of; use std::os::raw::{c_int, c_long, c_void}; diff --git a/tests/ui/sanitizer/incompatible.rs b/tests/ui/sanitizer/incompatible.rs index d000abb26ac74..94a6bac95e198 100644 --- a/tests/ui/sanitizer/incompatible.rs +++ b/tests/ui/sanitizer/incompatible.rs @@ -1,6 +1,6 @@ -//@ compile-flags: -Z sanitizer=address -Z sanitizer=memory --target x86_64-unknown-linux-gnu +//@ compile-flags: -Zunstable-options -Csanitize=address -Csanitize=memory --target x86_64-unknown-linux-gnu //@ needs-llvm-components: x86 -//@ error-pattern: error: `-Zsanitizer=address` is incompatible with `-Zsanitizer=memory` +//@ error-pattern: error: `-Csanitize=address` is incompatible with `-Csanitize=memory` #![feature(no_core)] #![no_core] diff --git a/tests/ui/sanitizer/incompatible.stderr b/tests/ui/sanitizer/incompatible.stderr index 4dff813ee1be6..9995fb36abfa6 100644 --- a/tests/ui/sanitizer/incompatible.stderr +++ b/tests/ui/sanitizer/incompatible.stderr @@ -1,4 +1,4 @@ -error: `-Zsanitizer=address` is incompatible with `-Zsanitizer=memory` +error: `-Csanitize=address` is incompatible with `-Csanitize=memory` error: aborting due to 1 previous error diff --git a/tests/ui/sanitizer/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/tests/ui/sanitizer/issue-111184-cfi-coroutine-witness.rs b/tests/ui/sanitizer/issue-111184-cfi-coroutine-witness.rs index e5b1e0322575c..76e9b1395ba17 100644 --- a/tests/ui/sanitizer/issue-111184-cfi-coroutine-witness.rs +++ b/tests/ui/sanitizer/issue-111184-cfi-coroutine-witness.rs @@ -2,7 +2,7 @@ // encode_ty and caused the compiler to ICE. // //@ needs-sanitizer-cfi -//@ compile-flags: -Ccodegen-units=1 -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi --edition=2021 +//@ compile-flags: -Ccodegen-units=1 -Clto -Ctarget-feature=-crt-static -Zunstable-options -Csanitize=cfi --edition=2021 //@ no-prefer-dynamic //@ only-x86_64-unknown-linux-gnu //@ build-pass diff --git a/tests/ui/sanitizer/issue-114275-cfi-const-expr-in-arry-len.rs b/tests/ui/sanitizer/issue-114275-cfi-const-expr-in-arry-len.rs index b1b7487fa2a4d..dad91975aeaa3 100644 --- a/tests/ui/sanitizer/issue-114275-cfi-const-expr-in-arry-len.rs +++ b/tests/ui/sanitizer/issue-114275-cfi-const-expr-in-arry-len.rs @@ -2,7 +2,7 @@ // was expecting array type lengths to be evaluated, this was causing an ICE. // //@ build-pass -//@ compile-flags: -Ccodegen-units=1 -Clto -Zsanitizer=cfi -Ctarget-feature=-crt-static +//@ compile-flags: -Ccodegen-units=1 -Clto -Zunstable-options -Csanitize=cfi -Ctarget-feature=-crt-static //@ needs-sanitizer-cfi #![crate_type = "lib"] diff --git a/tests/ui/sanitizer/issue-72154-address-lifetime-markers.rs b/tests/ui/sanitizer/issue-72154-address-lifetime-markers.rs index aa0c19db9a12b..9ff3c7f3129a8 100644 --- a/tests/ui/sanitizer/issue-72154-address-lifetime-markers.rs +++ b/tests/ui/sanitizer/issue-72154-address-lifetime-markers.rs @@ -7,7 +7,7 @@ //@ needs-sanitizer-address //@ ignore-cross-compile // -//@ compile-flags: -Copt-level=0 -Zsanitizer=address +//@ compile-flags: -Copt-level=0 -Zunstable-options -Csanitize=address //@ run-pass pub struct Wrap { diff --git a/tests/ui/sanitizer/kcfi-mangling.rs b/tests/ui/sanitizer/kcfi-mangling.rs index fde7b5451b6e2..96f14734f63fc 100644 --- a/tests/ui/sanitizer/kcfi-mangling.rs +++ b/tests/ui/sanitizer/kcfi-mangling.rs @@ -2,7 +2,7 @@ //@ needs-sanitizer-kcfi //@ no-prefer-dynamic -//@ compile-flags: -C panic=abort -Zsanitizer=kcfi -C symbol-mangling-version=v0 +//@ compile-flags: -C panic=abort -Zunstable-options -Csanitize=kcfi -C symbol-mangling-version=v0 //@ build-pass trait Foo { diff --git a/tests/ui/sanitizer/leak.rs b/tests/ui/sanitizer/leak.rs index 65915ec24b723..fe1c1bfd083f3 100644 --- a/tests/ui/sanitizer/leak.rs +++ b/tests/ui/sanitizer/leak.rs @@ -1,7 +1,7 @@ //@ needs-sanitizer-support //@ needs-sanitizer-leak // -//@ compile-flags: -Z sanitizer=leak -O +//@ compile-flags: -Zunstable-options -Csanitize=leak -O // //@ run-fail //@ error-pattern: LeakSanitizer: detected memory leaks diff --git a/tests/ui/sanitizer/memory-eager.rs b/tests/ui/sanitizer/memory-eager.rs index 9e7889fa1bc09..cfd7d66ab2afa 100644 --- a/tests/ui/sanitizer/memory-eager.rs +++ b/tests/ui/sanitizer/memory-eager.rs @@ -3,8 +3,10 @@ // //@ revisions: unoptimized optimized // -//@ [optimized]compile-flags: -Z sanitizer=memory -Zsanitizer-memory-track-origins -O -//@ [unoptimized]compile-flags: -Z sanitizer=memory -Zsanitizer-memory-track-origins +//@ [optimized]compile-flags: -Zunstable-options -Csanitize=memory +//@ [optimized]compile-flags: -Zsanitizer-memory-track-origins -O +//@ [unoptimized]compile-flags: -Zunstable-options -Csanitize=memory +//@ [unoptimized]compile-flags: -Zsanitizer-memory-track-origins // //@ run-fail //@ error-pattern: MemorySanitizer: use-of-uninitialized-value diff --git a/tests/ui/sanitizer/memory-passing.rs b/tests/ui/sanitizer/memory-passing.rs index c8ab64bfaf833..78c04f10ae127 100644 --- a/tests/ui/sanitizer/memory-passing.rs +++ b/tests/ui/sanitizer/memory-passing.rs @@ -3,8 +3,10 @@ // //@ revisions: unoptimized optimized // -//@ [optimized]compile-flags: -Z sanitizer=memory -Zsanitizer-memory-track-origins -O -//@ [unoptimized]compile-flags: -Z sanitizer=memory -Zsanitizer-memory-track-origins +//@ [optimized]compile-flags: -Zunstable-options -Csanitize=memory +//@ [optimized]compile-flags: -Zsanitizer-memory-track-origins -O +//@ [unoptimized]compile-flags: -Zunstable-options -Csanitize=memory +//@ [unoptimized]compile-flags: -Zsanitizer-memory-track-origins // //@ run-pass // diff --git a/tests/ui/sanitizer/memory.rs b/tests/ui/sanitizer/memory.rs index bd2d67717495f..ee9c9fbc904dd 100644 --- a/tests/ui/sanitizer/memory.rs +++ b/tests/ui/sanitizer/memory.rs @@ -3,8 +3,10 @@ // //@ revisions: unoptimized optimized // -//@ [optimized]compile-flags: -Z sanitizer=memory -Zsanitizer-memory-track-origins -O -//@ [unoptimized]compile-flags: -Z sanitizer=memory -Zsanitizer-memory-track-origins +//@ [optimized]compile-flags: -Zunstable-options -Csanitize=memory +//@ [optimized]compile-flags: -Zsanitizer-memory-track-origins -O +//@ [unoptimized]compile-flags: -Zunstable-options -Csanitize=memory +//@ [unoptimized]compile-flags: -Zsanitizer-memory-track-origins // //@ run-fail //@ error-pattern: MemorySanitizer: use-of-uninitialized-value diff --git a/tests/ui/sanitizer/new-llvm-pass-manager-thin-lto.rs b/tests/ui/sanitizer/new-llvm-pass-manager-thin-lto.rs index b7dd4a437821a..b1bcd5554f7dd 100644 --- a/tests/ui/sanitizer/new-llvm-pass-manager-thin-lto.rs +++ b/tests/ui/sanitizer/new-llvm-pass-manager-thin-lto.rs @@ -8,7 +8,7 @@ // //@ no-prefer-dynamic //@ revisions: opt0 opt1 -//@ compile-flags: -Zsanitizer=address -Clto=thin +//@ compile-flags: -Zunstable-options -Csanitize=address -Clto=thin //@[opt0]compile-flags: -Copt-level=0 //@[opt1]compile-flags: -Copt-level=1 //@ run-fail diff --git a/tests/ui/sanitizer/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/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.rs b/tests/ui/sanitizer/unsupported-target.rs deleted file mode 100644 index 7c7dc24b5d9a5..0000000000000 --- a/tests/ui/sanitizer/unsupported-target.rs +++ /dev/null @@ -1,6 +0,0 @@ -//@ compile-flags: -Z sanitizer=leak --target i686-unknown-linux-gnu -//@ needs-llvm-components: x86 -//@ error-pattern: error: leak sanitizer is not supported for this target -#![feature(no_core)] -#![no_core] -#![no_main] diff --git a/tests/ui/sanitizer/unsupported-target.stderr b/tests/ui/sanitizer/unsupported-target.stderr deleted file mode 100644 index bebbf3884ae67..0000000000000 --- a/tests/ui/sanitizer/unsupported-target.stderr +++ /dev/null @@ -1,4 +0,0 @@ -error: leak sanitizer is not supported for this target - -error: aborting due to 1 previous error - diff --git a/tests/ui/sanitizer/use-after-scope.rs b/tests/ui/sanitizer/use-after-scope.rs index 4d7f6f6c2f2b5..ffcb079118d97 100644 --- a/tests/ui/sanitizer/use-after-scope.rs +++ b/tests/ui/sanitizer/use-after-scope.rs @@ -2,7 +2,7 @@ //@ needs-sanitizer-address //@ ignore-cross-compile // -//@ compile-flags: -Zsanitizer=address +//@ compile-flags: -Zunstable-options -Csanitize=address //@ run-fail //@ error-pattern: ERROR: AddressSanitizer: stack-use-after-scope