Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to compile LLVM libraries to android/ARM

Tags:

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.

like image 707
Sid Kshatriya Avatar asked Jul 12 '11 14:07

Sid Kshatriya


People also ask

Does Android use LLVM?

For Android NDK, llvm became the default toolchain since r13b and gcc was removed since r18b. According to toolchains directory toolchains/llvm/prebuilt/darwin-x86_64 , llvm supports all the ABIs, i.e. x86, x86_64, arm, arm64.

Does GCC use LLVM?

How Is LLVM Different From GCC? LLVM and the GNU Compiler Collection (GCC) are both compilers. The difference is that GCC supports a number of programming languages while LLVM isn't a compiler for any given language. LLVM is a framework to generate object code from any kind of source code.

Can Clang cross compile?

On the other hand, Clang/LLVM is natively a cross-compiler, meaning that one set of programs can compile to all targets by setting the -target option.


3 Answers

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.

like image 91
Smart Android Apps Avatar answered Oct 27 '22 09:10

Smart Android Apps


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.

like image 44
Anton Korobeynikov Avatar answered Oct 27 '22 11:10

Anton Korobeynikov


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.

like image 32
Shawn Walton Avatar answered Oct 27 '22 11:10

Shawn Walton