Rust compilation in the browser with WASM

175 points _AngelOnFira_ 23 comments

I've been working on getting the Rust compiler working in the browser. It's like the playground, but instead of your code compiling and running remotely on a server, it's done entirely in your browser!

Website (~50MB): https://weblings.forest-anderson.ca

Repo: https://github.com/AngelOnFira/weblings

It works by
rustc -> cranelift IR -> waffle IR -> wasm linker
which then gives you a wasm binary that the browser can run. The full compile/link/execute time for small programs is mostly <100ms.

I've set up Rustlings in the web UI, you can go through the entire suite! I'm going to be using this project for some Rust education stuff down the line, but this playground was the first MVP :) I also want to explore building and flashing executables for embedded devices entirely through the browser.

Happy to answer any questions!