I am trying to cross-compile llvm/clang for Android arm.
I export the CC/CXX variables to the arm-linux-androideabi cross compilers, and then from my build folder I execute:
cmake -G "Unix Makefiles" --target arm-linux-androideabi --sysroot=$NDK/platforms/android-21/arch-arm/ ../llvm
The build folder is in the same directory with the llvm source code.
I get the error:
rm-linux-androideabi-g++: error: unrecognized command line option '-m32'
I know, it has something to do with g++ multilib
for arm-linux
but I cannot find it in the NDK.
I have also tried all the steps that are listed here, and the guide found here, with no luck.
Any help would be greatly appreciated. Thanks!
EDIT: NOw I am using the following command:
cmake -G "Unix Makefiles" --prefix=../outarm --target arm-linux-androideabi --sysroot=$NDK/platforms/android-21/arch-arm/ -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PIC=False -DCMAKE_CROSSCOMPILING=True -DLLVM_TABLEGEN=../osxbuild/bin/llvm-tblgen -DCLANG_TABLEGEN=../osxbuild/bin/clang-tblgen -DLLVM_TARGET_ARCH=ARM -DLLVM_TARGETS_TO_BUILD=ARM ../llvm
The compilation now begins, but it stops at 14% with the error:
arm-linux-androideabi-g++: error: unrecognized command line option '-bundle'
EDIT2:
I removed all the relative paths to absolute ones.
And changed the compiler from gcc to clang. Clang recognises -bundle
, but it does not use it. The full command w/ the error now is:
Command:
cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=$HOME/Desktop/clang-compilation/outarm -DCMAKE_BUILD_TYPE=Release -DLLVM_DEFAULT_TARGET_TRIPLE=arm-linux-androideabi --sysroot=$NDK/platforms/android-21/arch-arm/ -DLLVM_ENABLE_PIC=False -DLLVM_TARGET_ARCH=ARM -DLLVM_TARGETS_TO_BUILD=ARM -DLLVM_TABLEGEN=$HOME/Desktop/clang-compilation/osxbuild/bin/llvm-tblgen -DCLANG_TABLEGEN=$HOME/Desktop/clang-compilation/osxbuild/bin/clang-tblgen -DCMAKE_CXX_FLAGS='-I$HOME/android/toolchains/gcc/include/c++/4.9/arm-linux-androideabi -I$HOME/android/toolchains/gcc/include/' $HOME/Desktop/clang-compilation/llvm
make -j12
Error message: clang36++: warning: argument unused during compilation: '-bundle' /Users/paschalis/android/toolchains/gcc/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld: fatal error: -f/--auxiliary may not be used without -shared
Easiest way to build clang for android is:
source build/envsetup.sh
)mm
command to build AOSP root/platform/ndk
build/tools/build-llvm.py
(see here)AOSP/out
folder