Julia on iOS and Android


#1

Can anyone see any path towards running Julia code on iOS / Android?

It would be fantastic to be able to solve the two-language problem (e.g. prototyping in Python and deploying in C++).

The idea would be to release an app on the app-store that contains a Julia kernel.

Would it be possible to get Julia to precompile the Julia code, so that it generates a binary library exposing C-style functions, and the iOS/Android code could link against this library?

Something like this could massively accelerate the development of apps that require complex mathematics.

And how about the full-blown Julia process of dynamic compilation? Apple has a ‘no compilers’ rule but IIRC it has allowed many apps that violate this rule in the past. If the app consumer is allowed to write and execute arbitrary Julia code this may fall foul, but if the developer is the only one writing the Julia code then Apple may be willing to allow it.

π


Building -- and releasing -- a fully self-contained Application written in julia
#2

I use Julia on Android but it is not a direct way because Android’s own libc and ABI is not compatible with Julia’s generic binaries. However, having small linux directory and using proot through termux terminal app I can use Julia as if I am in regular linux. Some functions are not still usable but computationally I did not see any unusable features. Also, I use IJulia to interface Julia to a browser app instead of terminal screen.
Nontheless, this way may not work in the future Android releases as google restricts more user space features and deviates from regular linux.


#3

I have it running natively compiled using termux.


#4

Could you say more? You have it running on both iOS and Android? Could you detail the process?

Has anyone managed iOS?


#5

Just android.
ios would he a lot harder due to the restrictions they have on apps and executing native code.


#6

i have a github account with a fork of julia. Termux provides a llvm clang etc and i have added gcc with gfortran and openblas. etc
This allows me to compile julia on device. Unless someone with more knowledge of Julia than i can get cross compiling working ( there is one guy trying afaik ) what i have done is the best there is for now with regards to geting julia that runs on the bionic libc aka real android.


#7

The issue you’re going to run into with iOS is not App Store restrictions, but the fact that you cannot mark writable memory pages as executable. This is a security “feature”, but also means that any sort of JIT compilation just plain does not work.


#8

That’s a good knowledge.

Should it be possible to precompile Julia code & ship the binary on iOS?

Basically I’m designing a complex algorithm that ships as a (binary) library. I’m currently prototyping in Python and then coding up in C++.

It would be fantastic if I was able to simply code it up in Julia.


#9

In theory, yes, there should be no issue with shipping a compiled binary.

(BTW, for background I used to work on MacRuby and am familiar with the techniques that had to be employed for RubyMotion to deploy on iOS.)

The problem, of course, is maintaining dynamism while doing so. If all your types are specified in advance, it’s no problem. If not, then you need to (re-)implement dynamic dispatch that doesn’t require JIT’ing. See here for a (very advanced) dive into how Obj-C and Swift handle dynamic dispatch differently.


#10

I’m crosslinking Building -- and releasing -- a fully self-contained Application written in julia


#11

Hello its-pointless, could you please tell me how did you install gfortran on your device? termux doesn’t have gfortran, libatomic nor awk, which are build dependencies too.


#12

sure i have a seperate repo with all the needed packages at https://github.com/its-pointless/gcc_termux if you follow instructions in README.txt its relatively straight forward. From there you can install julia directly or you can clone https://github.com/its-pointless/julia and build it yourself.


#13

I’m cloning your julia fork, I’m exited! :slight_smile: Thanks!


#14

I’m getting uv.h not found, and “cannot find lbthread”, I’m reading all your comments I can find, but I’m not sure how to proceed. :open_mouth:

I’m stuck at the run: “setupclang and setupgcc-7” I don’t understand where should I get those commands.


#15

need to install bthread-dev. Its a pthread-cancel implementation for android. Its needed for julia’s libuv which is different.
The command
./buildjulia-termux.sh
should be enough as long as you installed the dependencies. Or i failed. One of those ones.


#16

After installing that I’m getting this new error:

clang

ln -sf /data/data/com.termux/files/usr/lib/libmpfr.so /data/data/com.termux/files/home/bin/julia/usr/lib/julia
    CC src/APInt-C.o
clang-6.0: warning: optimization flag '-falign-functions' is not supported [-Wignored-optimization-argument]
In file included from /data/data/com.termux/files/home/bin/julia/src/APInt-C.cpp:3:
./llvm-version.h:3:10: fatal error: 'llvm/Config/llvm-config.h' file not found
#include <llvm/Config/llvm-config.h>
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~                                                    1 error generated.
make[1]: *** [Makefile:136: APInt-C.o] Error 1
make: *** [Makefile:97: julia-src-release] Error 2
$

gcc

 ln -sf /data/data/com.termux/files/usr/lib/libmpfr.so /data/data/com.termux/files/home/bin/julia/usr/lib/julia                                                        CC src/APInt-C.o
g++: warning: unrecognized command line option '-Wcovered-switch-default'; did you mean '-Wno-switch-defaul'?
g++: warning: unrecognized command line option '-Wstring-conversion'; did you mean '-Wint-conversion'?
cc1plus: error: unrecognized command line option '-Wcovered-switch-default'
cc1plus: error: unrecognized command line option '-Wstring-conversion'
make[1]: *** [Makefile:136: APInt-C.o] Error 1
make: *** [Makefile:97: julia-src-release] Error 2
$

#17

yeah probably need all the llvm bits as well
libllvm-dev llvm libclang-dev etc

setupclang-gfort-7
is you want to run before you execute the script


#18

I really really apreciate all your help, I know that all this must seem implicit to you, but I promise I’ll make a blog post to document it, this is truly awesome. :sparkles:


#19

Oh god, this one is more cryptic:

Segmentation fault                           
make[1]: *** [Makefile:187: /data/data/com.termux/files/home/bin/julia/usr/lib/julia/libgit2.so] Error 139 
make: *** [Makefile:91: julia-base] Error 2           
$

#20

need to install system libgit2-dev ?