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?
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).
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 emptyfn 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
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 emptyfn 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?
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
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 ~~~
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 ~~~
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
orcargo +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: Nov 22 2024 at 16:03 UTC