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.
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 <[email protected]> --- 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..f8c063f3d333 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: -- 2.53.0
