Replies: 8 comments 4 replies
-
I presume that all compilation is occurring on the google go play server. Even the "Run program in browser as WebAssembly module" option ? |
Beta Was this translation helpful? Give feedback.
-
@gedw99 regarding WebAssembly, there are 2 modes:
Second option supports third-party packages, but not very stable at the moment. Thanks for a link, I'll take a look. |
Beta Was this translation helpful? Give feedback.
-
@gedw99 if you're interested in WebAssembly Go internals, please take a look at our Go interpreter WASM module source. https://github.com/x1unix/go-playground/tree/master/internal/gorepl One of interesting topics is custom FS mocking and custom wasm syscalls without |
Beta Was this translation helpful? Give feedback.
-
Hey @x1unix gowasm-gen-import looks like its central to this ? |
Beta Was this translation helpful? Give feedback.
-
Hey @x1unix I still am playing with your code, but i noticed that the go1.21rc3 effects you i think: It is because the undocumented CallImport was replaced by //go:wasmimport. It is to do with the way files are loaded, which i think your code also does install go1.21rc3 go version
go version go1.21rc3 darwin/amd64 Then run this: git clone git@github.com:gioui/gio-cmd.git
cd gio-cmd/gogio && gotip build -o $GOPATH/bin/gogio .
git clone git@github.com:gioui/gio-example.git
cd gio-example/explorer
gogio -x -target js -o explorer.wasm .
go list -f {{.ImportPath}} .
go list -f {{.Dir}} .
go build -ldflags=-X gioui.org/app/internal/log.appID=org.gioui.explorer -tags= -o explorer.wasm/main.wasm .
gogio: go build -ldflags=-X gioui.org/app/internal/log.appID=org.gioui.explorer -tags= -o explorer.wasm/main.wasm . failed: # gioui.org/x/explorer
/Users/apple/go/pkg/mod/gioui.org/x@v0.0.0-20220812201728-6e5ccb802ed1/explorer/explorer_js.s:6: unrecognized instruction "CallImport"
/Users/apple/go/pkg/mod/gioui.org/x@v0.0.0-20220812201728-6e5ccb802ed1/explorer/explorer_js.s:10: unrecognized instruction "CallImport"
/Users/apple/go/pkg/mod/gioui.org/x@v0.0.0-20220812201728-6e5ccb802ed1/explorer/explorer_js.s:14: unrecognized instruction "CallImport"
asm: assembly of /Users/apple/go/pkg/mod/gioui.org/x@v0.0.0-20220812201728-6e5ccb802ed1/explorer/explorer_js.s failed
|
Beta Was this translation helpful? Give feedback.
-
@gedw99 thanks for noticing that 🙏 , WASM topic isn't really popular in the Go community. Anyway, this will make my life easier, because atm I use a custom code generator that acts like Also, Go 1.21 will support WASI standard, which all WASM runtimes use. Project will try to use WASM it the future to keep aligned with a common standard. Btw, if you're interested how WASM imports work under the hook, please take a look at small my research article. |
Beta Was this translation helpful? Give feedback.
-
thanks will read your article :) Yes your affected also: cd go-playground/cmd/go-repl && GOOS=js GOARCH=wasm go build -o main.wasm .
go: downloading github.com/traefik/yaegi v0.15.1
# github.com/x1unix/go-playground/internal/gowasm/wlog
../../internal/gowasm/wlog/writer_js.s:9: unrecognized instruction "CallImport"
asm: assembly of ../../internal/gowasm/wlog/writer_js.s failed |
Beta Was this translation helpful? Give feedback.
-
wasm_exec.js has changed, not sure yet of its effects. it looks pretty minor. there is a new file too called "go_wasip1_wasm_exec" #!/usr/bin/env bash
# Copyright 2023 The Go Authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
case "$GOWASIRUNTIME" in
"wasmedge")
exec wasmedge --dir=/ --env PWD="$PWD" --env PATH="$PATH" ${GOWASIRUNTIMEARGS:-} "$1" "${@:2}"
;;
"wasmer")
exec wasmer run --dir=/ --env PWD="$PWD" --env PATH="$PATH" ${GOWASIRUNTIMEARGS:-} "$1" -- "${@:2}"
;;
"wasmtime")
exec wasmtime run --dir=/ --env PWD="$PWD" --env PATH="$PATH" --max-wasm-stack 1048576 ${GOWASIRUNTIMEARGS:-} "$1" -- "${@:2}"
;;
"wazero" | "")
exec wazero run -mount /:/ -env-inherit -cachedir "${TMPDIR:-/tmp}"/wazero ${GOWASIRUNTIMEARGS:-} "$1" "${@:2}"
;;
*)
echo "Unknown Go WASI runtime specified: $GOWASIRUNTIME"
exit 1
;;
esac
|
Beta Was this translation helpful? Give feedback.
-
@x1unix
Really learned alot from this project. I am needing to run many golang wasm workers, and i can see now how you did it.
The GUI is very snappy fast !
You might like this. Its is a golang debugger written in golang. The GUI / IDE is also golang.
It connects to standard delve.
It currently won't run in the browser because of the local FS calls, but with a remote FS over http it would.
https://github.com/gioui/gio-cmd/tree/main/gogio can be used for building for different targets such as wasm ( web ), but also mobile and desktops.
Beta Was this translation helpful? Give feedback.
All reactions