-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Match wasm32-unknown-unknown ABI with clang
#117236
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
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-bindgendoes not supportwasm32-wasitarget.The goal is to make
wasm-bindgensupportwasm32-wasitarget, and this PR is a part of that effort which aims to match the ABI ofwasm-32-unknown-unknowntarget to that ofwasm32-wasiandclang.There are discussions going on at
wasm-bindgenrepository about extending the support towasm32-wasi. In short,wasm-bindgenneeds a consistent C ABI betweenwasm32-unknown-unknownandwasm32-wasito 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-unknownstill uses the legacy ABI.wasm-bindgensays that Rust should switch to the new ABI first, but Rust is saying thatwasm-bindgenshould 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-wasistarted 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.wasmand.jscode withwasm-bindgen, they will just need to updatewasm-bindgenand 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::fsare not working right now withwasm32-unknown-unknown. This limitation prevents many crates liketokioandrayonfrom 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-bindgengets to supportwasm32-wasi, various crates will be able to use thread, time, file, network operations on the web only withstdwithout 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-bindgendevelopers soon enough!