From 1c17981f4acaedf1c262fd289c7945a521b43a2f Mon Sep 17 00:00:00 2001 From: Johan Brandhorst-Satzkorn Date: Mon, 17 Apr 2023 22:13:52 -0700 Subject: misc/wasm: support wasmtime in wasip1 Allow switching to wasmtime through the GOWASIRUNTIME variable. This will allow builders to run the wasip1 standard library tests against the wasmtime WASI runtime. For #59583 Change-Id: I4d5200df7bb27b66e041f00e89d4c2e585f5da7c Reviewed-on: https://go-review.googlesource.com/c/go/+/485615 Reviewed-by: Bryan Mills TryBot-Bypass: Johan Brandhorst-Satzkorn Run-TryBot: Johan Brandhorst-Satzkorn Reviewed-by: Cherry Mui --- misc/wasm/go_wasip1_wasm_exec | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'misc') diff --git a/misc/wasm/go_wasip1_wasm_exec b/misc/wasm/go_wasip1_wasm_exec index 37cba72368..9838212d98 100755 --- a/misc/wasm/go_wasip1_wasm_exec +++ b/misc/wasm/go_wasip1_wasm_exec @@ -3,4 +3,15 @@ # Use of this source code is governed by a BSD-style # license that can be found in the LICENSE file. -exec wazero run -mount /:/ -env-inherit -cachedir "${TMPDIR}"/wazero $1 "${@:2}" +case "$GOWASIRUNTIME" in + "wasmtime") + exec wasmtime run --dir=/ --env PWD="$PWD" --max-wasm-stack 1048576 "$1" -- "${@:2}" + ;; + "wazero" | "") + exec wazero run -mount /:/ -env-inherit -cachedir "${TMPDIR}"/wazero "$1" "${@:2}" + ;; + *) + echo "Unknown Go WASI runtime specified: $GOWASIRUNTIME" + exit 1 + ;; +esac -- cgit v1.2.3-54-g00ecf