From 94bf59ea34a1592ca8797e03ac4511e344139cdf Mon Sep 17 00:00:00 2001 From: Gus Caplan Date: Sat, 12 Dec 2020 22:31:35 -0600 Subject: [PATCH 1/3] Use correct ABI for wasm32 by default Introduces `RUSTC_USE_WASM32_BINDGEN_COMPAT_ABI` env var to use the compat ABI if need. --- compiler/rustc_target/src/abi/call/mod.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_target/src/abi/call/mod.rs b/compiler/rustc_target/src/abi/call/mod.rs index 5de9a8dfa7ac1..73c1296a68643 100644 --- a/compiler/rustc_target/src/abi/call/mod.rs +++ b/compiler/rustc_target/src/abi/call/mod.rs @@ -605,7 +605,12 @@ 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" if cx.target_spec().os != "emscripten" => { + "wasm32" + if cx.target_spec().os != "emscripten" + && std::env::var("RUSTC_USE_WASM32_BINDGEN_COMPAT_ABI") + .map(|x| &x != "0") + .unwrap_or(false) => + { wasm32_bindgen_compat::compute_abi_info(self) } "wasm32" | "asmjs" => wasm32::compute_abi_info(cx, self), From 8f64cec02234a8971d547e7c610015fabc87162e Mon Sep 17 00:00:00 2001 From: Gus Caplan Date: Mon, 14 Dec 2020 10:33:35 -0600 Subject: [PATCH 2/3] new target --- compiler/rustc_target/src/abi/call/mod.rs | 7 +------ compiler/rustc_target/src/spec/mod.rs | 1 + compiler/rustc_target/src/spec/wasm32_unknown_bindgen.rs | 9 +++++++++ src/doc/rustc/src/platform-support.md | 1 + 4 files changed, 12 insertions(+), 6 deletions(-) create mode 100644 compiler/rustc_target/src/spec/wasm32_unknown_bindgen.rs diff --git a/compiler/rustc_target/src/abi/call/mod.rs b/compiler/rustc_target/src/abi/call/mod.rs index 73c1296a68643..89a1f2a55343e 100644 --- a/compiler/rustc_target/src/abi/call/mod.rs +++ b/compiler/rustc_target/src/abi/call/mod.rs @@ -605,12 +605,7 @@ 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" - if cx.target_spec().os != "emscripten" - && std::env::var("RUSTC_USE_WASM32_BINDGEN_COMPAT_ABI") - .map(|x| &x != "0") - .unwrap_or(false) => - { + "wasm32" if cx.target_spec().os == "bindgen" => { wasm32_bindgen_compat::compute_abi_info(self) } "wasm32" | "asmjs" => wasm32::compute_abi_info(cx, self), diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index abc96eb3322ec..32d64bac05cbe 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -613,6 +613,7 @@ supported_targets! { ("thumbv7a-uwp-windows-msvc", thumbv7a_uwp_windows_msvc), ("asmjs-unknown-emscripten", asmjs_unknown_emscripten), + ("wasm32-unknown-bindgen", wasm32_unknown_bindgen), ("wasm32-unknown-emscripten", wasm32_unknown_emscripten), ("wasm32-unknown-unknown", wasm32_unknown_unknown), ("wasm32-wasi", wasm32_wasi), diff --git a/compiler/rustc_target/src/spec/wasm32_unknown_bindgen.rs b/compiler/rustc_target/src/spec/wasm32_unknown_bindgen.rs new file mode 100644 index 0000000000000..67163fcb4175c --- /dev/null +++ b/compiler/rustc_target/src/spec/wasm32_unknown_bindgen.rs @@ -0,0 +1,9 @@ +//! This target is a variant of `wasm32-unknown-unknown` which uses the bindgen +//! ABI instead of the normal ABI. +use super::{wasm32_unknown_unknown, Target}; + +pub fn target() -> Target { + let mut target = wasm32_unknown_unknown::target(); + target.options.os = "bindgen".to_string(); + target +} diff --git a/src/doc/rustc/src/platform-support.md b/src/doc/rustc/src/platform-support.md index ce8caae375e98..bbfffecfe88fd 100644 --- a/src/doc/rustc/src/platform-support.md +++ b/src/doc/rustc/src/platform-support.md @@ -126,6 +126,7 @@ target | std | host | notes `thumbv8m.base-none-eabi` | * | | ARMv8-M Baseline `thumbv8m.main-none-eabi` | * | | ARMv8-M Mainline `thumbv8m.main-none-eabihf` | * | | ARMv8-M Mainline, hardfloat +`wasm32-unknown-bindgen` | ✓ | | WebAssembly via wasm-bindgen `wasm32-unknown-emscripten` | ✓ | | WebAssembly via Emscripten `wasm32-unknown-unknown` | ✓ | | WebAssembly `wasm32-wasi` | ✓ | | WebAssembly with WASI From 5ba3be1d60618fcd7fb819fdee4590ec048f190f Mon Sep 17 00:00:00 2001 From: Gus Caplan Date: Mon, 11 Jan 2021 15:31:52 -0600 Subject: [PATCH 3/3] squash! fix wasi --- compiler/rustc_target/src/abi/call/mod.rs | 9 +++++---- compiler/rustc_target/src/spec/mod.rs | 1 - compiler/rustc_target/src/spec/wasm32_unknown_bindgen.rs | 9 --------- src/doc/rustc/src/platform-support.md | 1 - 4 files changed, 5 insertions(+), 15 deletions(-) delete mode 100644 compiler/rustc_target/src/spec/wasm32_unknown_bindgen.rs diff --git a/compiler/rustc_target/src/abi/call/mod.rs b/compiler/rustc_target/src/abi/call/mod.rs index 89a1f2a55343e..a9e595d11e759 100644 --- a/compiler/rustc_target/src/abi/call/mod.rs +++ b/compiler/rustc_target/src/abi/call/mod.rs @@ -605,10 +605,11 @@ 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" if cx.target_spec().os == "bindgen" => { - wasm32_bindgen_compat::compute_abi_info(self) - } - "wasm32" | "asmjs" => wasm32::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), + }, + "asmjs" => wasm32::compute_abi_info(cx, self), a => return Err(format!("unrecognized arch \"{}\" in target specification", a)), } diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index 32d64bac05cbe..abc96eb3322ec 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -613,7 +613,6 @@ supported_targets! { ("thumbv7a-uwp-windows-msvc", thumbv7a_uwp_windows_msvc), ("asmjs-unknown-emscripten", asmjs_unknown_emscripten), - ("wasm32-unknown-bindgen", wasm32_unknown_bindgen), ("wasm32-unknown-emscripten", wasm32_unknown_emscripten), ("wasm32-unknown-unknown", wasm32_unknown_unknown), ("wasm32-wasi", wasm32_wasi), diff --git a/compiler/rustc_target/src/spec/wasm32_unknown_bindgen.rs b/compiler/rustc_target/src/spec/wasm32_unknown_bindgen.rs deleted file mode 100644 index 67163fcb4175c..0000000000000 --- a/compiler/rustc_target/src/spec/wasm32_unknown_bindgen.rs +++ /dev/null @@ -1,9 +0,0 @@ -//! This target is a variant of `wasm32-unknown-unknown` which uses the bindgen -//! ABI instead of the normal ABI. -use super::{wasm32_unknown_unknown, Target}; - -pub fn target() -> Target { - let mut target = wasm32_unknown_unknown::target(); - target.options.os = "bindgen".to_string(); - target -} diff --git a/src/doc/rustc/src/platform-support.md b/src/doc/rustc/src/platform-support.md index bbfffecfe88fd..ce8caae375e98 100644 --- a/src/doc/rustc/src/platform-support.md +++ b/src/doc/rustc/src/platform-support.md @@ -126,7 +126,6 @@ target | std | host | notes `thumbv8m.base-none-eabi` | * | | ARMv8-M Baseline `thumbv8m.main-none-eabi` | * | | ARMv8-M Mainline `thumbv8m.main-none-eabihf` | * | | ARMv8-M Mainline, hardfloat -`wasm32-unknown-bindgen` | ✓ | | WebAssembly via wasm-bindgen `wasm32-unknown-emscripten` | ✓ | | WebAssembly via Emscripten `wasm32-unknown-unknown` | ✓ | | WebAssembly `wasm32-wasi` | ✓ | | WebAssembly with WASI