[REFERENCE] How to compile an Android kernel

Search This thread

bksvc

Member
Nov 6, 2019
8
0
Samsung Galaxy Note 20
I can't compile zImage
My kernel source code : https://opensource.samsung.com/uploadSearch?searchValue=sm-n980f
Version : N980FXXS3EULF
: My Command Set :
export ARCH=arm64
export CROSS_COMPILE=/home/SM-N980F/new-make/gcc-linaro/bin/aarch64-linux-gnu-
mkdir kout
make -C /home/SM-N980F/new-make/ O=output/ exynos9830-c1slte_defconfig

: ERROR OUT :
make: Entering directory '/home/SM-N980F/new-make'
make[1]: Entering directory '/home/SM-N980F/new-make/output'
HOSTCC scripts/basic/fixdep
GEN ./Makefile
HOSTCC scripts/kconfig/conf.o
YACC scripts/kconfig/zconf.tab.c
LEX scripts/kconfig/zconf.lex.c
HOSTCC scripts/kconfig/zconf.tab.o
HOSTLD scripts/kconfig/conf
arch/arm64/Kconfig:1339:warning: multi-line strings not supported
drivers/input/misc/hall/Kconfig:41: syntax error
drivers/input/misc/hall/Kconfig:40: invalid option
drivers/gpu/arm/Kconfig:28: syntax error
drivers/gpu/arm/Kconfig:27: invalid option
drivers/gpu/arm/Kconfig:29: syntax error
drivers/gpu/arm/Kconfig:28: invalid option
'rivers/soc/samsung/linkforward/Kconfig:4:warning: ignoring unsupported character '
'rivers/soc/samsung/linkforward/Kconfig:5:warning: ignoring unsupported character '
'rivers/soc/samsung/linkforward/Kconfig:6:warning: ignoring unsupported character '
'rivers/soc/samsung/linkforward/Kconfig:7:warning: ignoring unsupported character '
'rivers/soc/samsung/linkforward/Kconfig:8:warning: ignoring unsupported character '
fs/sdcardfs/Kconfig:19: syntax error
fs/sdcardfs/Kconfig:18: invalid option
make[2]: *** [../scripts/kconfig/Makefile:104: exynos9830-c1slte_defconfig] Error 1
make[1]: *** [/home/burak/SM-N980F/new-make/Makefile:547: exynos9830-c1slte_defconfig] Error 2
make[1]: Leaving directory '/home/SM-N980F/new-make/output'
make: *** [Makefile:146: sub-make] Error 2
make: Leaving directory '/home/SM-N980F/new-make'
 

nalas

Senior Member
Nov 19, 2012
1,473
1,240
Poland
I can't compile zImage
My kernel source code : https://opensource.samsung.com/uploadSearch?searchValue=sm-n980f
Version : N980FXXS3EULF
: My Command Set :
export ARCH=arm64
export CROSS_COMPILE=/home/SM-N980F/new-make/gcc-linaro/bin/aarch64-linux-gnu-
mkdir kout
make -C /home/SM-N980F/new-make/ O=output/ exynos9830-c1slte_defconfig

: ERROR OUT :
make: Entering directory '/home/SM-N980F/new-make'
make[1]: Entering directory '/home/SM-N980F/new-make/output'
HOSTCC scripts/basic/fixdep
GEN ./Makefile
HOSTCC scripts/kconfig/conf.o
YACC scripts/kconfig/zconf.tab.c
LEX scripts/kconfig/zconf.lex.c
HOSTCC scripts/kconfig/zconf.tab.o
HOSTLD scripts/kconfig/conf
arch/arm64/Kconfig:1339:warning: multi-line strings not supported
drivers/input/misc/hall/Kconfig:41: syntax error
drivers/input/misc/hall/Kconfig:40: invalid option
drivers/gpu/arm/Kconfig:28: syntax error
drivers/gpu/arm/Kconfig:27: invalid option
drivers/gpu/arm/Kconfig:29: syntax error
drivers/gpu/arm/Kconfig:28: invalid option
'rivers/soc/samsung/linkforward/Kconfig:4:warning: ignoring unsupported character '
'rivers/soc/samsung/linkforward/Kconfig:5:warning: ignoring unsupported character '
'rivers/soc/samsung/linkforward/Kconfig:6:warning: ignoring unsupported character '
'rivers/soc/samsung/linkforward/Kconfig:7:warning: ignoring unsupported character '
'rivers/soc/samsung/linkforward/Kconfig:8:warning: ignoring unsupported character '
fs/sdcardfs/Kconfig:19: syntax error
fs/sdcardfs/Kconfig:18: invalid option
make[2]: *** [../scripts/kconfig/Makefile:104: exynos9830-c1slte_defconfig] Error 1
make[1]: *** [/home/burak/SM-N980F/new-make/Makefile:547: exynos9830-c1slte_defconfig] Error 2
make[1]: Leaving directory '/home/SM-N980F/new-make/output'
make: *** [Makefile:146: sub-make] Error 2
make: Leaving directory '/home/SM-N980F/new-make'
Try to use gcc google used by samsung or clang used by samsung...

You will find version it in Makefile or defconfig begin lines...

Linux-android-4.9

Linaro can breaks compile or you have to add some commits with fix linaro gcc in your source.

Look at github repos...

Are a lot of n980 series ... exynos 9830
 

lolvatveo

Senior Member
Nov 1, 2020
169
6
don't have wifi or bluetooth after compile kernel, no error while compiling. someone say I don't import qcacald module, etc my device is qualcomm and there are no guide how to do
 

lolvatveo

Senior Member
Nov 1, 2020
169
6
I can determine my version after searching for a long time

export ANDROID_MAJOR_VERSION=n
export PLATFORM_VERSION=7.1.1
will be test in next compile
 

lolvatveo

Senior Member
Nov 1, 2020
169
6
Many developers have successfully compiled on samsung j5 2016 without wifi bluetooth error, so this kernel is a bit weird. I have tried both toolchain armeabi 4.8, 4.9 no need install any ndk package https://github.com/sayedather/arm-eabi-4.8-toolchain

This developer using linaro toolchain 6.4.1 to compile kernel which requires ndk package installed otherwise it will lead to error arm-eabi-gcc: no such file or dir and I haven't used it to compile, is wifi bluetooth error related to toolchain?
although there are no errors when compiling but I will post some warning logs
 
Last edited:

V3rB0se

Senior Member
Jun 12, 2022
67
38
Sindh, Karachi
Many developers have successfully compiled on samsung j5 2016 without wifi bluetooth error, so this kernel is a bit weird. I have tried both toolchain armeabi 4.8, 4.9 no need install any ndk package https://github.com/sayedather/arm-eabi-4.8-toolchain

This developer using linaro toolchain 6.4.1 to compile kernel which requires ndk package otherwise it will lead to error arm-eabi-gcc: no such file or dir and I haven't used it to compile, is wifi bluetooth error related to toolchain?
no it isn't related to toolchain it's an issue with samsung secure storage.
 

goryu

New member
Sep 13, 2022
1
0
I'm a noob at kernel development.

I only have the resources of using my OnePlus7t HD1907


OnePlus 7t HD1907 Kernel version 4.19.157-per+
ASOP PixelExperience 12.1 Rooted using Magisk

I complied everything on my OnePlus 7T so I didn't know if I needed a CROSS_COMPILE option.

Using termux I chrooted into ubuntu 22.04 then I compile the 5.16.x kernel from gitlab sm8150 oneplus7

Termux$su
Termux#cp /proc/config.gz UbuntuChroot/root/newkernelfolder/.config
Termux#exit
Termux$sudo ./startUbuntuChroot.sh
UbuntuChroot~#cd newKernelfolder
UbuntuChroot~/newKernelfolder#apt install *required dependencies
UbuntuChroot~/newKernelfolder#ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- make hotdogb_defconfig
UbuntuChroot~/newKernelfolder#make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- menuconfig

I checked the Virtualization slot saved to .config then exit the menuconfig. I don't know if this enables KVM so here it goes.

UbuntuChroot~/newKernelfolder#ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- make -J6 (took about 10 minutes)

I successfully compiled it and checked the folder where I can find the kernel image.

UbuntuChroot~/newKernelfolder#cd /arch/arm64/boot/

In this folder I found the files Image, Image.gz, Makefile, dts(folder)

Ok this is how far I got with my knowldege of what I think I'm doing right. I want to know how can I make a boot.img so I test this on my OnePlus 7t. I don't care if I brick it because I have another phone. My goal was to enable kvm on it.

I'm confused is to if I'm doing all this right or if I'm missing any steps. How do I create a boot.img from the steps above?
 

V3rB0se

Senior Member
Jun 12, 2022
67
38
Sindh, Karachi
I'm a noob at kernel development.

I only have the resources of using my OnePlus7t HD1907


OnePlus 7t HD1907 Kernel version 4.19.157-per+
ASOP PixelExperience 12.1 Rooted using Magisk

I complied everything on my OnePlus 7T so I didn't know if I needed a CROSS_COMPILE option.

Using termux I chrooted into ubuntu 22.04 then I compile the 5.16.x kernel from gitlab sm8150 oneplus7

Termux$su
Termux#cp /proc/config.gz UbuntuChroot/root/newkernelfolder/.config
Termux#exit
Termux$sudo ./startUbuntuChroot.sh
UbuntuChroot~#cd newKernelfolder
UbuntuChroot~/newKernelfolder#apt install *required dependencies
UbuntuChroot~/newKernelfolder#ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- make hotdogb_defconfig
UbuntuChroot~/newKernelfolder#make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- menuconfig

I checked the Virtualization slot saved to .config then exit the menuconfig. I don't know if this enables KVM so here it goes.

UbuntuChroot~/newKernelfolder#ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- make -J6 (took about 10 minutes)

I successfully compiled it and checked the folder where I can find the kernel image.

UbuntuChroot~/newKernelfolder#cd /arch/arm64/boot/

In this folder I found the files Image, Image.gz, Makefile, dts(folder)

Ok this is how far I got with my knowldege of what I think I'm doing right. I want to know how can I make a boot.img so I test this on my OnePlus 7t. I don't care if I brick it because I have another phone. My goal was to enable kvm on it.

I'm confused is to if I'm doing all this right or if I'm missing any steps. How do I create a boot.img from the steps above?
you can use AnyKernel3 template to flash the kernel. no need to unpack and repack the boot.img.
 
  • Like
Reactions: goryu

xdroidfreakz

Member
Mar 2, 2014
8
10
I tried compiling the kernel pixel 3a and got this problem
source kernel:
any suggestion? how to find the location of the error

CC lib/list_sort.o
In file included from /home/idoniex/Bluecross-ElementalX-P3a-4.00xx/techpack/audio/asoc/codecs/sdm660_cdc/msm
-digital-cdc.c:28:
/home/idoniex/Bluecross-ElementalX-P3a-4.00xx/techpack/audio/include/soc/internal.h:1:1: error: expected iden
tifier or '('
../../../../drivers/base/regmap/internal.h
^
/home/idoniex/Bluecross-ElementalX-P3a-4.00xx/techpack/audio/asoc/codecs/sdm660_cdc/msm-digital-cdc.c:108:25:
error: incomplete definition of type 'struct regmap'
msm_dig_cdc->regmap->cache_only = true;
~~~~~~~~~~~~~~~~~~~^
/home/idoniex/Bluecross-ElementalX-P3a-4.00xx/include/linux/regmap.h:29:8: note: forward declaration of 'stru
ct regmap'
struct regmap;
^
/home/idoniex/Bluecross-ElementalX-P3a-4.00xx/techpack/audio/asoc/codecs/sdm660_cdc/msm-digital-cdc.c:239:41:
error: use of undeclared identifier 'COMPANDER_1'
if (dig_cdc->comp_enabled[interp_n] != COMPANDER_1 &&
^
CC lib/uuid.o
/home/idoniex/Bluecross-ElementalX-P3a-4.00xx/techpack/audio/asoc/codecs/sdm660_cdc/msm-digital-cdc.c:698:30:
error: use of undeclared identifier 'COMPANDER_1'
SOC_SINGLE_EXT("COMP0 RX1", COMPANDER_1, MSM89XX_RX1, 1, 0,
^
/home/idoniex/Bluecross-ElementalX-P3a-4.00xx/techpack/audio/asoc/codecs/sdm660_cdc/msm-digital-cdc.c:698:30:
error: use of undeclared identifier 'COMPANDER_1'
/home/idoniex/Bluecross-ElementalX-P3a-4.00xx/techpack/audio/asoc/codecs/sdm660_cdc/msm-digital-cdc.c:701:30:
error: use of undeclared identifier 'COMPANDER_1'
SOC_SINGLE_EXT("COMP0 RX2", COMPANDER_1, MSM89XX_RX2, 1, 0,
^
/home/idoniex/Bluecross-ElementalX-P3a-4.00xx/techpack/audio/asoc/codecs/sdm660_cdc/msm-digital-cdc.c:701:30:
error: use of undeclared identifier 'COMPANDER_1'
/home/idoniex/Bluecross-ElementalX-P3a-4.00xx/techpack/audio/asoc/codecs/sdm660_cdc/msm-digital-cdc.c:1340:4:
error: invalid application of 'sizeof' to an incomplete type 'const struct snd_kcontrol_new []'
ARRAY_SIZE(compander_kcontrols));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/idoniex/Bluecross-ElementalX-P3a-4.00xx/include/linux/kernel.h:55:32: note: expanded from macro 'ARRAY_
SIZE'
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
^~~~~
/home/idoniex/Bluecross-ElementalX-P3a-4.00xx/techpack/audio/asoc/codecs/sdm660_cdc/msm-digital-cdc.c:1354:34
: error: use of undeclared identifier 'COMPANDER_NONE'; did you mean 'DPM_ORDER_NONE'?
msm_dig_cdc->comp_enabled = COMPANDER_NONE;
^~~~~~~~~~~~~~
DPM_ORDER_NONE
/home/idoniex/Bluecross-ElementalX-P3a-4.00xx/include/linux/pm.h:783:2: note: 'DPM_ORDER_NONE' declared here
DPM_ORDER_NONE,
^
9 errors generated.
make[6]: *** [/home/idoniex/Bluecross-ElementalX-P3a-4.00xx/scripts/Makefile.build:342: techpack/audio/asoc/c
odecs/sdm660_cdc/msm-digital-cdc.o] Error 1
make[5]: *** [/home/idoniex/Bluecross-ElementalX-P3a-4.00xx/scripts/Makefile.build:656: techpack/audio/asoc/c
odecs/sdm660_cdc] Error 2
make[4]: *** [/home/idoniex/Bluecross-ElementalX-P3a-4.00xx/scripts/Makefile.build:656: techpack/audio/asoc/c
odecs] Error 2
make[3]: *** [/home/idoniex/Bluecross-ElementalX-P3a-4.00xx/scripts/Makefile.build:656: techpack/audio/asoc]
Error 2
make[2]: *** [/home/idoniex/Bluecross-ElementalX-P3a-4.00xx/scripts/Makefile.build:656: techpack/audio] Error
2
make[1]: *** [/home/idoniex/Bluecross-ElementalX-P3a-4.00xx/Makefile:1125: techpack] Error 2
make[1]: *** Waiting for unfinished jobs....
 

SlendowManX

New member
Dec 24, 2018
2
0
20220925_175627.jpg
I always keep getting these errors
 

bksvc

Member
Nov 6, 2019
8
0
Samsung Galaxy Note 20
Try to use gcc google used by samsung or clang used by samsung...

You will find version it in Makefile or defconfig begin lines...

Linux-android-4.9

Linaro can breaks compile or you have to add some commits with fix linaro gcc in your source.

Look at github repos...

Are a lot of n980 series ... exynos 9830
Sorry for the late reply i tried with clang and it worked
really thank you ^^
 

Top Liked Posts

  • There are no posts matching your filters.
  • 1
    I'm a noob at kernel development.

    I only have the resources of using my OnePlus7t HD1907


    OnePlus 7t HD1907 Kernel version 4.19.157-per+
    ASOP PixelExperience 12.1 Rooted using Magisk

    I complied everything on my OnePlus 7T so I didn't know if I needed a CROSS_COMPILE option.

    Using termux I chrooted into ubuntu 22.04 then I compile the 5.16.x kernel from gitlab sm8150 oneplus7

    Termux$su
    Termux#cp /proc/config.gz UbuntuChroot/root/newkernelfolder/.config
    Termux#exit
    Termux$sudo ./startUbuntuChroot.sh
    UbuntuChroot~#cd newKernelfolder
    UbuntuChroot~/newKernelfolder#apt install *required dependencies
    UbuntuChroot~/newKernelfolder#ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- make hotdogb_defconfig
    UbuntuChroot~/newKernelfolder#make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- menuconfig

    I checked the Virtualization slot saved to .config then exit the menuconfig. I don't know if this enables KVM so here it goes.

    UbuntuChroot~/newKernelfolder#ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- make -J6 (took about 10 minutes)

    I successfully compiled it and checked the folder where I can find the kernel image.

    UbuntuChroot~/newKernelfolder#cd /arch/arm64/boot/

    In this folder I found the files Image, Image.gz, Makefile, dts(folder)

    Ok this is how far I got with my knowldege of what I think I'm doing right. I want to know how can I make a boot.img so I test this on my OnePlus 7t. I don't care if I brick it because I have another phone. My goal was to enable kvm on it.

    I'm confused is to if I'm doing all this right or if I'm missing any steps. How do I create a boot.img from the steps above?
    you can use AnyKernel3 template to flash the kernel. no need to unpack and repack the boot.img.
  • 224
    Introduction

    Hello everyone, I will be going over how to compile a kernel from beginning to end!

    Prerequisites:
    • A Linux environment (preferably 64-bit)
    • Knowledge of how to navigate the command line
    • Common sense
    • A learning spirit, there will be no spoonfeeding here

    What this guide will cover:
    1. Downloading the source
    2. Downloading a cross compiler
    3. Building the kernel
    4. Flashing the kernel

    What this guide will NOT cover:
    • Setting up a build environment (plenty of existing Linux installation guides)
    • Adding features to the kernel (plenty of git cherry-picking guides)

    I know this has been done before but on a cursory search, I have not seen a guide that was recently updated at all.


    1. Downloading the source


    If you have a custom kernel you want to build, move along after cloning the kernel using the git clone command below.

    If you are compiling your stock kernel, it is ultimately up to you to know where to get your kernel source from but here are some common places:

    Google: https://android.googlesource.com/kernel/msm/ (pick your architecture and look at the branches)
    LG: http://opensource.lge.com/index
    Samsung: http://opensource.samsung.com/reception.do
    HTC: https://www.htcdev.com/devcenter/downloads
    OnePlus: https://github.com/OnePlusOSS
    Motorola: https://github.com/MotorolaMobilityLLC
    Sony: https://github.com/sonyxperiadev/kernel

    To download the kernel, you can either use git clone or download the tarball and extract it:
    Code:
    git clone -b <branch_to_checkout> <url> <desired_folder_name>
    
    OR
    
    tar -xvf <filename>

    For example, if I wanted to grab the latest Nexus 6P from Google above:
    Code:
    git clone -b android-msm-angler-3.10-nougat-mr2 https://android.googlesource.com/kernel/msm/ angler
    This will clone the kernel/msm repo into an angler folder and checkout the android-msm-angler-3.10-nougat-mr2 automatically.

    I can try and help you locate your source if necessary.



    2. Downloading a cross compiler


    Since most Android devices are ARM based, we need a compiler that is targeting ARM devices. A host (or native) compiler will not work unless you are compiling on another ARM device.

    You can either compile one yourself if you know how (crosstool-NG is a great tool for this) or download a prebuilt one. Luckily Google provides a high quality toolchain for this, in both an arm (32-bit) and arm64 (64-bit). It's up to you to know the architecture of your device. Typically speaking, most devices in the past two-three years are 64-bit.

    Another popular toolchain is UberTC, which can be found here: https://bitbucket.org/matthewdalex/. Most kernels will need patches for anything higher than 4.9 and while I don't mind assisting with finding them, you should compile with Google's toolchain first.

    Once you have decided, clone the toolchain:
    Code:
    git clone <url>


    3. Compile the kernel


    1. Point the Makefile to your compiler (run this from within the toolchain folder!!)
    Code:
    export CROSS_COMPILE=$(pwd)/bin/<toolchain_prefix>-
    Example:
    Code:
    export CROSS_COMPILE=$(pwd)/bin/aarch64-linux-android-

    NOTE #1: For kernels that can be compiled with Clang (like the Pixel 2), see this guide. I will support it here if there are any questions.

    NOTE #2: Pixel and Pixel 2 users, you will need to follow these steps as well if compiling for Android Pie.

    2. Tell the Makefile the architecture of the device
    Code:
    export ARCH=<arch> && export SUBARCH=<arch>
    Example:
    Code:
    export ARCH=arm64 && export SUBARCH=arm64

    3. Locate your proper defconfig
    Navigate to the arch/<arch>/configs folder within the kernel source (e.g. arch/arm64/configs) and locate your device's or custom kernel developer's proper config file. For example, it will often be in the form of <codename>_defconfig or <kernel_name>_defconfig. Generic Qualcomm configs may be used as well (msm-perf_defconfig, msmcortex-perf_defconfig). When in doubt, ask here if you are confused. A defconfig tells the compiler what options to add to the kernel.

    4. Build the kernel

    Code:
    make clean
    make mrproper
    make <defconfig_name>
    make -j$(nproc --all)

    If those commands succeed, you will have an Image, Image-dtb, Image.gz, or Image.gz-dtb file at the end.

    If it failed, as was pointed out to me by @flar2 while making a complete idiot of myself, you may need to specify an output directory while making new CAF based kernels, like so:
    Code:
    mkdir -p out
    make O=out clean
    make O=out mrproper
    make O=out <defconfig_name>
    make O=out -j$(nproc --all)

    If after that something is still broken, you may need to fix some headers or other issues. If it is a custom kernel, bring it up with your developer.
    If it's an OEM, it's up to you to try and fix it, which we can assist with.



    4. Flash the kernel


    Assuming you were able to compile the kernel successfully, you now need to flash it! I will be covering two different ways to flash a compiled kernel: unpacking and repacking the boot image by hand using Android Image Kitchen or AnyKernel2, both by the brilliant @osm0sis. If there are any per-device nuances, please let me know and I'll add them here! Additionally, this section can vary drastically by device, you may need to consult developers of your device for assistance if necessary.

    Android Image Kitchen

    1. Pull your device's boot image from the latest image available for your device (whether it be a ROM or stock)
    2. Download the latest Android Image Kitchen from this thread.
    3. Run the following with the boot image:
      Code:
      unpackimg.sh <image_name>.img
    4. Locate the zImage file and replace it with your kernel image (rename it to what came out of the boot image)
    5. Run the following to repack:
      Code:
      repackimg.sh
    6. Flash the new boot image with fastboot or TWRP!

    AnyKernel2

    1. Download the latest AnyKernel2 zip: https://github.com/osm0sis/AnyKernel2/archive/master.zip
    2. Apply this patch to clean out all of the demo files:
      Code:
      wget https://github.com/nathanchance/AnyKernel2/commit/addb6ea860aab14f0ef684f6956d17418f95f29a.diff
      patch -p1 < addb6ea860aab14f0ef684f6956d17418f95f29a.diff
      rm addb6ea860aab14f0ef684f6956d17418f95f29a.diff
    3. Place your kernel image in the root of the file.
    4. Open the anykernel.sh file and modify the following values:
      • kernel.string: your kernel name
      • device.name#: List all of your device's codenames (from the /system/build.prop: ro.product.device, ro.build.product)
      • block: Your boot image's path in your fstab. The fstab can be opened from the root of your device and it will look something like this:
        https://android.googlesource.com/device/huawei/angler/+/master/fstab.angler
        The first column is the value you want to set block to.
    5. After that, zip up the kernel and flash it!
      Code:
      zip -r9 kernel.zip * -x README.md kernel.zip


    Tips and tricks


    1. Remove GCC wrapper

    A lot of kernels from CAF include a Python script that will essentially turn on -Werror, causing your build to error at the most benign stuff. This is necessary with higher GCC versions as there are a lot more warnings.

    Here is the diff of what you need to change in the Makefile:
    Code:
    diff --git a/Makefile b/Makefile
    index 1aaa760f255f..bfccd5594630 100644
    --- a/Makefile
    +++ b/Makefile
    @@ -326,7 +326,7 @@ include $(srctree)/scripts/Kbuild.include
    
     AS		= $(CROSS_COMPILE)as
     LD		= $(CROSS_COMPILE)ld
    -REAL_CC		= $(CROSS_COMPILE)gcc
    +CC		= $(CROSS_COMPILE)gcc
     CPP		= $(CC) -E
     AR		= $(CROSS_COMPILE)ar
     NM		= $(CROSS_COMPILE)nm
    @@ -340,10 +340,6 @@ DEPMOD		= /sbin/depmod
     PERL		= perl
     CHECK		= sparse
    
    -# Use the wrapper for the compiler.  This wrapper scans for new
    -# warnings and causes the build to stop upon encountering them.
    -CC		= $(srctree)/scripts/gcc-wrapper.py $(REAL_CC)
    -
     CHECKFLAGS     := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
     		  -Wbitwise -Wno-return-void $(CF)
     CFLAGS_MODULE   =

    2. Using a higher level GCC toolchain

    Using a higher GCC toolchain (5.x, 6.x, 7.x or even 8.x) will require you to nuke the GCC wrapper script as above and use a unified GCC header file (pick the following if you have an include/linux/compiler-gcc#.h file):

    3.4/3.10: https://git.kernel.org/pub/scm/linu...h?id=a4a4f1cd733fe5b345db4e8cc19bb8868d562a8a
    3.18: https://git.kernel.org/pub/scm/linu...h?id=677fa15cd6d5b0843e7b9c58409f67d656b1ec2f

    You may get a lot of warnings but they are not entirely necessary to fix.


    3. Adding upstream Linux to kernel source

    Once you have gotten familiar with git and the compilation process, you should consider upstreaming your kernel. This will allow you to stay on top of CVE and bug fixes by staying up to date with the latest work of the Linux kernel developers.



    Receiving help

    I am happy to answer anything that I touched on in this guide. I may point you to another thread if it's better suited but I don't mind off topic (within reason) within the thread. I also want this to be a collaborative effort; other developers, if you have something to add, correct, or improve upon, please let me know!

    I am particular in how people ask for help. I do NOT respond to posts asking for a hand out ("How do I fix this?", "Please fix this!", etc.). I only respond to posts with clear logs and steps that you have tried. Basically, show me that you have read this guide and have a specific issue. I am not here to hold your hand through this, this is a developers' forum.
    20
    Compile Android Pie kernels for the Pixel (XL) and Pixel 2 (XL)

    Google added a new compat vDSO on Android Pie for 32-bit userspace, which requires a 32-bit toolchain (commit). As a result, if CROSS_COMPILE_ARM32 is not set, your build will error.

    After setting your main CROSS_COMPILE in step 1, clone this toolchain (or another compatible arm toolchain) next to the aarch64 one (if in the toolchain folder after running 'export CROSS_COMPILE', type 'cd ..'). Move into the 32-bit toolchain folder using cd then run
    Code:
    export CROSS_COMPILE_ARM32=$(pwd)/bin/<toolchain_prefix>
    Example:
    Code:
    export CROSS_COMPILE_ARM32=$(pwd)/bin/arm-linux-androideabi-

    Then continue on with the rest of the steps.
    8
    @nathanchance thx for great work
    But how to build kernel with gcc 9.2.0
    could you please add manual for that

    Unfortunately, my time nowadays is limited between my job, school, and more important open source projects.

    However, compiling with GCC 9.2.0 is the same as compiling with GCC 4.9.4, you point the CROSS_COMPILE variable at the GCC 9.2.0 toolchain (or use PATH and update the CROSS_COMPILE prefix to match) and go from there. There are probably going to be new warnings that you will need to solve and there are potentially some other commits that you will need to pick to get a boot off.

    If anyone else wants to pitch in and write something up, I'd be happy to add it to the OP.
    7
    @nathanchance Thank you so much for this guide
    I am getting errors trying to compile U11 kernel forked from ElementalX by @flar2
    https://imgur.com/a/tE5Elfw

    Code:
    make clean
    lib/Makefile:17: *** recipe commences before first target.  Stop.
    Makefile:1213: recipe for target '_clean_lib' failed
    make: *** [_clean_lib] Error 2

    Just skip the make clean for now and go straight to make.

    everything worked fine but after 5min got this error please help
    Code:
    kernel/built-in.o: In function `sched_slice.isra.75':
    jump_label.c:(.text+0x3d8e0): undefined reference to `__multi3'
    jump_label.c:(.text+0x3d8e0): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol `__multi3'
    kernel/built-in.o: In function `update_curr':
    jump_label.c:(.text+0x3de48): undefined reference to `__multi3'
    jump_label.c:(.text+0x3de48): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol `__multi3'
    kernel/built-in.o: In function `task_dead_fair':
    jump_label.c:(.text+0x3e490): undefined reference to `__multi3'
    jump_label.c:(.text+0x3e490): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol `__multi3'
    jump_label.c:(.text+0x3e4ac): undefined reference to `__multi3'
    jump_label.c:(.text+0x3e4ac): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol `__multi3'
    jump_label.c:(.text+0x3e56c): undefined reference to `__multi3'
    jump_label.c:(.text+0x3e56c): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol `__multi3'
    kernel/built-in.o:jump_label.c:(.text+0x3e590): more undefined references to `__multi3' follow
    kernel/built-in.o: In function `task_dead_fair':
    jump_label.c:(.text+0x3e590): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol `__multi3'
    kernel/built-in.o: In function `migrate_task_rq_fair':
    jump_label.c:(.text+0x3e6cc): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol `__multi3'
    jump_label.c:(.text+0x3e6e8): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol `__multi3'
    jump_label.c:(.text+0x3e7a8): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol `__multi3'
    jump_label.c:(.text+0x3e7cc): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol `__multi3'
    kernel/built-in.o: In function `check_preempt_wakeup':
    jump_label.c:(.text+0x3ea44): additional relocation overflows omitted from the output
    Makefile:986: recipe for target 'vmlinux' failed
    make: *** [vmlinux] Error 1
    please help

    Normally I just ignore posts like this since you clearly didn't follow the "Receiving help" section but I want to make this an educational opportunity. How in the world am I supposed to help you when you give me quite literally zero information?

    Nothing about device, toolchain, kernel source link.

    Please realize I'm not a wizard or magician. I cannot read your mind. My initial guess is your kernel source is broken or your toolchain is. Please come back with more info if you want my help.
    6
    You're on fire with this kernel stuff:D

    Sent from my LEX727 using XDA Labs