Skip to content

Instantly share code, notes, and snippets.

@syoyo
Created December 21, 2015 11:44
Show Gist options
  • Save syoyo/9acc46554723db14d3a5 to your computer and use it in GitHub Desktop.
Save syoyo/9acc46554723db14d3a5 to your computer and use it in GitHub Desktop.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment