[Redmi K20 Pro / Xiaomi Mi 9T Pro Questions & Answe] Anon333266:
Hello,

I am trying to compile a Kernel on Arch Linux for my Device Mi 9T Pro (raphael), but everytime it comes to compile the kernel it fails.

I used the guide from Nathan Chance (https://xdaforums.com/android/software-hacking/reference-how-to-compile-android-kernel-t3627297), but even when I go step by step, it doesn't work.

The first point is, that it fails to properly use a parent directory.

I am using this repository:

https://github.com/UtsavBalar1231/kernel_xiaomi_raphael

This is what needs to be done:

mkdir -p out

make O=out distclean

make O=out mrproper

make O=out raphael-stock_defconfig

make O=out -j16

This is what I do:

##Going into the kernel source directory and setting the variables

export CROSS_COMPILE=/home/user/Toolchains/gcc-7.5.0/bin/aarch64-linux-gnu-

export ARCH=arm64 && export SUBARCH=arm64

##Creating a parent directory

mkdir -p out

##Setting up the directory

make O=out clean

make[1]: Entering directory '/home/user/build/xiaomi/out'
grep: .config: No such file or directory
grep: .config: No such file or directory
grep: .config: No such file or directory
grep: .config: No such file or directory
grep: .config: No such file or directory
grep: .config: No such file or directory
grep: .config: No such file or directory
grep: .config: No such file or directory
find: ‘arch/arm64/boot/dts/’: No such file or directory
find: ‘arch/arm64/boot/dts/’: No such file or directory
make[1]: Leaving directory '/home/user/build/xiaomi/out'

make O=out mrproper

make[1]: Entering directory '/home/user/build/xiaomi/out'
grep: .config: No such file or directory
grep: .config: No such file or directory
grep: .config: No such file or directory
grep: .config: No such file or directory
grep: .config: No such file or directory
grep: .config: No such file or directory
grep: .config: No such file or directory
grep: .config: No such file or directory
find: ‘arch/arm64/boot/dts/’: No such file or directory
find: ‘arch/arm64/boot/dts/’: No such file or directory
make[1]: Leaving directory '/home/user/build/xiaomi/out'

make O=out raphael-stock_defconfig //works

make[1]: Entering directory '/home/user/build/xiaomi/out'
HOSTCC scripts/basic/fixdep
GEN ./Makefile
HOSTCC scripts/kconfig/conf.o
SHIPPED scripts/kconfig/zconf.tab.c
SHIPPED scripts/kconfig/zconf.lex.c
HOSTCC scripts/kconfig/zconf.tab.o
HOSTLD scripts/kconfig/conf
#
# configuration written to .config
#
make[1]: Leaving directory '/home/user/build/xiaomi/out'

make O=out -j16

/usr/bin/ld: scripts/dtc/yamltree.o: in function `yaml_propval_int':
yamltree.c:(.text+0x161): undefined reference to `yaml_sequence_start_event_initialize'
/usr/bin/ld: yamltree.c:(.text+0x16c): undefined reference to `yaml_emitter_emit'
/usr/bin/ld: yamltree.c:(.text+0x1ed): undefined reference to `yaml_scalar_event_initialize'
/usr/bin/ld: yamltree.c:(.text+0x1fa): undefined reference to `yaml_emitter_emit'
/usr/bin/ld: yamltree.c:(.text+0x359): undefined reference to `yaml_scalar_event_initialize'
/usr/bin/ld: yamltree.c:(.text+0x384): undefined reference to `yaml_sequence_end_event_initialize'
/usr/bin/ld: yamltree.c:(.text+0x38f): undefined reference to `yaml_emitter_emit'
/usr/bin/ld: scripts/dtc/yamltree.o: in function `yaml_tree':
yamltree.c:(.text+0x522): undefined reference to `yaml_mapping_start_event_initialize'
/usr/bin/ld: yamltree.c:(.text+0x52d): undefined reference to `yaml_emitter_emit'
/usr/bin/ld: yamltree.c:(.text+0x5b9): undefined reference to `yaml_scalar_event_initialize'
/usr/bin/ld: yamltree.c:(.text+0x5c4): undefined reference to `yaml_emitter_emit'
/usr/bin/ld: yamltree.c:(.text+0x602): undefined reference to `yaml_sequence_start_event_initialize'
/usr/bin/ld: yamltree.c:(.text+0x60d): undefined reference to `yaml_emitter_emit'
/usr/bin/ld: yamltree.c:(.text+0x6b8): undefined reference to `yaml_sequence_end_event_initialize'
/usr/bin/ld: yamltree.c:(.text+0x6c3): undefined reference to `yaml_emitter_emit'
/usr/bin/ld: yamltree.c:(.text+0x756): undefined reference to `yaml_scalar_event_initialize'
/usr/bin/ld: yamltree.c:(.text+0x761): undefined reference to `yaml_emitter_emit'
/usr/bin/ld: yamltree.c:(.text+0x838): undefined reference to `yaml_scalar_event_initialize'
/usr/bin/ld: yamltree.c:(.text+0x843): undefined reference to `yaml_emitter_emit'
/usr/bin/ld: yamltree.c:(.text+0x86e): undefined reference to `yaml_mapping_end_event_initialize'
/usr/bin/ld: yamltree.c:(.text+0x879): undefined reference to `yaml_emitter_emit'
/usr/bin/ld: yamltree.c:(.text+0x8e1): undefined reference to `yaml_scalar_event_initialize'
/usr/bin/ld: yamltree.c:(.text+0x8ec): undefined reference to `yaml_emitter_emit'
/usr/bin/ld: scripts/dtc/yamltree.o: in function `dt_to_yaml':
yamltree.c:(.text+0xa8d): undefined reference to `yaml_emitter_initialize'
/usr/bin/ld: yamltree.c:(.text+0xa9b): undefined reference to `yaml_emitter_set_output_file'
/usr/bin/ld: yamltree.c:(.text+0xaa8): undefined reference to `yaml_stream_start_event_initialize'
/usr/bin/ld: yamltree.c:(.text+0xab3): undefined reference to `yaml_emitter_emit'
/usr/bin/ld: yamltree.c:(.text+0xacc): undefined reference to `yaml_document_start_event_initialize'
/usr/bin/ld: yamltree.c:(.text+0xad7): undefined reference to `yaml_emitter_emit'
/usr/bin/ld: yamltree.c:(.text+0xaf8): undefined reference to `yaml_sequence_start_event_initialize'
/usr/bin/ld: yamltree.c:(.text+0xb03): undefined reference to `yaml_emitter_emit'
/usr/bin/ld: yamltree.c:(.text+0xb1f): undefined reference to `yaml_sequence_end_event_initialize'
/usr/bin/ld: yamltree.c:(.text+0xb2a): undefined reference to `yaml_emitter_emit'
/usr/bin/ld: yamltree.c:(.text+0xb3c): undefined reference to `yaml_document_end_event_initialize'
/usr/bin/ld: yamltree.c:(.text+0xb47): undefined reference to `yaml_emitter_emit'
/usr/bin/ld: yamltree.c:(.text+0xb57): undefined reference to `yaml_stream_end_event_initialize'
/usr/bin/ld: yamltree.c:(.text+0xb62): undefined reference to `yaml_emitter_emit'
/usr/bin/ld: yamltree.c:(.text+0xb6e): undefined reference to `yaml_emitter_delete'
collect2: error: ld returned 1 exit status
make[3]: *** [scripts/Makefile.host:111: scripts/dtc/dtc] Error 1
make[2]: *** [../scripts/Makefile.build:675: scripts/dtc] Error 2
make[2]: *** Waiting for unfinished jobs....
HOSTLD scripts/mod/modpost
UPD include/generated/asm-offsets.h
CALL ../scripts/checksyscalls.sh
make[1]: *** [/home/user/build/xiaomi/Makefile:603: scripts] Error 2
make[1]: *** Waiting for unfinished jobs....
make[1]: Leaving directory '/home/user/build/xiaomi/out'
make: *** [Makefile:146: sub-make] Error 2

What is going wrong?