androidllvmcross-compilingandroid-kernel

Google removed cross compilers for Android Kernel. Where are they now?


I've used UBERTC prebuilt cross compilers so far, but I get errors when compiling an android kernel, and they haven't updated their stuff since 2016, so I just would like to find an alternative.

Google should have them, obviosly. But I'm unable to find them. They should be here, but the repo is empty and the last commit says:

Remove aarch64-linux-android gcc-4.9 libs and includes

Android has moved to LLVM.

The bins were already removed. Remove everything else except for OWNERS.

So, I suppose they've moved them elsewhere. But where?

I wouldn't like to hear that you need to compile the whole AOSP tree to get to the compilers. I really hope there is another way.


Solution

  • I've found the old toolchain. The funny thing is: the latest commit before the repository was cleaned out does not contain gcc for some reason. So I had to "climb" up the git tree to find one which contains it. Here is 32-bit ARM toochain and 64-bit ARM toolchan. It's gcc 4.9 from back in 2019.

    What they meant by

    Android has moved to LLVM.

    is that you should be able to cross-compile kernels with clang and llvm and should not use their stand-alone solution anymore. But they didn't provide any info on how to do it. So yeah, nice job.

    Downloading looks like this:

    # clone the repo, it will be empty
    git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9 toolchain
    # go to the repo folder
    cd toolchain
    # use the hash of the commit to restore the commit which actually contains the toolchain
    git checkout e9b2ab0932573a0ca90cad11ab75d9619f19c458
    

    There are also alternative toolchains for those like myself, who haven't wrapped their heads around llvm and clang just yet. Here is one from arm.com based on gcc 11.2. There are also Linaro ones.

    Anyways, you should sometimes use the old toolchains to build older kernels, since new compilers tend to throw more warnings, which are treated by Makefile as errors by default. For example, I'm not able to compile my kernel with the arm.com ones, because they are too smart and spot too many warnings, which I haven't found a way to disable. Modifying the Makefile doesn't seem like a valid option, as it's ~2k lines long.

    If someone knows, how to disable those, I'd really love to know that too. But for now I'm gonna try to stick with the google toolchain for the older kernels.

    GLHF, lol.