Skip to content

Add iOS support to Substrate VM #373

Closed

Description

@sirthias

If Substract VM allowed for writing libraries in any of the supported languages (most importantly Java) and these libraries could be called into from iOS application code (written in Swift or Objective-C) then this would be a complete game changer for the "holy grail" of mobile development: Joint code bases for truly native mobile applications.

Rich client logic could then be written purely in Java, packaged as a library and be usable from thin layers of UI code on either platform. Currently this is not properly possible.
There are a few tools promising a solution in that area (e.g. Robo VM or Multi-OS-Engine), but they all come with quite a few strings attached and severely lack the technological soundness of Graal.

It'd be absolutely awesome if Graal would finally be the tool to properly bridge this so far insurmountable chasm between the two major mobile universes.

Activity

  1. cstancu commented on Apr 23, 2018

    @cstancu
    Member

    Hi @sirthias, iOS support is on our TODO list. AFAIK the kernel design on iOS is essentially the same as macOS, which we currently support. But first we need to implement AArch64 support. The Graal team is already working on an AArch64 back-end. Once that is implemented we need to extend the AArch64 support to SubstrateVM. Then we can support JVM languages that are currently supported on other platforms, i.e, Java, Scala, Kotlin, etc. As for other languages, i.e., JS, Python, etc., they are implemented using Truffle/Graal on top of SubstrateVM and interpreted/JITed at runtime. On iOS you cannot allocate executable memory so JITing is not possible. However you can still run Truffle languages in interpreter mode.

  2. sirthias commented on Apr 23, 2018

    @sirthias
    Author

    Thank you for this additional info, @cstancu!
    So, JVM languages will be supported (eventually) via SubstrateVM's AOT compiler, but everything requiring Truffle/Graal can never be supported since JITting is disallowed on iOS.

    While it'd be theoretically better to also have JS, Python, Ruby, etc. supported on iOS I'd say that the by far more important target is Java (and other JVM languages) since they are what people are already using on the Android side.

    So to me the prospect of having SubstrateVM-powered Java/Scala/Kotlin/Closure-libraries run nicely on iOS is absolutely fantastic!

    What would you personally say, how long the AArch64 support will take to arrive in SubstrateVM?
    I know that estimates like this always have to be taken with several giant boulders of salt but it's still interesting to understand what the rough magnitude of this effort is and thus whether it's likely going to take months or rather years...

  3. cstancu commented on Apr 23, 2018

    @cstancu
    Member

    The Truffle languages can be supported as long as Truffle runs in interpreter mode. You won't get the same performance as with a JIT but it would still be useful for certain scenarios.

  4. cstancu commented on Apr 23, 2018

    @cstancu
    Member

    As for estimates, it is hard to give any estimate at this time, but it is definitely months not years. And of course we accept pull requests and would provide assistance if anyone wants to work on it.

  5. sirthias commented on Apr 24, 2018

    @sirthias
    Author

    Ok, great. Thank you, @cstancu!

  6. zaharidichev commented on May 22, 2018

    @zaharidichev

    Hi there @cstancu Thanks a lot for elaborating on these topics. So it appears to me that the two major pieces of work are finishing the AArch64 compiler backend and then providing support for that in SVM.

    Is there any kind of board outlining planned broken down work on any of these major tasks. Just asking because if there is any way to help, I would be more than glad to (although the matter can be at times intimidating).

    I see @daniel-stewart-qdt is doing some work on AArch64, so maybe he can provide some info on what the next planned steps are as well. In any case, willing to help where and how I can :)

  7. ScalaWilliam commented on Oct 27, 2018

    @ScalaWilliam

    This is interesting.

  8. priand commented on Jan 11, 2019

    @priand

    @cstancu Any ETA on the iOS support? As @sirthias said, having a AOT compiler for JVM based languages will be a game changer for the Java community.

  9. sanzinger commented on Jan 14, 2019

    @sanzinger
    Contributor

    We have no ETA for this. We are currently working on SubstrateVM on AArch64 for Linux (See #910). Other platforms are not decided yet.

    I hope this answers the original question.

  10. self-assigned this
    on Jan 14, 2019
  11. sirthias commented on Jan 16, 2019

    @sirthias
    Author

    @sanzinger The description text of this ticket does not include any question.
    Rather, this ticket was meant as a point of reference for other people looking for information about graal support for iOS. Judging from the number of upvotes and comments it appears to me as this ticket was actually doing this job.

    Therefore I am a bit surprised to see it simply being closed, especially since the PR you've referenced doesn't mention "iOS" anywhere.

    Does your closing of this ticket actually mean "Won't Fix"?
    If no, i.e. there hasn't been a decision to not support iOS eventually, would it maybe be better to keep this ticket open until such a decision has actually been made, iOS support is available or another ticket properly supersedes it?

  12. sanzinger commented on Jan 16, 2019

    @sanzinger
    Contributor

    At the moment we do not have a decision if we are going to support iOS. At the moment we are occupied getting AArch64/Linux running.

    I think we get a clear picture how iOS goes, when we have completed AArch64/Linux in a usable state.

  13. 11 remaining items

  14. sirthias commented on May 4, 2020

    @sirthias
    Author

    Ok, thank you for these details!
    I guess we could live with all but your 3rd point, but maybe it's related to your first.

    I'll definitely play around with your forks and try to get sth off the ground.
    The good thing is that, in our use case, the shared library would simply be a heap of rather complicated business logic and nothing that needs interacting with native libs.

    It would be great though to have proper threading support. Do you have any perspective on that? Did you encounter any issues wrt thread scheduling/concurrency abstractions?
    Without having given it a lot of thought yet I'd assume the substrate-based shared lib to behave like any other native ios library, with the ability to start and use "its own" threads or simply run on the caller thread.
    Are there any gotchas wrt the memory model? I would expect graal to make sure that all the JVM guarantees are properly upheld whatever the target platform but could imagine that there are certain edges cases that one should be aware of.

  15. CedricGatay commented on May 4, 2020

    @CedricGatay

    As far I remember, I had no concurrency issues / memory leaks during my testings (the framework is using akka / scala and makes use of concurrency).

    I don't know if the random crashes were due to JNI loading ,but I sincerely doubt it, as it was rather random and backtrace were not necessary involving native code. However I might have done things the wrong way (and Graal have evolved too).

    One of the "difficult" things was finding the proper LLVM / Graal combination to make the build "pass", afterwards it runs "properly".

  16. sirthias commented on May 4, 2020

    @sirthias
    Author

    Ok, thank you, Cedric!

  17. vjovanov commented on May 4, 2020

    @vjovanov
    Member

    @CedricGatay we have made quite a few improvements in the last couple of months:

    • The LLVM is shipped with Graal so there are no difficulties with finding the right version.
    • The LLVM backend passes all our tests.
    • The debug symbols are coming soon so the stack traces should become usable.
    • The build-time is improved quite a bit.

    We are currently working on improving testing on mobile devices.

    I was wondering about the artifact size, was it 200 MB with JavaFX or just your code?
    Asking because a lot of the overhead comes from JavaFX at the moment. For the shared library use case @sirthias is referring to, I don't expect the binary to be large.

  18. CedricGatay commented on May 4, 2020

    @CedricGatay

    Glad that most of the issues are being fixed @vjovanov !

    The binary size was coming from transitive dependencies I guess from the project I was building to native (https://github.com/ACINQ/eclair) without the GUI part (so without JFX parts). But it gets scala + akka as a base.

  19. vjovanov commented on May 4, 2020

    @vjovanov
    Member

    It would be great though to have proper threading support. Do you have any perspective on that? Did you encounter any issues wrt thread scheduling/concurrency abstractions?

    You can both start new threads and use the OS threads that are passed through the entry points. The memory model is the same as on the JVM.

  20. sirthias commented on May 4, 2020

    @sirthias
    Author

    The memory model is the same as on the JVM.

    Thank you, @vjovanov, that's what I assumed, as otherwise lots of things would fall apart.

  21. nhoughto commented on May 4, 2020

    @nhoughto

    The shared library is super interesting, compelling use case for us would be no jni etc. like kotlin mpp but without having to deal with kotlin migrations 🤔

    https://kotlinlang.org/docs/reference/multiplatform.html

  22. ScalaWilliam commented on Mar 20, 2021

    @ScalaWilliam

    @sanzinger @vjovanov when I google 'graalvm ios', this GitHub issue is the first result I see, and gives me the impression that iOS would not be supported by GraalVM.

    But then there are pages like this https://github.com/lazar-mitrovic/GraalREPL

    What is the situation? Can you share a clarification? It seems users could be very confused.

    I only know to look into this beyond this GitHub issue because I am familiar with JavaFX/ScalaFX, Gluon and the iOS announcements earlier.

    The reason why I am asking this is because I am currently writing an article about Scala on iOS/Android and noticed this is now a possibility through GraalVM/Gluon.

  23. frank-dspeed commented on Aug 19, 2021

    @frank-dspeed

    @ScalaWilliam long story short it is working already but there are edge cases like os specific parts for example "Only Interpreter Mode" that is what your seeing in that example

    So iOS is fully supported including webview via javaFx and so on.

    I am Not aware of the shared lib stuff but for application development it is working.

  24. insinfo commented on May 2, 2022

    @insinfo

    is it already possible to compile a native shared library written in java for iOS with GraalVM?

  25. frank-dspeed commented on May 3, 2022

    @frank-dspeed

    @insinfo your correct this is possible but not supported at present but the moving parts are in place even jvm on jvm works in android

  26. LifeIsStrange commented on Jul 31, 2022

    @LifeIsStrange

    It seems support for shared libraries on IOS is there! (not yet upstreamed)
    gluonhq/substrate@a1a6a37
    @vjovanov @jperedadnr
    Hope that means we are not far from a well working IOS support and from upstreaming to improve the default experience.

  27. frank-dspeed commented on Aug 1, 2022

    @frank-dspeed

    @LifeIsStrange that is only a example that builds for ios everything is from graalvm upstream glueon did not invent anything there :)

  28. hooji commented on Feb 3, 2025

    @hooji

    So, can we write a full iOS app in Java (including access to Apple APIs) and compile to native? If so, any tutorials/examples?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions