-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Disable support for wasm32-wasi
#3233
Conversation
AFAIK, there are browser-like JS environments that support WASI too - Node.js and Deno. Ideally, we should be able to compile Rust code for the Isn't this pull request breaking support for such scenario? |
Oh, interesting point. I’m not familiar enough with Node or Deno WASI support — is there any distinction in compile target between “WASI within JS environment” and “WASI without JS environment”? If not, that’s… unfortunate. |
I am afraid I am not an expert in this area either :( I think there are very few people that are running WASI in Node.js & Deno context, so maybe it's not that bad if wasm-bindgen stops working for I have two suggestions if I may:
|
wasm32-wasi
I think this should probably either be behind a feature, or is the wrong approach, due to the possible Node/Deno compatibility issues. |
I honestly don't know much about WASI, but it seems a bit counterintuitive to me to use WASI with Node.js or Deno if you intend to access JS, because WASI wouldn't offer anything in that case. If you want to use parts of the WASI API nevertheless, you can just import that through JS. But yeah, input from somebody actually knowledgeable about this would be appreciated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm happy to get this merged @gbj, got notified from #3421 (comment).
Would you mind rebasing and adding a comment to the changelog?
Thanks! |
At present,
wasm-bindgen
inserts bindings on any target that has a) the target architecturewasm32
and b) not the target OSemscripten
. This means thatwasm-bindgen
does insert bindings for the targetwasm32-wasi
, which causeswasm32-wasi
binaries to behavior differently from binaries on all other targets. See further discussion here bytecodealliance/wasmtime#5557This PR simply updates the "is this Emscripten?" check to add an "is this WASI?" check, leading to a panic if a
wasm-bindgen
function is called but not preventing WASI runtimes likewasmtime
from loading and running the binary.I've tested this against the very example I gave in my issue in the
wasmtime
repo (linked above), and it resolved that issue, allowing you to load and run a binary withwasm-bindgen
dependencies (likeweb-sys
) as long as you don't actually run them — as is the behavior on other native targets.