@@ -18,7 +18,7 @@ use rustc_symbol_mangling::mangle_internal_symbol;
18
18
use rustc_target:: spec:: 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
// Sort so we get a stable incr. comp. hash.
246
221
symbols. sort_by_cached_key ( |s| s. 0 . symbol_name_for_local_instance ( tcx) ) ;
247
222
@@ -516,6 +491,31 @@ pub(crate) fn provide(providers: &mut Providers) {
516
491
upstream_monomorphizations_for_provider;
517
492
}
518
493
494
+ pub ( crate ) fn allocator_shim_symbols (
495
+ tcx : TyCtxt < ' _ > ,
496
+ ) -> impl Iterator < Item = ( String , SymbolExportKind ) > {
497
+ ALLOCATOR_METHODS
498
+ . iter ( )
499
+ . map ( move |method| mangle_internal_symbol ( tcx, global_fn_name ( method. name ) . as_str ( ) ) )
500
+ . chain ( [
501
+ mangle_internal_symbol ( tcx, "__rust_alloc_error_handler" ) ,
502
+ mangle_internal_symbol ( tcx, OomStrategy :: SYMBOL ) ,
503
+ mangle_internal_symbol ( tcx, NO_ALLOC_SHIM_IS_UNSTABLE ) ,
504
+ ] )
505
+ . map ( move |symbol_name| {
506
+ let exported_symbol = ExportedSymbol :: NoDefId ( SymbolName :: new ( tcx, & symbol_name) ) ;
507
+
508
+ (
509
+ symbol_export:: exporting_symbol_name_for_instance_in_crate (
510
+ tcx,
511
+ exported_symbol,
512
+ LOCAL_CRATE ,
513
+ ) ,
514
+ SymbolExportKind :: Text ,
515
+ )
516
+ } )
517
+ }
518
+
519
519
fn symbol_export_level ( tcx : TyCtxt < ' _ > , sym_def_id : DefId ) -> SymbolExportLevel {
520
520
// We export anything that's not mangled at the "C" layer as it probably has
521
521
// to do with ABI concerns. We do not, however, apply such treatment to
0 commit comments