Distributing rustc for wasm compilation

Hi, I'm using wasmtime to create a simulation engine. Most of the engine is written in rust and exposed as functions callable from wasm, but I want users to be able to write their own code (or have it generated for them) to use the exposed functions. To do this I want to distribute rustc along with the application so it can compile --target wasm32-unknown-unknown on the users machine (likely linux x86/arm).

I tried looking for information about what I would need to include to do this but I couldn't find much other than this stackoverflow thread about providing your own rustup server which is not suitable for me. I'd need the application to work without internet, ideally I can package rustc and possibly cargo with the wasm32-unknown-unknown target and hardcode them to be used by my application.

Would this be as simple as including the binaries for the target host platform and invoking them directly (aka not through environment vars setup by rustup) ?

Just the rustc executable is not enough. You did need to ship the rest of the rust toolchain for the standard library and such, but if you ship the entire rust toolchain, directly calling rustc should work fine.

1 Like