[Sony Xperia XZ2 ROMs, Kernels, Recoveries, & Other] MartinX3:
It is not possible to build the omni module with the aosp kernel sources.

So I will prebuild it with the xperia AOSP sources and then build omni boot/twrp with the prebuild one.

omni 8.1

Building Kernel Modules
make: Entering directory '/media/martin/extLinux/Develop/android/platform_manifest_twrp_omni_8.1/kernel/sony/akari'
make[1]: Verzeichnis „/media/martin/extLinux/Develop/android/platform_manifest_twrp_omni_8.1/out/target/product/akari/obj/KERNEL_OBJ“ wird betreten
CHK include/config/kernel.release
GEN ./Makefile
CHK include/generated/uapi/linux/version.h
CHK include/generated/utsrelease.h
Using /media/martin/extLinux/Develop/android/platform_manifest_twrp_omni_8.1/kernel/sony/akari as source for kernel
CHK scripts/mod/devicetable-offsets.h
CHK include/generated/timeconst.h
CHK include/generated/bounds.h
CHK include/generated/asm-offsets.h
CALL /media/martin/extLinux/Develop/android/platform_manifest_twrp_omni_8.1/kernel/sony/akari/scripts/checksyscalls.sh
Building modules, stage 2.
MODPOST 3 modules
make[1]: Verzeichnis „/media/martin/extLinux/Develop/android/platform_manifest_twrp_omni_8.1/out/target/product/akari/obj/KERNEL_OBJ“ wird verlassen
make: Leaving directory '/media/martin/extLinux/Develop/android/platform_manifest_twrp_omni_8.1/kernel/sony/akari'
[ 99% 8737/8739] build INSTALLED_KERNEL_MODULES
Installing Kernel Modules
make: Entering directory '/media/martin/extLinux/Develop/android/platform_manifest_twrp_omni_8.1/kernel/sony/akari'
make[1]: Verzeichnis „/media/martin/extLinux/Develop/android/platform_manifest_twrp_omni_8.1/out/target/product/akari/obj/KERNEL_OBJ“ wird betreten
INSTALL drivers/media/usb/gspca/gspca_main.ko
INSTALL drivers/soc/qcom/llcc_perfmon.ko
INSTALL fs/efivarfs/efivarfs.ko
DEPMOD 4.9.103
make[1]: Verzeichnis „/media/martin/extLinux/Develop/android/platform_manifest_twrp_omni_8.1/out/target/product/akari/obj/KERNEL_OBJ“ wird verlassen
make: Leaving directory '/media/martin/extLinux/Develop/android/platform_manifest_twrp_omni_8.1/kernel/sony/akari'
depmod: WARNING: could not open /media/martin/extLinux/Develop/android/platform_manifest_twrp_omni_8.1/out/target/product/akari/obj/PACKAGING/depmod_system_intermediates/lib/modules/0.0/modules.order: No such file or directory
depmod: WARNING: could not open /media/martin/extLinux/Develop/android/platform_manifest_twrp_omni_8.1/out/target/product/akari/obj/PACKAGING/depmod_system_intermediates/lib/modules/0.0/modules.builtin: No such file or directory
[ 99% 8738/8739] Prebuilt: (/media/martin/extLinux/Develop/android/platform_manifest_twrp_omni_8.1/out/target/product/akari/kernel)
FAILED: /media/martin/extLinux/Develop/android/platform_manifest_twrp_omni_8.1/out/target/product/akari/kernel
/bin/bash -c "(rm -f /media/martin/extLinux/Develop/android/platform_manifest_twrp_omni_8.1/out/target/product/akari/kernel ) && (cp /media/martin/extLinux/Develop/android/platform_manifest_twrp_omni_8.1/out/target/product/akari/obj/KERNEL_OBJ/arch/arm64/boot/ /media/martin/extLinux/Develop/android/platform_manifest_twrp_omni_8.1/out/target/product/akari/kernel )"
cp: -r not specified; omitting directory '/media/martin/extLinux/Develop/android/platform_manifest_twrp_omni_8.1/out/target/product/akari/obj/KERNEL_OBJ/arch/arm64/boot/'
ninja: build stopped: subcommand failed.
22:16:36 ninja failed with: exit status 1

#### failed to build some targets (10:15 (mm:ss)) ####

omni 8.0 (maybe because it is a 8.1 kernel)

make[1]: Verzeichnis „/media/martin/extLinux/Develop/android/platform_manifest_twrp_omni_8.0/out/target/product/akari/obj/KERNEL_OBJ“ wird verlassen
make: Leaving directory '/media/martin/extLinux/Develop/android/platform_manifest_twrp_omni_8.0/kernel/sony/akari'
[ 57% 4/7] build TARGET_KERNEL_BINARIES
FAILED: TARGET_KERNEL_BINARIES
/bin/bash -c "(make -j4 CFLAGS_MODULE=\"-fno-pic\" -C kernel/sony/akari O=/media/martin/extLinux/Develop/android/platform_manifest_twrp_omni_8.0/out/target/product/akari/obj/KERNEL_OBJ ARCH=arm64 CROSS_COMPILE=\" aarch64-linux-android-\" zImage ) && (if grep -q 'CONFIG_OF=y' /media/martin/extLinux/Develop/android/platform_manifest_twrp_omni_8.0/out/target/product/akari/obj/KERNEL_OBJ/.config ;	then	echo -e \"Building DTBs\" ;	make -j4 CFLAGS_MODULE=\"-fno-pic\" -C kernel/sony/akari O=/media/martin/extLinux/Develop/android/platform_manifest_twrp_omni_8.0/out/target/product/akari/obj/KERNEL_OBJ ARCH=arm64 CROSS_COMPILE=\" aarch64-linux-android-\" dtbs ;	else	echo \"DTBs not enabled\" ;	fi ) && (if grep -q 'CONFIG_MODULES=y' /media/martin/extLinux/Develop/android/platform_manifest_twrp_omni_8.0/out/target/product/akari/obj/KERNEL_OBJ/.config ;	then	echo -e \"Building Kernel Modules\" ;	make -j4 CFLAGS_MODULE=\"-fno-pic\" -C kernel/sony/akari O=/media/martin/extLinux/Develop/android/platform_manifest_twrp_omni_8.0/out/target/product/akari/obj/KERNEL_OBJ ARCH=arm64 CROSS_COMPILE=\" aarch64-linux-android-\" modules &&	make -j4 CFLAGS_MODULE=\"-fno-pic\" -C kernel/sony/akari O=/media/martin/extLinux/Develop/android/platform_manifest_twrp_omni_8.0/out/target/product/akari/obj/KERNEL_OBJ INSTALL_MOD_PATH=../../system ARCH=arm64 CROSS_COMPILE=\" aarch64-linux-android-\" modules_install &&	mdpath=\`find /media/martin/extLinux/Develop/android/platform_manifest_twrp_omni_8.0/out/target/product/akari/system/lib/modules -type f -name modules.order\`; if [ \"\$mdpath\" != \"\" ];then mpath=\`dirname \$mdpath\`; ko=\`find \$mpath/kernel -type f -name *.ko\`; for i in \$ko; do aarch64-linux-android-strip --strip-unneeded \$i; mv \$i /media/martin/extLinux/Develop/android/platform_manifest_twrp_omni_8.0/out/target/product/akari/system/lib/modules/; done; fi &&	mdpath=\`find /media/martin/extLinux/Develop/android/platform_manifest_twrp_omni_8.0/out/target/product/akari/system/lib/modules -type f -name modules.order\`; if [ \"\$mdpath\" != \"\" ];then mpath=\`dirname \$mdpath\`; rm -rf \$mpath; fi ;	else	echo \"Kernel Modules not enabled\" ;	fi )"
make: Entering directory '/media/martin/extLinux/Develop/android/platform_manifest_twrp_omni_8.0/kernel/sony/akari'
make[1]: Verzeichnis „/media/martin/extLinux/Develop/android/platform_manifest_twrp_omni_8.0/out/target/product/akari/obj/KERNEL_OBJ“ wird betreten
GEN ./Makefile
scripts/kconfig/conf --silentoldconfig Kconfig
make[1]: *** Keine Regel, um „zImage“ zu erstellen. Schluss.
make[1]: Verzeichnis „/media/martin/extLinux/Develop/android/platform_manifest_twrp_omni_8.0/out/target/product/akari/obj/KERNEL_OBJ“ wird verlassen
Makefile:152: recipe for target 'sub-make' failed
make: *** [sub-make] Error 2
make: Leaving directory '/media/martin/extLinux/Develop/android/platform_manifest_twrp_omni_8.0/kernel/sony/akari'
ninja: build stopped: subcommand failed.
22:30:06 ninja failed with: exit status 1
build/core/main.mk:21: recipe for target 'run_soong_ui' failed
make: *** [run_soong_ui] Error 1
make: Leaving directory '/media/martin/extLinux/Develop/android/platform_manifest_twrp_omni_8.0'

#### make failed to build some targets (53 seconds) ####

AOSP Xperia is building the boot image in 2 minutes.

Maybe the kernel is incomplete or only compatible with the xperia build environment.