Compiling Rust to WASM from inside WASM!
See the codeWeblings 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 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:
A few things had to be set up to get this toolchain working:
wasm-ld from LLVM. I was hoping that the
Wild linker might have WASM linking
support, but that's still on the
way.⭐ - 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!
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:
(If you know of others, please make a PR!)
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.
13 commits
Rust
70.7%
JavaScript
15.2%
HTML
14.2%
Compiling Rust to WASM from inside WASM!
See the codeWeblings 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 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:
A few things had to be set up to get this toolchain working:
wasm-ld from LLVM. I was hoping that the
Wild linker might have WASM linking
support, but that's still on the
way.⭐ - 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!
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:
(If you know of others, please make a PR!)
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.
13 commits
Rust
70.7%
JavaScript
15.2%
HTML
14.2%