@@ -5,6 +5,7 @@ use std::path::{Path, PathBuf};
55use std:: { env, io, iter, mem, str} ;
66
77use cc:: windows_registry;
8+ use rustc_ast:: expand:: allocator:: { ALLOCATOR_METHODS , NO_ALLOC_SHIM_IS_UNSTABLE , global_fn_name} ;
89use rustc_hir:: def_id:: { CrateNum , LOCAL_CRATE } ;
910use rustc_metadata:: {
1011 find_native_static_library, try_find_native_dynamic_library, try_find_native_static_library,
@@ -16,14 +17,16 @@ use rustc_middle::middle::exported_symbols::{
1617} ;
1718use rustc_middle:: ty:: TyCtxt ;
1819use rustc_session:: Session ;
19- use rustc_session:: config:: { self , CrateType , DebugInfo , LinkerPluginLto , Lto , OptLevel , Strip } ;
20+ use rustc_session:: config:: {
21+ self , CrateType , DebugInfo , LinkerPluginLto , Lto , OomStrategy , OptLevel , Strip ,
22+ } ;
2023use rustc_span:: sym;
24+ use rustc_symbol_mangling:: mangle_internal_symbol;
2125use rustc_target:: spec:: { Cc , LinkOutputKind , LinkerFlavor , Lld } ;
2226use tracing:: { debug, warn} ;
2327
2428use super :: command:: Command ;
2529use super :: symbol_export;
26- use crate :: back:: symbol_export:: allocator_shim_symbols;
2730use crate :: base:: needs_allocator_shim_for_linking;
2831use crate :: errors;
2932
@@ -1846,7 +1849,17 @@ fn exported_symbols_for_non_proc_macro(
18461849 && needs_allocator_shim_for_linking ( tcx. dependency_formats ( ( ) ) , crate_type)
18471850 && tcx. allocator_kind ( ( ) ) . is_some ( )
18481851 {
1849- symbols. extend ( allocator_shim_symbols ( tcx) ) ;
1852+ for symbol_name in ALLOCATOR_METHODS
1853+ . iter ( )
1854+ . map ( |method| mangle_internal_symbol ( tcx, global_fn_name ( method. name ) . as_str ( ) ) )
1855+ . chain ( [
1856+ mangle_internal_symbol ( tcx, "__rust_alloc_error_handler" ) ,
1857+ mangle_internal_symbol ( tcx, OomStrategy :: SYMBOL ) ,
1858+ mangle_internal_symbol ( tcx, NO_ALLOC_SHIM_IS_UNSTABLE ) ,
1859+ ] )
1860+ {
1861+ symbols. push ( ( symbol_name, SymbolExportKind :: Text ) ) ;
1862+ }
18501863 }
18511864
18521865 symbols
0 commit comments