Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CONFIG_WERROR=y and CONFIG_LD_ORPHAN_WARN_LEVEL="error" break kpatch-build #1391

Closed
joe-lawrence opened this issue May 1, 2024 · 2 comments
Assignees

Comments

@joe-lawrence
Copy link
Contributor

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.)

@joe-lawrence
Copy link
Contributor Author

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.

@joe-lawrence joe-lawrence self-assigned this May 1, 2024
@zhjwong
Copy link

zhjwong commented May 7, 2024

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!

swine pushed a commit to swine/kpatch that referenced this issue May 31, 2024
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: dynup#1391 ("CONFIG_WERROR=y and CONFIG_LD_ORPHAN_WARN_LEVEL="error" break kpatch-build")
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
joe-lawrence added a commit to joe-lawrence/kpatch that referenced this issue Jun 7, 2024
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: dynup#1391 ("CONFIG_WERROR=y and CONFIG_LD_ORPHAN_WARN_LEVEL="error" break kpatch-build")
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants