Open owenthereal opened 6 months ago
I'm trying to run a wasi program with threads enabled, but I'm getting the following when running it with wasmtime-go:
package main import ( "fmt" "log" "os" "path/filepath" "github.com/bytecodealliance/wasmtime-go" ) func main() { dir, err := os.MkdirTemp("", "out") if err != nil { log.Fatal(err) } defer os.RemoveAll(dir) stdoutPath := filepath.Join(dir, "stdout") f, err := os.ReadFile(os.Args[1]) if err != nil { log.Fatal(err) } cfg := wasmtime.NewConfig() cfg.SetWasmThreads(true) engine := wasmtime.NewEngineWithConfig(cfg) module, err := wasmtime.NewModule(engine, f) if err != nil { log.Fatal(err) } linker := wasmtime.NewLinker(engine) err = linker.DefineWasi() if err != nil { log.Fatal(err) } wasiConfig := wasmtime.NewWasiConfig() wasiConfig.SetStdoutFile(stdoutPath) store := wasmtime.NewStore(engine) store.SetWasi(wasiConfig) instance, err := linker.Instantiate(store, module) if err != nil { log.Fatal(err) } nom := instance.GetFunc(store, "_start") _, err = nom.Call(store) if err != nil { log.Fatal(err) } // Print WASM stdout out, err := os.ReadFile(stdoutPath) if err != nil { log.Fatal(err) } fmt.Print(string(out)) }
I was able to run it with wasmtime though: wasmtime --wasm threads --wasi threads program.wasm
wasmtime --wasm threads --wasi threads program.wasm
Thanks for the report! This is expected though in that this import is part of the wasi-threads proposal which has not been implemented in the C API (nor standardized to a large degree)
I'm trying to run a wasi program with threads enabled, but I'm getting the following when running it with wasmtime-go:
I was able to run it with wasmtime though:
wasmtime --wasm threads --wasi threads program.wasm