Skip to content

The wasm compiled by go cannot be run using the iwasm tool provided by wasm-micro-runtime #68868

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

Closed
littetimo567 opened this issue Aug 14, 2024 · 3 comments

Comments

@littetimo567
Copy link

littetimo567 commented Aug 14, 2024

Go version

go 1.23.0.linux/amd64

Output of go env in your module/workspace:

O111MODULE='on'
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/ema/.cache/go-build'
GOENV='/home/ema/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/ema/golang/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/ema/golang/'
GOPRIVATE=''
GOPROXY='https://goproxy.cn,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.23.0'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/ema/.config/go/telemetry'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/home/ema/core/local/emawamr/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build2475111588=/tmp/go-build -gno-record-gcc-switches'

What did you do?

I have a go file and want to compile it into a wasm file.

package main
import (
	"fmt"
)

func main() {}

//export Greet
func Greet() {
	fmt.Println("this is greet test")
}

First, I compile it into a greet.wasm using the go command :

GOOS=wasip1 GOARCH=wasm go build -o greet.wasm greet.go

And then, using tinygo to compile into greet2.wasm

tinygo build -target wasi -o greet2.wasm greet.go

Run the function Greet of greet.wasm and greet2.wasm using the iwasm tool provided by wasm-micro-runtime

What did you see happen?

The greet2.wasm was run successfully, but the greet.wasm was run failed, and display a error: lookup function failed

What did you expect to see?

The iwasm tool of wasm-micro-runtime can run the function from wasm which compiled by go

@littetimo567
Copy link
Author

GOOS=wasip1 GOARCH=wasm only supported after go 1.21.0.linux/amd64 and not GOOS=js

@seankhliao
Copy link
Member

see #65199

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

3 participants