CONFIG_WERROR=y and CONFIG_LD_ORPHAN_WARN_LEVEL="error" break kpatch-build
Closed this issue · 2 comments
Zhijun Wang reports seeing this on recent CentOS-Stream 9 builds.
I can confirm with upstream v6.8 and CONFIG_LD_ORPHAN_WARN_LEVEL="error":
$ git describe
v6.8
$ grep -e ORPHAN -e WERROR .config
CONFIG_WERROR=y
CONFIG_LD_ORPHAN_WARN=y
CONFIG_LD_ORPHAN_WARN_LEVEL="error"
CONFIG_ARCH_WANT_LD_ORPHAN_WARN=y
This combination breaks CONFIG_WERROR=y
kernel builds with -ffunction-sections
as the linker complaints about orphan sections are now promoted to errors.
$ KCFLAGS="-ffunction-sections" make -j$(nproc)
[ ... snip ... ]
LD .tmp_vmlinux.btf
ld: error: unplaced orphan section `.text.cc_mkdec' from `arch/x86/coco/core.o'
ld: error: unplaced orphan section `.text.cc_mkenc' from `arch/x86/coco/core.o'
ld: error: unplaced orphan section `.text.tdx_tlb_flush_required' from `arch/x86/coco/tdx/tdx.o'
ld: error: unplaced orphan section `.text.tdx_cache_flush_required' from `arch/x86/coco/tdx/tdx.o'
[ ... snip ... ]
BTF .btf.vmlinux.bin.o
pahole: .tmp_vmlinux.btf: Invalid argument
LD .tmp_vmlinux.kallsyms1
.btf.vmlinux.bin.o: file not recognized: file format not recognized
make[2]: *** [scripts/Makefile.vmlinux:37: vmlinux] Error 1
make[1]: *** [/root/linux/Makefile:1162: vmlinux] Error 2
make: *** [Makefile:240: __sub-make] Error 2
(To be specific, upstream v6.2+ kernel commit torvalds/linux@e1789d7c752e ("kbuild: upgrade the orphan section warning to an error if CONFIG_WERROR is set") propagates the linker error up. I suspect this commit has finally made its way back to CS-9.)
This branch: https://github.com/joe-lawrence/kpatch/tree/ld-orphan-error works around the problem by restoring --orphan-handling="warn"
in the kernel Makefile. Sent to Zhijun for further testing.
The branch https://github.com/joe-lawrence/kpatch/tree/ld-orphan-error fixed the 'ld: error: unplaced orphan section' error on CentOS-Stream 9 builds. Thanks Joe!