Wasm Builders 🧱

Cover image for Running .Net where it has never run before RISC-V, FreeBSD and beyond...
Mustafa Unal
Mustafa Unal

Posted on

Running .Net where it has never run before RISC-V, FreeBSD and beyond...

.Net supports more platforms than Microsoft Windows. But people seems to think otherwise. .Net currently supports Windows, Linux and MacOS in x64 and Arm64 platforms. But If you want to run it on other architectures or operating systems there is no way until now.
WASI is a new possible target for .Net 7 compiler. Its experimentally supported as you can see in github. If you want to get your feet wet first install .Net 7 preview from
here you can test it with

dotnet new console -o MyFirstWasiApp
cd MyFirstWasiApp
dotnet add package Wasi.Sdk --prerelease
dotnet build
Enter fullscreen mode Exit fullscreen mode

So how can you run it ? Since its WebAssembly you need a runtime to execute it. Steve Sanders recommends wasmtime which can run in supports Windows, Linux and MacOS in x64 and Arm64 the same environments that .Net natively execute. So what do I get in return ?
People are interested in WebAsssembly and WASI so you might wander what is the hype is all about ? You can consider WebAssembly as a platform agnostic Intermediate Language like in .Net IL. So you can run it with browser and anywhere with a WebAssembly runtime. WASI is a standard which allows WebAssembly to make standardized system calls hence the name WebAssembly System Interface. WASI is a new standard that is currently developed by WebAssembly System Interface Subgroup Charter a subgroup in WebAssembly standard working group.
What all of this means? It means if we have a working WASI runtime for our platform we can run our WebAssembly anywhere. There are a few runtimes available but they are written in way hard to retarget without too much effort except Wazero
GitHub. Wazero is written in Golang with portability in mind. Wazero supports two modes ahead of time compiling when platform is supported or interpreted for every platform it can run.
Wazero is a work in progress expected to release its 1.0 version in Q3 2022 so be warned it misses some specifications. The problem with Wazero is, it do not has a executable to run WebAssembly ( or I could not find it) so I write a simple one. which you can find in https://github.com/bleakview/wasabi/

I use Qemu to emulate environments.

Linux RISC-V 64

Linux RISC-V 64

Linux PowerPC64le

Linux PowerPC64le

FreeBSD Amd64

FreeBSD Amd64

Yes I can run .Net WASI executables on different enviroments, so what are the downsides? When AoT is not supported for the platform, interpreted running is slow and Wazero do not currently supports sockets so no Asp.Net for you.
If .Net 7 release version supports WASI we get the real platform independent executable. Also if WebAssembly began to replace docker .Net will be ready from day one.

As a side note since WASI is a standard I tested it with AssemblyScript WASI files and it works just fine. Technically wasabi can run your programs in the following platforms - platforms supported by Golang as of now- but I do not test them all:

aix/ppc64
darwin/amd64
darwin/arm64
dragonfly/amd64
freebsd/386
freebsd/amd64
freebsd/arm
freebsd/arm64
illumos/amd64
linux/386
linux/amd64
linux/arm
linux/arm64
linux/mips
linux/mips64
linux/mips64le
linux/mipsle
linux/ppc64
linux/ppc64le
linux/riscv64
linux/s390x
netbsd/386
netbsd/amd64
netbsd/arm
netbsd/arm64
openbsd/386
openbsd/amd64
openbsd/arm
openbsd/arm64
openbsd/mips64
plan9/386
plan9/amd64
plan9/arm
solaris/amd64
windows/386
windows/amd64
windows/arm
windows/arm64

Keep tinkering...

Top comments (0)