...

Text file src/github.com/tetratelabs/wazero/imports/README.md

Documentation: github.com/tetratelabs/wazero/imports

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

View as plain text