Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

panic: unknown module: go #40

Closed
glycerine opened this issue Oct 23, 2018 · 6 comments
Closed

panic: unknown module: go #40

glycerine opened this issue Oct 23, 2018 · 6 comments

Comments

@glycerine
Copy link

osx high sierra, v10.13.6

A basic test of life and the output of the go11 wasm produces the error panic: unknown module: go.

jaten@jatens-MacBook-Pro ~/go/src/github.com/perlin-network/life (master) $ export PATH=/usr/local/go1.11.1/bin:$PATH
jaten@jatens-MacBook-Pro ~/go/src/github.com/perlin-network/life (master) $ go version
go version go1.11.1 darwin/amd64
jaten@jatens-MacBook-Pro ~/go/src/github.com/perlin-network/life (master) $ GOARCH=wasm GOOS=js go build -o lib.wasm m.go
jaten@jatens-MacBook-Pro ~/go/src/github.com/perlin-network/life (master) $ ls -alFtr|tail
drwxrwxr-x   3 jaten  staff       96 Oct 22 22:39 spec/
drwxrwxr-x  14 jaten  staff      448 Oct 22 22:39 tests/
drwxrwxr-x   3 jaten  staff       96 Oct 22 22:39 utils/
drwxrwxr-x  13 jaten  staff      416 Oct 22 22:39 .git/
-rw-rw-r--   1 jaten  staff      350 Oct 22 22:40 go.sum
drwxrwxr-x   4 jaten  staff      128 Oct 22 22:40 vendor/
-rwxrwxr-x   1 jaten  staff  3496456 Oct 22 22:40 test_runner*
-rw-rw-r--   1 jaten  staff      177 Oct 22 22:44 m.go
-rwxrwxr-x   1 jaten  staff  2532371 Oct 22 22:44 lib.wasm*
drwxrwxr-x  22 jaten  staff      704 Oct 22 22:44 ./
jaten@jatens-MacBook-Pro ~/go/src/github.com/perlin-network/life (master) $ life ./lib.wasm
Resolve func: go debug
panic: unknown module: go

goroutine 1 [running]:
main.main()
	/Users/jaten/go/src/github.com/perlin-network/life/main.go:78 +0x63d
jaten@jatens-MacBook-Pro ~/go/src/github.com/perlin-network/life (master) $ cat m.go
package main

import (
	"fmt"
	"time"
)

func main() {
	t0 := time.Now()
	a := 0
	for i := 0; i < 10000000; i++ {
		a++
	}
	fmt.Printf("a = %v, elap=%v\n", a, time.Since(t0))
}
jaten@jatens-MacBook-Pro ~/go/src/github.com/perlin-network/life (master) $ go run m.go # positive control
a = 10000000, elap=2.941357ms
jaten@jatens-MacBook-Pro ~/go/src/github.com/perlin-network/life (master) $ git log|head
commit 4e2637791edc5716293a29710531e36d39da4d5c
Merge: 1eb3d14 6525bd2
Author: Heyang Zhou <6104981+losfair@users.noreply.github.com>
Date:   Fri Oct 12 11:18:30 2018 +0800

    Merge pull request #38 from perlin-network/return-on-gas-limit
    
    Allow normal return instead of error when gas limit is exceeded.

jaten@jatens-MacBook-Pro ~/go/src/github.com/perlin-network/life (master) $ 
@iwasaki-kenta
Copy link
Contributor

iwasaki-kenta commented Oct 24, 2018

Hello,

Life itself focuses on execution of pure WebAssembly modules; Go modules compiled down to WebAssembly require some external functions to be available under a namespace titled go (hence the unknown module: go error).

In order to support Go modules compiled down to WebAssembly, it is a matter of creating an import resolver that provides implementations of all the external functions necessary under go (instructions denoted on README).

Import resolvers may be created for supporting virtually any kind of functionality; even for supporting interfacing with the GPU or creating a GUI straight from a WebAssembly module for example.

The .js build one gets from building a Go module into WebAssembly contains a browser-based JavaScript implementation of the go namespace, which actually can be ported over into an import resolver that may be used in Life.

We would really love for any initial work done by the community for specifically supporting Go modules compiled down to WebAssembly, or otherwise look into further work on having the Go compiler spit out pure WebAssembly modules (rather than rely on an external set of functions from a defined go namespace).

It unfortunately isn't one of our biggest priorities right now to be creating stub implementations for said import resolvers, though we are more than happy to help should anyone look to kickstart one off (for Go for example).

@miguelmota
Copy link

miguelmota commented Nov 30, 2018

Having the same problem

package main

import "fmt"

func main() {
	fmt.Println("Hello, WebAssembly!")
}
GOOS=js GOARCH=wasm go build -o main.wasm
$ ./life -entry '' main.wasm
Resolve func: go debug
panic: unknown module: go

goroutine 1 [running]:
main.main()
        /Users/mota/.gvm/pkgsets/go1.11/global/src/github.com/perlin-network/life/main.go:79 +0x886

would be helpful to see a working example of compiling Go to WASM that can be resolved by this library

@losfair losfair closed this as completed Nov 30, 2018
@glycerine
Copy link
Author

@losfair It's fair to lock this issue to prevent me toos. But it still an open issue that most who try Life with Go will hit. Closing it is misleading. And it deters community contribution; which was requested above.

@losfair
Copy link
Contributor

losfair commented Dec 1, 2018

@glycerine Life itself is a virtual machine and we think runtime support like the Go runtime is out of scope of this project. Discussions in #23 provide some suggestions on running Go on Life though.

@glycerine
Copy link
Author

@losfair I'm surprised you aren't compiling from Go, since Life is written in Go. Out of curiousity, how are you generating your wasm code to run on Life?

@Irooniam
Copy link

Hello,

anyone have any luck using Life's Import resolvers to use go-compiled wasm modules within Life?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants