tinygo-org / tinygo

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

WebAssembly: indicate initialization status of runtime #2851

Open jzabinski-dolios opened 2 years ago

jzabinski-dolios commented 2 years ago

For WebAssembly, the embedder needs to use wasm_exec's run(instance) method in global.Go so that TinyGo's runtime can be initialized prior to calling any of the WebAssembly module's exported functions. But there doesn't seem to be anything in global.Go indicating whether the runtime has been initialized. An easy workaround would be to create a wrapper object for run elsewhere in Javascript, but I feel like it would be useful to store a variable indicating the initialization status of the runtime in global.Go itself.

dgryski commented 2 years ago

This seems pretty doable.

codefromthecrypt commented 1 year ago

do any other compilers do this (rust, clang etc)? might be nice to see how.

dgryski commented 1 year ago

If this ends up being part of https://github.com/tinygo-org/tinygo/issues/2735 then we could close this one.