Getting errors building android-hikey-linaro-4.19 kernel

I am having trouble building hikey-linaro-4.19 kernel. I pulled the kernel release following Using Reference Boards  |  Android Open Source Project - using HiKey 960 boards instructions:
repo init -u kernel/manifest - Git at Google -b android-hikey-linaro-4.19
repo sync -j8 -c
build/build.sh
I get several errors:
first error:
Setting up for build

  • cd hikey-linaro
  • make LLVM=1 LLVM_IAS=1 DEPMOD=depmod O=/home/rftest/UWB/hikey-kernel/out/android-hikey-linaro-4.19/hikey-linaro mrproper
    make[1]: Entering directory ‘/home/rftest/UWB/hikey-kernel/out/android-hikey-linaro-4.19/hikey-linaro’
    make[3]: arm-linux-gnueabi-gcc: Command not found – NOTE am I missing an env setup?
    /bin/sh: 1: cd: can’t cd to drivers/gpu/arm/utgard – NOTE this dir exists
    /bin/sh: 1: cd: can’t cd to drivers/gpu/arm/utgard – NOTE this dir exists
    grep: include/linux/mali/mali_utgard_uk_types.h: No such file or directory
    make[1]: Leaving directory ‘/home/rftest/UWB/hikey-kernel/out/android-hikey-linaro-4.19/hikey-linaro’

second error:
/home/rftest/UWB/hikey-kernel/build/build-tools/path/linux-x86/bison: 7: /home/rftest/UWB/hikey-kernel/build/build-tools/path/linux-x86/bison: /home/rftest/UWB/hikey-kernel/build/build-tools/path/linux-x86/…/…/…/…/prebuilts/build-tools/linux-x86/bin/bison: not found
scripts/Makefile.lib:196: recipe for target ‘scripts/kconfig/zconf.tab.c’ failed
make[2]: *** [scripts/kconfig/zconf.tab.c] Error 127
make[2]: *** Waiting for unfinished jobs…
/home/rftest/UWB/hikey-kernel/hikey-linaro/Makefile:554: recipe for target ‘hikey960_defconfig’ failed
make[1]: *** [hikey960_defconfig] Error 2 – NOTE where do I get this config? I can not find it - my build.config points to hikey-linaro/build.config.hikey960

rftest@rftest-PowerEdge-T630:~/UWB/hikey-kernel$
Makefile:146: recipe for target ‘sub-make’ failed
make: *** [sub-make] Error 2

I looked at the logs for the CI builds (Artifact Viewer ) for some clue about what might be happening.

Most of the setup errors look like they happen during CI builds too which just leaves us with the problem finding bison. It looks to me like there are some assumptions about the directory structure here. The config file for bison reaches out to the parent of the kernel manifest repo and looks for a directory for prebuilts/ (which is part of the normal aosp “sources”).

In short, if you move the kernel compile repo inside your main aosp repo then it should work OK. It is noteable that the path used by the CI system is /buildbot/src/android/hikey-linaro-android-4.19 which does look like it might be nested inside the AOSP sources.

Alternatively I was able to get a successful build just by adding a soft-link to help the kernel build find the prebuilts (note that I also built with -s to keep the logs nice and short):

BUILD_CONFIG=hikey-linaro/build.config.hikey960 build/build.sh -j$(nproc) -s
bionic-1804-lts$ ls -go ..
total 4
drwxrwxr-x. 1 136 Feb 10 10:36 android-hikey960-linaro-4.19
drwxrwxr-x. 1 516 Jan 19 16:48 aosp-master
lrwxrwxrwx. 1  22 Feb 10 10:36 prebuilts -> aosp-master/prebuilts/
bionic-1804-lts$ BUILD_CONFIG=hikey-linaro/build.config.hikey960 build/build.sh -j$(nproc) -s
========================================================
 Setting up for build
+ cd hikey-linaro
+ make LLVM=1 LLVM_IAS=1 DEPMOD=depmod O=/build/drt/aosp/android-hikey960-linaro-4.19/out/android-hikey-linaro-4.19/hikey-linaro -j32 -s mrproper
make[3]: arm-linux-gnueabi-gcc: No such file or directory
/bin/sh: line 0: cd: drivers/gpu/arm/utgard: No such file or directory
/bin/sh: line 0: cd: drivers/gpu/arm/utgard: No such file or directory
grep: include/linux/mali/mali_utgard_uk_types.h: No such file or directory
+ set +x
+ cd hikey-linaro
+ make LLVM=1 LLVM_IAS=1 DEPMOD=depmod O=/build/drt/aosp/android-hikey960-linaro-4.19/out/android-hikey-linaro-4.19/hikey-linaro -j32 -s hikey960_defconfig
+ set +x
========================================================
 Building kernel
+ cd /build/drt/aosp/android-hikey960-linaro-4.19/out/android-hikey-linaro-4.19/hikey-linaro
+ make O=/build/drt/aosp/android-hikey960-linaro-4.19/out/android-hikey-linaro-4.19/hikey-linaro LLVM=1 LLVM_IAS=1 DEPMOD=depmod -j32 -s
grep: include/linux/mali/mali_utgard_uk_types.h: No such file or directory
/build/drt/aosp/android-hikey960-linaro-4.19/hikey-linaro/drivers/clk/clk.c:53:27: warning: unused variable 'orphan_list' [-Wunused-variable]
static struct hlist_head *orphan_list[] = {
                          ^
1 warning generated.
grep: include/linux/mali/mali_utgard_uk_types.h: No such file or directory
/build/drt/aosp/android-hikey960-linaro-4.19/hikey-linaro/drivers/usb/gadget/configfs.c:1536:12: warning: unused function 'configfs_composite_setup' [-Wunused-function]
static int configfs_composite_setup(struct usb_gadget *gadget,
           ^
/build/drt/aosp/android-hikey960-linaro-4.19/hikey-linaro/drivers/usb/gadget/configfs.c:1561:13: warning: unused function 'configfs_composite_disconnect' [-Wunused-function]
static void configfs_composite_disconnect(struct usb_gadget *gadget)
            ^
2 warnings generated.
+ set +x
========================================================
 Installing kernel modules into staging directory
========================================================
 Generating test_mappings.zip
========================================================
 Copying files
  arch/arm64/boot/Image.gz-dtb
  arch/arm64/boot/dts/hisilicon/hi3660-hikey960.dtb
  vmlinux
  System.map
========================================================
 Installing UAPI kernel headers:
 Copying kernel UAPI headers to /build/drt/aosp/android-hikey960-linaro-4.19/out/android-hikey-linaro-4.19/dist/kernel-uapi-headers.tar.gz
========================================================
 Copying kernel headers to /build/drt/aosp/android-hikey960-linaro-4.19/out/android-hikey-linaro-4.19/dist/kernel-headers.tar.gz
/build/drt/aosp/android-hikey960-linaro-4.19/hikey-linaro /build/drt/aosp/android-hikey960-linaro-4.19
/build/drt/aosp/android-hikey960-linaro-4.19
========================================================
 Copying modules files
========================================================
 Files copied to /build/drt/aosp/android-hikey960-linaro-4.19/out/android-hikey-linaro-4.19/dist
bionic-1804-lts$ 

PS No idea if the resulting kernel actually works of course… but it does build!