Created
January 15, 2020 05:54
-
-
Save creationix/c73838af65d24cac4cbd03217214400e to your computer and use it in GitHub Desktop.
Zig to wasm supports tiny modules.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export fn add(a: i32, b: i32) i32 { | |
return a + b; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ 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