-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tracking Issue for perma-unstable wasm-c-abi
flag
#122532
Comments
Introduce perma-unstable `wasm-c-abi` flag Now that `wasm-bindgen` v0.2.88 supports the spec-compliant C ABI, the idea is to switch to that in a future version of Rust. In the meantime it would be good to let people test and play around with it. This PR introduces a new perma-unstable `-Zwasm-c-abi` compiler flag, which switches to the new spec-compliant C ABI when targeting `wasm32-unknown-unknown`. Alternatively, we could also stabilize this and then deprecate it when we switch. I will leave this to the Rust maintainers to decide. This is a companion PR to rust-lang#117918, but they could be merged independently. MCP: rust-lang/compiler-team#703 Tracking issue: rust-lang#122532
Introduce perma-unstable `wasm-c-abi` flag Now that `wasm-bindgen` v0.2.88 supports the spec-compliant C ABI, the idea is to switch to that in a future version of Rust. In the meantime it would be good to let people test and play around with it. This PR introduces a new perma-unstable `-Zwasm-c-abi` compiler flag, which switches to the new spec-compliant C ABI when targeting `wasm32-unknown-unknown`. Alternatively, we could also stabilize this and then deprecate it when we switch. I will leave this to the Rust maintainers to decide. This is a companion PR to rust-lang#117918, but they could be merged independently. MCP: rust-lang/compiler-team#703 Tracking issue: rust-lang#122532
Introduce perma-unstable `wasm-c-abi` flag Now that `wasm-bindgen` v0.2.88 supports the spec-compliant C ABI, the idea is to switch to that in a future version of Rust. In the meantime it would be good to let people test and play around with it. This PR introduces a new perma-unstable `-Zwasm-c-abi` compiler flag, which switches to the new spec-compliant C ABI when targeting `wasm32-unknown-unknown`. Alternatively, we could also stabilize this and then deprecate it when we switch. I will leave this to the Rust maintainers to decide. This is a companion PR to rust-lang#117918, but they could be merged independently. MCP: rust-lang/compiler-team#703 Tracking issue: rust-lang#122532
Introduce perma-unstable `wasm-c-abi` flag Now that `wasm-bindgen` v0.2.88 supports the spec-compliant C ABI, the idea is to switch to that in a future version of Rust. In the meantime it would be good to let people test and play around with it. This PR introduces a new perma-unstable `-Zwasm-c-abi` compiler flag, which switches to the new spec-compliant C ABI when targeting `wasm32-unknown-unknown`. Alternatively, we could also stabilize this and then deprecate it when we switch. I will leave this to the Rust maintainers to decide. This is a companion PR to rust-lang#117918, but they could be merged independently. MCP: rust-lang/compiler-team#703 Tracking issue: rust-lang#122532
Introduce perma-unstable `wasm-c-abi` flag Now that `wasm-bindgen` v0.2.88 supports the spec-compliant C ABI, the idea is to switch to that in a future version of Rust. In the meantime it would be good to let people test and play around with it. This PR introduces a new perma-unstable `-Zwasm-c-abi` compiler flag, which switches to the new spec-compliant C ABI when targeting `wasm32-unknown-unknown`. Alternatively, we could also stabilize this and then deprecate it when we switch. I will leave this to the Rust maintainers to decide. This is a companion PR to rust-lang#117918, but they could be merged independently. MCP: rust-lang/compiler-team#703 Tracking issue: rust-lang#122532
Introduce perma-unstable `wasm-c-abi` flag Now that `wasm-bindgen` v0.2.88 supports the spec-compliant C ABI, the idea is to switch to that in a future version of Rust. In the meantime it would be good to let people test and play around with it. This PR introduces a new perma-unstable `-Zwasm-c-abi` compiler flag, which switches to the new spec-compliant C ABI when targeting `wasm32-unknown-unknown`. Alternatively, we could also stabilize this and then deprecate it when we switch. I will leave this to the Rust maintainers to decide. This is a companion PR to #117918, but they could be merged independently. MCP: rust-lang/compiler-team#703 Tracking issue: rust-lang/rust#122532
Introduce perma-unstable `wasm-c-abi` flag Now that `wasm-bindgen` v0.2.88 supports the spec-compliant C ABI, the idea is to switch to that in a future version of Rust. In the meantime it would be good to let people test and play around with it. This PR introduces a new perma-unstable `-Zwasm-c-abi` compiler flag, which switches to the new spec-compliant C ABI when targeting `wasm32-unknown-unknown`. Alternatively, we could also stabilize this and then deprecate it when we switch. I will leave this to the Rust maintainers to decide. This is a companion PR to #117918, but they could be merged independently. MCP: rust-lang/compiler-team#703 Tracking issue: rust-lang/rust#122532
Introduce perma-unstable `wasm-c-abi` flag Now that `wasm-bindgen` v0.2.88 supports the spec-compliant C ABI, the idea is to switch to that in a future version of Rust. In the meantime it would be good to let people test and play around with it. This PR introduces a new perma-unstable `-Zwasm-c-abi` compiler flag, which switches to the new spec-compliant C ABI when targeting `wasm32-unknown-unknown`. Alternatively, we could also stabilize this and then deprecate it when we switch. I will leave this to the Rust maintainers to decide. This is a companion PR to #117918, but they could be merged independently. MCP: rust-lang/compiler-team#703 Tracking issue: rust-lang/rust#122532
Introduce perma-unstable `wasm-c-abi` flag Now that `wasm-bindgen` v0.2.88 supports the spec-compliant C ABI, the idea is to switch to that in a future version of Rust. In the meantime it would be good to let people test and play around with it. This PR introduces a new perma-unstable `-Zwasm-c-abi` compiler flag, which switches to the new spec-compliant C ABI when targeting `wasm32-unknown-unknown`. Alternatively, we could also stabilize this and then deprecate it when we switch. I will leave this to the Rust maintainers to decide. This is a companion PR to #117918, but they could be merged independently. MCP: rust-lang/compiler-team#703 Tracking issue: rust-lang/rust#122532
Since 1.78 a future-compat-warning for using too-old versions of wasm-bindgen has been in place, and now 75% of the ecosystem's downloads of crates are wasm-bindgen 0.2.89 or higher. I have opened #129534 as a discussion point for whether we should move the warning to a deny. |
wasm-bindgen 0.2.62 is not compatible with a wasm ABI change that rustc wishes to enable by default for wasm32-unknown-unknown, currently gated behind passing the -Zwasm-c-abi flag to rustc. wasm-bindgen 0.2.89 should exhibit seamless behavior before and after the ABI change to match the C ABI, so depend on that. For more information, see - rust-lang/rust#115666 - rust-lang/rust#117918 - rust-lang/rust#122532
This comment has been minimized.
This comment has been minimized.
… r=workingjubilee Make the wasm_c_abi future compat warning a hard error This is the next step in getting rid of the broken C abi for wasm32-unknown-unknown. The lint was made deny-by-default in rust-lang#129534 3 months ago. This still keeps the `-Zwasm-c-abi` flag set to `legacy` by default. It will be flipped in a future PR. cc rust-lang#122532
… r=workingjubilee Make the wasm_c_abi future compat warning a hard error This is the next step in getting rid of the broken C abi for wasm32-unknown-unknown. The lint was made deny-by-default in rust-lang#129534 3 months ago. This still keeps the `-Zwasm-c-abi` flag set to `legacy` by default. It will be flipped in a future PR. cc rust-lang#122532
… r=workingjubilee Make the wasm_c_abi future compat warning a hard error This is the next step in getting rid of the broken C abi for wasm32-unknown-unknown. The lint was made deny-by-default in rust-lang#129534 3 months ago. This still keeps the `-Zwasm-c-abi` flag set to `legacy` by default. It will be flipped in a future PR. cc rust-lang#122532
Rollup merge of rust-lang#133951 - bjorn3:wasm_c_abi_lint_hard_error, r=workingjubilee Make the wasm_c_abi future compat warning a hard error This is the next step in getting rid of the broken C abi for wasm32-unknown-unknown. The lint was made deny-by-default in rust-lang#129534 3 months ago. This still keeps the `-Zwasm-c-abi` flag set to `legacy` by default. It will be flipped in a future PR. cc rust-lang#122532
Hi! I was recently informed that there are plans to switch the default soon. I work on Diplomat, a tool that generates multi-language bindings (including JS-wasm), used by ICU4X, My expectation here was that there would be a period of time where both compilation modes are available on stable before things are switched over, as is the norm for almost all breaking changes in Rust. I have been waiting for that period of time to migrate Diplomat, so that Diplomat (and ICU4X) users will have an "apply I'm rather surprised to hear that it's just going to be a simple switchover. It's not a huge deal for Diplomat-WASM to require nightly for working around this, but it's a bit messy, and like I said it is surprising. (I'm also surprised that the extent of future-incompat work was to ensure people use the latest wasm-bindgen: wasm-bindgen isn't the only tool around, and there are people who work directly with WASM with no generated bindings!) |
Yeah, it's too new, and the primary compiler used for wasm is .... rustc, so....... |
So far in my experience, wasm being new meant everything was extremely well-done as they learned from all the past mistakes. There's even a formal language spec :)
But I have only been following from afar.
|
#138601 implements the suggested lint.
I'm fine with just removing the FCW in the same PR that also does the ABI switch (without ever having it be an actual error), if that works for you. |
That doesn't seem to be entirely true, this was at least partially intentionally:
However, whoever wrote this apparently did not consider that the way rustc translates Rust types to LLVM types is not stable so we can't ever just use the "bare" LLVM ABI in this way. Anyway at this point that is only of historical interest. |
This comment from the comes from the introduction of |
This has gotten to be quite a long thread but I can try to comment on at least some parts from a wasm target maintainer perspective. IMO the main thing here is that the ABI was "broken" from the get-go (my mistake) and then by the time we discovered it (years later) I had run out of steam and couldn't champion the change to wasm-bindgen. This then started a multi-year process (5+ I think?) to change the ABI where no one person was ever solely dedicated to completing the migration. Naturally thoughout this time people have come and gone and progress has been made but it's inevitable that with such a large cast of characters and such a large amount of time that things fall through the cracks. When this started (which I think was 2020 or pre-2020, I forget), I'm relatively certain wasm-bindgen was the only thing in play, and I think that mentality stuck by default despite that not being true years later. Regardless of this past though it seems like we're all aligned on (a) everyone here's operating in good-faith (yay!) and (b) the goal is to change the ABI still. I definitely agree the ABI should still change here myself, and on the topic of changing from a "good ABI" to a "not as good ABI" in terms of what the actual ABI is, this is another long-running issue on the wasm side and I think that discussion should happen on tool-conventions (I can point to issues if desired) rather than here. The goal here is to align with Clang and stop implicitly relying on Rust compiler internals. Personally I'd think it best if we could get away with FCW + blog. Question for you though @Manishearth as that has pretty serious implications for Diplomat, are you ok with these? (sorry if this was already discussed)
If you're ok with that, that seems like a reasonable plan to move forward to me, with a possible schedule looking like:
That's going to be probably a longer transition period than envisioned (I think?). (1) here can happen here-and-now, but (3) is ~12 weeks out and (5) is probably minimum 24 weeks out, possibly more. |
FWIW I was thinking we'd remove the FCW the moment we change the default. In fact the current implementation does this already -- the lint only fires when |
That seems good. The schedule is a bit fast according to ICU4X standards (we change MSRV slowly), but if the FCW has helpful advice for people in this situation, and is framed less like an FCW and more like "this is compiler-version dependent, take care, here's a link for how to fix", and the lint goes away with explicit I will discuss this with other ICU4X and Diplomat team members to ensure everyone is on the same page and fine with this path. |
They only learned from things people wrote down and made public. The horrors of the hard lessons learned in, say, the evolution of the x86 Microsoft C++ ABI, seem to have been buried in Redmond. |
To me this depends on the transition plan. It sounds like Diplomat's plan is something along the lines of:
If the FCW is removed when the default is changed (which I take to also remove I should definitely clarify though that to me I'm considering two knobs: one is the change of the default value of
Oh I'm just throwing out ideas. I'm not actually in charge of timelines or anything. Personally I think it's valuable for everything to have a bounded amount of time, but extending a release or two is probably fine.
To clarify, and to be double-sure: this is not possible with a stable or beta compiler, only a nightly compiler. My thinking is there is no plan to move I want to be extra careful to clarify this since most projects in the past I know of are hesitant to do both, but if that's ok for Diplomat it definitely makes the compiler's life easier |
No, the flag can stay around a bit longer once the default is changed. Just the FCW is gone then. (Or, impossible to hit on stable. It might still exist and trigger for people that set |
Ah ok, I think you and I are thinking the same thing then, so sounds good! In some sense the FCW "will break" warning is correct with |
Yep. But one way to deal with the transition is, during it, to explicitly pass a wasm-c-abi flag on nightly. It's not great to have to use nightly for this, but for building |
Up above @RalfJung added I-compiler-nominated, so in an effort to expedite team discussion of this I'm going to try to summarize the current status with respect to the compiler team. The main points are:
My understanding is that this plan works for Diplomat and the hope is that this works for other users as well if they come out of the woodwork. Also this is my best understanding of the conclusions of this thread, if I got something wrong here someone please let me know. |
The current plan that Diplomat and ICU4X are coalescing around is:
This means that the plan for an FCW and eventual switchover in the near future is probably acceptable to us. Will keep you posted if other needs come up. |
So another "fix" is to set The timeline you had above would be
I am confused here, how would an older compiler help when using spec ABI bindinings? |
typo, sorry! |
Might be nice to keep the |
As a nightly-only flag I assume people using it would anyway track latest nightly fairly closely? But yeah we can keep that flag around a bit longer, forget about it, and remove it in 5 years when someone finally notices. ;) Once the legacy ABI is finally gone from rustc, this transition is done as far as I am concerned. |
There can be other constraints on the nightly version you use. Not relevant for this particular thing, but e.g. ICU4X pins some nightlies in its tests so that we can track cross-language LTO codesize. |
Just to give another example of this: The multivalue extension has been talked about for ages. It is implemented everywhere1. Yet, nowhere, do I see any mention of what this means in JS (which has no native concept of returning multiple values). I had to reverse engineer it, turns out that it returns an array of the scalars splatted out, which is reasonable, but it's really hard to find any docs that tell you how this work. Not just official docs, any docs whatsoever. You can figure it out from the wasm-js interface spec and the multivalue spec if you want to. An observation about the wasm ecosystem from a relative outsider: Wasm was initially marketed as this thing for running fast native code from JS, but the focus has overall shifted to a more general usage as a way to safely embed native code in many kinds of applications that have nothing to do with JS. It feels like this has ended up with the JS-wasm use case getting less attention over time, leading to an overall lack of docs. I think things like this issue are also a knock on effect: where folks were trying to fix the C interop problem but did not really consider there to be any users of JS-wasm outside of wasm-bindgen, despite JS-wasm being the original primary purpose of wasm. I had to struggle to convince people that it was possible to use the current ABI because people were convinced it was unusably broken (it was broken, just not unusably so for JS-wasm). Footnotes
|
T-compiler visited this issue during the triage meeting (on Zulip#t-compiler/meetings > [wekly] 2025-03-20 @ 💬). First of all thanks @RalfJung and @alexcrichton for the great effort to summarize the main points. We basically have nothing to add and find the plan sound (although understandadly a bit of a burden for the parties involved). We take from this comment an actionable for us to be more transparent and document better stability promises (or lack thereof). @rustbot label -I-compiler-nominated |
If no one else wants to volunteer to write a blog post I'm happy to draft that up in the next few days with a plan to merge the blog post around the time #138601 lands. |
@alexcrichton I can't take point on this but I can probably help review it and write a paragraph or two if you share a hackmd with me when you start. |
I've written up an initial draft |
add FCW to warn about wasm ABI transition See rust-lang#122532 for context: the "C" ABI on wasm32-unk-unk will change. The goal of this lint is to warn about any function definition and calls whose behavior will be affected by the change. My understanding is the following: - scalar arguments are fine - including 128 bit types, they get passed as two `i64` arguments in both ABIs - `repr(C)` structs (recursively) wrapping a single scalar argument are fine (unless they have extra padding due to over-alignment attributes) - all return values are fine `@bjorn3` `@alexcrichton` `@Manishearth` is that correct? I am making this a "show up in future compat reports" lint to maximize the chances people become aware of this. OTOH this likely means warnings for most users of Diplomat so maybe we shouldn't do this? IIUC, wasm-bindgen should be unaffected by this lint as they only pass scalar types as arguments. Tracking issue: rust-lang#138762 Transition plan blog post: rust-lang/blog.rust-lang.org#1531
This is a tracking issue for the MCP "perma-unstable
wasm-c-abi
flag" (rust-lang/compiler-team#703).For background, see rust-lang/compiler-team#703. The short summary is that the ABI rustc uses for
extern "C"
on wasm32-unknown-unknown is not spec-compliant and exposes various unstable implementation details of rustc and LLVM. We plan to transition to the official "C" ABI for this target. This will change how non-scalar arguments are passed across this ABI boundary, so if you have code running that is built for wasm32-unknown-unknown and called directly by JavaScript, it may have to be adjusted to follow the new ABI rules. Options for how to manage the transition are still being considered; see #138762 for further guidance.The
-Zwasm-c-abi
flag lets you test your code with the new ABI.About tracking issues
Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.
Steps
instructions?)
Formatting for new syntax has been added to the Style Guide (nightly-style-procedure)Stabilization PR (see instructions on rustc-dev-guide)Implementation history
wasm-c-abi
flag #117919wasm_c_abi
future-incompat
lint #117918Related issues
The text was updated successfully, but these errors were encountered: