Stream: git-wasmtime

Topic: wasmtime / issue #2580 Wasmtime: Clarify the relationship...


view this post on Zulip Wasmtime GitHub notifications bot (Feb 02 2023 at 01:54):

hbina commented on issue #2580:

How do I make sure that the WASM module that I created is a Reactor? There doesn't seem to be much documentation on what makes a Reactor and Command, and why a module would be build as one over another?

view this post on Zulip Wasmtime GitHub notifications bot (Feb 02 2023 at 12:19):

bjorn3 commented on issue #2580:

Any module with an _initialize function is a reactor I believe. The difference between a command and a reactor is that a command must be destroyed after calling the main function, while a reactor requires running the _initialize function and then you are free to run any exported functions you want on the instance. It is kind of like a binary (command) vs library (reactor).

view this post on Zulip Wasmtime GitHub notifications bot (Feb 02 2023 at 12:33):

hbina commented on issue #2580:

Do I have to manually put the function there via func_wrap or something like that? My code is definitely a binary, it has an empty fn main() {}

See https://github.com/lapce/lapce-rust/blob/master/src/main.rs#L31

which expands like so https://github.com/lapce/lapce-plugin-rust/blob/master/src/lib.rs#L99-L125

view this post on Zulip Wasmtime GitHub notifications bot (Feb 02 2023 at 12:34):

hbina edited a comment on issue #2580:

Do I have to manually put the function there via func_wrap or something like that? My code is definitely a binary, it has an empty fn main() {}

See https://github.com/lapce/lapce-rust/blob/master/src/main.rs#L31

which expands like so https://github.com/lapce/lapce-plugin-rust/blob/master/src/lib.rs#L99-L125

Edit: Wait did I get that right, a command is the stateful one?

view this post on Zulip Wasmtime GitHub notifications bot (Feb 02 2023 at 13:00):

bjorn3 commented on issue #2580:

It will have to be compiled as reactor if you want to use wasi. Otherwise at_exit entries and global destructors will run right after the rust main function there is called and before lapce can call handle_rpc: https://github.com/WebAssembly/wasi-libc/blob/9bec2d3aff198770e98544cb6f13add60e1f5fe6/libc-bottom-half/crt/crt1-command.c#L46

view this post on Zulip Wasmtime GitHub notifications bot (Feb 02 2023 at 13:04):

hbina commented on issue #2580:

I can't seem to use the flag that you mentioned in Zulip. Perhaps if I change the plugin to look like a lib.rs it will be compiled as a reactor automatically?

hbina@akarin ~/g/lapce-rust (master)> cargo +nightly -Zwasi-exec-model=reactor build
error: unknown `-Z` flag specified: wasi-exec-model
~~~

view this post on Zulip Wasmtime GitHub notifications bot (Feb 02 2023 at 13:07):

hbina edited a comment on issue #2580:

I can't seem to use the flag that you mentioned in Zulip. Perhaps if I change the plugin to look like a lib.rs it will be compiled as a reactor automatically?

hbina@akarin ~/g/lapce-rust (master)> cargo +nightly -Zwasi-exec-model=reactor build
error: unknown `-Z` flag specified: wasi-exec-model
~~~

view this post on Zulip Wasmtime GitHub notifications bot (Feb 02 2023 at 13:41):

bjorn3 commented on issue #2580:

You have to pass it to rustc, not cargo. So for example RUSTFLAGS="-Zwasi-exec-model=reactor" cargo +nightly build or cargo +nightly rustc -- -Zwasi-exec-model=reactor.

Perhaps if I change the plugin to look like a lib.rs it will be compiled as a reactor automatically?

I don't think it does, but you could try.


Last updated: Dec 23 2024 at 12:05 UTC