@@ -7,13 +7,15 @@ use rustc_ast::expand::allocator::{
7
7
} ;
8
8
use rustc_codegen_ssa:: base:: allocator_kind_for_codegen;
9
9
use rustc_session:: config:: OomStrategy ;
10
+ use rustc_symbol_mangling:: mangle_internal_symbol;
10
11
11
12
use crate :: prelude:: * ;
12
13
13
14
/// Returns whether an allocator shim was created
14
15
pub ( crate ) fn codegen ( tcx : TyCtxt < ' _ > , module : & mut dyn Module ) -> bool {
15
16
let Some ( kind) = allocator_kind_for_codegen ( tcx) else { return false } ;
16
17
codegen_inner (
18
+ tcx,
17
19
module,
18
20
kind,
19
21
tcx. alloc_error_handler_kind ( ( ) ) . unwrap ( ) ,
@@ -23,6 +25,7 @@ pub(crate) fn codegen(tcx: TyCtxt<'_>, module: &mut dyn Module) -> bool {
23
25
}
24
26
25
27
fn codegen_inner (
28
+ tcx : TyCtxt < ' _ > ,
26
29
module : & mut dyn Module ,
27
30
kind : AllocatorKind ,
28
31
alloc_error_handler_kind : AllocatorKind ,
@@ -62,8 +65,8 @@ fn codegen_inner(
62
65
crate :: common:: create_wrapper_function (
63
66
module,
64
67
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 ) ) ,
67
70
) ;
68
71
}
69
72
}
@@ -76,19 +79,32 @@ fn codegen_inner(
76
79
crate :: common:: create_wrapper_function (
77
80
module,
78
81
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) ) ,
81
84
) ;
82
85
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 ( ) ;
84
94
let mut data = DataDescription :: new ( ) ;
85
95
data. set_align ( 1 ) ;
86
96
let val = oom_strategy. should_panic ( ) ;
87
97
data. define ( Box :: new ( [ val] ) ) ;
88
98
module. define_data ( data_id, & data) . unwrap ( ) ;
89
99
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 ( ) ;
92
108
let mut data = DataDescription :: new ( ) ;
93
109
data. set_align ( 1 ) ;
94
110
data. define ( Box :: new ( [ 0 ] ) ) ;
0 commit comments