-
Notifications
You must be signed in to change notification settings - Fork 95
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
Add the ability to call specific modules in wasmtime. #102
Conversation
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.
thanks for the PR! @brendanburns
We are currently holding off merging in new prs until #78 closes.
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.
lgtm!
If I understand correctly, this (e.g. Is this pattern done anywhere else? I suppose I want to know how someone would know to ignore a # as a valid file character. My guess is what will happen after this change, for runtimes that aren't aware of this PR, is that they will fail on file-not-found.. Basically, the runtime will think the entry point wasm is literally @giuseppe do you know anywhere else that has special logic like this in treatment of the ENTRYPOINT binary? p.s. even if you can call "foo", you may also need to initialize the wasm, especially as this project is called runwasi. For example, if you try to call an exported function from tinygo compiled to wasi, it will fail if initialization isn't called first ( |
I wanted to make you aware of the fact that you can't just call a specific method. See these docs. If your application is a command module, then it has a _start function, the initialization of the application is compiled into that _start, so you will first have to call _start before calling anything else. If your application is a reactor module, you will have a _initialize function that you should call before anything else. For example Emscripten uses the _start/_initialize to initialize the following:
Wasi-libc uses the _start/_initialize to initialize the following:
You can look for I don't know about other compilers but they probably use a similar system. |
Thanks for the feedback! Two replies: The hash syntax is stolen from Java, eg https://stackoverflow.com/questions/11247793/why-do-some-folks-use-classmethod-instead-of-class-method-in-correspondence But I think :: is equally valid and we could switch to that. I tested this with wasmtime + c and it works correctly in the sense that the method executes and returns, a similar call pattern is used in the wasmtime binary if you specify a specific method to call on the command line. I think what the 'correct' behavior here is is under specified. I was viewing it like a stateless function, in which case that initialization may not make sense, but I agree that things like missing environment variables may confuse the user. I'll look into adding more clarity and reducing confusion. Thanks again for the feedback! |
I think my point is that any filename encoding will break the ability to know if a binary exists or not, unless all runtimes are taught the special delimiter that might be inside ENTRYPOINT[0] So, lifecycle concerns aside, this will make format very coupled to one runtime and different than normal docker, too. Is there another way to pass this extra method info in a way your runtime can see it? Also, since this isn't about WASI is there a strong need to support this? I mean was a user asking to do this? It seems for a wasi project, maybe you don't need to scope in something like this because it causes problems with what ENTRYPOINT means (specifically position zero is the real file) |
I'm not sure why any other runtime needs to be taught about this. This is intended to be specific to the Is entrypoint formally defined anywhere? The best I can see in the spec is: https://github.com/opencontainers/image-spec/blob/main/config.md Where it says
Which seems to indicate that it is up to each runtime to interpret what Entrypoint means. |
IF this is indeed specific to runwasi then it should be documented somewhere as this is different than OCI runtimes for wasi which will interpret ENTRYPOINT[0] as the binary. It should also implement for all its implementing runtimes, at least to give a proper error. Right now, the only thing that parses this is wasmtime, so if you passed this info to wasmedge I'm pretty sure you'd get an ugly error. Make sense? |
This enables someone to pass
/main.wasm#foo
as thearg[0]
and for it to call a specific method in that WASM file instead of assuming that_start
is the only entrypoint.