1
1
use crate :: abi:: { self , Abi , Align , FieldsShape , Size } ;
2
2
use crate :: abi:: { HasDataLayout , LayoutOf , TyAndLayout , TyAndLayoutMethods } ;
3
- use crate :: spec:: { self , HasTargetSpec } ;
3
+ use crate :: spec:: { self , HasTargetSpec , Target } ;
4
4
5
5
mod aarch64;
6
6
mod amdgpu;
@@ -631,9 +631,10 @@ impl<'a, Ty> FnAbi<'a, Ty> {
631
631
"nvptx64" => nvptx64:: compute_abi_info ( self ) ,
632
632
"hexagon" => hexagon:: compute_abi_info ( self ) ,
633
633
"riscv32" | "riscv64" => riscv:: compute_abi_info ( cx, self ) ,
634
- "wasm32" => match cx. target_spec ( ) . os . as_str ( ) {
635
- "emscripten" | "wasi" => wasm32:: compute_abi_info ( cx, self ) ,
636
- _ => wasm32_bindgen_compat:: compute_abi_info ( self ) ,
634
+ "wasm32" => if use_wasm_bindgen_compat_abi ( cx. target_spec ( ) ) {
635
+ wasm32_bindgen_compat:: compute_abi_info ( self )
636
+ } else {
637
+ wasm32:: compute_abi_info ( cx, self )
637
638
} ,
638
639
"asmjs" => wasm32:: compute_abi_info ( cx, self ) ,
639
640
a => return Err ( format ! ( "unrecognized arch \" {}\" in target specification" , a) ) ,
@@ -642,3 +643,14 @@ impl<'a, Ty> FnAbi<'a, Ty> {
642
643
Ok ( ( ) )
643
644
}
644
645
}
646
+
647
+ pub fn use_wasm_bindgen_compat_abi ( target_spec : & Target ) -> bool {
648
+ if target_spec. arch . as_str ( ) == "wasm32" {
649
+ match target_spec. os . as_str ( ) {
650
+ "emscripten" | "wasi" => false ,
651
+ _ => true ,
652
+ }
653
+ } else {
654
+ false
655
+ }
656
+ }
0 commit comments