rinthnoid opened issue #11716:
Hi contributors,
I made some plugins using WASM's component model in rust using cargo component build command and voila it worked perfectly for windows for me.But the problem arises when I tried to compile it for android from same program same os (windows) it was hell of a nightmare to be able embed the
wasmtimeinto a rust library and It took plain 3 days to still to figure out that it is somehow not possible for android right now (at least for now) so it just wasted a 3 days and nights :expressionless:.I got something like this in error when compiling for android -
. . . error[E0433]: failed to resolve: use of unresolved module or unlinked crate `linux_raw_sys` --> D:\Programs\.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\rustix-1.1.2\src\thread\prctl.rs:257:16 | 257 | IPCOwner = linux_raw_sys::general::CAP_IPC_OWNER, | ^^^^^^^^^^^^^ use of unresolved module or unlinked crate `linux_raw_sys` | = help: if you wanted to use a crate named `linux_raw_sys`, use `cargo add linux_raw_sys` to add it to your `Cargo.toml` error[E0433]: failed to resolve: use of unresolved module or unlinked crate `linux_raw_sys` --> D:\Programs\.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\rustix-1.1.2\src\thread\prctl.rs:259:20 | 259 | SystemModule = linux_raw_sys::general::CAP_SYS_MODULE, | ^^^^^^^^^^^^^ use of unresolved module or unlinked crate `linux_raw_sys` | = help: if you wanted to use a crate named `linux_raw_sys`, use `cargo add linux_raw_sys` to add it to your `Cargo.toml` error[E0433]: failed to resolve: use of unresolved module or unlinked crate `linux_raw_sys` --> D:\Programs\.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\rustix-1.1.2\src\thread\prctl.rs:262:19 | 262 | SystemRawIO = linux_raw_sys::general::CAP_SYS_RAWIO, | ^^^^^^^^^^^^^ use of unresolved module or unlinked crate `linux_raw_sys` | = help: if you wanted to use a crate named `linux_raw_sys`, use `cargo add linux_raw_sys` to add it to your `Cargo.toml` . . . .I also made an easy reproducible example
// src/main.rs use anyhow::Result; use wasmtime::{Config, Engine, Store, StoreContextMut}; use wasmtime::component::{Component, Linker, ResourceTable}; use wasmtime_wasi::{p2,WasiCtx, WasiCtxView, WasiView}; use reqwest::{blocking::Client,}; wasmtime::component::bindgen!({ inline: r#" package component:adder; world example { import log: func(s: string); import fetch-http: func(url: string) -> string; export hello-world: func(name: string) -> string; export get-json: func(url: string) -> string; } "#, }); /// Per-store host state required by wasmtime-wasi. struct Host { wasi: WasiCtx, table: ResourceTable, } impl WasiView for Host { fn ctx(&mut self) -> WasiCtxView<'_> { WasiCtxView { ctx: &mut self.wasi, table: &mut self.table, } } } fn build_host_state() -> Host { // Configure the WasiCtx (inherit host stdio so guest prints appear in host console). let mut builder = WasiCtx::builder(); builder.inherit_stdio(); Host { wasi: builder.build(), table: ResourceTable::new(), } } fn main() -> Result<()> { // Engine configured for the component model (synchronous mode). let mut config = Config::new(); config.wasm_component_model(true); config.async_support(false); let engine = Engine::new(&config)?; // Load the component compiled from your component crate. let component = Component::from_file(&engine, "./adder.wasm")?; // Linker for host imports; parameterized by our Host state. let mut linker: Linker<Host> = Linker::new(&engine); // Register WASI Preview-2 implementations into the linker (sync API). p2::add_to_linker_sync(&mut linker)?; // Provide the implementation for the `log` function that the component imports. linker.root().func_wrap("log", |mut _cx: StoreContextMut<'_, Host>, (s,): (String,)| { println!("Guest says: {}", s); Ok(()) })?; // Provide a simple implementation for the `fetch-http` function that the component imports. linker.root().func_wrap("fetch-http", |mut _cx: StoreContextMut<'_, Host>, (url,): (String,)| { println!("Fetching URL: {}", url); let json_response = match Client::new().get(&url).send() { Ok(resp) => match resp.text() { Ok(body) => body, Err(e) => format!("error reading response body: {}", e), }, Err(e) => format!("request error: {}", e), }; Ok((json_response,)) })?; // Create the store (holds our Host state) and instantiate the component. let host_state = build_host_state(); let mut store = Store::new(&engine, host_state); let instance = Example::instantiate(&mut store, &component, &linker)?; // Call the exported function and print the string. let s = instance.call_hello_world(&mut store, "Nezha")?; println!("WASM said: {}", s); let json = instance.call_get_json(&mut store, "https://jsonplaceholder.typicode.com/todos/2")?; println!("Fetched JSON: {}", json); Ok(()) }and then use this command - [for emulator but same for other arch like arm64 etc]
cargo build -v --target x86_64-linux-androidI also tried these things -
- first added the
linux_raw_sys-> didn't help just produced more error something like"use of unresolved module or unlinked- then I disabled the
default_feature=false-> It did helped me to compile it for android but now it only support.cwasmwhich is not bad but it require platform specific comiplation as fast I saw since it was rasing error likethis is only compiled for windows, etcand also It is now what I thought when started plugin dev using component model.So these are things I tried (took lot of time to research cause there are less and less article and explanation) and failed miserably. And the whole ideas was to create a fast cross platform (specially the mobile devices) plugins for my app cause that will literally change the world for plugin dev if it work on almost all platform without any these errors.
Expected Results
If I am doing something wrong then please make this thread for the specially for ref material for future programmers so that they can also develop android library embedded with
wasmtime runtime. And try to sprinkle as much as info about this so that if you are facing some problems then any android developer can extend this feature forwasmtime.Cause right now
wasmtimeis the only library which support component model fully not other library come near to it. So it will help a lot this new emerging community if people use this then they will likely raise more issue and people contribute more.Actual Results
Errors as state above
Versions and Environment
Wasmtime version or commit: v36.0.2
Operating system: Windows 11
Architecture: -
Extra Info
building for android targets
- cargo build -v --target x86_64-linux-android
etcThanks you so much for making this awesome support of component model and the feature rich wasm runtime it is really a great deal for me.
rinthnoid added the bug label to Issue #11716.
alexcrichton closed issue #11716:
Hi contributors,
I made some plugins using WASM's component model in rust using cargo component build command and voila it worked perfectly for windows for me.But the problem arises when I tried to compile it for android from same program same os (windows) it was hell of a nightmare to be able embed the
wasmtimeinto a rust library and It took plain 3 days to still to figure out that it is somehow not possible for android right now (at least for now) so it just wasted a 3 days and nights :expressionless:.I got something like this in error when compiling for android -
. . . error[E0433]: failed to resolve: use of unresolved module or unlinked crate `linux_raw_sys` --> D:\Programs\.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\rustix-1.1.2\src\thread\prctl.rs:257:16 | 257 | IPCOwner = linux_raw_sys::general::CAP_IPC_OWNER, | ^^^^^^^^^^^^^ use of unresolved module or unlinked crate `linux_raw_sys` | = help: if you wanted to use a crate named `linux_raw_sys`, use `cargo add linux_raw_sys` to add it to your `Cargo.toml` error[E0433]: failed to resolve: use of unresolved module or unlinked crate `linux_raw_sys` --> D:\Programs\.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\rustix-1.1.2\src\thread\prctl.rs:259:20 | 259 | SystemModule = linux_raw_sys::general::CAP_SYS_MODULE, | ^^^^^^^^^^^^^ use of unresolved module or unlinked crate `linux_raw_sys` | = help: if you wanted to use a crate named `linux_raw_sys`, use `cargo add linux_raw_sys` to add it to your `Cargo.toml` error[E0433]: failed to resolve: use of unresolved module or unlinked crate `linux_raw_sys` --> D:\Programs\.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\rustix-1.1.2\src\thread\prctl.rs:262:19 | 262 | SystemRawIO = linux_raw_sys::general::CAP_SYS_RAWIO, | ^^^^^^^^^^^^^ use of unresolved module or unlinked crate `linux_raw_sys` | = help: if you wanted to use a crate named `linux_raw_sys`, use `cargo add linux_raw_sys` to add it to your `Cargo.toml` . . . .I also made an easy reproducible example
// src/main.rs use anyhow::Result; use wasmtime::{Config, Engine, Store, StoreContextMut}; use wasmtime::component::{Component, Linker, ResourceTable}; use wasmtime_wasi::{p2,WasiCtx, WasiCtxView, WasiView}; use reqwest::{blocking::Client,}; wasmtime::component::bindgen!({ inline: r#" package component:adder; world example { import log: func(s: string); import fetch-http: func(url: string) -> string; export hello-world: func(name: string) -> string; export get-json: func(url: string) -> string; } "#, }); /// Per-store host state required by wasmtime-wasi. struct Host { wasi: WasiCtx, table: ResourceTable, } impl WasiView for Host { fn ctx(&mut self) -> WasiCtxView<'_> { WasiCtxView { ctx: &mut self.wasi, table: &mut self.table, } } } fn build_host_state() -> Host { // Configure the WasiCtx (inherit host stdio so guest prints appear in host console). let mut builder = WasiCtx::builder(); builder.inherit_stdio(); Host { wasi: builder.build(), table: ResourceTable::new(), } } fn main() -> Result<()> { // Engine configured for the component model (synchronous mode). let mut config = Config::new(); config.wasm_component_model(true); config.async_support(false); let engine = Engine::new(&config)?; // Load the component compiled from your component crate. let component = Component::from_file(&engine, "./adder.wasm")?; // Linker for host imports; parameterized by our Host state. let mut linker: Linker<Host> = Linker::new(&engine); // Register WASI Preview-2 implementations into the linker (sync API). p2::add_to_linker_sync(&mut linker)?; // Provide the implementation for the `log` function that the component imports. linker.root().func_wrap("log", |mut _cx: StoreContextMut<'_, Host>, (s,): (String,)| { println!("Guest says: {}", s); Ok(()) })?; // Provide a simple implementation for the `fetch-http` function that the component imports. linker.root().func_wrap("fetch-http", |mut _cx: StoreContextMut<'_, Host>, (url,): (String,)| { println!("Fetching URL: {}", url); let json_response = match Client::new().get(&url).send() { Ok(resp) => match resp.text() { Ok(body) => body, Err(e) => format!("error reading response body: {}", e), }, Err(e) => format!("request error: {}", e), }; Ok((json_response,)) })?; // Create the store (holds our Host state) and instantiate the component. let host_state = build_host_state(); let mut store = Store::new(&engine, host_state); let instance = Example::instantiate(&mut store, &component, &linker)?; // Call the exported function and print the string. let s = instance.call_hello_world(&mut store, "Nezha")?; println!("WASM said: {}", s); let json = instance.call_get_json(&mut store, "https://jsonplaceholder.typicode.com/todos/2")?; println!("Fetched JSON: {}", json); Ok(()) }and then use this command - [for emulator but same for other arch like arm64 etc]
cargo build -v --target x86_64-linux-androidI also tried these things -
- first added the
linux_raw_sys-> didn't help just produced more error something like"use of unresolved module or unlinked- then I disabled the
default_feature=false-> It did helped me to compile it for android but now it only support.cwasmwhich is not bad but it require platform specific comiplation as fast I saw since it was rasing error likethis is only compiled for windows, etcand also It is now what I thought when started plugin dev using component model.So these are things I tried (took lot of time to research cause there are less and less article and explanation) and failed miserably. And the whole ideas was to create a fast cross platform (specially the mobile devices) plugins for my app cause that will literally change the world for plugin dev if it work on almost all platform without any these errors.
Expected Results
If I am doing something wrong then please make this thread for the specially for ref material for future programmers so that they can also develop android library embedded with
wasmtime runtime. And try to sprinkle as much as info about this so that if you are facing some problems then any android developer can extend this feature forwasmtime.Cause right now
wasmtimeis the only library which support component model fully not other library come near to it. So it will help a lot this new emerging community if people use this then they will likely raise more issue and people contribute more.Actual Results
Errors as state above
Versions and Environment
Wasmtime version or commit: v36.0.2
Operating system: Windows 11
Architecture: -
Extra Info
building for android targets
- cargo build -v --target x86_64-linux-android
etcThanks you so much for making this awesome support of component model and the feature rich wasm runtime it is really a great deal for me.
alexcrichton commented on issue #11716:
Thanks for the report, but this is not something we can reasonably fix/handle in Wasmtime. Some possible pointers for you, however, are:
- The
x86_64-linux-androidtarget is tier 3 for Wasmtime meaning we have no maintainer and no testing for the target. All we verify is that things build on CI. This is a reflection of a lack of expertise in this target, so we're generally unable to help out with build issues.- The Rust project has official target documentation which is somewhat sparse for Android, but that's where official Rust docs would be about building for Android.
- I understand how build errors can be confusing but your attempted workarounds are drastically changing the meaning of what you're building. It's unlikely you can blindly apply fixes without understanding what they're doing to try to get and end result. For example this is a compilation error in a dependency of Wasmtime,
rustix, which is not developed in this repository. While that is still related to Wasmtime insofar as it's a dependency it's unlikely to help finding a resolution by posting this on a dependent ofrustixas opposed torustixitself. Furthermore adding dependencies to your project such aslinux_raw_syshas no effect on dependencies, which is why that ended up changing nothing. When you disable features you're removing dependencies from the build, but as you've seen you're changing the meaning of what you're building.- If you're having issues with cross-compiling cwasms, have you read over documentation at https://docs.wasmtime.dev/examples-pre-compiling-wasm.html?
There's unfortunately not really much we can do in this repository here about this. We do not have expertise for Android available to help out. This might be a bug in
rustix, but I do not personally have the expertise in that area to say whether it is or not.Given that this looks like a general toolchain issue, build configuration issue, or an issue in a dependency on a tier 3 platform, I'm going to close this. Wasmtime does not guarantee that it works on Android at this time due to the tier 3 target status (a result of the lack of expertise amongst maintainers on Android). As such we can't guarantee that free support is available for platforms like this.
It's fine to continue discussion here, and if a Wasmtime-related fix is necessary I'm happy to reopen.
Ludea commented on issue #11716:
Relevant issue: https://github.com/bytecodealliance/rustix/issues/1519
rinthnoid commented on issue #11716:
Thanks @alexcrichton for citing some info for me as well as future developers I think It will help us lot for this direction and will look forward if I will able to learn something with that .
and Thanks @Ludea for referencing this issue I think it is being followed specially in
rustixlibrary finally!! I will follow it there too.:blush::raised_hands:
Last updated: Dec 06 2025 at 06:05 UTC