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