Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Trouble instantiating a wasm object with wasmer #3651

Closed
inviti8 opened this issue Mar 7, 2023 · 5 comments
Closed

Trouble instantiating a wasm object with wasmer #3651

inviti8 opened this issue Mar 7, 2023 · 5 comments
Labels
❓ question I've a question!

Comments

@inviti8
Copy link

inviti8 commented Mar 7, 2023

Summary

Trying to use wasmer to work with a wasm object compiled from Go. When using wasmer, to create the instance, it throws an error. This wasm object works for js web assembly. This is the error thrown:
` instance = Instance(module)

RuntimeError: Error while importing "go"."debug": unknown import. Expected Function(FunctionType { params: [I32], results: [] })`

Not sure of what the issue may be, so don't where to look in order to debug the issue. Any info you may have would be greatly appreciated.

Thanks much!

@inviti8 inviti8 added the ❓ question I've a question! label Mar 7, 2023
@ptitSeb
Copy link
Contributor

ptitSeb commented Mar 7, 2023

Your module try to use go debug function and it's not part of the wasi standard. Did you target WASM32-WASI or something else?

What command line did you used? something like tinygo build -wasm-abi=generic -target=wasi -o main.wasm main.go?

@inviti8
Copy link
Author

inviti8 commented Mar 7, 2023

Hi, thanks for the quick response. This is the the full shell script:

# wget https://github.com/tinygo-org/tinygo/blob/v0.26.0/targets/wasm_exec.js
# build wasm module containing go functions
GOOS=js GOARCH=wasm go build -o ./dero_wallet.wasm 
# tinygo build -o main.wasm -target wasm ./main.go
sha512sum ./dero_wallet.wasm > ./sha512sums.txt

@theduke
Copy link
Contributor

theduke commented Mar 7, 2023

You are building with GOOS=js, which builds for the browser and requires a Javascript helper that provides the go.debug import.

You can build with Go for WASM, but then you will need to provide all the required interaction with the Wasm code yourself (via function exports and imports).

You can also use tinygo, which has WASI support. WASI allows you to use basic things like standard IO (stdin,out,err), file system access, etc.

You need to pick between one of those options, but building for JS will not work.

@inviti8
Copy link
Author

inviti8 commented Mar 7, 2023

Thanks for the details, much appreciated. :) I'm new to web assembly stuff.

you will need to provide all the required interaction with the Wasm code yourself (via function exports and imports)

In all honesty, not sure how to do that. Could you point me to a good example so I can wrap my head around how it works? Again much appreciated.

@Michael-F-Bryan
Copy link
Contributor

Hey @inviti8, I haven't used tinygo before, but you might be able to find some resources by reading through tinygo-org/tinygo#3040.

@wasmerio wasmerio locked and limited conversation to collaborators Mar 21, 2023
@Michael-F-Bryan Michael-F-Bryan converted this issue into discussion #3696 Mar 21, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
❓ question I've a question!
Projects
None yet
Development

No branches or pull requests

4 participants