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

Support a WASI reactor target #587

Open
andrewmd5 opened this issue Jan 19, 2024 · 3 comments
Open

Support a WASI reactor target #587

andrewmd5 opened this issue Jan 19, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@andrewmd5
Copy link

Operating system: macOS
Processor architecture: M1 (arm64)
Rust version: not applicable
Javy version: latest

Problem

WASI/WASM ceremony is all over the place depending on what compiler produced the module. Most expect _start or _initialize to be called prior to any exported functions being invoked.

In the case of modules produced by Javy, if _start is called any subsequent calls to exported functions will fail with wasmtime reporting they’re unreachable.

If I remove my calls to _start then I can call into my exported functions without issue.

@andrewmd5 andrewmd5 added the bug Something isn't working label Jan 19, 2024
@saulecabrera
Copy link
Member

Javy-generated modules, are WASI-compliant by default. More concretely, Javy-generated modules are Commands, which according to the WASI specification:

A Command has a "main" function, and when this function returns the program terminates.

The main function referenced in the specification is the exported _start function; in that sense, calling any other function after calling _start will result in a panic. In theory we could make Javy modules be configurable (either a Command or Reactor) if that's something that you need for your use-case.

@andrewmd5
Copy link
Author

Right, I figured that was the case. The reason for my issue is because if we look at say TinyGo's WASM/WASI target, it requires you to call _start before calling any other methods and in reality behaves like a reactor even though it is a command module (they're currently working on a reactor compile target.)

Why this is relevant is my use-case loads extensions written in any programming language which are compiled to a WASI module, and we have to workaround and support the various calling conventions and ceremony each compiler requires since everyone is fast and loose with the standards.

So, with that being said, a reactor target would be great for Javy so we can have setup code and still call exported functions.

@saulecabrera saulecabrera added enhancement New feature or request and removed bug Something isn't working labels Jan 22, 2024
@jeffcharles jeffcharles changed the title Exported function calls fail if “_start” called first Support a WASI reactor target Jan 22, 2024
@saulecabrera
Copy link
Member

If you're willing to work on a PR to add this functionality, I'd be happy to review it.

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

No branches or pull requests

2 participants