tinygo-org / tinygo

Go compiler for small places. Microcontrollers, WebAssembly (WASM/WASI), and command-line tools. Based on LLVM.
https://tinygo.org
Other
15.48k stars 913 forks source link

`init()` for `wasip2` reactor components #4488

Closed rvolosatovs closed 1 month ago

rvolosatovs commented 1 month ago

Currently, init() functions do not run in wasip2 reactor components run in Wasmtime 25.

A recent change to wasm-tools introduced support for _initialize in component new step https://github.com/bytecodealliance/wasm-tools/pull/1747, however even with:

init() functions do not run in reactors, which manifests in e.g. stdio not being available and runtime panics e.g. printing to os.Stdout

It's possible that the outdated WASI-libc version is the cause here, I'll try updating it and report

Refs #4482

Update 1:

neither updating vendored wasi-libc to https://github.com/WebAssembly/wasi-libc/commit/5ed3ec5701b58347d28a87c84ccc95f9c54b0148, nor https://github.com/WebAssembly/wasi-libc/commits/wasi-sdk-22 seemed to have changed anything, but I'm also not familiar with the build process enough to know if I had to do something more that just go install to make sure TinyGo uses the latest wasi-libc