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

Using WASI from wasmer cli #2978

Closed
ljulliar opened this issue Jun 27, 2022 · 6 comments · Fixed by #2997
Closed

Using WASI from wasmer cli #2978

ljulliar opened this issue Jun 27, 2022 · 6 comments · Fixed by #2997
Labels
🕵️ needs investigation The issue/PR needs further investigation priority-low Low priority issue ❓ question I've a question!
Milestone

Comments

@ljulliar
Copy link

ljulliar commented Jun 27, 2022

Hi all,

I'm generating WASM module from a compiler of my own. In one of the module I wrote I'd like to use the WASI interface. I am therefore importing the various WASI functions from the module wasi_unstable but when I try to execute this model with the wasmer runtime through the command line I get the following error:

error: failed to run `../rlang_apps/base64_benchmark/rlang_base64_benchmark.wasm`
╰─▶ 1: Error while importing "wasi_unstable"."args_sizes_get": unknown import. Expected Function(FunctionType { params: [I32, I32], results: [I32] })

Is it that I am importing the wrong module name ? Or is there an option on the wasmer CLI to "activate" the WASI module at execution time ?

Thanks for your help.

@ljulliar ljulliar added the ❓ question I've a question! label Jun 27, 2022
@jcaesar
Copy link
Contributor

jcaesar commented Jun 29, 2022

In general, this should work, WASI is active by default. One suspicion though: You're not by any chance using wasmer run --invoke _foobar? Because using --invoke deactivates WASI.

For reference: You can save this file as test.wat and execute it with wasmer run test.wat just fine (not that it does anything):

(module
  (import "wasi_unstable" "args_sizes_get"
    (func $__wasi_args_sizes_get (param i32 i32) (result i32)))
  (func $_start)
  (memory 1)
  (export "memory" (memory 0))
  (export "_start" (func $_start))
)

(If --invoke was the problem: I think this is the second issue I've seen along these lines. Might as well leave it open and make a PR that enables WASI even with invoke.)

@ljulliar
Copy link
Author

ljulliar commented Jun 29, 2022 via email

@jcaesar
Copy link
Contributor

jcaesar commented Jul 1, 2022

Possibly related to #1716.

@jcaesar
Copy link
Contributor

jcaesar commented Jul 4, 2022

@fschutt Thank you for fixing this. For reference, an easy way to reproduce this problem from a rust-compiled binary is

#[no_mangle]
pub extern "system" fn invokeme() {
    println!("Hello, world!");
}

You'll have to compile that as a [lib] with crate-type = ["cdylib"].

@syrusakbary
Copy link
Member

Thanks for opening the issue @ljulliar. It seems this may be fixed by #2997.
If not, it might be caused by not attaching the WASI imports when instantiating the instance.

If you have code we can look at that will help on debugging the issue!

@syrusakbary syrusakbary added this to the v3.x milestone Jul 5, 2022
@syrusakbary syrusakbary added priority-low Low priority issue 🕵️ needs investigation The issue/PR needs further investigation labels Jul 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🕵️ needs investigation The issue/PR needs further investigation priority-low Low priority issue ❓ question I've a question!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants