-
Notifications
You must be signed in to change notification settings - Fork 9
/
go_wasip1_wasm_exec
executable file
·30 lines (28 loc) · 1.11 KB
/
go_wasip1_wasm_exec
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env bash
# go_wasip1_wasm_exec is a script that Go uses to run WASM modules
# compiled with GOOS=wasip1 GOARCH=wasm.
#
# From `go help run`:
#
# If [...] GOOS or GOARCH is different from the system default, and a
# program named go_$GOOS_$GOARCH_exec can be found on the current search
# path, 'go run' invokes the binary using that program. This allows
# execution of cross-compiled programs when a simulator or other execution
# method is available.
#
# To use the script, first ensure wasirun is installed and available in $PATH:
#
# $ go install github.com/stealthrocket/wasi-go/cmd/wasirun@latest
#
# Then, add the directory this script resides in to your $PATH:
#
# $ export PATH="$PATH:/path/to/stealthrocket/wasi-go/share"
#
# This will grant you the ability to run WASM modules using wasirun:
#
# $ GOOS-wasip1 GOARCH=wasm go run ...
#
# Note that there is a similar script in the Go source repository under
# ./misc/wasm, but it only supports the wasmtime and wazero runtimes (and
# their WASI host modules) at this time.
exec wasirun --dir / --env PWD="$PWD" ${GOWASIRUNTIMEARGS:-} "$1" -- "${@:2}"