Skip to content

Instantly share code, notes, and snippets.

@creationix
Created January 15, 2020 05:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save creationix/c73838af65d24cac4cbd03217214400e to your computer and use it in GitHub Desktop.
Save creationix/c73838af65d24cac4cbd03217214400e to your computer and use it in GitHub Desktop.
Zig to wasm supports tiny modules.
(module
(type (;0;) (func (param i32 i32) (result i32)))
(func $add (type 0) (param i32 i32) (result i32)
local.get 1
local.get 0
i32.add)
(table (;0;) 1 1 funcref)
(memory (;0;) 2)
(global (;0;) (mut i32) (i32.const 66560))
(export "memory" (memory 0))
(export "add" (func $add)))
export fn add(a: i32, b: i32) i32 {
return a + b;
}
$ zig build-lib add.zig -target wasm32-freestanding --release-small --strip --single-threaded
$ wasm2wat add.wasm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment