NativeAOT-LLVM: Init callback declaration#2364
Conversation
0f9e48b to
8c78dc0
Compare
8c78dc0 to
e9d1f02
Compare
|
Worth mentioning here is what node.js does. At the bottom of this document https://nodejs.org/api/wasi.html it describes how the node.js runtime initializes WASI modules/compoents. Ive not tested this because I have been focusing on wasmtime because it looks to be leading the way in terms of WIT support and wasm component linking and running. However on the surface it looks like with this change, if node.js was used as the host, then |
jkotas
left a comment
There was a problem hiding this comment.
This looks good to me. @SingleAccretion ?
SingleAccretion
left a comment
There was a problem hiding this comment.
The code changes LGTM, but I do have a question about wasmtime's behavior w.r.t. _initialize.
On the surface of things, bytecodealliance/wasmtime#1565 claims to execute for it reactors. Why does it not work in this case?
|
Yes, a good question, I will try to get a more definitive answer and update here, but my current understanding is that wasmtime will call |
This PR accepts the recommendation from NativeAOT_StaticInitialization and teherby removes
NativeAOT_StaticInitializationand its initialisation. This enables the runtime to be initialised without the use of static c++ ctors which are not invoked presently for WASI reactor components.WebAssembly/wasi-libc#74
WebAssembly/WASI#13
Instead the initialisation from a WASI reactor component is done via the wasi-libc
_initializefunction. The call to this function is done in/Bootstrap/main.cppwhich is#if defed in for WASI andNATIVEAOT_DLLWASI reactor components can now be compiled and executed (although the WIT codegen is not ready yet).
This change does introduce the problem of intialisation of
CustomNativeMainfrom a WASI program as it is not distnguishable from a wasi reactor compoent, and the crt1.o for the program case does not contain_initialize,_intializeis only present for the reactor version of crt1 https://github.com/WebAssembly/wasi-libc/blob/9f51a7102085ec6a6ced5778f0864c9af9f50000/libc-bottom-half/crt/crt1-reactor.c#L7-L27To solve the problem of no
_initializefor WASI +NATIVEAOT_DLLfrom aCustomNativeMainI added a__weakdummy function.