background
The built-in kernel version of Ubuntu22.04 is 5.15. Today I wanted to compile a higher version of the 5.16.5 kernel, but unexpectedly an error occurred during compilation:
CALL scripts/checksyscalls.sh
CALL scripts/atomic/check-atomics.sh
DESCEND objtool
DESCEND bpf/resolve_btfids
CHK include/generated/compile.h
CHK kernel/kheaders_data.tar.xz
GEN .version
CHK include/generated/compile.h
UPD include/generated/compile.h
CC init/version.o
AR init/built-in.a
LD vmlinux.o
MODPOST vmlinux.symvers
MODINFO modules.builtin.modinfo
GEN modules.builtin
LD .tmp_vmlinux.btf
BTF .btf.vmlinux.bin.o
LD .tmp_vmlinux.kallsyms1
KSYMS .tmp_vmlinux.kallsyms1.S
AS .tmp_vmlinux.kallsyms1.S
LD .tmp_vmlinux.kallsyms2
KSYMS .tmp_vmlinux.kallsyms2.S
AS .tmp_vmlinux.kallsyms2.S
LD vmlinux
BTFIDS vmlinux
FAILED: load BTF from vmlinux: Invalid argument
make: *** [Makefile:1161: vmlinux] Error 255
make: *** Deleting file 'vmlinux'
I searched online and said that I need to change CONFIG_DEBUG_INFO_BTF=y in the .config configuration file to CONFIG_DEBUG_INFO_BTF=n. This way the compilation will not report an error. But I want to enable this option [option related to ebpf]. Further search found that it is because the version of the program pahole is too high. The current version is 1.25.
pahole --version
v1.25
Solution
Modify the scripts/pahole-flags.sh script in the kernel source directory and add the following lines of shell code:
if [ "${pahole_ver}" -ge "124" ]; then
# see PAHOLE_HAS_LANG_EXCLUDE
extra_paholeopt="${extra_paholeopt} --skip_encoding_btf_enum64"
fi
problem solved.
Reference:
https://lore.kernel.org/bpf/[email protected]/t/
https:/ /bbs.archlinux.org/viewtopic.php?pid=2067555