Eliminater74
6/7/2017 - 12:33 AM

clang/LLVM for Android ARM64 corss compile script

clang/LLVM for Android ARM64 corss compile script

#!/bin/bash

rm -rf CMake*

export NDK=/home/syoyo/local/android-ndk-r10e
export SYSROOT=$NDK/platforms/android-21/arch-arm64

export CC="$NDK/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/aarch64-linux-android-gcc"

export CXX="$NDK/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/aarch64-linux-android-g++"

export CFLAGS="--sysroot=$SYSROOT"
export CXXFLAGS="-std=c++11 -I$NDK/sources/cxx-stl/gnu-libstdc++/4.9/include -I$NDK/sources/cxx-stl/gnu-libstdc++/4.9/libs/arm64-v8a/include --sysroot=$SYSROOT"
export LDFLAGS="-L$NDK/sources/cxx-stl/gnu-libstdc++/4.9/libs/arm64-v8a -lgnustl_shared -lm"

cmake -Bbuild ../llvm -DCMAKE_CROSSCOMPILING=True -DCMAKE_INSTALL_PREFIX=$HOME/local/android-cross \
	-DCMAKE_C_COMPILER=$CC \
	-DLLVM_TABLEGEN=/home/syoyo/work/llvm-build/bin/llvm-tblgen \
	-DCLANG_TABLEGEN=/home/syoyo/work/llvm-build/bin/clang-tblgen \
	-DLLVM_DEFAULT_TARGET_TRIPLE=arm-linux-gnueabihf \
	-DLLVM_TARGET_ARCH=ARM \
	-DLLVM_TARGETS_TO_BUILD=ARM