From 4eb23953d6843406a83f2a3cb977ab12e18a68b6 Mon Sep 17 00:00:00 2001 From: liuxinyi Date: Mon, 9 Dec 2024 11:22:11 +0800 Subject: [PATCH] [rust] revert -C sanitizer Signed-off-by: liuxinyi --- compiler/rustc_codegen_llvm/src/abi.rs | 2 +- compiler/rustc_codegen_llvm/src/attributes.rs | 4 ++-- compiler/rustc_codegen_ssa/src/back/link.rs | 4 ++-- .../rustc_codegen_ssa/src/back/symbol_export.rs | 2 +- compiler/rustc_codegen_ssa/src/back/write.rs | 2 +- compiler/rustc_session/src/config.rs | 2 +- compiler/rustc_session/src/options.rs | 4 ++-- compiler/rustc_session/src/session.rs | 14 +++++++------- 8 files changed, 17 insertions(+), 17 deletions(-) diff --git a/compiler/rustc_codegen_llvm/src/abi.rs b/compiler/rustc_codegen_llvm/src/abi.rs index f67cddfa7db..d221bad28ef 100644 --- a/compiler/rustc_codegen_llvm/src/abi.rs +++ b/compiler/rustc_codegen_llvm/src/abi.rs @@ -81,7 +81,7 @@ fn apply_attrs_to_callsite( attrs.push(llattr.create_attr(cx.llcx)); } } - } else if cx.tcx.sess.opts.cg.sanitizer.contains(SanitizerSet::MEMORY) { + } else if cx.tcx.sess.opts.unstable_opts.sanitizer.contains(SanitizerSet::MEMORY) { // 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 979a5ccde25..39275272e42 100644 --- a/compiler/rustc_codegen_llvm/src/attributes.rs +++ b/compiler/rustc_codegen_llvm/src/attributes.rs @@ -60,7 +60,7 @@ pub fn sanitize_attrs<'ll>( no_sanitize: SanitizerSet, ) -> SmallVec<[&'ll Attribute; 4]> { let mut attrs = SmallVec::new(); - let enabled = cx.tcx.sess.opts.cg.sanitizer - no_sanitize; + let enabled = cx.tcx.sess.opts.unstable_opts.sanitizer - no_sanitize; if enabled.contains(SanitizerSet::ADDRESS) || enabled.contains(SanitizerSet::KERNELADDRESS) { attrs.push(llvm::AttributeKind::SanitizeAddress.create_attr(cx.llcx)); } @@ -182,7 +182,7 @@ fn probestack_attr<'ll>(cx: &CodegenCx<'ll, '_>) -> Option<&'ll Attribute> { if cx .sess() .opts - .cg + .unstable_opts .sanitizer .intersects(SanitizerSet::ADDRESS | SanitizerSet::THREAD) { diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index 090acaf2241..b603a878746 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -1192,7 +1192,7 @@ fn add_sanitizer_libraries(sess: &Session, crate_type: CrateType, linker: &mut d return; } - let sanitizer = sess.opts.cg.sanitizer; + let sanitizer = sess.opts.unstable_opts.sanitizer; if sanitizer.contains(SanitizerSet::ADDRESS) { link_sanitizer_runtime(sess, linker, "asan"); } @@ -2257,7 +2257,7 @@ fn add_order_independent_options( && crate_type == CrateType::Executable && !matches!(flavor, LinkerFlavor::Gnu(Cc::Yes, _)) { - let prefix = if sess.opts.cg.sanitizer.contains(SanitizerSet::ADDRESS) { + let prefix = if sess.opts.unstable_opts.sanitizer.contains(SanitizerSet::ADDRESS) { "asan/" } else { "" diff --git a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs index 588b39662a2..a8b6030ac85 100644 --- a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs +++ b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs @@ -274,7 +274,7 @@ fn exported_symbols_provider_local( })); } - if tcx.sess.opts.cg.sanitizer.contains(SanitizerSet::MEMORY) { + if tcx.sess.opts.unstable_opts.sanitizer.contains(SanitizerSet::MEMORY) { let mut msan_weak_symbols = Vec::new(); // Similar to profiling, preserve weak msan symbol during LTO. diff --git a/compiler/rustc_codegen_ssa/src/back/write.rs b/compiler/rustc_codegen_ssa/src/back/write.rs index 86311c4958f..ececa29b231 100644 --- a/compiler/rustc_codegen_ssa/src/back/write.rs +++ b/compiler/rustc_codegen_ssa/src/back/write.rs @@ -194,7 +194,7 @@ macro_rules! if_regular { false ), - sanitizer: if_regular!(sess.opts.cg.sanitizer, SanitizerSet::empty()), + sanitizer: if_regular!(sess.opts.unstable_opts.sanitizer, SanitizerSet::empty()), sanitizer_recover: if_regular!( sess.opts.unstable_opts.sanitizer_recover, SanitizerSet::empty() diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index 13f3a26031a..f97cb3440d2 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -1238,7 +1238,7 @@ fn default_configuration(sess: &Session) -> CrateConfig { let panic_strategy = sess.panic_strategy(); ret.insert((sym::panic, Some(panic_strategy.desc_symbol()))); - for mut s in sess.opts.cg.sanitizer { + for mut s in sess.opts.unstable_opts.sanitizer { // KASAN should use the same attribute name as ASAN, as it's still ASAN // under the hood if s == SanitizerSet::KERNELADDRESS { diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index 5a53be73cb9..7840a0ecf0b 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -1362,8 +1362,6 @@ pub(crate) fn parse_dump_solver_proof_tree( "output remarks for these optimization passes (space separated, or \"all\")"), rpath: bool = (false, parse_bool, [UNTRACKED], "set rpath values in libs/exes (default: no)"), - sanitizer: SanitizerSet = (SanitizerSet::empty(), parse_sanitizers, [TRACKED], - "use a sanitizer"), save_temps: bool = (false, parse_bool, [UNTRACKED], "save all temporary output files during compilation (default: no)"), soft_float: bool = (false, parse_bool, [TRACKED], @@ -1714,6 +1712,8 @@ pub(crate) fn parse_dump_solver_proof_tree( written to standard error output)"), report_delayed_bugs: bool = (false, parse_bool, [TRACKED], "immediately print bugs registered with `delay_span_bug` (default: no)"), + 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 338df1219e6..5be122ffbde 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -773,7 +773,7 @@ pub fn init_features(&self, features: rustc_feature::Features) { } pub fn is_sanitizer_cfi_enabled(&self) -> bool { - self.opts.cg.sanitizer.contains(SanitizerSet::CFI) + self.opts.unstable_opts.sanitizer.contains(SanitizerSet::CFI) } pub fn is_sanitizer_cfi_canonical_jump_tables_disabled(&self) -> bool { @@ -793,7 +793,7 @@ pub fn is_sanitizer_cfi_normalize_integers_enabled(&self) -> bool { } pub fn is_sanitizer_kcfi_enabled(&self) -> bool { - self.opts.cg.sanitizer.contains(SanitizerSet::KCFI) + self.opts.unstable_opts.sanitizer.contains(SanitizerSet::KCFI) } pub fn is_split_lto_unit_enabled(&self) -> bool { @@ -1035,7 +1035,7 @@ pub fn emit_lifetime_markers(&self) -> bool { // 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.cg.sanitizer.intersects(SanitizerSet::ADDRESS | SanitizerSet::KERNELADDRESS | SanitizerSet::MEMORY | SanitizerSet::HWADDRESS) + || self.opts.unstable_opts.sanitizer.intersects(SanitizerSet::ADDRESS | SanitizerSet::KERNELADDRESS | SanitizerSet::MEMORY | SanitizerSet::HWADDRESS) } pub fn diagnostic_width(&self) -> usize { @@ -1150,7 +1150,7 @@ pub fn fewer_names(&self) -> bool { 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.cg.sanitizer.intersects(SanitizerSet::ADDRESS | SanitizerSet::MEMORY); + || self.opts.unstable_opts.sanitizer.intersects(SanitizerSet::ADDRESS | SanitizerSet::MEMORY); !more_names } } @@ -1588,7 +1588,7 @@ fn validate_commandline_args_with_session_available(sess: &Session) { // Sanitizers can only be used on platforms that we know have working sanitizer codegen. let supported_sanitizers = sess.target.options.supported_sanitizers; - let unsupported_sanitizers = sess.opts.cg.sanitizer - supported_sanitizers; + let unsupported_sanitizers = sess.opts.unstable_opts.sanitizer - supported_sanitizers; match unsupported_sanitizers.into_iter().count() { 0 => {} 1 => { @@ -1601,7 +1601,7 @@ fn validate_commandline_args_with_session_available(sess: &Session) { } } // Cannot mix and match sanitizers. - let mut sanitizer_iter = sess.opts.cg.sanitizer.into_iter(); + let mut sanitizer_iter = sess.opts.unstable_opts.sanitizer.into_iter(); if let (Some(first), Some(second)) = (sanitizer_iter.next(), sanitizer_iter.next()) { sess.emit_err(errors::CannotMixAndMatchSanitizers { first: first.to_string(), @@ -1610,7 +1610,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.cg.sanitizer.is_empty() { + if sess.crt_static(None) && !sess.opts.unstable_opts.sanitizer.is_empty() { sess.emit_err(errors::CannotEnableCrtStaticLinux); } -- Gitee