noah
browser_wasi_shim
noah | browser_wasi_shim | |
---|---|---|
2 | 5 | |
1,860 | 271 | |
- | - | |
0.3 | 8.6 | |
almost 4 years ago | 22 days ago | |
C | TypeScript | |
GNU General Public License v3.0 or later | Apache License 2.0 |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
noah
-
The Tug-of-War over Server-Side WebAssembly
The other day I came across an interesting "alternative" to WASM which gives you OS portability using fully native code, without CPU portability, the latter seeming not that big of a deal these days anyway as cross compilers have got quite good and there are only two CPU archs in wide usage anyway.
The idea is to simply run normal Linux binaries on macOS and Windows. How? You create a virtual machine using the Mac/Windows APIs without any OS inside, in fact without even any virtual hardware. It's literally just a new address space and some trivial min-viable VM configuration. Then you map the ELF binary and a ld.so into the VM with a minimal ELF interpreter, kick off execution and anytime there's a syscall you trap it and translate to the host OS syscalls. It can work quite well on macOS because the syscall interface is so similar.
Note that this sort of VM is not:
• A sandbox
• A hardware abstraction
Apps run this way hold all their data in the filing system of the host OS, they use the network stack of the host OS, etc. The VM is only being used to allow trapping and emulation of the syscall interface. The app isn't aware that it's being run in a special CPU mode on top of an emulated kernel.
Advantages: lightweight, simple, apps can use all CPU features, can run at native speed, the Linux syscall interface is highly stable, based on POSIX specifications and you can easily pick a subset of it to standardize.
Disadvantages: requires the emulator, apps exposed to missing features or quirks of the host OS e.g. Windows file system performance is much lower than Linux.
WSL1 sort of worked that way, albeit without the VM aspect that lets userspace apps do it. They abandoned it partly for performance reasons and users expected all existing Linux apps to just work. But WASM doesn't target existing apps. It expects developers to bend and do things the WASM way, and accepts that not all apps are compatible with it, so that's not necessarily a problem.
An example of how to implement this is NOAH:
https://github.com/linux-noah/noah/
-
Lima: Linux-on-Mac (“macOS Subsystem for Linux”, “Containerd for Mac”)
There was an attempt, but it was archived https://github.com/linux-noah/noah
browser_wasi_shim
-
Rust + WASM + Typescript [+ React]
There are many options, but what worked best for me is compiling with cargo-wasi and loading the resulting Wasm file with browser_wasi_shim. Using wasm32-wasi instead of wasm32-unknown-unknown requires a bit more work (the communication with JS has to be set up manually), but gives the flexibility of having just a Wasm file that can be dropped in and loaded dynamically. (There's wit-bindgen for generating wrapping code according to an interface definition but I didn't have much success with it.)
- Is it possible to read a file through webassembly?
-
Extending web applications with WebAssembly and Python
The webassembly-language-runtimes is focused on providing WASI-based language interpreters, what would require a WASI polyfill at the browser level (https://wasi.dev/polyfill/) and (https://github.com/bjorn3/browser_wasi_shim).
Pyodide is certainly another option, but is emscripten based, not based in webassembly-language-runtimes or WASI.
-
The Tug-of-War over Server-Side WebAssembly
Indeed, some people are doing this:
- WASI once had an official polyfill https://wasi.dev/polyfill/, now apparently succeeded by https://github.com/bjorn3/browser_wasi_shim
- wasmer-js provides a JS polyfill for WASI https://docs.wasmer.io/integrations/js/wasi
- Cloudflare has a WIP polyfill https://github.com/cloudflare/workers-wasi
I'm generally leery of non-temporary polyfills, so I'm not sure that any of these feel like a long-term viable option for me.
-
Browser to Haskell Wasm Reactor Module Communication Example
Browser client library uses browser_wasi_shim to communicate with the module.
What are some alternatives?
lima - Linux virtual machines, with a focus on running containers
wasi-threads
HomeBrew - 🍺 The missing package manager for macOS (or Linux)
cargo-wasi - A lightweight Cargo subcommand to build Rust code for the `wasm32-wasi` target
Docker-OSX - Run macOS VM in a Docker! Run near native OSX-KVM in Docker! X11 Forwarding! CI/CD for OS X Security Research! Docker mac Containers.
webassembly-language-runtimes - Wasm Language Runtimes provides popular language runtimes (Ruby, Python, …) precompiled to WebAssembly that are tested for compatibility and kept up to date when new versions of upstream languages are released
yabai - A tiling window manager for macOS based on binary space partitioning
memory-control - A proposal to introduce finer grained control of WebAssembly memory.
workers-wasi
wasmer-js - Monorepo for Javascript WebAssembly packages by Wasmer
hangover - Hangover runs simple Win32 applications on arm64 Linux