Is it possible to compile LLVM libraries to android/ARM

12,476

Solution 1

It now seems possible, the NDK now supports Clang which uses LLVM. So maybe it can be made to work with any LLVM language. AOSP should give us some insight on how they added Clang support. See the latest Android NDK for details on Clang support.

Android NDK, Revision 8c (November 2012)
Important changes:
Added the Clang 3.1 compiler to the NDK. The GNU Compiler Collection (GCC) 4.6 is still the default, so you must explicitly enable the Clang compiler option as follows:
For ndk-build, export NDK_TOOLCHAIN_VERSION=clang3.1 or add this environment variable setting to Application.mk.
For standalone builds, add --llvm-version=3.1 to make-standalone-toolchain.sh and replace CC and CXX in your makefile with /bin/clang and /bin/clang++. See STANDALONE-TOOLCHAIN.html for details.
Note: This feature is experimental. Please try it and report any issues.

Solution 2

While you can surely compile LLVM on ARM (it's pretty trivial - just ordinary configure + make system), you're still out of luck: JIT on ARM is still work-in-progress, so I'd not expect it working for everything non-trivial.

Solution 3

It seems like the Android NDK would help in this, as one of its usages per its FAQ page is to reuse C/C++ code.

Solution 4

I think we shuld see on mix of LLVM + Android NDK (C++).

I'm thinking about SmallTalk-like dymanic object system (*), and LLVM usage is very interesting for lazy dynamic compilation on Android devices.

First try you shuld build something like tiny Buildroot/OpenWrt Linux system (or build you own using CLFS or my scripts: https://github.com/ponyatov/L/tree/clock ) for ARM device like Raspberry Pi (it's my case for testing). If you got good results on this variant, later you can migrate to Android device itself. I think you'll need some C++/NDK glue code to adopt LLVM/Pure core vs Android runtime and GUI. (**)

(*) but with my own language syntax, lisp-like functional abilities to mutate all system internals, parser/compiler integrated framework, and maybe some basics of symbolic computer algebra

(**) is Android Pi alive ?

Share:
12,476
Sid Kshatriya
Author by

Sid Kshatriya

I'm a Drupal Developer!

Updated on June 06, 2022

Comments

  • Sid Kshatriya
    Sid Kshatriya about 2 years

    I'm fascinated by the Pure algebraic/functional language. The Pure interpreter uses the LLVM JIT compiler as its backend.

    I would like to compile Pure so that it runs on Android(ARM). Pure has a dependency on the LLVM JIT. So I need to compile LLVM source for Pure to run.

    Is it possible to compile LLVM source for Android (ARM) devices? There really seems to be no information about this on the web. Maybe my search terms are wrong. Searching for Android LLVM does not bring up many good hits either.

  • SK-logic
    SK-logic almost 13 years
    It is perfectly possible to compile and run LLVM on ARM devices. Have not tested Android yet, but Debian is proved to be ok.
  • Sid Kshatriya
    Sid Kshatriya almost 13 years
    @SK-Logic: Seem to be no resources about how to go about this on the net.
  • NullPointer
    NullPointer almost 13 years
    @SK - Didn't know that. Would be helpful if you have any more links on the subject
  • SK-logic
    SK-logic almost 13 years
    @Sid NoParrots, @NullPointer - it is trivial, for cross-compilation you only need to set your CC and CXX variables to your cross-toolchain, and run llvm's configure script as configure --target=arm-linux --host=x86_64-linux --disable-shared --targets=arm (and whatever else you'd need). If you want to bootstrap an ARM llvm using llvm+clang, then it is a little bit more complicated, but yet possible.
  • Sid Kshatriya
    Sid Kshatriya almost 13 years
    Actually the question is LLVM on Android ARM which is slightly different from traditional Linux ARM due to bionic libraries etc.
  • Anton Korobeynikov
    Anton Korobeynikov almost 13 years
    @Sid, bionic is just ordinary C library. Given that you have decent C++ compiler, it's not a problem to build LLVM for any linux flavor, such as Android.
  • Sid Kshatriya
    Sid Kshatriya almost 13 years
    thanks for your answer. I'm aware of the NDK. The questions is whether its possible for the LLVM project to be compiled on android. Not every piece of C/C++ code will compile and work properly on android.