-
Notifications
You must be signed in to change notification settings - Fork 17
Initial support for building for wasm32-unknown-unknown
#241
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
base: main
Are you sure you want to change the base?
Initial support for building for wasm32-unknown-unknown
#241
Conversation
As noted above, on macOS, you must build with the homebrew build of LLVM and not the one from Xcode or the command line tools. This is because the homebrew build is the one that actually supports the |
4eeade2
to
72a2a53
Compare
On macOS, this needs clang from homebrew as the Apple provided one doesn't include target support for wasm32-unknown-unknown. An implementation of malloc as well as the other functions declared in the wasm-sysroot headers needs to be supplied. These implementations should come from the copy of musl libc that is used in the WASI libc (top half), as located in https://github.com/WebAssembly/wasi-libc/tree/main/libc-top-half/musl/src Enabling flecs_rest (and therefore flecs_http) won't work here as there isn't support for that in the wasm32 environment. Better fixes for the changes in flecs_ecs_sys/src/flecs.[ch] need to be done. time stuff isn't hooked up yet (ecs_os_has_time() will return false for now still. build with: CC=/opt/homebrew/opt/llvm/bin/clang cargo build --target wasm32-unknown-unknown --features flecs_base,flecs_query_rust_traits --no-default-features This will result in a compiler crash due to what is probably a bug in rustc.
72a2a53
to
f67363f
Compare
Big things to be done in the
This uses the same (mostly useless) PRs into this branch to add the above things to the wasm-sysroot are welcome. And I think most of the features from flecs that can run at least parse now ... there be might be some more undefined symbols than those that I just listed. But the real problem is fixing the Rust compiler crash when building |
The things that trigger the Rust compiler error can be hacked around by:
|
As noted above, Additionally, a small amount of work has to be done to allow Then, you'll run into issues with And then you'll run into |
Forcing LTO... [profile.dev]
lto = true ...avoids the LLVM crash. |
The workaround for the compiler crash in #256. |
On macOS, this needs clang from homebrew as the Apple provided one doesn't include target support for wasm32-unknown-unknown.
An implementation of malloc as well as the other functions declared in the wasm-sysroot headers needs to be supplied. These implementations should come from the copy of musl libc that is used in the WASI libc (top half), as located in https://github.com/WebAssembly/wasi-libc/tree/main/libc-top-half/musl/src
Enabling flecs_rest (and therefore flecs_http) won't work here as there isn't support for that in the wasm32 environment.
Better fixes for the changes in flecs_ecs_sys/src/flecs.[ch] need to be done.
time stuff isn't hooked up yet (ecs_os_has_time() will return false for now still.
build with:
CC=/opt/homebrew/opt/llvm/bin/clang cargo build --target wasm32-unknown-unknown --features flecs_base,flecs_query_rust_traits --no-default-features
This will result in a compiler crash due to what is probably a bug in rustc.