Would it be possible for a rust compiler to run inside the browser WASM sandbox? If so could this rust compiler running inside chrome be used to compile rust code inside the WASM sandbox of Chrome? Are there any super simple rustc/llvm, cranelift etc alternative compilers that can compile to WASM? A quick search shows even Cranelift with its 100x fewer lines of code than rustc still cannot be compiled to WASM.
You can compile rustc to wasi with a couple of small patches (disabling threads, disabling sysroot auto detection, setting cg_clif as codegen backend) and then run this in the browser using https://github.com/bjorn3/browser_wasi_shim/. See examples/rustc.html.
See also https://garriga.dev/rubri/ and https://github.com/oligamiq/rubrc
Last updated: Dec 06 2025 at 07:03 UTC