wasilibs / nottinygc

Higher-performance allocator for TinyGo WASI apps
MIT License
64 stars 6 forks source link

Wasm VM failed Failed to initialize Wasm code #47

Closed swapnilaniljanorkarjanorkar-sap closed 4 months ago

swapnilaniljanorkarjanorkar-sap commented 4 months ago

I'm trying to run the wasm plugin in envoy but getting following error while running.

[2024-04-15 10:47:48.818][1][error][wasm] [source/extensions/common/wasm/wasm_vm.cc:39] Failed to load Wasm module due to a missing import: wasi_snapshot_preview1.sched_yield
[2024-04-15 10:47:48.818][1][error][wasm] [source/extensions/common/wasm/wasm.cc:118] Wasm VM failed Failed to initialize Wasm code
[2024-04-15 10:47:48.819][1][critical][wasm] [source/extensions/common/wasm/wasm.cc:472] Plugin configured to fail closed failed to load
[2024-04-15 10:47:48.821][1][critical][main] [source/server/server.cc:113] error initializing configuration '/etc/envoy/envoy.yaml': Unable to create Wasm HTTP filter 
[2024-04-15 10:47:48.822][1][info][main] [source/server/server.cc:815] exiting
Unable to create Wasm HTTP filter 
make: *** [run] Error 1

As mentioned in the README file, I have added "github.com/wasilibs/nottinygc" in import statements.

anuraaga commented 4 months ago

Hi @swapnilaniljanorkarjanorkar-sap - did you add the build tag too?

https://github.com/wasilibs/nottinygc?tab=readme-ov-file#using-with-envoy

swapnilaniljanorkarjanorkar-sap commented 4 months ago

Hi @swapnilaniljanorkarjanorkar-sap - did you add the build tag too?

https://github.com/wasilibs/nottinygc?tab=readme-ov-file#using-with-envoy

Hi @anuraaga After adding both the tags (custommalloc and nottinygc_envoy) I could build the wasm plugin.

tinygo build -o plugin.wasm -gc=custom -tags="custommalloc nottinygc_envoy" -scheduler=none -target=wasi main.go
anuraaga commented 4 months ago

Sounds like it worked, thanks for confirming