WebAssembly target
robert-w-gries opened this issue · comments
Tracking phil-opp/blog_os#368
Motivation
Rust has the ability to compile to WebAssembly and all relevant browsers now ship support for the WebAssembly standard
This WebAssembly target could have several use cases for blog_os
Run the kernel in a browser
Worth it for the cool factor alone :-)
Allow the compilation and running of the kernel at different stages of your blog posts
After you explain a complex topic, such as paging, you generally provide code as a reference. It'd be nice to be able to compile that code within the blog post's webpage and run the full kernel. The reader could even fiddle with the code, re-run it, and see how their modifications affect the kernel.
The Rust by Example website has the functionality I'm talking about.
Experiment with the concept of kernels hosted on browsers.
I know that javascript PC emulators exist, but WebAssembly seems to have more potential in terms of performance and codability.
Extremely portable emulation
Everyone has a browser and everyone could run the kernel regardless of which OS they're using.
Random Notes
- There's a WIP wasm rustc target that looks relevant: rust-lang/rust#45905
- Here's a blog post from Jan 2017 that details how to build a webasm project
- Here's a recent, interesting forum topic from last month that discusses the state of webasm in Rust
- rustc-emscripten docker image
More thoughts:
wasm
arch could be a shim for running scheduler and interprocess code directly in browser. Printing and keyboard input would be done through javascript event listeners.
This feature would be useful for testing non-architecture specific code. Common code includes scheduling, interprocess comunnication, and userspace processes.