wa-lang.org/wazero@v1.0.2/imports/README.md (about)

     1  ## wazero imports
     2  
     3  Packages in this directory implement the *host* imports needed for specific
     4  languages or shared compiler toolchains.
     5  
     6  * [AssemblyScript](assemblyscript) e.g. `asc X.ts --debug -b none -o X.wasm`
     7  * [Emscripten](emscripten) e.g. `em++ ... -s STANDALONE_WASM -o X.wasm X.cc`
     8  * [Go](go) e.g. `GOARCH=wasm GOOS=js go build -o X.wasm X.go`
     9  * [WASI](wasi_snapshot_preview1) e.g. `tinygo build -o X.wasm -target=wasi X.go`
    10  
    11  Note: You may not see a language listed here because it either works without
    12  host imports, or it uses WASI. Refer to https://wazero.io/languages/ for more.
    13  
    14  Please [open an issue](https://github.com/tetratelabs/wazero/issues/new) if you
    15  would like to see support for another compiled language or toolchain.
    16  
    17  ## Overview
    18  
    19  WebAssembly has a virtual machine architecture where the *host* is the process
    20  embedding wazero and the *guest* is a program compiled into the WebAssembly
    21  Binary Format, also known as Wasm (`%.wasm`).
    22  
    23  The only features that work by default are computational in nature, and the
    24  only way to communicate is via functions, memory or global variables.
    25  
    26  When a compiler targets Wasm, it often needs to import functions from the host
    27  to satisfy system calls needed for functionality like printing to the console,
    28  getting the time, or generating random values. The technical term for this
    29  bridge is Application Binary Interface (ABI), but we'll call them simply host
    30  imports.
    31  
    32  Packages in this directory are sometimes well re-used, such as the case in
    33  [WASI](https://wazero.io/specs/#wasi). For example, Rust, TinyGo, and Zig can
    34  all target WebAssembly in a way that imports the same "wasi_snapshot_preview1"
    35  module in the compiled `%.wasm` file. To support any of these, wazero users can
    36  invoke `wasi_snapshot_preview1.Instantiate` on their `wazero.Runtime`.
    37  
    38  Other times, host imports are either completely compiler-specific, such as the
    39  case with `GOARCH=wasm GOOS=js`, or coexist alongside WASI, such as the case
    40  with Emscripten.