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

feat(vm) Add support for iOS #1832

Closed
Connoropolous opened this issue Nov 22, 2020 · 10 comments
Closed

feat(vm) Add support for iOS #1832

Connoropolous opened this issue Nov 22, 2020 · 10 comments
Labels
🎉 enhancement New feature! 📦 lib-vm About wasmer-vm
Milestone

Comments

@Connoropolous
Copy link

Summary

Is IOS on the roadmap for wasmer anywhere, and if so does it have a predicted timeline?
I noted there is VERY recent support for the new apple silicon chips.

Additional details

I was trying to compile a project with a dependency on (https://github.com/holochain/holochain) (with target aarch64-apple-ios ) which has a dependency currently on wasmer-runtime-core v0.16.2 and discovered that we can't build wasmer-runtime-core for that target.

Holochain uses wasmer for executing apps built on their p2p framework... and I am interested in running those p2p apps in native ios applications.

This was the issue that was popping up when I tried...

error[E0425]: cannot find function `get_fault_info` in this scope
   --> /Users/x/.cargo/registry/src/github.com-1ecc6299db9ec823/wasmer-runtime-core-0.16.2/src/fault.rs:285:21
    |
285 |         let fault = get_fault_info(siginfo as _, ucontext);
    |                     ^^^^^^^^^^^^^^ not found in this scope
@Connoropolous Connoropolous added the ❓ question I've a question! label Nov 22, 2020
@MarkMcCaskey
Copy link
Contributor

Hey @Connoropolous, we hope to run Wasmer pretty much everywhere in the future!

However, iOS in particular is fairly tricky as Apple does not allow JITs in the app store. However it should be possible to use precompiled Wasm modules with Wasmer or execute the Wasm without a JIT.

You might have better luck with Wasmer 1.0.0-alpha* releases of Wasmer / the latest version on master, but I imagine there's likely to be more cases similar to the one you ran into above.

@Connoropolous
Copy link
Author

@MarkMcCaskey thanks for the info! On latest releases has it been tried to compile for apple-ios targets, or are you confident from your background knowledge that it won't work? (I will try if you haven't tried, just to see)

@syrusakbary
Copy link
Member

The issue is not that it won't work, but that Apple have never approved any app in the store that uses JIT compilation techniques.

However, the JIT restriction might have changed in iOS 14.2 - https://9to5mac.com/2020/11/06/ios-14-2-brings-jit-compilation-support-which-enables-emulation-apps-at-full-performance/

So I'd encourage you to try it out and post here your findings!

@Connoropolous
Copy link
Author

Connoropolous commented Nov 26, 2020

My first findings suggest there would need to be PRs put through to make it happen, it's not quite there. Good to hear that Apple could open to this.

This is attempting to compile from version 1.0.0-alpha5
cargo build --release --target x86_64-apple-ios --manifest-path lib/deprecated/runtime/Cargo.toml
and with aarch64-apple-ios

error: unsupported platform
--> /Users/x/code/rsm/wasmer/lib/vm/src/trap/traphandlers.rs:209:21
|
209 | compile_error!("unsupported platform");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0425]: cannot find function pthread_getattr_np in crate libc
--> /Users/x/code/rsm/wasmer/lib/vm/src/trap/traphandlers.rs:94:19
|
94 | libc::pthread_getattr_np(this_thread, &mut thread_attrs);
| ^^^^^^^^^^^^^^^^^^ help: a function with a similar name exists: pthread_getname_np
|
::: /Users/x/.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.73/src/unix/bsd/apple/mod.rs:3393:5
|
3393 | / pub fn pthread_getname_np(
3394 | | thread: ::pthread_t,
3395 | | name: *mut ::c_char,
3396 | | len: ::size_t,
3397 | | ) -> ::c_int;
| |_________________- similarly named function pthread_getname_np defined here

error[E0425]: cannot find function pthread_attr_getstack in crate libc
--> /Users/x/code/rsm/wasmer/lib/vm/src/trap/traphandlers.rs:97:19
|
97 | libc::pthread_attr_getstack(&thread_attrs, &mut stackaddr, &mut stacksize);
| ^^^^^^^^^^^^^^^^^^^^^ help: a function with a similar name exists: pthread_attr_destroy
|
::: /Users/connor/.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.73/src/unix/mod.rs:1089:5
|
1089 | pub fn pthread_attr_destroy(attr: *mut ::pthread_attr_t) -> ::c_int;
| -------------------------------------------------------------------- similarly named function pthread_attr_destroy defined here

error[E0308]: mismatched types
--> /Users/x/code/rsm/wasmer/lib/vm/src/trap/traphandlers.rs:194:52
|
194 | 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 4 previous errors

@panicfrog
Copy link

in the website, i found that the wasmer can run on iOS Android, how to do that?

@kkebo
Copy link

kkebo commented Apr 22, 2021

@panicfrog You misunderstood about it. It just says that WebAssembly can run on iOS, not Wasmer.

@Hywan Hywan added 🎉 enhancement New feature! 📦 lib-vm About wasmer-vm and removed ❓ question I've a question! labels Jul 16, 2021
@Hywan Hywan changed the title IOS support feat(vm) Add support for iOS Jul 16, 2021
@NathHorrigan
Copy link
Contributor

Hi @Hywan ,

I've seen you've had some activity on this issue.

I've been trying to compile Wasmer to iOS using the dylib engine but having issues with each compiler that I use.

Currently I'm trying LLVM but once I drag the libwasmer.a file to Xcode and run I get the following error. Any ideas?

ld: in /.../example/ios/libwasmer.a(Scalar.cpp.o), archive member 'Scalar.cpp.o' with length 19360 is not mach-o or llvm bitcode for architecture arm64

@Hywan
Copy link
Contributor

Hywan commented Aug 12, 2021

Can be kinda relevant #2516.

@syrusakbary
Copy link
Member

As of this PR: #2535 we now support iOS on Wasmer master (the version 2.0.1/2.1.0 will be released soon

@afa7789
Copy link

afa7789 commented Apr 13, 2022

https://wasmer.io/posts/wasmer-2.1
https://stackoverflow.com/questions/68963743/how-to-use-wasmer-in-ios

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🎉 enhancement New feature! 📦 lib-vm About wasmer-vm
Projects
None yet
Development

No branches or pull requests

9 participants