@@ -18,7 +18,7 @@ use rustc_symbol_mangling::mangle_internal_symbol;
18
18
use rustc_target:: spec:: { SanitizerSet , TlsModel } ;
19
19
use tracing:: debug;
20
20
21
- use crate :: base :: allocator_kind_for_codegen ;
21
+ use crate :: back :: symbol_export ;
22
22
23
23
fn threshold ( tcx : TyCtxt < ' _ > ) -> SymbolExportLevel {
24
24
crates_export_threshold ( tcx. crate_types ( ) )
@@ -217,31 +217,6 @@ fn exported_non_generic_symbols_provider_local<'tcx>(
217
217
) ) ;
218
218
}
219
219
220
- // Mark allocator shim symbols as exported only if they were generated.
221
- if allocator_kind_for_codegen ( tcx) . is_some ( ) {
222
- for symbol_name in ALLOCATOR_METHODS
223
- . iter ( )
224
- . map ( |method| mangle_internal_symbol ( tcx, global_fn_name ( method. name ) . as_str ( ) ) )
225
- . chain ( [
226
- mangle_internal_symbol ( tcx, "__rust_alloc_error_handler" ) ,
227
- mangle_internal_symbol ( tcx, OomStrategy :: SYMBOL ) ,
228
- mangle_internal_symbol ( tcx, NO_ALLOC_SHIM_IS_UNSTABLE ) ,
229
- ] )
230
- {
231
- let exported_symbol = ExportedSymbol :: NoDefId ( SymbolName :: new ( tcx, & symbol_name) ) ;
232
-
233
- symbols. push ( (
234
- exported_symbol,
235
- SymbolExportInfo {
236
- level : SymbolExportLevel :: Rust ,
237
- kind : SymbolExportKind :: Text ,
238
- used : false ,
239
- rustc_std_internal_symbol : true ,
240
- } ,
241
- ) ) ;
242
- }
243
- }
244
-
245
220
if tcx. sess . instrument_coverage ( ) || tcx. sess . opts . cg . profile_generate . enabled ( ) {
246
221
// These are weak symbols that point to the profile version and the
247
222
// profile name, which need to be treated as exported so LTO doesn't nix
@@ -563,6 +538,31 @@ pub(crate) fn provide(providers: &mut Providers) {
563
538
upstream_monomorphizations_for_provider;
564
539
}
565
540
541
+ pub ( crate ) fn allocator_shim_symbols (
542
+ tcx : TyCtxt < ' _ > ,
543
+ ) -> impl Iterator < Item = ( String , SymbolExportKind ) > {
544
+ ALLOCATOR_METHODS
545
+ . iter ( )
546
+ . map ( move |method| mangle_internal_symbol ( tcx, global_fn_name ( method. name ) . as_str ( ) ) )
547
+ . chain ( [
548
+ mangle_internal_symbol ( tcx, "__rust_alloc_error_handler" ) ,
549
+ mangle_internal_symbol ( tcx, OomStrategy :: SYMBOL ) ,
550
+ mangle_internal_symbol ( tcx, NO_ALLOC_SHIM_IS_UNSTABLE ) ,
551
+ ] )
552
+ . map ( move |symbol_name| {
553
+ let exported_symbol = ExportedSymbol :: NoDefId ( SymbolName :: new ( tcx, & symbol_name) ) ;
554
+
555
+ (
556
+ symbol_export:: exporting_symbol_name_for_instance_in_crate (
557
+ tcx,
558
+ exported_symbol,
559
+ LOCAL_CRATE ,
560
+ ) ,
561
+ SymbolExportKind :: Text ,
562
+ )
563
+ } )
564
+ }
565
+
566
566
fn symbol_export_level ( tcx : TyCtxt < ' _ > , sym_def_id : DefId ) -> SymbolExportLevel {
567
567
// We export anything that's not mangled at the "C" layer as it probably has
568
568
// to do with ABI concerns. We do not, however, apply such treatment to
0 commit comments