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. |
daxpedda
left a comment
There was a problem hiding this comment.
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-bindgeninserts bindings on any target that has a) the target architecturewasm32and b) not the target OSemscripten. This means thatwasm-bindgendoes insert bindings for the targetwasm32-wasi, which causeswasm32-wasibinaries 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-bindgenfunction is called but not preventing WASI runtimes likewasmtimefrom loading and running the binary.I've tested this against the very example I gave in my issue in the
wasmtimerepo (linked above), and it resolved that issue, allowing you to load and run a binary withwasm-bindgendependencies (likeweb-sys) as long as you don't actually run them — as is the behavior on other native targets.