-
Notifications
You must be signed in to change notification settings - Fork 204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NativeAOT-LLVM: Init callback declaration #2364
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me. @SingleAccretion ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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_StaticInitialization
and 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
_initialize
function. The call to this function is done in/Bootstrap/main.cpp
which is#if def
ed in for WASI andNATIVEAOT_DLL
WASI 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
CustomNativeMain
from 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
,_intialize
is 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
_initialize
for WASI +NATIVEAOT_DLL
from aCustomNativeMain
I added a__weak
dummy function.