Basis Doesn't Work on Wasm Target
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 161
Description
## Bevy version
0.15.1
## \[Optional\] Relevant system information
> If you cannot get Bevy to build or run on your machine, please include:
>
> - the Rust version you're using (you can get this by running `cargo --version`)
`rustc 1.86.0-nightly (4a4309466 2025-02-02)`
> - the operating system or browser used, including its version
> - e.g. Windows 10, Ubuntu 18.04, iOS 14
Archlinux
## What you did
Compile bevy with the feature `basis-universal`.
## What went wrong
Works fine on native, but if I compile for the wasm32-unknown-unknown target, there are hundreds of error messages like this:
```
warning: basis-universal-sys@0.3.1: In file included from vendor/basis_universal/encoder/pvpngreader.cpp:14:
warning: basis-universal-sys@0.3.1: vendor/basis_universal/encoder/../transcoder/basisu.h:53:10: fatal error: 'stdlib.h' file not found
warning: basis-universal-sys@0.3.1: 53 | #include
warning: basis-universal-sys@0.3.1: | ^~~~~~~~~~
warning: basis-universal-sys@0.3.1: 1 error generated.
warning: basis-universal-sys@0.3.1: ToolExecError: Command LC_ALL="C" "clang++" "-O0" "-ffunction-sections" "-fdata-sections" "-fno-exceptions" "-g" "-fno-omit-frame-pointer" "--target=wasm32-unknown-unknown" "-Wall" "-Wextra" "-DBASISD_SUPPORT_KTX2_ZSTD=0" "-o" "/home/anlumo/Documents/dungeonfog/catalyst/target/wasm32-unknown-unknown/debug/build/basis-universal-sys-c1c2199e0df7ab26/out/dfe9b9f658ee268e-pvpngreader.o" "-c" "vendor/basis_universal/encoder/pvpngreader.cpp" with args clang++ did not execute successfully (status code exit status: 1).cargo:warning=In file included from vendor/basis_universal/encoder/jpgd.cpp:27:
warning: basis-universal-sys@0.3.1: vendor/basis_universal/encoder/jpgd.h:6:10: fatal error: 'stdlib.h' file not found
warning: basis-universal-sys@0.3.1: 6 | #include
warning: basis-universal-sys@0.3.1: | ^~~~~~~~~~
warning: basis-universal-sys@0.3.1: 1 error generated.
warning: basis-universal-sys@0.3.1: ToolExecError: Command LC_ALL="C" "clang++" "-O0" "-ffunction-sections" "-fdata-sections" "-fno-exceptions" "-g" "-fno-omit-frame-pointer" "--target=wasm32-unknown-unknown" "-Wall" "-Wextra" "-DBASISD_SUPPORT_KTX2_ZSTD=0" "-o" "/home/anlumo/Documents/dungeonfog/catalyst/target/wasm32-unknown-unknown/debug/build/basis-universal-sys-c1c2199e0df7ab26/out/dfe9b9f658ee268e-jpgd.o" "-c" "vendor/basis_universal/encoder/jpgd.cpp" with args clang++ did not execute successfully (status code exit status: 1).
```
## Additional information
This is C++ code, that won't work on wasm due to incompatible ABIs. basis *does* have web support (I think by compiling the C++ code to wasm), but that needs special handling through the JavaScript library's interface.
I'm not sure if this is considered a bug or a feature request. It's a bug in that it's supposed to just work but doesn't, but fixing it will require a new implementation specifically for the web.
Contributor guide
Assessment
This issue has not been assessed yet.