wasmer
wasmer copied to clipboard
Add support for Android NDK
Describe the bug
device: x86_64-linux os: centos7.7 wasmer version: 1.0.1,1.0.2, master cmd: make build-capi build tool: https://github.com/bbqsrc/cargo-ndk I got these errors for aarch64-linux-android on all wamser version:
Compiling wasmer-c-api v1.0.2 (/data/wasmer-master/lib/c-api)
error: unsupported platform
--> lib/vm/src/trap/traphandlers.rs:275:21
|
275 | compile_error!("unsupported platform");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0599]: no method named `si_addr` found for struct `siginfo_t` in the current scope
--> lib/vm/src/trap/traphandlers.rs:119:43
|
119 | let addr = (*siginfo).si_addr() as usize;
| ^^^^^^^ method not found in `siginfo_t`
error[E0308]: mismatched types
--> lib/vm/src/trap/traphandlers.rs:197:52
|
197 | unsafe fn get_pc(cx: *mut libc::c_void) -> *const u8 {
| ------ ^^^^^^^^^ expected *-ptr, found `()`
| |
| implicitly returns `()` as its body has no tail or `return` expression
|
= note: expected raw pointer `*const u8`
found unit type `()`
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0308, E0599.
For more information about an error, try `rustc --explain E0308`.
error: could not compile `wasmer-vm`
Hello,
As the error says, the targeted platform isn't supported yet by the runtime. What's your usecase or project :-)?
@Hywan Thanks for your replay. I want to use wasmer for embedded-use in unity3d game.
And this game runs on an Android platform, is that correct?
Yes, It's just like lua. my main purpose is do some thing like hot reload scripts to fix game bugs on android/ios
Let me see if we can push this idea further. cc @syrusakbary
I would also really love to see Android support.
There are many use cases. The main benefit is that it would make using C or Rust code in Android apps much, much easier, because you wouldn't need to deal with the hassle of handling native compilation.
This would especially be true if https://github.com/wasmerio/wasmer-java had pre-built JARs for the various Android architectures.
Please also note that Android has multiple ABIs. (See https://developer.android.com/ndk/guides/abis )
By far the most important one is armeabi-v7a, followed by arm64-v8a.
Thank you for your comment.
This would also support building Rust libs / apps that depend on wasmer on Termux. e.g. zellij uses wasm plugins
Would love to see support for Android. For me the build error is mman::shm_open not being available for Android. My use case is to make the Solidity compiler portable across all platforms supported by wasmer by embedding the wasm module.
+1
~Looks like the Termux guys actually got it to compile on Android?~
~https://github.com/termux/termux-packages/pull/7982~
~Is it possible we bring their patch here to make things work? I would like to give it a try this weekend.~
Nvm I overlooked the part where it says ARM builds are not supported yet.
Update:
I just tested building wasmer-vm and it works:
$ rustc -vV
rustc 1.64.0
binary: rustc
commit-hash: unknown
commit-date: unknown
host: aarch64-linux-android
release: 1.64.0
LLVM version: 15.0.1
$ cargo build --package wasmer-vm
Repo checked out at tag 2.3.0.
I was able to use Zellij on Android after bumping wasmer to 2.3.0: https://github.com/zellij-org/zellij/issues/1021#issuecomment-1300565593
There's also a Termux package for wasmer that builds without applying custom patches.
So I think this issue is already resolved? In that case maybe someone from the team can close this to avoid confusion on Android support. Having an open issue gives the wrong (?) impression that it's not supported.
Hey I just built my library (which uses wasmer) to all android targets using cargo-ndk. So just to confirm, this issue can be closed :smile:
Awesome, closing the issue
Are android and ios officially supported now? I haven't seen relevant documents
I think it's supported in the sense that "it works now", not in that the team would put in work on bug fixes etc.