Hi everyone, I wasted my entire day trying to compile the kernel for a old Neffos X1 Max

I downloaded the source from here https://www.neffos.com/en/support/gpl-code-center

Then git cloned the kali-nethunter-kernel and made a local.config like this

Code:
#!/bin/bash


################################################################################################
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Kernel Source:
# git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
################################################################################################


##############################################
# Toolchains
##############################################


# Architecture (arm or arm64)
export ARCH=arm64


# Speed up the build
CCACHE=true


### Most arm64 kernels above version 4.x is fine with Clang.


# Comment out this section if the above applies to your device.
# Clang
#unset CLANG_ROOT
#unset CLANG_PATH
#unset LD_LIBRARY_PATH
#unset CLANG_TRIPLE
#unset CC


# GCC 64bit


## arm64 cross compiler directory:
CCD64="${TD}/aarch64-linux-android-4.9"
export CROSS_COMPILE=${CCD64}/bin/aarch64-linux-android-


## Source repository:
#CROSS_COMPILE_SRC="https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/+archive/refs/heads/nougat-release.tar.gz"
#CROSS_COMPILE_SRC_TYPE="wget"


# Additional compiler arguments
MAKE_ARGS="-j8"
Based on a README into the kernel source files

Code:
################################################################################


For TP903(X1 Max)


1. How to Build
- get Toolchain
From android git server, codesourcery and etc ..
- aarch64-linux-android-4.9


- edit Makefile
edit CROSS_COMPILE to right toolchain path(You downloaded).
Ex)   export PATH=$PATH:$(android platform directory you download)/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin
Ex)   export CROSS_COMPILE=aarch64-linux-android-


- copy defconfig files
copy file in folder "configs" to  kernel-3.18/arch/arm64/configs
copy files in folder "dts" to  kernel-3.18/arch/arm64/boot/dts


enter kernel-3.18
$ mkdir ../out
$ make ARCH=arm64 O=../out tplink6755_65_n_defconfig
$ make ARCH=arm64 O=../out -j8


2. Output files
- Kernel : out/arch/arm64/boot/Image.gz
- module : out/drivers/*/*.ko


3. How to Clean
$ make ARCH=arm64 distclean
$ rm -rf out


################################################################################


Kernel release package version instruction


USE zImage NOTE:


1. This package make out zImage only, you have to get ramdisk and add kernel cmdline to generate a total boot.img before replace your phone's bootimage.
2. If your phone already enable secboot feature, please decrypt or unlock the secboot feature first.
3. Please make sure your phone software version is same with this release package, if not, please download the match version first.


This kernel package is released for the phone software version 2018-1-25


How to build Module
- It is only for modules are needed to using Android build system.
- Please check its own install information under its folder for other module.


################################################################################


[Step to build]
1. Get android open source.
    : version info -
    ( Download site : http://source.android.com )


2. Copy module that you want to build - to original android open source
   If same module exist in android open source, you should replace it. (no overwrite)


# It is possible to build all modules at once.


3. excute build command
   Please refer to the site: http://source.android.com
I've manually downloaded the toolchain from here https://android.googlesource.com/pla...nto ~/android/
I then got this error...

Code:
[   INFO   ] Create config
make: Entering directory '/home/pierluigi/GPL_X1_series_V2/alps/kernel-3.18'
make[1]: Entering directory '/home/pierluigi/GPL_X1_series_V2/alps/kernel-3.18/kali-nethunter-kernel/out'
  HOSTCC  scripts/basic/fixdep
  GEN     ./Makefile
  HOSTCC  scripts/kconfig/conf.o
  SHIPPED scripts/kconfig/zconf.tab.c
  SHIPPED scripts/kconfig/zconf.lex.c
  SHIPPED scripts/kconfig/zconf.hash.c
  HOSTCC  scripts/kconfig/zconf.tab.o
  HOSTLD  scripts/kconfig/conf
#
# configuration written to .config
#
make[1]: Leaving directory '/home/pierluigi/GPL_X1_series_V2/alps/kernel-3.18/kali-nethunter-kernel/out'
make: Leaving directory '/home/pierluigi/GPL_X1_series_V2/alps/kernel-3.18'


[   INFO   ] ~~~~~~~~~~~~~~~~~~
[   INFO   ]  ccache enabled
[   INFO   ] ~~~~~~~~~~~~~~~~~~
ccache clang
/home/pierluigi/android/toolchains/aarch64-linux-android-4.9/bin/aarch64-linux-android-
/home/pierluigi/android/toolchains/armhf-4.9/bin/arm-linux-androideabi-
[   INFO   ] ~~~~~~~~~~~~~~~~~~
[   INFO   ]  Building kernel
[   INFO   ] ~~~~~~~~~~~~~~~~~~
make: Entering directory '/home/pierluigi/GPL_X1_series_V2/alps/kernel-3.18'
make[1]: Entering directory '/home/pierluigi/GPL_X1_series_V2/alps/kernel-3.18/kali-nethunter-kernel/out'
  GEN     ./Makefile
scripts/kconfig/conf --silentoldconfig Kconfig
/home/pierluigi/GPL_X1_series_V2/alps/kernel-3.18/tools/dct/DrvGen /home/pierluigi/GPL_X1_series_V2/alps/kernel-3.18/drivers/misc/mediatek/dws/mt6755/tplink6755_65_n.dws arch/arm64/boot/dts/ arch/arm64/boot/dts/ cust_dtsi
  CHK     include/config/kernel.release
[dct info] ver_main: #2 ver_sub: #3 build sn: #160630
[dct info] run code: #09.21.2022 00:56:18 #136541733
[dct info] parameter count: 5
[dct info] param #0: /home/pierluigi/GPL_X1_series_V2/alps/kernel-3.18/tools/dct/DrvGen
[dct info] param #1: /home/pierluigi/GPL_X1_series_V2/alps/kernel-3.18/drivers/misc/mediatek/dws/mt6755/tplink6755_65_n.dws
[dct info] param #2: arch/arm64/boot/dts/
[dct info] param #3: arch/arm64/boot/dts/
[dct info] param #4: cust_dtsi
[dct info] source_file:/home/pierluigi/GPL_X1_series_V2/alps/kernel-3.18/drivers/misc/mediatek/dws/mt6755/tplink6755_65_n.dws
[dct info] gen_path:/home/pierluigi/GPL_X1_series_V2/alps/kernel-3.18/kali-nethunter-kernel/out/arch/arm64/boot/dts
[dct info] log_path:/home/pierluigi/GPL_X1_series_V2/alps/kernel-3.18/kali-nethunter-kernel/out/arch/arm64/boot/dts
[dct info] gen_files:
=>> cust_dtsi
  GEN     ./Makefile
  WRAP    arch/arm64/include/generated/asm/bug.h
  WRAP    arch/arm64/include/generated/asm/bugs.h
  WRAP    arch/arm64/include/generated/asm/checksum.h
  WRAP    arch/arm64/include/generated/asm/clkdev.h
  WRAP    arch/arm64/include/generated/asm/cputime.h
  UPD     include/config/kernel.release
  WRAP    arch/arm64/include/generated/asm/current.h
  WRAP    arch/arm64/include/generated/asm/delay.h
  WRAP    arch/arm64/include/generated/asm/div64.h
  WRAP    arch/arm64/include/generated/asm/dma.h
  WRAP    arch/arm64/include/generated/asm/dma-contiguous.h
  WRAP    arch/arm64/include/generated/asm/early_ioremap.h
  WRAP    arch/arm64/include/generated/asm/emergency-restart.h
  CHK     include/generated/uapi/linux/version.h
  WRAP    arch/arm64/include/generated/asm/errno.h
  WRAP    arch/arm64/include/generated/asm/ftrace.h
  WRAP    arch/arm64/include/generated/asm/hash.h
  WRAP    arch/arm64/include/generated/asm/hw_irq.h
  WRAP    arch/arm64/include/generated/asm/ioctl.h
  UPD     include/generated/uapi/linux/version.h
  WRAP    arch/arm64/include/generated/asm/ioctls.h
  WRAP    arch/arm64/include/generated/asm/ipcbuf.h
  WRAP    arch/arm64/include/generated/asm/irq_regs.h
  WRAP    arch/arm64/include/generated/asm/kdebug.h
  WRAP    arch/arm64/include/generated/asm/kmap_types.h
  WRAP    arch/arm64/include/generated/asm/kvm_para.h
  WRAP    arch/arm64/include/generated/asm/local.h
  WRAP    arch/arm64/include/generated/asm/local64.h
  WRAP    arch/arm64/include/generated/asm/mcs_spinlock.h
  WRAP    arch/arm64/include/generated/asm/mman.h
[dct info] dws file(/home/pierluigi/GPL_X1_series_V2/alps/kernel-3.18/drivers/misc/mediatek/dws/mt6755/tplink6755_65_n.dws) info: xml version: , xml Encoding:
[dct warning] cannot parse dws file /home/pierluigi/GPL_X1_series_V2/alps/kernel-3.18/drivers/misc/mediatek/dws/mt6755/tplink6755_65_n.dws: Encountered incorrectly encoded content.
[dct info] try to read dws file by using old dct tool.
  WRAP    arch/arm64/include/generated/asm/msgbuf.h
  WRAP    arch/arm64/include/generated/asm/mutex.h
  WRAP    arch/arm64/include/generated/asm/pci.h
Enter main function!
The 0th param is:
/home/pierluigi/GPL_X1_series_V2/alps/kernel-3.18/tools/dct/old_dct/DrvGen
The 1th param is:
/home/pierluigi/GPL_X1_series_V2/alps/kernel-3.18/drivers/misc/mediatek/dws/mt6755/tplink6755_65_n.dws
The 2th param is:
/home/pierluigi/GPL_X1_series_V2/alps/kernel-3.18/kali-nethunter-kernel/out/arch/arm64/boot/dts/
The 3th param is:
/home/pierluigi/GPL_X1_series_V2/alps/kernel-3.18/kali-nethunter-kernel/out/arch/arm64/boot/dts/
The 4th param is:
cust_dtsi
  WRAP    arch/arm64/include/generated/asm/pci-bridge.h
begin to open log file!
DCT gen no log file for AOSP!
start to gen code!
start to read workspace!
/home/pierluigi/GPL_X1_series_V2/alps/kernel-3.18/drivers/misc/mediatek/dws/mt6755/tplink6755_65_n.dws
  WRAP    arch/arm64/include/generated/asm/poll.h
  WRAP    arch/arm64/include/generated/asm/preempt.h
  WRAP    arch/arm64/include/generated/asm/resource.h
  WRAP    arch/arm64/include/generated/asm/rwsem.h
  WRAP    arch/arm64/include/generated/asm/scatterlist.h
  WRAP    arch/arm64/include/generated/asm/sections.h
  WRAP    arch/arm64/include/generated/asm/segment.h
  WRAP    arch/arm64/include/generated/asm/sembuf.h
  WRAP    arch/arm64/include/generated/asm/serial.h
  WRAP    arch/arm64/include/generated/asm/shmbuf.h
  WRAP    arch/arm64/include/generated/asm/simd.h
  WRAP    arch/arm64/include/generated/asm/socket.h
  WRAP    arch/arm64/include/generated/asm/sockios.h
  WRAP    arch/arm64/include/generated/asm/sizes.h
  WRAP    arch/arm64/include/generated/asm/swab.h
  WRAP    arch/arm64/include/generated/asm/switch_to.h
  WRAP    arch/arm64/include/generated/asm/termbits.h
  WRAP    arch/arm64/include/generated/asm/termios.h
  WRAP    arch/arm64/include/generated/asm/topology.h
  WRAP    arch/arm64/include/generated/asm/trace_clock.h
  WRAP    arch/arm64/include/generated/asm/types.h
  WRAP    arch/arm64/include/generated/asm/unaligned.h
  WRAP    arch/arm64/include/generated/asm/user.h
  WRAP    arch/arm64/include/generated/asm/vga.h
  WRAP    arch/arm64/include/generated/asm/xor.h
  WRAP    arch/arm64/include/generated/uapi/asm/kvm_para.h
  Using /home/pierluigi/GPL_X1_series_V2/alps/kernel-3.18 as source for kernel
start to parse fig file!
  CHK     include/generated/utsrelease.h
  UPD     include/generated/utsrelease.h
  HOSTCC  scripts/kallsyms
  HOSTCC  scripts/pnmtologo
  HOSTCC  scripts/sortextable
  HOSTCC  scripts/dtc/dtc.o
  CC      scripts/mod/empty.o
  HOSTCC  scripts/selinux/genheaders/genheaders
  HOSTCC  scripts/selinux/mdp/mdp
clang-10: error: unknown argument: '-fstack-usage'
  HOSTCC  scripts/dtc/flattree.o
/home/pierluigi/GPL_X1_series_V2/alps/kernel-3.18/scripts/Makefile.build:257: recipe for target 'scripts/mod/empty.o' failed
make[3]: *** [scripts/mod/empty.o] Error 1
/home/pierluigi/GPL_X1_series_V2/alps/kernel-3.18/scripts/Makefile.build:402: recipe for target 'scripts/mod' failed
make[2]: *** [scripts/mod] Error 2
make[2]: *** Waiting for unfinished jobs....
  HOSTCC  scripts/dtc/fstree.o
  HOSTCC  scripts/dtc/data.o
  HOSTCC  scripts/dtc/livetree.o
  HOSTCC  scripts/dtc/treesource.o
start to parse fig file!
Start to gen cust_eint.dtsi...
Gen cust_eint.dtsi successfully!
Start to gen cust_gpio_usage_mapping.dtsi...
Gen cust_gpio_usage_mapping.dtsi file successfully!.
Start to gen cust_md1_eint.dtsi...
Gen cust_md1_eint.dtsi file successfully!.
Gen cust_pmic.dtsi file successfully!.
Start to gen cust_adc.dtsi...
Gen cust_adc.dtsi file successfully!.
Start to gen cust_clk_buf.dtsi...
Gen cust_clk_buf.dtsi file successfully!
Start to gen cust_kpd.dtsi...
Gen cust_kpd.dtsi file successfully!.
Start to gen cust_i2c.dtsi...
Gen cust_i2c.dtsi file successfully!.
  HOSTCC  scripts/dtc/srcpos.o
  HOSTCC  scripts/dtc/checks.o
  CC      kernel/bounds.s
  HOSTCC  scripts/dtc/util.o
  SHIPPED scripts/dtc/dtc-lexer.lex.c
  SHIPPED scripts/dtc/dtc-parser.tab.h
  SHIPPED scripts/dtc/dtc-parser.tab.c
  HOSTCC  scripts/dtc/dtc-lexer.lex.o
  HOSTCC  scripts/dtc/dtc-parser.tab.o
clang-10: error: unknown argument: '-fstack-usage'
/home/pierluigi/GPL_X1_series_V2/alps/kernel-3.18/./Kbuild:35: recipe for target 'kernel/bounds.s' failed
make[2]: *** [kernel/bounds.s] Error 1
/home/pierluigi/GPL_X1_series_V2/alps/kernel-3.18/Makefile:982: recipe for target 'prepare0' failed
make[1]: *** [prepare0] Error 2
make[1]: *** Waiting for unfinished jobs....
  HOSTLD  scripts/dtc/dtc
/home/pierluigi/GPL_X1_series_V2/alps/kernel-3.18/Makefile:555: recipe for target 'scripts' failed
make[1]: *** [scripts] Error 2
make[1]: Leaving directory '/home/pierluigi/GPL_X1_series_V2/alps/kernel-3.18/kali-nethunter-kernel/out'
Makefile:145: recipe for target 'sub-make' failed
make: *** [sub-make] Error 2
make: Leaving directory '/home/pierluigi/GPL_X1_series_V2/alps/kernel-3.18'


real    0m3.632s
user    0m2.952s
sys     0m0.646s
[ SUCCESS  ] Kernel build completed
[ QUESTION ] Save .config as nethunter_defconfig? [y/n]
Could anyone help me with that?