@@ -18,7 +18,7 @@ use rustc_symbol_mangling::mangle_internal_symbol;
1818use rustc_target:: spec:: TlsModel ;
1919use tracing:: debug;
2020
21- use crate :: base :: allocator_kind_for_codegen ;
21+ use crate :: back :: symbol_export ;
2222
2323fn threshold ( tcx : TyCtxt < ' _ > ) -> SymbolExportLevel {
2424 crates_export_threshold ( tcx. crate_types ( ) )
@@ -217,31 +217,6 @@ fn exported_non_generic_symbols_provider_local<'tcx>(
217217 ) ) ;
218218 }
219219
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-
245220 // Sort so we get a stable incr. comp. hash.
246221 symbols. sort_by_cached_key ( |s| s. 0 . symbol_name_for_local_instance ( tcx) ) ;
247222
@@ -516,6 +491,31 @@ pub(crate) fn provide(providers: &mut Providers) {
516491 upstream_monomorphizations_for_provider;
517492}
518493
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+
519519fn symbol_export_level ( tcx : TyCtxt < ' _ > , sym_def_id : DefId ) -> SymbolExportLevel {
520520 // We export anything that's not mangled at the "C" layer as it probably has
521521 // to do with ABI concerns. We do not, however, apply such treatment to
0 commit comments