@@ -7,13 +7,15 @@ use rustc_ast::expand::allocator::{
77} ;
88use rustc_codegen_ssa:: base:: allocator_kind_for_codegen;
99use rustc_session:: config:: OomStrategy ;
10+ use rustc_symbol_mangling:: mangle_internal_symbol;
1011
1112use crate :: prelude:: * ;
1213
1314/// Returns whether an allocator shim was created
1415pub ( crate ) fn codegen ( tcx : TyCtxt < ' _ > , module : & mut dyn Module ) -> bool {
1516 let Some ( kind) = allocator_kind_for_codegen ( tcx) else { return false } ;
1617 codegen_inner (
18+ tcx,
1719 module,
1820 kind,
1921 tcx. alloc_error_handler_kind ( ( ) ) . unwrap ( ) ,
@@ -23,6 +25,7 @@ pub(crate) fn codegen(tcx: TyCtxt<'_>, module: &mut dyn Module) -> bool {
2325}
2426
2527fn codegen_inner (
28+ tcx : TyCtxt < ' _ > ,
2629 module : & mut dyn Module ,
2730 kind : AllocatorKind ,
2831 alloc_error_handler_kind : AllocatorKind ,
@@ -62,8 +65,8 @@ fn codegen_inner(
6265 crate :: common:: create_wrapper_function (
6366 module,
6467 sig,
65- & global_fn_name ( method. name ) ,
66- & default_fn_name ( method. name ) ,
68+ & mangle_internal_symbol ( tcx , & global_fn_name ( method. name ) ) ,
69+ & mangle_internal_symbol ( tcx , & default_fn_name ( method. name ) ) ,
6770 ) ;
6871 }
6972 }
@@ -76,19 +79,32 @@ fn codegen_inner(
7679 crate :: common:: create_wrapper_function (
7780 module,
7881 sig,
79- "__rust_alloc_error_handler" ,
80- & alloc_error_handler_name ( alloc_error_handler_kind) ,
82+ & mangle_internal_symbol ( tcx , "__rust_alloc_error_handler" ) ,
83+ & mangle_internal_symbol ( tcx , alloc_error_handler_name ( alloc_error_handler_kind) ) ,
8184 ) ;
8285
83- let data_id = module. declare_data ( OomStrategy :: SYMBOL , Linkage :: Export , false , false ) . unwrap ( ) ;
86+ let data_id = module
87+ . declare_data (
88+ & mangle_internal_symbol ( tcx, OomStrategy :: SYMBOL ) ,
89+ Linkage :: Export ,
90+ false ,
91+ false ,
92+ )
93+ . unwrap ( ) ;
8494 let mut data = DataDescription :: new ( ) ;
8595 data. set_align ( 1 ) ;
8696 let val = oom_strategy. should_panic ( ) ;
8797 data. define ( Box :: new ( [ val] ) ) ;
8898 module. define_data ( data_id, & data) . unwrap ( ) ;
8999
90- let data_id =
91- module. declare_data ( NO_ALLOC_SHIM_IS_UNSTABLE , Linkage :: Export , false , false ) . unwrap ( ) ;
100+ let data_id = module
101+ . declare_data (
102+ & mangle_internal_symbol ( tcx, NO_ALLOC_SHIM_IS_UNSTABLE ) ,
103+ Linkage :: Export ,
104+ false ,
105+ false ,
106+ )
107+ . unwrap ( ) ;
92108 let mut data = DataDescription :: new ( ) ;
93109 data. set_align ( 1 ) ;
94110 data. define ( Box :: new ( [ 0 ] ) ) ;
0 commit comments