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

Failed to parse GoLang WebAssembly module #161

Open
k33g opened this issue Feb 15, 2022 · 5 comments
Open

Failed to parse GoLang WebAssembly module #161

k33g opened this issue Feb 15, 2022 · 5 comments

Comments

@k33g
Copy link

k33g commented Feb 15, 2022

When loading a wasm GoLang module (build with TinyGo), I get this error:

Error: failed to parse WebAssembly module

Caused by:
    Invalid input WebAssembly code at offset 294: duplicate import name `wasi_snapshot_preview1::fd_write` already defined

I use wagi v0.6.2 (and it works with v0.4.0)

My source code is:

package main

import "fmt"

func main() {
	fmt.Println("content-type: text/plain;utf-8")
	fmt.Println("")
	fmt.Println("👋 Hello World 🌍")
}
@radu-matei
Copy link
Member

Hi, @k33g, thanks a lot for the report!
What version of the TinyGo compiler should I use to replicate this?

Thanks!

@k33g
Copy link
Author

k33g commented Feb 16, 2022

@radu-matei I use tinygo version 0.21.0 linux/amd64 (using go version go1.17.5 and LLVM version 11.0.0)

@technosophos
Copy link
Contributor

Have you tried running with the wasmtime CLI? I am wondering if the LLVM version is to old.

I pasted your exact code into main.go and then compiled with the following command:

$ tinygo build -o test.wasm -target wasi main.go

Then I used the following modules.toml:

[[module]]
module = "test.wasm"
route = "/"

I ran it with:

wagi -c modules.toml 
No log_dir specified, using temporary directory /var/folders/rk/mkbs8vx12zs0gkm680h_gth00000gn/T/.tmpUebthv for logs
Ready: serving on 127.0.0.1:3000

And hitting it with curl gave me this:

$ curl -v localhost:3000
*   Trying 127.0.0.1:3000...
* Connected to localhost (127.0.0.1) port 3000 (#0)
> GET / HTTP/1.1
> Host: localhost:3000
> User-Agent: curl/7.77.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< content-type: text/plain;utf-8
< content-length: 22
< date: Sat, 05 Mar 2022 00:36:47 GMT
<
👋 Hello World 🌍
* Connection #0 to host localhost left intact

Version of TinyGo:

$ tinygo version
tinygo version 0.22.0 darwin/amd64 (using go version go1.17.6 and LLVM version 13.0.0)

@k33g
Copy link
Author

k33g commented Mar 5, 2022

@technosophos I will try, thanks 👍

@k33g
Copy link
Author

k33g commented Apr 8, 2022

Sorry @technosophos for the late delay
I did tests again:

  • wagi: 0.8.1
  • tinygo version 0.21.0 linux/amd64 (using go version go1.17.5 and LLVM version 11.0.0)
  • I ran the wasm module with wasmtime: no problem ✅
  • I try again with wagi:
No log_dir specified, using temporary directory /tmp/.tmpSgTNHp for logs
Error: Failed to compile one or more Wasm modules

Caused by:
    0: Error compiling Wasm module ./hello/main.wasm
    1: failed to parse WebAssembly module
    2: Invalid input WebAssembly code at offset 294: duplicate import name `wasi_snapshot_preview1::fd_write` already defined

And everything is ok with the 0.4.0 version of wagi

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