Is it able to use clang to build hikey-linaro?

Hi, Hikey 960 experts,
I’m following this guide (Using Reference Boards  |  Android Open Source Project) to build kernel 4.14 for Hikey960. Everything goes fine and the new kernel can successfully run.
However, when compiling the kernel, it constantly warns me that Android GCC has been deprecated in favor of Clang, and will be removed from Android in 2020-01.
I wonder if hikey-linaro is able to be build by Clang. If so, do you have a guide? Thanks!

@jstultz any input on this one? I thought aosp kernel uses clang by default.

The build instructions still use gcc. I think that the snapshot builds are using clang.

This is what I use;

#!/bin/bash

AOSP_ROOT={set this as appropriate}

mPATH=$AOSP_ROOT/prebuilts/clang/host/linux-x86/clang-r353983c/bin:$AOSP_ROOT/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin

PATH=$mPATH:$PATH make ARCH=arm64 hikey960_defconfig
PATH=$mPATH:$PATH make ARCH=arm64 CC=clang CLANG_TRIPLE=aarch64-linux-gnu- CROSS_COMPILE=aarch64-linux-android- -j$(nproc)
3 Likes

Thank you! This works for me :slight_smile:

Thank you! This works for me. i think the resolution should tell all the people who build the hikey960 kernel.
also resolve the problem" aarch64-linux-android-gcc: Command not found"
and “Android GCC has been deprecated in favor of Clang, and will be removed from
Android in 2020-01 as per the deprecation plan in:
Android GCC 4.9 Deprecation Schedule

Hi,

I inquired internally and my colleague gave me the suggestion for the Clang version is updated to clang-r377782b [1].

So following @doitright script (excellent!), below is the updated one:

#!/bin/bash                                                                                                            
                                                                                                                       
AOSP_ROOT={set this as appropriate}                                                                                           
CLANG_VERSION=r377782b                                                                                                 
                                                                                                                       
mPATH=$AOSP_ROOT/prebuilts/clang/host/linux-x86/clang-$CLANG_VERSION/bin:$AOSP_ROOT/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin                                                                                             
                                                                                                                       
PATH=$mPATH:$PATH make ARCH=arm64 hikey960_defconfig                                                                   
PATH=$mPATH:$PATH make ARCH=arm64 CC=clang CLANG_TRIPLE=aarch64-linux-gnu- CROSS_COMPILE=aarch64-linux-android- -j$(nproc) Image.gz dtbs                                                                                                      

I’d like sync internally and check if can update the Android device page for the building steps [2].

Thanks!

[1] platform/prebuilts/clang/host/linux-x86 - Git at Google
[2] https://source.android.com/source/devices

1 Like