kpatch-build: demote CONFIG_LD_ORPHAN_WARN_LEVEL

Upstream kernel v6.1+ commit linux@e1789d7c752e ("kbuild: upgrade the
orphan section warning to an error if CONFIG_WERROR is set") and
CONFIG_WERROR will result in failed kernel builds due to the linker
reporting tons of "unplaced orphan section `.text.<function>`
<object-file.o>" errors.

Workaround this by temporarily demoting such errors in the top-level
kernel Makefile.

Reported-and-tested-by: Zhijun Wang <zhijwang@redhat.com>
Closes: #1391 ("CONFIG_WERROR=y and CONFIG_LD_ORPHAN_WARN_LEVEL="error" break kpatch-build")
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
This commit is contained in:
Joe Lawrence 2024-04-30 15:27:03 -04:00
parent b363972b79
commit 56dfdbeb5b
1 changed files with 9 additions and 0 deletions

View File

@ -186,6 +186,7 @@ cleanup() {
# restore any files that were modified for the build
[[ -e "$TEMPDIR/vmlinux" ]] && mv -f "$TEMPDIR/vmlinux" "$KERNEL_SRCDIR/"
[[ -e "$TEMPDIR/Makefile" ]] && mv -f "$TEMPDIR/Makefile" "$KERNEL_SRCDIR/"
[[ -e "$TEMPDIR/link-vmlinux.sh" ]] && mv -f "$TEMPDIR/link-vmlinux.sh" "$KERNEL_SRCDIR/scripts"
[[ -e "$TEMPDIR/Makefile.modfinal" ]] && mv -f "$TEMPDIR/Makefile.modfinal" "$KERNEL_SRCDIR/scripts"
[[ -e "$TEMPDIR/setlocalversion" ]] && mv -f "$TEMPDIR/setlocalversion" "$KERNEL_SRCDIR/scripts"
@ -1174,6 +1175,14 @@ if [[ -n "$CONFIG_DEBUG_INFO_BTF" ]]; then
fi
fi
# CONFIG_LD_ORPHAN_WARN_LEVEL="error" will fail kernel builds with
# --ffunction-sections with lots of "ld: error: unplaced orphan section"
# errors. Temporarily demote to "warn"ings in the kernel Makefile.
if [[ "$CONFIG_LD_ORPHAN_WARN_LEVEL" == "error" ]]; then
cp -f "$KERNEL_SRCDIR/Makefile" "$TEMPDIR/Makefile" || die
sed -i 's/--orphan-handling=[$](CONFIG_LD_ORPHAN_WARN_LEVEL)/--orphan-handling="warn"/g' "$KERNEL_SRCDIR/Makefile" || die
fi
if [[ -n "$CONFIG_CC_IS_CLANG" ]]; then
echo "WARNING: Clang support is experimental"
fi