Stream: git-wasmtime

Topic: wasmtime / issue #8841 wasmtime main.wasm ,then encounte...


view this post on Zulip Wasmtime GitHub notifications bot (Jun 19 2024 at 12:18):

dylanpoe opened issue #8841:

hello, I use golang build a main.wasm files

//go:build js && wasm

// main.go
package main

import (
    "syscall/js"
)

func main() {
    js.Global().Call("alert", "Hello World")
}

and build the main.wasm by the code

 GOOS=js GOARCH=wasm go build -o  main.wasm

then use the wasmtime main.wasm, got the error

Error: failed to run main module `main.wasm`

Caused by:
    0: failed to instantiate "main.wasm"
    1: unknown import: `gojs::runtime.scheduleTimeoutEvent` has not been defined

hot t fix it ?

view this post on Zulip Wasmtime GitHub notifications bot (Jun 19 2024 at 12:33):

bjorn3 commented on issue #8841:

GOOS=js uses a Go specific syscall interface which is only implemented by the JS code available at https://github.com/golang/go/blob/master/misc/wasm/wasm_exec.js This only works in the browser and with Node.JS and is incompatible with any native WASM runtime. For Wasmtime and other native WASM runtimes you have to use GOOS=wasip1 instead and are not allowed to use the syscalls/js package.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 19 2024 at 17:54):

alexcrichton closed issue #8841:

hello, I use golang build a main.wasm files

//go:build js && wasm

// main.go
package main

import (
    "syscall/js"
)

func main() {
    js.Global().Call("alert", "Hello World")
}

and build the main.wasm by the code

 GOOS=js GOARCH=wasm go build -o  main.wasm

then use the wasmtime main.wasm, got the error

Error: failed to run main module `main.wasm`

Caused by:
    0: failed to instantiate "main.wasm"
    1: unknown import: `gojs::runtime.scheduleTimeoutEvent` has not been defined

hot t fix it ?


Last updated: Oct 23 2024 at 20:03 UTC