WebAssembly / WASI

WebAssembly System Interface
Other
4.82k stars 249 forks source link

A WebAssembly port of Debian #351

Closed davidar closed 3 years ago

davidar commented 3 years ago

The wasmtime WASI background mentions a thought experiment about porting the Debian userspace to WebAssembly. I realise it's probably still too early for this to be much more than a thought experiment, but I'm curious whether there's been much discussion on this topic (as I haven't been able to find it mentioned anywhere else)?

sunfishcode commented 3 years ago

There have been experiments porting things like coreutils to WASI. Programs that don't rely too heavily on process-related behavior (fork, exec, signals, uid/gid) can often be ported fairly easily.

Can you say more about what you're interested in?

davidar commented 3 years ago

I'm particularly interested in cross-compiling Debian packages to WASI (without needing to manually patch them, for the most part). It wouldn't necessarily require support for processes and such (so long as the package of interest and its dependencies didn't), though I guess it would require the WASI SDK to be able to operate as a largely drop-in replacement. Dynamic linking may also be a current obstacle.

I guess I'm coming at this from the perspective of appreciating the intention behind things like WAPM, but also feeling like it's reinventing a wheel that Debian et al already solved a long time ago, and with a greater degree of automation and stronger guarantees of reproducible builds (if not byte-for-byte at least in terms of functionality). (More broadly my interest is from a software portability/archival/bootstrapping perspective, as porting a WASM interpreter to a new platform seems an easier task than a full system emulator or a C compiler.)

Perhaps Nix would be a better target for this (given NixOS/nixpkgs#56555, NixOS/nix#2759, a small amount of discussion here)? Anyway, at the moment I'm mainly just interested in finding out who else has been thinking about this topic, and whether they have any tentative plans or preliminary work, etc.

sunfishcode commented 3 years ago

I think WebAssembly and WASI are cool, however for the purpose you describe here, RISC-V sounds like a better fit. The Debian port to RISC-V is already well underway, and if you look at the challenges that remain, any WebAssembly-based approach would likely have all the same challenges plus many more. There are a number of RISC-V emulators available. RISC-V is an open-standard ISA. You could run real Linux.