diff options
| author | bjorn3 <bjorn3@users.noreply.github.com> | 2021-01-25 21:28:29 +0100 |
|---|---|---|
| committer | bjorn3 <bjorn3@users.noreply.github.com> | 2021-01-25 21:32:57 +0100 |
| commit | e7a056fe20f7ec5a475923ff2f4eda8ca9e1a74b (patch) | |
| tree | 26f45af8f9f69ac10587a88b04797211db5b2df3 /compiler | |
| parent | 4d2766e3524129f0d7ec6ad34c4045150ad4f978 (diff) | |
| download | rust-e7a056fe20f7ec5a475923ff2f4eda8ca9e1a74b.tar.gz rust-e7a056fe20f7ec5a475923ff2f4eda8ca9e1a74b.zip | |
Share wasm-bindgen compat abi selection code
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_middle/src/ty/layout.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_target/src/abi/call/mod.rs | 20 |
2 files changed, 17 insertions, 5 deletions
diff --git a/compiler/rustc_middle/src/ty/layout.rs b/compiler/rustc_middle/src/ty/layout.rs index a6b7b393213..2bec761b0e5 100644 --- a/compiler/rustc_middle/src/ty/layout.rs +++ b/compiler/rustc_middle/src/ty/layout.rs @@ -2752,7 +2752,7 @@ where attrs }); - if target.arch == "wasm32" && target.os == "unknown" { + if call::use_wasm_bindgen_compat_abi(target) { // wasm-bindgen depends on ABI details and is incompatible with the // correct C ABI, so this is being kept around until wasm-bindgen // can be fixed to work with the correct ABI. See #63649 for further diff --git a/compiler/rustc_target/src/abi/call/mod.rs b/compiler/rustc_target/src/abi/call/mod.rs index 2cbd52bf3e9..521aea6dd72 100644 --- a/compiler/rustc_target/src/abi/call/mod.rs +++ b/compiler/rustc_target/src/abi/call/mod.rs @@ -1,6 +1,6 @@ use crate::abi::{self, Abi, Align, FieldsShape, Size}; use crate::abi::{HasDataLayout, LayoutOf, TyAndLayout, TyAndLayoutMethods}; -use crate::spec::{self, HasTargetSpec}; +use crate::spec::{self, HasTargetSpec, Target}; mod aarch64; mod amdgpu; @@ -631,9 +631,10 @@ impl<'a, Ty> FnAbi<'a, Ty> { "nvptx64" => nvptx64::compute_abi_info(self), "hexagon" => hexagon::compute_abi_info(self), "riscv32" | "riscv64" => riscv::compute_abi_info(cx, self), - "wasm32" => match cx.target_spec().os.as_str() { - "emscripten" | "wasi" => wasm32::compute_abi_info(cx, self), - _ => wasm32_bindgen_compat::compute_abi_info(self), + "wasm32" => if use_wasm_bindgen_compat_abi(cx.target_spec()) { + wasm32_bindgen_compat::compute_abi_info(self) + } else { + wasm32::compute_abi_info(cx, self) }, "asmjs" => wasm32::compute_abi_info(cx, self), a => return Err(format!("unrecognized arch \"{}\" in target specification", a)), @@ -642,3 +643,14 @@ impl<'a, Ty> FnAbi<'a, Ty> { Ok(()) } } + +pub fn use_wasm_bindgen_compat_abi(target_spec: &Target) -> bool { + if target_spec.arch.as_str() == "wasm32" { + match target_spec.os.as_str() { + "emscripten" | "wasi" => false, + _ => true, + } + } else { + false + } +} |
