Skip to content
Ashton Meuser edited this page Oct 6, 2023 · 1 revision

Overview

WASI is a common system interface for WebAssembly. Many languages and frameworks targeting Wasm take advantage of or rely on WASI. To support these, Godot Wasm supports a small subset of common WASI import functions by default. This enables easier use of WASI-reliant Wasm modules without reimplementing common functionality.

Information regarding specific WASI import functions can be found in the WASI specification.

Supported Import Functions

Note that some functions are stubbed out to ensure a safer Wasm sandbox while maintaining compatibility. For example, Wasm modules are intentionally unable to access environment variables using wasi_snapshot_preview1.environ_sizes_get which simply reports no accessible environment variables.

Permission Model

The above WASI import functions are enabled by default but can be configured using the Wasm.permissions dictionary. The following permissions can be set to toggle functionality of default WASI functions.

  • print
  • time
  • random
  • args
  • exit

Permissions can be queried using wasm.has_permission(PERMISSION) (replacing PERMISSION with the relevant permission string e.g. print) and set using an update dictionary wasm.permission = { 'print': false }.

Note that an error is reported if a module attempts to access a WASI import function whose permission is disabled.

Clone this wiki locally