-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Match wasm32-unknown-unknown
ABI with clang
#117236
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @wesleywiser (or someone else) soon. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
|
These commits modify compiler targets. |
This comment has been minimized.
This comment has been minimized.
These commits modify compiler targets. |
I believe it would be better for Rust to follow bjorn3's recommendation here: #71871 (comment). Providing a crate specific version warning would be great! Also want to note that Additionally I would like to point out some misunderstandings that might arise from the OP:
The current non-standard ABI doesn't stop
This PR would not fix this issue. Maybe
To clarify: I'm absolutely in favor of this change, but it should be done with care, imo. |
Yeah, it's the main reason this PR was made. If
Yeah, looks like this is something that cannot be solved with Rust ABI or
Glad to hear that. Hope that other developers also investigate in this topic to reach consensus :) |
wasm32-unknown-unknown
ABI with clangwasm32-unknown-unknown
ABI with clang
Do you have any suggestions to integrate this idea in this PR? Should we search for crates that uses the legacy ABI directly without |
Shims wouldn't solve that as well. You can't compile to The WASI shim solution for
I'm not familiar with crate-specific warnings in Rust (not that I'm familiar with rustc at all really). But that would be my (actually bjorn3's) suggestion: detect old versions of
I wouldn't know how, but my impression so far is that this wouldn't be necessary. |
Yeah, I also think that can be a sane way to warn the users. To clarify, I don't expect |
Currently,
wasm-bindgen
does not supportwasm32-wasi
target.The goal is to make
wasm-bindgen
supportwasm32-wasi
target, and this PR is a part of that effort which aims to match the ABI ofwasm-32-unknown-unknown
target to that ofwasm32-wasi
andclang
.There are discussions going on at
wasm-bindgen
repository about extending the support towasm32-wasi
. In short,wasm-bindgen
needs a consistent C ABI betweenwasm32-unknown-unknown
andwasm32-wasi
to support both of them.These links might also be helpful:
Take a look at the comment by @alexcrichton who wrote this code. We can understand why this legacy ABI was introduced in the first place from this post.
After more than 2 years,
wasm32-unknown-unknown
still uses the legacy ABI.wasm-bindgen
says that Rust should switch to the new ABI first, but Rust is saying thatwasm-bindgen
should support the new ABI first. It's somewhat like a chicken-egg problem.Up until now, this legacy ABI was working fine. However recently
wasm32-wasi
started becoming a thing and the Rust ecosystem is actively being built around it. That's why I and some other contributors came up to suggest this change. Since most of the users do not use C ABI directly, but instead generate.wasm
and.js
code withwasm-bindgen
, they will just need to updatewasm-bindgen
and re-generate the code. Appropriate warning and version-specific workaround should be provided from Rust compiler, though.To narrow the focus on web browsers, many native functionalities including
std::thread
,std::time::Instant
,std::fs
are not working right now withwasm32-unknown-unknown
. This limitation prevents many crates liketokio
andrayon
from working on the web, leaving the vast majority of Rust ecosystem being fallen out from the web platform. Consequently, fragmentation arises as many crates now ship with separated wasm and non-wasm versions, simply because they can't usestd
.If
wasm-bindgen
gets to supportwasm32-wasi
, various crates will be able to use thread, time, file, network operations on the web only withstd
without any custom JavaScript glue, just like they do on native platforms. JavaScript polyfill libraries(such aswasmer-js
,browser_wasi_shim
) claims that they can handle that WASI syscalls, utilizing existing web APIs to mimic native functionalities.I hope we can achieve consensus between Rust developers and
wasm-bindgen
developers soon enough!