Skip to content

Commit

Permalink
Updates/clarifications
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcrichton committed Sep 3, 2024
1 parent 992b0b3 commit 2d6d6a8
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/doc/rustc/src/platform-support/wasm32-unknown-unknown.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
;; ...
)
;; ...
)
Expand All @@ -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.

0 comments on commit 2d6d6a8

Please sign in to comment.