-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
WASM cannot build for wasm32-wasi #4906
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
Comments
Do you have bevy listed elsewhere in your However, I don't think wasm32-wasi will work right now, as our |
Audio is indeed behind a feature flag, just one that that is enabled by default: https://github.com/bevyengine/bevy/blob/main/docs/cargo_features.md. EDIT: yeah what @infmagic2047 said |
I looked at just pulling the pieces I need but wasm_bindgen is utilized throughout the code, such as: bevy/crates/bevy_app/src/schedule_runner.rs Lines 116 to 155 in f907d67
It seems the engine authors equate the wasm32 target with being run in a browser which does not fit my use case. I would like the code to stay lean and mean and not attempt to punt to javascript at all (the code in the not wasm32 branch would suffice for me). I will explore writing patches but worry it is going to be a huge undertaking. Probably less of a burden than writing my own engine, however :P |
You can't use |
The problem here goes way further than just audio, if I am not mistaken. Like @schtauffen mentioned bevy currently uses wasm-bindgen even on non graphical/audio related functionalities. So for example even if try to build just a bevy App() without any default-features or the default plugins, it will try to build with wasm-bindgen which is currently breaking on wasm32-wasi targets. |
To recap: the initial errors were user error but the ticket itself is valid and is related to the use of wasm-bindgen as mentioned by @pedronasser . I initially forked and began working towards a wasm32-wasi friendly version with 0.7 but wasn't successful. I plan to attempt again from scratch with 0.8; |
I cannot seem to remove labels, can S-User-Error be removed? @jakobhellermann |
This is also a huge issue for my work on the |
# Objective - Contributes to #15460 - Supersedes #8520 - Fixes #4906 ## Solution - Added a new `web` feature to `bevy`, and several of its crates. - Enabled new `web` feature automatically within crates without `no_std` support. ## Testing - `cargo build --no-default-features --target wasm32v1-none` --- ## Migration Guide When using Bevy crates which _don't_ automatically enable the `web` feature, please enable it when building for the browser. ## Notes - I added [`cfg_if`](https://crates.io/crates/cfg-if) to help manage some of the feature gate gore that this extra feature introduces. It's still pretty ugly, but I think much easier to read. - Certain `wasm` targets (e.g., [wasm32-wasip1](https://doc.rust-lang.org/nightly/rustc/platform-support/wasm32-wasip1.html#wasm32-wasip1)) provide an incomplete implementation for `std`. I have not tested these platforms, but I suspect Bevy's liberal use of usually unsupported features (e.g., threading) will cause these targets to fail. As such, consider `wasm32-unknown-unknown` as the only `wasm` platform with support from Bevy for `std`. All others likely will need to be treated as `no_std` platforms.
Bevy version
0.7
What you did
Cargo.toml
.cargo/config.toml
ran
cargo run --bin server --target wasm32-wasi
What went wrong
I expect bevy to compile for use inside wasm. Instead, it gives errors:
Additional information
I would not expect javascript/browser (js-sys, web-sys) interop to be required to compile to wasm.
The text was updated successfully, but these errors were encountered: