@@ -44,16 +44,7 @@ pub fn link_module(
44
44
FloorF64 => wasmtime_f64_floor as usize ,
45
45
TruncF64 => wasmtime_f64_trunc as usize ,
46
46
NearestF64 => wasmtime_f64_nearest as usize ,
47
- #[ cfg( not( target_os = "windows" ) ) ]
48
- Probestack => __rust_probestack as usize ,
49
- #[ cfg( all( target_os = "windows" , target_env = "gnu" ) ) ]
50
- Probestack => ___chkstk as usize ,
51
- #[ cfg( all(
52
- target_os = "windows" ,
53
- target_env = "msvc" ,
54
- target_pointer_width = "64"
55
- ) ) ]
56
- Probestack => __chkstk as usize ,
47
+ Probestack => PROBESTACK as usize ,
57
48
other => panic ! ( "unexpected libcall: {}" , other) ,
58
49
}
59
50
}
@@ -107,19 +98,33 @@ pub fn link_module(
107
98
}
108
99
}
109
100
110
- /// A declaration for the stack probe function in Rust's standard library, for
111
- /// catching callstack overflow.
112
- extern "C" {
113
- #[ cfg( not( target_os = "windows" ) ) ]
114
- pub fn __rust_probestack ( ) ;
115
- #[ cfg( all(
116
- target_os = "windows" ,
117
- target_env = "msvc" ,
118
- target_pointer_width = "64"
119
- ) ) ]
120
- pub fn __chkstk ( ) ;
121
- // ___chkstk (note the triple underscore) is implemented in compiler-builtins/src/x86_64.rs
122
- // by the Rust compiler for the MinGW target
123
- #[ cfg( all( target_os = "windows" , target_env = "gnu" ) ) ]
124
- pub fn ___chkstk ( ) ;
101
+ // A declaration for the stack probe function in Rust's standard library, for
102
+ // catching callstack overflow.
103
+ cfg_if:: cfg_if! {
104
+ if #[ cfg( any(
105
+ target_arch="aarch64" ,
106
+ all(
107
+ target_os = "windows" ,
108
+ target_env = "msvc" ,
109
+ target_pointer_width = "64"
110
+ )
111
+ ) ) ] {
112
+ extern "C" {
113
+ pub fn __chkstk( ) ;
114
+ }
115
+ const PROBESTACK : unsafe extern "C" fn ( ) = __chkstk;
116
+ } else if #[ cfg( all( target_os = "windows" , target_env = "gnu" ) ) ] {
117
+ extern "C" {
118
+ // ___chkstk (note the triple underscore) is implemented in compiler-builtins/src/x86_64.rs
119
+ // by the Rust compiler for the MinGW target
120
+ #[ cfg( all( target_os = "windows" , target_env = "gnu" ) ) ]
121
+ pub fn ___chkstk( ) ;
122
+ }
123
+ const PROBESTACK : unsafe extern "C" fn ( ) = ___chkstk;
124
+ } else {
125
+ extern "C" {
126
+ pub fn __rust_probestack( ) ;
127
+ }
128
+ static PROBESTACK : unsafe extern "C" fn ( ) = __rust_probestack;
129
+ }
125
130
}
0 commit comments