wasmerio / wasmer

🚀 The leading Wasm Runtime supporting WASIX, WASI and Emscripten
https://wasmer.io
MIT License
18.62k stars 797 forks source link

Is it possible to compile wasix without rayon support? #4308

Open casimiro opened 11 months ago

casimiro commented 11 months ago

Summary

rayon is listed as an optional dependency of wasix, however it seems impossible to build wasix without rayon.

Additional details

Being able to compile wasix without rayon is useful when embedding the C library in environments where thread pooling doesn't make sense.

See https://github.com/wasmerio/wasmer/issues/4113

theduke commented 11 months ago

This is similar to the discussion in https://github.com/wasmerio/wasmer/discussions/4299

In short: you have to use a custom VirtualTaskManager with your own thread pool.

casimiro commented 11 months ago

Thank you for the quick reply, @theduke.

Since I'm not embedding Wasmer within another Rust application, I tried to circumvent the thread pool creation in wasix by removing the sys-thread feature from the wasix dependency in lib/c-api/Cargo.toml:

wasmer-wasix = { version = "0.16.0", path = "../wasix", default-features = false, features = ["sys", "logging"], optional = true }

But the compilation C library stops with the following error:

   Compiling wasmer-middlewares v4.2.3 (/home/casimiro/KongHQ/wasmx/work/runtimes/libwasmer/repos/wasmer/lib/middlewares)
warning: unused import: `crate::PluggableRuntime`
  --> lib/wasix/src/state/builder.rs:17:5
   |
17 | use crate::PluggableRuntime;
   |     ^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: `#[warn(unused_imports)]` on by default

   Compiling cranelift-frontend v0.91.1
warning: `wasmer-wasix` (lib) generated 1 warning (run `cargo fix --lib -p wasmer-wasix` to apply 1 suggestion)
error[E0432]: unresolved import `wasmer_wasix::runtime::task_manager::tokio`
  --> lib/c-api/src/wasm_c_api/wasi/mod.rs:23:29
   |
23 |     runtime::task_manager::{tokio::TokioTaskManager, InlineWaker},
   |                             ^^^^^ could not find `tokio` in `task_manager`

From the discussion in the referenced issue and the output above I assume it's currently not possible to compile the Wasmer C library without sys-thread (i.e., without rayon) by simply disabling features in Cargo files.