commit: 247d9bc5a4c171b86e158a6ca4b9d1c6c23f26b9 Author: Ionen Wolkens <ionen <AT> gentoo <DOT> org> AuthorDate: Wed Mar 11 16:04:38 2026 +0000 Commit: Ionen Wolkens <ionen <AT> gentoo <DOT> org> CommitDate: Thu Mar 12 01:24:20 2026 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=247d9bc5
linux-mod-r1.eclass: abort and explain if kernel's objtool is broken This is only intended to catch the most common case. Considered trying to rebuild objtool live, but felt that may be too fragile between different kernel versions and changing build and usage logic. Fortunately feel binutils does not receive new releases often enough for this to become a real hassle similarly to GCC plugins, esp. when users will not necessarily need to update modules until they update their kernel with the new toolchain. Dist kernels could optionally use binutils-libs:= to rebuild albeit that may just result in unnecessary rebuilds for the majority that are not using out-of-tree modules. Either way, the warning would still be needed for *-sources users. Closes: https://bugs.gentoo.org/971092 Signed-off-by: Ionen Wolkens <ionen <AT> gentoo.org> eclass/linux-mod-r1.eclass | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/eclass/linux-mod-r1.eclass b/eclass/linux-mod-r1.eclass index 49ae882f7e95..247739b95198 100644 --- a/eclass/linux-mod-r1.eclass +++ b/eclass/linux-mod-r1.eclass @@ -352,6 +352,7 @@ linux-mod-r1_pkg_setup() { _modules_prepare_cross _modules_sanity_gccplugins + _modules_sanity_objtool } # @FUNCTION: linux-mod-r1_src_compile @@ -1277,6 +1278,37 @@ _modules_sanity_modversion() { done } +# @FUNCTION: _modules_sanity_objtool +# @INTERNAL +# @DESCRIPTION: +# Checks that the kernel's objtool is usable if it exists. If not, +# abort right away with an explanation rather than do so later with +# a confusing error (bug #971092). +# +# Ever since it started to use binutils-libs in kernel >=6.19, it has +# become likely to be broken whenever binutils-libs is upgraded. +_modules_sanity_objtool() { + # ignore cross to keep this simple/safe without doing proper + # testing, albeit objtool should in theory be usable on CBUILD + tc-is-cross-compiler && return 0 + + local objtool=${KV_OUT_DIR}/tools/objtool/objtool + # if missing, assume this is a older kernel + if [[ -e ${objtool} ]]; then + "${objtool}" &>/dev/null + + # without arguments objtool is likely to return 129 unless + # one of its libraries is missing which results in 127 + if [[ ${?} -eq 127 ]]; then + eerror "Detected that '${objtool}' is not usable." + eerror "This is often because it uses old libraries that have been removed from" + eerror "the system. This can typically be fixed by rebuilding the kernel after" + eerror "doing \`make clean\` (or re-installing for distribution kernels)." + die "kernel ${KV_FULL} needs to be rebuilt" + fi + fi +} + # @FUNCTION: _modules_set_makeargs # @INTERNAL # @DESCRIPTION:
