[Not noob friendly.]
- Clone this toolchain repo in tools folder
$ git clone https://github.com/mranonymz/android-kernel-tools.git tools- Set path according to your choice.
PATH="tools/build-tools/linux-x86/bin:$PATH"
PATH="tools/build-tools/path/linux-x86:$PATH"
PATH="tools/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin:$PATH"
PATH="tools/gcc/linux-x86/arm/arm-linux-androideabi-4.9/bin:$PATH"
PATH="tools/clang/host/linux-x86/**clang-r407598**/bin:$PATH"
PATH="tools/misc/linux-x86/lz4:$PATH"
PATH="tools/misc/linux-x86/dtc:$PATH"
PATH="tools/misc/linux-x86/libufdt:$PATH"
export LD_LIBRARY_PATH="tools/clang/host/linux-x86/**clang-r407598**/lib64:$LD_LIBRARY_PATH"Here clang-r353983d for AOSP clang 9.0.4 and clang-r399163b for AOSP clang 11.0.5. and clang-r407598 for AOSP clang 12.0.1.
- Use these command for compiling with clang.
$ make \
O=out \
ARCH=arm64 \
SUBARCH=ARM64 \
CC=clang \
HOSTCC=clang \
HOSTCXX=clang++ \
CLANG_TRIPLE=aarch64-linux-gnu- \
CROSS_COMPILE=aarch64-linux-android- \
CROSS_COMPILE_ARM32=arm-linux-androideabi- \
${DEVICE}_defconfig- Use this command for compiling only with gcc.
$ make \
O=out \
ARCH=arm64 \
SUBARCH=ARM64 \
CLANG_TRIPLE=aarch64-linux-gnu- \
CROSS_COMPILE=aarch64-linux-android- \
CROSS_COMPILE_ARM32=arm-linux-androideabi- \
${DEVICE}_defconfigHere ${DEVICE}_defconfig is the kernel config file used to compile kernel.