Open npchp110 opened 3 years ago
@npchp110 The reason for this problem has been explained by the @Hywan in this issue. https://github.com/wasmerio/wasmer-go/issues/275
As for how to solve this problem, you can refer to the demo I recently submitted. Of course, you also need to compile a wasm program that conforms to the wasi standard. #315
If you want to know more details, you can read this technical blog, but it needs to be translated because I use Chinese for content writing. https://soulteary.com/2021/11/21/use-docker-and-golang-to-quickly-get-started-with-webassembly.html
I've been having this issue right now, even after following the blog article of @soulteary
https://github.com/wasmerio/wasmer-go/issues/275#issuecomment-1416547986
As I've mentioned in the other issue, my solution was to build my binary this way:
tinygo build --no-debug -o simple.wasm -target=wasi -panic=trap -scheduler=none main.go
The problem was that the default panic handler tries to print information. The option -panic=trap
removes that behaviour, so all other unnecessary functions go away.
Just tagging along here, I'm also seeing Missing import: wasi_snapshot_preview1 . clock_time_get
after resolving the fd_write
import.
Just tagging along here, I'm also seeing
Missing import: wasi_snapshot_preview1 . clock_time_get
after resolving thefd_write
import.
Resolved with this: https://github.com/wasmerio/wasmer-go/pull/315/files
wasiEnv, _ := wasmer.NewWasiStateBuilder("wasi-program").
// Choose according to your actual situation
// Argument("--foo").
// Environment("ABC", "DEF").
// MapDirectory("./", ".").
Finalize()
importObject, err := wasiEnv.GenerateImportObject(store, module)
check(err)
Describe the bug
Failed to instantiate the module: Missing import:
wasi_snapshot_preview1
.fd_write
Steps to reproduce
user wasmer to load test.wasm, Failed to instantiate the module
Additional context
tinygo version 0.20.0 linux/amd64 (using go version go1.17.1 and LLVM version 11.0.0)