@@ -245,50 +245,37 @@ fn exported_symbols_provider_local(
245245 ) )
246246 }
247247
248+ // Rust assumes that all code provided to (non-plugin) LTO comes from Rust, so it knows about
249+ // all symbols that are involved. This doesn't hold up for symbols that get injected by LLVM,
250+ // so they need to be special-cased.
251+ let mut externally_injected_weak_symbols = Vec :: new ( ) ;
248252 if tcx. sess . instrument_coverage ( ) || tcx. sess . opts . cg . profile_generate . enabled ( ) {
249253 // These are weak symbols that point to the profile version and the
250254 // profile name, which need to be treated as exported so LTO doesn't nix
251255 // them.
252- const PROFILER_WEAK_SYMBOLS : [ & str ; 2 ] =
253- [ "__llvm_profile_raw_version" , "__llvm_profile_filename" ] ;
254-
255- symbols. extend ( PROFILER_WEAK_SYMBOLS . iter ( ) . map ( |sym| {
256- let exported_symbol = ExportedSymbol :: NoDefId ( SymbolName :: new ( tcx, sym) ) ;
257- (
258- exported_symbol,
259- SymbolExportInfo {
260- level : SymbolExportLevel :: C ,
261- kind : SymbolExportKind :: Data ,
262- used : false ,
263- } ,
264- )
265- } ) ) ;
256+ externally_injected_weak_symbols. push ( "__llvm_profile_raw_version" ) ;
257+ externally_injected_weak_symbols. push ( "__llvm_profile_filename" ) ;
266258 }
267-
268259 if tcx. sess . opts . unstable_opts . sanitizer . contains ( SanitizerSet :: MEMORY ) {
269- let mut msan_weak_symbols = Vec :: new ( ) ;
270-
271260 // Similar to profiling, preserve weak msan symbol during LTO.
272261 if tcx. sess . opts . unstable_opts . sanitizer_recover . contains ( SanitizerSet :: MEMORY ) {
273- msan_weak_symbols . push ( "__msan_keep_going" ) ;
262+ externally_injected_weak_symbols . push ( "__msan_keep_going" ) ;
274263 }
275-
276264 if tcx. sess . opts . unstable_opts . sanitizer_memory_track_origins != 0 {
277- msan_weak_symbols . push ( "__msan_track_origins" ) ;
265+ externally_injected_weak_symbols . push ( "__msan_track_origins" ) ;
278266 }
279-
280- symbols. extend ( msan_weak_symbols. into_iter ( ) . map ( |sym| {
281- let exported_symbol = ExportedSymbol :: NoDefId ( SymbolName :: new ( tcx, sym) ) ;
282- (
283- exported_symbol,
284- SymbolExportInfo {
285- level : SymbolExportLevel :: C ,
286- kind : SymbolExportKind :: Data ,
287- used : false ,
288- } ,
289- )
290- } ) ) ;
291267 }
268+ symbols. extend ( externally_injected_weak_symbols. into_iter ( ) . map ( |sym| {
269+ let exported_symbol = ExportedSymbol :: NoDefId ( SymbolName :: new ( tcx, sym) ) ;
270+ (
271+ exported_symbol,
272+ SymbolExportInfo {
273+ level : SymbolExportLevel :: C ,
274+ kind : SymbolExportKind :: Data ,
275+ used : false ,
276+ } ,
277+ )
278+ } ) ) ;
292279
293280 if tcx. sess . crate_types ( ) . contains ( & CrateType :: Dylib )
294281 || tcx. sess . crate_types ( ) . contains ( & CrateType :: ProcMacro )
0 commit comments