First round of Kbuild fixes for 7.0

- Ensure tools/objtool is cleaned by 'make clean' and 'make mrproper'
 
 - Fix test program for CONFIG_CC_CAN_LINK to avoid a warning, which is
   made fatal by -Werror
 
 - Drop explicit LZMA parallel compression in scripts/make_fit.py
 
 - Several fixes for commit 62089b8048 ("kbuild: rpm-pkg: Generate
   debuginfo package manually")
 -----BEGIN PGP SIGNATURE-----
 
 iHUEABYKAB0WIQR74yXHMTGczQHYypIdayaRccAalgUCaZYm2AAKCRAdayaRccAa
 lg5gAP0aeqyRzFjCAcle4vDqh1bLIY3+RxMgL4/d25tJfq+01wEAlvrLWdDl0eh8
 RdncqkIWNQA8YwlQDDVO0K1wcu+Mzw4=
 =CoUD
 -----END PGP SIGNATURE-----

Merge tag 'kbuild-fixes-7.0-1' of git://git.kernel.org/pub/scm/linux/kernel/git/kbuild/linux

Pull Kbuild fixes from Nathan Chancellor:

 - Ensure tools/objtool is cleaned by 'make clean' and 'make mrproper'

 - Fix test program for CONFIG_CC_CAN_LINK to avoid a warning, which is
   made fatal by -Werror

 - Drop explicit LZMA parallel compression in scripts/make_fit.py

 - Several fixes for commit 62089b8048 ("kbuild: rpm-pkg: Generate
   debuginfo package manually")

* tag 'kbuild-fixes-7.0-1' of git://git.kernel.org/pub/scm/linux/kernel/git/kbuild/linux:
  kbuild: rpm-pkg: Disable automatic requires for manual debuginfo package
  kbuild: rpm-pkg: Fix manual debuginfo generation when using .src.rpm
  kernel: rpm-pkg: Restore find-debuginfo.sh approach to -debuginfo package
  kbuild: rpm-pkg: Restrict manual debug package creation
  scripts/make_fit.py: Drop explicit LZMA parallel compression
  kbuild: Fix CC_CAN_LINK detection
  kbuild: Add objtool to top-level clean target
This commit is contained in:
Linus Torvalds 2026-02-18 14:59:55 -08:00
commit 956b9cbd7f
6 changed files with 104 additions and 15 deletions

View file

@ -1497,6 +1497,15 @@ ifneq ($(wildcard $(resolve_btfids_O)),)
$(Q)$(MAKE) -sC $(srctree)/tools/bpf/resolve_btfids O=$(resolve_btfids_O) clean
endif
PHONY += objtool_clean
objtool_O = $(abspath $(objtree))/tools/objtool
objtool_clean:
ifneq ($(wildcard $(objtool_O)),)
$(Q)$(MAKE) -sC $(abs_srctree)/tools/objtool O=$(objtool_O) srctree=$(abs_srctree) clean
endif
tools/: FORCE
$(Q)mkdir -p $(objtree)/tools
$(Q)$(MAKE) O=$(abspath $(objtree)) subdir=tools -C $(srctree)/tools/
@ -1666,7 +1675,7 @@ vmlinuxclean:
$(Q)$(CONFIG_SHELL) $(srctree)/scripts/link-vmlinux.sh clean
$(Q)$(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) clean)
clean: archclean vmlinuxclean resolve_btfids_clean
clean: archclean vmlinuxclean resolve_btfids_clean objtool_clean
# mrproper - Delete all generated files, including .config
#

View file

@ -5,7 +5,7 @@ cat << "END" | $@ -Werror -Wl,--fatal-warnings -x c - -o /dev/null >/dev/null 2>
#include <stdio.h>
int main(void)
{
printf("");
printf("\n");
return 0;
}
END

View file

@ -54,7 +54,7 @@ COMP_TOOLS = {
'bzip2': CompTool('.bz2', 'pbzip2,bzip2'),
'gzip': CompTool('.gz', 'pigz,gzip'),
'lz4': CompTool('.lz4', 'lz4'),
'lzma': CompTool('.lzma', 'plzip,lzma'),
'lzma': CompTool('.lzma', 'lzma'),
'lzo': CompTool('.lzo', 'lzop'),
'xz': CompTool('.xz', 'xz'),
'zstd': CompTool('.zstd', 'zstd'),

View file

@ -2,8 +2,6 @@
%{!?_arch: %define _arch dummy}
%{!?make: %define make make}
%define makeflags %{?_smp_mflags} ARCH=%{ARCH}
%define __spec_install_post /usr/lib/rpm/brp-compress || :
%define debug_package %{nil}
Name: kernel
Summary: The Linux Kernel
@ -47,14 +45,50 @@ This package provides kernel headers and makefiles sufficient to build modules
against the %{version} kernel package.
%endif
%if %{with_debuginfo}
%if %{with_debuginfo_manual}
%package debuginfo
Summary: Debug information package for the Linux kernel
Group: Development/Debug
AutoReq: 0
AutoProv: 1
%description debuginfo
This package provides debug information for the kernel image and modules from the
%{version} package.
%define install_mod_strip 1
%endif
%if %{with_debuginfo_rpm}
# list of debuginfo-related options taken from distribution kernel.spec
# files
%undefine _include_minidebuginfo
%undefine _find_debuginfo_dwz_opts
%undefine _unique_build_ids
%undefine _unique_debug_names
%undefine _unique_debug_srcs
%undefine _debugsource_packages
%undefine _debuginfo_subpackages
%global _find_debuginfo_opts -r
%global _missing_build_ids_terminate_build 1
%global _no_recompute_build_ids 1
%{debug_package}
# later, we make all modules executable so that find-debuginfo.sh strips
# them up. but they don't actually need to be executable, so remove the
# executable bit, taking care to do it _after_ find-debuginfo.sh has run
%define __spec_install_post \
%{?__debug_package:%{__debug_install_post}} \
%{__arch_install_post} \
%{__os_install_post} \
find %{buildroot}/lib/modules/%{KERNELRELEASE} -name "*.ko" -type f \\\
| xargs --no-run-if-empty chmod u-x
%else
%define __spec_install_post /usr/lib/rpm/brp-compress || :
%endif
# some (but not all) versions of rpmbuild emit %%debug_package with
# %%install. since we've already emitted it manually, that would cause
# a package redefinition error. ensure that doesn't happen
%define debug_package %{nil}
%prep
%setup -q -n linux
cp %{SOURCE1} .config
@ -67,7 +101,7 @@ patch -p1 < %{SOURCE2}
mkdir -p %{buildroot}/lib/modules/%{KERNELRELEASE}
cp $(%{make} %{makeflags} -s image_name) %{buildroot}/lib/modules/%{KERNELRELEASE}/vmlinuz
# DEPMOD=true makes depmod no-op. We do not package depmod-generated files.
%{make} %{makeflags} INSTALL_MOD_PATH=%{buildroot} INSTALL_MOD_STRIP=1 DEPMOD=true modules_install
%{make} %{makeflags} INSTALL_MOD_PATH=%{buildroot} %{?install_mod_strip:INSTALL_MOD_STRIP=1} DEPMOD=true modules_install
%{make} %{makeflags} INSTALL_HDR_PATH=%{buildroot}/usr headers_install
cp System.map %{buildroot}/lib/modules/%{KERNELRELEASE}
cp .config %{buildroot}/lib/modules/%{KERNELRELEASE}/config
@ -98,22 +132,30 @@ ln -fns /usr/src/kernels/%{KERNELRELEASE} %{buildroot}/lib/modules/%{KERNELRELEA
echo "%exclude /lib/modules/%{KERNELRELEASE}/build"
} > %{buildroot}/kernel.list
%if %{with_debuginfo}
%if 0%{with_debuginfo_manual}%{with_debuginfo_rpm} > 0
# copying vmlinux directly to the debug directory means it will not get
# stripped (but its source paths will still be collected + fixed up)
mkdir -p %{buildroot}/usr/lib/debug/lib/modules/%{KERNELRELEASE}
cp vmlinux %{buildroot}/usr/lib/debug/lib/modules/%{KERNELRELEASE}
%endif
%if %{with_debuginfo_rpm}
# make modules executable so that find-debuginfo.sh strips them. this
# will be undone later in %%__spec_install_post
find %{buildroot}/lib/modules/%{KERNELRELEASE} -name "*.ko" -type f \
| xargs --no-run-if-empty chmod u+x
%endif
%if %{with_debuginfo_manual}
echo /usr/lib/debug/lib/modules/%{KERNELRELEASE}/vmlinux > %{buildroot}/debuginfo.list
while read -r mod; do
mod="${mod%.o}.ko"
dbg="%{buildroot}/usr/lib/debug/lib/modules/%{KERNELRELEASE}/kernel/${mod}"
buildid=$("${READELF}" -n "${mod}" | sed -n 's@^.*Build ID: \(..\)\(.*\)@\1/\2@p')
buildid=$("${READELF:-readelf}" -n "${mod}" | sed -n 's@^.*Build ID: \(..\)\(.*\)@\1/\2@p')
link="%{buildroot}/usr/lib/debug/.build-id/${buildid}.debug"
mkdir -p "${dbg%/*}" "${link%/*}"
"${OBJCOPY}" --only-keep-debug "${mod}" "${dbg}"
"${OBJCOPY:-objcopy}" --only-keep-debug "${mod}" "${dbg}"
ln -sf --relative "${dbg}" "${link}"
echo "${dbg#%{buildroot}}" >> %{buildroot}/debuginfo.list
@ -123,6 +165,10 @@ done < modules.order
%clean
rm -rf %{buildroot}
%if %{with_debuginfo_rpm}
rm -f debugfiles.list debuglinks.list debugsourcefiles.list debugsources.list \
elfbins.list
%endif
%post
if [ -x /usr/bin/kernel-install ]; then
@ -162,7 +208,7 @@ fi
/lib/modules/%{KERNELRELEASE}/build
%endif
%if %{with_debuginfo}
%if %{with_debuginfo_manual}
%files -f %{buildroot}/debuginfo.list debuginfo
%defattr (-, root, root)
%exclude /debuginfo.list

View file

@ -23,15 +23,47 @@ else
echo '%define with_devel 0'
fi
# use %{debug_package} machinery to generate -debuginfo
with_debuginfo_rpm=0
# manually generate -debuginfo package
with_debuginfo_manual=0
# debuginfo package generation uses find-debuginfo.sh under the hood,
# which only works on uncompressed modules that contain debuginfo
if grep -q CONFIG_DEBUG_INFO=y include/config/auto.conf &&
(! grep -q CONFIG_MODULE_COMPRESS=y include/config/auto.conf) &&
(! grep -q CONFIG_DEBUG_INFO_SPLIT=y include/config/auto.conf); then
echo '%define with_debuginfo %{?_without_debuginfo: 0} %{?!_without_debuginfo: 1}'
else
echo '%define with_debuginfo 0'
# If module signing is enabled (which may be required to boot with
# lockdown enabled), the find-debuginfo.sh machinery cannot be used
# because the signatures will be stripped off the modules. However, due
# to an rpm bug in versions prior to 4.20.0
#
# https://github.com/rpm-software-management/rpm/issues/3057
# https://github.com/rpm-software-management/rpm/commit/49f906998f3cf1f4152162ca61ac0869251c380f
#
# We cannot provide our own debuginfo package because it does not listen
# to our custom files list, failing the build due to unpackaged files.
# Manually generate the debug info package if using rpm 4.20.0. If not
# using rpm 4.20.0, avoid generating a -debuginfo package altogether,
# as it is not safe.
if grep -q CONFIG_MODULE_SIG=y include/config/auto.conf; then
rpm_ver_str=$(rpm --version 2>/dev/null)
# Split the version on spaces
IFS=' '
set -- $rpm_ver_str
if [ "${1:-}" = RPM -a "${2:-}" = version ]; then
IFS=.
set -- $3
rpm_ver=$(( 1000000 * $1 + 10000 * $2 + 100 * $3 + ${4:-0} ))
if [ "$rpm_ver" -ge 4200000 ]; then
with_debuginfo_manual='%{?_without_debuginfo:0}%{?!_without_debuginfo:1}'
fi
fi
else
with_debuginfo_rpm='%{?_without_debuginfo:0}%{?!_without_debuginfo:1}'
fi
fi
echo "%define with_debuginfo_manual $with_debuginfo_manual"
echo "%define with_debuginfo_rpm $with_debuginfo_rpm"
cat<<EOF
%define ARCH ${ARCH}

View file

@ -29,6 +29,8 @@ srctree := $(patsubst %/,%,$(dir $(CURDIR)))
srctree := $(patsubst %/,%,$(dir $(srctree)))
endif
RM ?= rm -f
LIBSUBCMD_DIR = $(srctree)/tools/lib/subcmd/
ifneq ($(OUTPUT),)
LIBSUBCMD_OUTPUT = $(abspath $(OUTPUT))/libsubcmd