From 2d6d6a84df371390046269fe4955d2e4300f118f Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 27 Aug 2024 07:33:49 -0700 Subject: [PATCH] Updates/clarifications --- .../platform-support/wasm32-unknown-unknown.md | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/doc/rustc/src/platform-support/wasm32-unknown-unknown.md b/src/doc/rustc/src/platform-support/wasm32-unknown-unknown.md index 6ce022e5ebb..0e06a820a22 100644 --- a/src/doc/rustc/src/platform-support/wasm32-unknown-unknown.md +++ b/src/doc/rustc/src/platform-support/wasm32-unknown-unknown.md @@ -205,7 +205,7 @@ be fixed in a future version of Rust. For example this Rust code: -```rust +```rust,ignore (does-not-link) #[repr(C)] struct MyPair { a: u32, @@ -280,20 +280,22 @@ unfortunate accident which got relied on. The `wasm-bindgen` project prior to seen as not worth the tradeoff of breaking `wasm-bindgen` historically to fix this issue in the compiler. -Thanks to the heroic efforts of many involved in this, however, the nightly -compiler currently supports a `-Zwasm-c-abi` implemented in +Thanks to the heroic efforts of many involved in this, however, `wasm-bindgen` +0.2.89 and later are compatible with the correct definition of `extern "C"` and +the nightly compiler currently supports a `-Zwasm-c-abi` implemented in [#117919](https://github.com/rust-lang/rust/pull/117919). This nightly-only flag can be used to indicate whether the spec-defined version of `extern "C"` should be used instead of the "legacy" version of whatever-the-Rust-target-originally-implemented. For example using the above code you can see (lightly edited for clarity): -``` +```shell $ rustc +nightly -Zwasm-c-abi=spec foo.rs --target wasm32-unknown-unknown --crate-type lib --emit obj -O $ wasm-tools print foo.o (module (import "env" "take_my_pair" (func $take_my_pair (param i32) (result i32))) (func $call_c (result i32) + ;; ... ) ;; ... ) @@ -305,6 +307,8 @@ they should. The `-Zwasm-c-abi` compiler flag is tracked in [#122532](https://github.com/rust-lang/rust/issues/122532) and a lint was implemented in [#117918](https://github.com/rust-lang/rust/issues/117918) to -help warn users about the transition. The current plan is to, in the future, -switch `-Zwasm-c-api=spec` to being the default. Some time after that the -`-Zwasm-c-abi` flag and the "legacy" implementation will all be removed. +help warn users about the transition if they're using `wasm-bindgen` 0.2.88 or +prior. The current plan is to, in the future, switch `-Zwasm-c-api=spec` to +being the default. Some time after that the `-Zwasm-c-abi` flag and the +"legacy" implementation will all be removed. During this process users on a +sufficiently updated version of `wasm-bindgen` should not experience breakage.