Search code examples
linux-kernelclangcross-compilingbetaandroid-11

Error when Compiling Linux Kernel for Android 11 (R) Beta version 1 with clang-r383902


I am using an Ubuntu 20.04 machine with the newest version of platform-tools installed and (I believe) all necessary dependencies.

I created a new directory ~/beta1-kernel-coral and within this directory I cloned the kernel:

git clone -b android-msm-coral-4.14-r-beta-1 https://android.googlesource.com/kernel/msm/

I noticed the clang version used was clang-r383902. I downloaded this directory and extracted it so that I had two separate directories within ~/beta1-kernel-coral: msm and clang-r383902.

From within ~/beta1-kernel-coral/msm, I ran two commands:

make floral_defconfig
make menuconfig

Next, using Nathan Chance's guide from Github, I ran the following command:

PATH="/home/jherwig/beta1-kernel-coral/clang-r383902/android_prebuilts_clang_host_linux-x86_clang-6443078-10.0/bin:/usr/bin:/usr/bin:${PATH}" make -j$(nproc --all) ARCH=arm64 CC=clang CLANG_TRIPLE=aarch64-linux-gnu- CROSS_COMPILE=aarch64-linux-android- CROSS_COMPILE_ARM32=arm-linux-androideabi-

The kernel began compiling until I received the following output:

https://pastebin.com/61pkd6uf

In Nathan's guide, he intructs to use:

PATH="<path to clang folder>/bin:<path to 64-bit gcc folder>/bin:<path to 32-bit gcc folder>/bin:${PATH}" \ ...

Since I installed gcc-multilib, I thought <path to 64-bit gcc folder> and <path to 32-bit gcc folder> would be in /usr/bin. When I type which gcc in terminal I get /usr/bin/gcc.


Solution

  • CAF kernels are NOT mainline kernels and you cannot compile them as such. You must run make distclean and specify an out directory for each make command, including the defconfig

    Example: make O=out

    If you do not specify O=out for each make command you'll hit these errors The value assigned to O can be anything, doesn't have to be out but you cannot build the kernel in the same directory as the source

    Change this:

    make floral_defconfig

    make menuconfig

    To this:

    make floral_defconfig O=out

    make menuconfig O=out

    The build it with:

    make O=out

    Remember to make distclean in the source directory first