Skip to content
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

who is supposed to call _initialize of an adapted reactor module? #7592

Open
yamt opened this issue Nov 28, 2023 · 3 comments
Open

who is supposed to call _initialize of an adapted reactor module? #7592

yamt opened this issue Nov 28, 2023 · 3 comments

Comments

@yamt
Copy link

yamt commented Nov 28, 2023

i have a preview1 reactor module, which exports _initialize.
when adapting it with wasi_snapshot_preview1.reactor.wasm and loading the resulted component with wasmtime,
i expected the _initialize export of the original module is somehow called during the component startup.
however, it doesn't seem to be called.

@alexcrichton
Copy link
Member

Currently the *.reactor.wasm adapter doesn't do anything with _initialize, so you'll likely want to build your own adapter which calls it as part of the start function or implicitly as part of exports.

Alternatively a convention could be built into wit-component to perhaps do this automatically but that would be pretty complicated implementation-wise since it would need to handle the fact that _initialize is optional.

@yamt
Copy link
Author

yamt commented Nov 29, 2023

Currently the *.reactor.wasm adapter doesn't do anything with _initialize, so you'll likely want to build your own adapter which calls it as part of the start function or implicitly as part of exports.

ok.
i put a hack in the (non-standard) entry point of my module and it's working well.

Alternatively a convention could be built into wit-component to perhaps do this automatically but that would be pretty complicated implementation-wise since it would need to handle the fact that _initialize is optional.

i guess it's necessary for a reactor built with wasi-libc to work correctly.

@alexcrichton
Copy link
Member

Most of the usage of _initialize in wasi-libc for example has been pushed to lazy instead of eager initialization, which if possible is what I would recommend for other uses as well. Otherwise feel free to open an issue on the wasm-tools repository for a proposal about how to add _initialize support to wit-component and adapters of course!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants