Hello I'm trying to use emscripten with Rust, through the wasm32-unknown-emscripten target, ultimately to a port a large application (why not wasm32-unknown-unknown instead? I might try that next, but would like use Emscripten for the reasons in this post: Wasm unknown vs emscripten - #5 by derekdreery)
So I reached the point where I'm able to compile with --target wasm32-unknown-emscripten
, progress... but the application crashes immediately. I tracked it down to the winit dependency, used by the glutin SDL wrapper. The problem isn't anything specific with my app, it even reproduces with the winit "hello world" example (window)! Filed this issue to winit:
Emscripten support broken: missing function: emscripten_set_mousemove_callback / assertion failed: validate_hidpi_factor(dpi_factor) · Issue #760 · rust-windowing/winit · GitHub missing function: emscripten_set_mousemove_callback
There is also a closed issue on the Emscripten issue tracker with some insights, same error message, but apparently a different cause: https://github.com/emscripten-core/emscripten/issues/7525. Note that I reproduced the issue on a fresh reinstall, so there are not any stale caches etc. causing the issue.
The Emscripten developers raised the question, maybe the Rust compiler stores precompiled libraries which are outdated and need to rebuilt? I updated to Rust stable 1.32, and it installed info: installing component 'rust-std' for 'wasm32-unknown-emscripten'
, is it possible these are compiled with an outdated Emscripten SDK?
Ultimately my question is: what is a simple known-working configuration for using Emscripten with Rust? If I can setup a trivial example working program, I can backtrack and isolate what is causing the issues here.
What I know doesn't work: emsdk 1.38.22 with winit 0.18.1, testing the example as described in winit#760:
rustup target install wasm32-unknown-emscripten
cargo build --example window --target wasm32-unknown-emscripten
This rules out using glutin, at least with this emsdk. What crates and versions are people using Rust with Emscripten actually using? Older versions of emsdk? Other compatible crates? Is this even a winit problem or emscripten problem or rust-std problem? What actually works? Any help appreciated.