Weblings is a Rust compiler toolchain compiled to WASM. This means that you can compile and execute Rust code in your browser!

Tech stack tl;dr rust code -> rustc -> cranelift IR -> waffle -> wasm object files -> linker -> wasm executable -> browser execution

The web UI

The primary way to interface with this WASM toolchain is through the web UI, which you can access at https://weblings.forest-anderson.ca. It has two sections:

The stack

A few things had to be set up to get this toolchain working:

⭐ - these steps were written with AI tooling to achieve the goals of this project, but I'd love to see them included in Cranelift/Wild, and hope to find a way to upstream them!

Why?

I've set up this toolchain so that I can build out some tooling that I'll be using in upcoming projects to teach computer memory principles. I've been exploring visualizing memory segments during C code execution, and I'll be hopefully expanding that to Rust soon. Also, I want more ways to get quick feedback when learning Rust concepts!

There is also the question of why to use Cranelift instead of LLVM as the compiler backend. Here are a few things on my mind:

  • LLVM would be a larger toolchain to include (I think)
  • Cranelift is faster to get (I did not test numbers)
  • The whole toolchain in Rust is pretty neat!

Prior art

  • rubrc: (website) Uses rustc compiled to WASM, with LLVM as the backend, also compiled to WASM.
  • rubri: (website) Uses Miri to create a Rust interpreter that can run in WASM.

(If you know of others, please make a PR!)

AI Assistance

AI tooling was used to create the Leptos web UI, the Cranelift -> Waffle IR translation, the WASM linker, and various other scripts. *.md files in this repo are human made.