Rust + WASM

Hello! I’m working on a hobby project with Rust that compiles natively and to WASM. I use fmod while native, but would like to use it while running in WASM.

Natively, I bind to the C-api directly. This obviously is going to get more complicated in WASM.

First off, in Rust, I don’t use emscripten – I compile to the target Rust calls “wasm32-unknown-unknown”, which does not use emscripten. There is an emscripten target, but it seems like that’s not the general direction people are going, so I’d like to go for this without emscripten.

Secondly, although there are provided wasm and js files, I want to have a single WASM module output. I could instead use JS interop to get all the appropriate fmod functions, but not only does that sound slow, it also sounds painful to write and use. If that is the best option, though, then I’m willing to look into that.

Instead, I’d like to be able to compile fmod directly with my application in WASM, so that it can be contained in one module.

Forgive me for any weirdnesses in this question – I am a gamedev, not a compiler engineer, so I think like most devs, I just grit my teeth and struggle through the platform issues, so this is a bit outside my domain.

Hi! I’m actually working on some rust bindings that might be useful to you.
I haven’t looked into webassembly much but I noticed that there’s some .a files you might be able to link against?

I think I couldn’t because these were compiled against emscriptem, and I’m trying to build in an environment without emscriptem. I suspect there would be a lot of ABI calling convention problems, but i’m not an expert in this domain at all!

The FMOD html5 libs are dependent on emscripten so you are correct that you wouldn’t be able to use our precompiled static libs without emscripten. Furthermore, all of the outputs type we have for playing audio in a browser also depend on emscripten, so it would not be possible for you to make a WASM module using FMOD without compiling with emscripten, or linking to emscripten somehow.

So, you wouldn’t be able to create a single WASM without using emscripten, and as far as I can tell emscripten isn’t supported, or at least isn’t maintained in rust, so I think the JS interop approach would be the only way to get FMOD working in a rust WASM project.