11use crate :: abi:: { self , Abi , Align , FieldsShape , Size } ;
22use crate :: abi:: { HasDataLayout , LayoutOf , TyAndLayout , TyAndLayoutMethods } ;
3- use crate :: spec:: { self , HasTargetSpec } ;
3+ use crate :: spec:: { self , HasTargetSpec , Target } ;
44
55mod aarch64;
66mod amdgpu;
@@ -631,9 +631,10 @@ impl<'a, Ty> FnAbi<'a, Ty> {
631631 "nvptx64" => nvptx64:: compute_abi_info ( self ) ,
632632 "hexagon" => hexagon:: compute_abi_info ( self ) ,
633633 "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 )
637638 } ,
638639 "asmjs" => wasm32:: compute_abi_info ( cx, self ) ,
639640 a => return Err ( format ! ( "unrecognized arch \" {}\" in target specification" , a) ) ,
@@ -642,3 +643,14 @@ impl<'a, Ty> FnAbi<'a, Ty> {
642643 Ok ( ( ) )
643644 }
644645}
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