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

Running tests with some wasmtime features enabled #108

Open
marmeladema opened this issue Sep 8, 2021 · 3 comments
Open

Running tests with some wasmtime features enabled #108

marmeladema opened this issue Sep 8, 2021 · 3 comments

Comments

@marmeladema
Copy link

Hello!

I am very new to the wasm ecosystem and trying a bit all the tools/framework/runtime out there.
I am working on porting https://github.com/cloudflare/sliceslice-rs to wasm.
That project requires simd instructions to work.

I have a wip branch working but to run the tests, I cannot simple do:

$ cargo wasi test
    Finished test [unoptimized + debuginfo] target(s) in 0.00s
     Running unittests (target/wasm32-wasi/debug/deps/sliceslice-c22d039e805d5bb0.wasm)
     Running tests/i386.rs (target/wasm32-wasi/debug/deps/i386-310c1b29d531f32f.wasm)
     Running `/home/adema/code/sliceslice-rs/target/wasm32-wasi/debug/deps/sliceslice-c22d039e805d5bb0.wasm`
Error: failed to run main module `/home/adema/code/sliceslice-rs/target/wasm32-wasi/debug/deps/sliceslice-c22d039e805d5bb0.wasm`

Caused by:
    0: WebAssembly translation error
    1: Invalid input WebAssembly code at offset 337919: SIMD support is not enabled

because the simd feature of wasmtime is not enabled by default.

My problem is that I haven't found a way to enable simd from cargo-wasi.
To run the tests, I have to manually run:

$ wasmtime --enable-simd /home/adema/code/sliceslice-rs/target/wasm32-wasi/debug/deps/sliceslice-c22d039e805d5bb0.wasm

running 14 tests
test tests::memchr_search_different ... ok
test tests::memchr_search_middle ... ok
test tests::memchr_search_mutiple ... ok
test tests::memchr_search_prefix ... ok
test tests::memchr_search_same ... ok
test tests::memchr_search_suffix ... ok
test tests::needle_array_size ... ok
test tests::needle_slice_size ... ok
test wasm32::tests::search_different ... ok
test wasm32::tests::search_middle ... ok
test wasm32::tests::search_multiple ... ok
test wasm32::tests::search_prefix ... ok
test wasm32::tests::search_same ... ok
test wasm32::tests::search_suffix ... ok

test result: ok. 14 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

but that requires finding the wasm binary path which is not easily predictable.

My question is then: is there a way to pass command line options to wasmtime?
I can see different options if that's not already implemented:

  • by specifying cargo metadata variable
  • by using an environment variable like WASMTIMEFLAGS
  • by specifying command line arguments tocargo wasi test

Thank you in advance for taking the time to read this 👍

@alexcrichton
Copy link
Member

Thanks for the report! This isn't supported well today unfortunately. Some initial work was done at #19 but it stalled out because I don't think there's an idea of what the best design for this is right now.

@marmeladema
Copy link
Author

From a user perspective, I think I would prefer the cargo metadata option the most because I think people should not have to know which wasmtime features to enable or disable.
If you agree with this, and if we restrict ourselves to specifying only wasmtime features, how much work do you think it would be?

What I had in mind was something like:

[package.metadata.wasi.wasmtime.features]
simd = true

or if we want to have per profile configuration:

[package.metadata.wasi.wasmtime.profile.release]
features = { simd = true }

@marmeladema
Copy link
Author

@alexcrichton I don't know exactly what changed but I am now able to run cargo wasi without problem! Maybe the simd feature is enabled by default now?
Anyway, that's really neat, I was able to port sliceslice to wasm32 👍

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

No branches or pull requests

2 participants