3 ms·
It's very annoying how immature the tooling is around multiple languages compiling down to WebAssembly. I tried to have a Rust-C codebase compile to wasm, which
by hardwaregeek 4y ago
It's very annoying how immature the tooling is around multiple languages compiling down to WebAssembly. I tried to have a Rust-C codebase compile to wasm, which failed on `wasm32-unknown-unknown` for C compiler errors. Okay, I'll try `wasm32-unknown-emscripten`. That worked surprisingly enough, but I couldn't get the JS output file to be ES6. So I go online and ask on the Rust forums. A bunch of people come out of the woodwork to tell me that the emscripten backend is broken, that it doesn't interoperate properly with C, and that I should be using `wasm32-wasi`. Okay...I try that and woo more arcane compiler errors.
It should be easier than this.
- efnx 4y agoTo make compiling easy, cargo will compile C sources (and more using build.rs), but of course that makes your Rust code dependent on compiling C code, and if your C build step isn’t ready for cross compilation then your Rust compile step cannot be. Did you try wasm-pack?
- hardwaregeek 4y agowasm-pack doesn't do any sort of help for compiling C code. It mostly just helps with interop and bundling. I know that cargo compiles C, but it really should not be that hard to compile C code to WASI and provide a libc that works with WASI. The emscripten backend worked well except for this one minor issue, but when I asked online, I got a response that made it seem like I was being ridiculous for using emscripten in 2022. Meanwhile the WASI backend is clearly not mature yet either.