diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2025-08-28 21:41:03 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-28 21:41:03 +0200 |
| commit | a60b96a3d47ca522439df646534dd5e27beb5a07 (patch) | |
| tree | 0e2a2d0bc7d4b5e153728b1b3a96eafeb6406942 /compiler/rustc_codegen_ssa | |
| parent | b944a436607be5680a89cc59902ca850adc3f0f5 (diff) | |
| parent | 23e72ab41e27842eae0d60a6f4750c5151aabcbc (diff) | |
| download | rust-a60b96a3d47ca522439df646534dd5e27beb5a07.tar.gz rust-a60b96a3d47ca522439df646534dd5e27beb5a07.zip | |
Rollup merge of #145965 - bjorn3:sanitize_symbol_export_improvements, r=lqd
Move exporting of profiler and sanitizer symbols to the LLVM backend Only the LLVM backend needs those specific symbols exported and it only needs them to be exported for LTO, not from cdylibs in general.
Diffstat (limited to 'compiler/rustc_codegen_ssa')
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/back/symbol_export.rs | 49 |
1 files changed, 1 insertions, 48 deletions
diff --git a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs index 13419bcb22c..d8a1480e911 100644 --- a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs +++ b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs @@ -15,7 +15,7 @@ use rustc_middle::ty::{self, GenericArgKind, GenericArgsRef, Instance, SymbolNam use rustc_middle::util::Providers; use rustc_session::config::{CrateType, OomStrategy}; use rustc_symbol_mangling::mangle_internal_symbol; -use rustc_target::spec::{SanitizerSet, TlsModel}; +use rustc_target::spec::TlsModel; use tracing::debug; use crate::base::allocator_kind_for_codegen; @@ -242,53 +242,6 @@ fn exported_non_generic_symbols_provider_local<'tcx>( } } - if tcx.sess.instrument_coverage() || tcx.sess.opts.cg.profile_generate.enabled() { - // These are weak symbols that point to the profile version and the - // profile name, which need to be treated as exported so LTO doesn't nix - // them. - const PROFILER_WEAK_SYMBOLS: [&str; 2] = - ["__llvm_profile_raw_version", "__llvm_profile_filename"]; - - symbols.extend(PROFILER_WEAK_SYMBOLS.iter().map(|sym| { - let exported_symbol = ExportedSymbol::NoDefId(SymbolName::new(tcx, sym)); - ( - exported_symbol, - SymbolExportInfo { - level: SymbolExportLevel::C, - kind: SymbolExportKind::Data, - used: false, - rustc_std_internal_symbol: false, - }, - ) - })); - } - - 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. - if tcx.sess.opts.unstable_opts.sanitizer_recover.contains(SanitizerSet::MEMORY) { - msan_weak_symbols.push("__msan_keep_going"); - } - - if tcx.sess.opts.unstable_opts.sanitizer_memory_track_origins != 0 { - msan_weak_symbols.push("__msan_track_origins"); - } - - symbols.extend(msan_weak_symbols.into_iter().map(|sym| { - let exported_symbol = ExportedSymbol::NoDefId(SymbolName::new(tcx, sym)); - ( - exported_symbol, - SymbolExportInfo { - level: SymbolExportLevel::C, - kind: SymbolExportKind::Data, - used: false, - rustc_std_internal_symbol: false, - }, - ) - })); - } - // Sort so we get a stable incr. comp. hash. symbols.sort_by_cached_key(|s| s.0.symbol_name_for_local_instance(tcx)); |
