Kbuild fixes for 6.19, round 3

- kbuild: rpm-pkg: Generate debuginfo package manually, allowing
    signed kernel modules in rpm package, again
 
  - kbuild: Fix permissions of modules.builtin.modinfo
 
  - kbuild: Do not run kernel-doc when building external modules
 
 Cc: Ethan Zuo <yuxuan.zuo@outlook.com>
 Cc: Holger Kiehl <Holger.Kiehl@dwd.de>
 Cc: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
 Cc: Nathan Chancellor <nathan@kernel.org>
 Cc: Randy Dunlap <rdunlap@infradead.org>
 Cc: Rong Zhang <i@rong.moe>
 Cc: Uday Shankar <ushankar@purestorage.com>
 Cc: linux-kbuild@vger.kernel.org
 Cc: linux-kernel@vger.kernel.org
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEh0E3p4c3JKeBvsLGB1IKcBYmEmkFAml+Hv8ACgkQB1IKcBYm
 EmnClxAApczvQMYJWjFyoUcmMlB79dB6yZaaTp9T6+JGaWMS8zbkaU/dVDcY42Bs
 5GptCyWLKHohifG1GYIg2wKpCZbhNMAHNAL1xcJKnyqJ/ypoatwwdsVPlHw4D3Vx
 0VQVr4ofs9HeXMXznJtFCNoNMRWNoQIJncGYC1ki1X3X918b3Lr4237DWlR7NZpY
 Br+6oD6k9qEQ6hS+Q4nLwT+nYmHFwWkhOMO5tZfw1InLYBkoKC6kvimE9VvnF3hL
 Jb7xS7nHVV2yMvbAdFHvxKYc4EmpSV3rAE/kaYymSHepPbavqPPeVwp9CbWH3dg8
 qoXvUrndFs/CawNqqaAuDcXK+ppO+tnWTWjhNHKcvTh/YnnVByRKOs2QB1169/wg
 ENMlehDbLhMEkQBOmvIuc0nqkjIBtYKRjGpycHYuDCvSqrLxr9zgAIZRfgOnlPNb
 PxYWPSQd4kc1A0JGhvkwZGHyBzkfu8MFC6w2yHEA+Wt5aZQWwTfKGwyQue9PLX0a
 q8rgjBwe+tjCb8Q0LHcChFFG0jeAKEIBsiehfVC2x44Femcnjjrx/+MZy+qhKqLF
 TeWVPnlTvjOETxcP2LOx2kxHX7MHSq3lJSwu/3xR5U+PInbabTlyBjjepIsJU5Tz
 2qjrWLVlApHHK0juy3yNUebBo68qr3sgFxBJlRGhBaCVBvmBn9s=
 =2S41
 -----END PGP SIGNATURE-----

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

Pull Kbuild fixes from Nicolas Schier:

 - Generate rpm-pkg debuginfo package manually, allowing signed kernel
   modules in rpm package, again

 - Fix permissions of modules.builtin.modinfo

 - Do not run kernel-doc when building external modules

* tag 'kbuild-fixes-6.19-3' of git://git.kernel.org/pub/scm/linux/kernel/git/kbuild/linux:
  kbuild: Do not run kernel-doc when building external modules
  kbuild: Fix permissions of modules.builtin.modinfo
  kbuild: rpm-pkg: Generate debuginfo package manually
This commit is contained in:
Linus Torvalds 2026-01-31 08:21:32 -08:00
commit 44f4119c7c
3 changed files with 34 additions and 36 deletions

View file

@ -166,11 +166,13 @@ else ifeq ($(KBUILD_CHECKSRC),2)
cmd_force_checksrc = $(CHECK) $(CHECKFLAGS) $(c_flags) $<
endif
ifeq ($(KBUILD_EXTMOD),)
ifneq ($(KBUILD_EXTRA_WARN),)
cmd_checkdoc = PYTHONDONTWRITEBYTECODE=1 $(PYTHON3) $(KERNELDOC) -none $(KDOCFLAGS) \
$(if $(findstring 2, $(KBUILD_EXTRA_WARN)), -Wall) \
$<
endif
endif
# Compile C sources (.c)
# ---------------------------------------------------------------------------

View file

@ -113,7 +113,8 @@ vmlinux: vmlinux.unstripped FORCE
# what kmod expects to parse.
quiet_cmd_modules_builtin_modinfo = GEN $@
cmd_modules_builtin_modinfo = $(cmd_objcopy); \
sed -i 's/\x00\+$$/\x00/g' $@
sed -i 's/\x00\+$$/\x00/g' $@; \
chmod -x $@
OBJCOPYFLAGS_modules.builtin.modinfo := -j .modinfo -O binary

View file

@ -2,6 +2,8 @@
%{!?_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
@ -46,34 +48,12 @@ against the %{version} kernel package.
%endif
%if %{with_debuginfo}
# 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}
%package debuginfo
Summary: Debug information package for the Linux kernel
%description debuginfo
This package provides debug information for the kernel image and modules from the
%{version} package.
%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}
# 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
%prep
%setup -q -n linux
@ -87,7 +67,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} DEPMOD=true modules_install
%{make} %{makeflags} INSTALL_MOD_PATH=%{buildroot} 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
@ -118,22 +98,31 @@ ln -fns /usr/src/kernels/%{KERNELRELEASE} %{buildroot}/lib/modules/%{KERNELRELEA
echo "%exclude /lib/modules/%{KERNELRELEASE}/build"
} > %{buildroot}/kernel.list
# 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
%if %{with_debuginfo}
# 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}
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')
link="%{buildroot}/usr/lib/debug/.build-id/${buildid}.debug"
mkdir -p "${dbg%/*}" "${link%/*}"
"${OBJCOPY}" --only-keep-debug "${mod}" "${dbg}"
ln -sf --relative "${dbg}" "${link}"
echo "${dbg#%{buildroot}}" >> %{buildroot}/debuginfo.list
echo "${link#%{buildroot}}" >> %{buildroot}/debuginfo.list
done < modules.order
%endif
%clean
rm -rf %{buildroot}
rm -f debugfiles.list debuglinks.list debugsourcefiles.list debugsources.list \
elfbins.list
%post
if [ -x /usr/bin/kernel-install ]; then
@ -172,3 +161,9 @@ fi
/usr/src/kernels/%{KERNELRELEASE}
/lib/modules/%{KERNELRELEASE}/build
%endif
%if %{with_debuginfo}
%files -f %{buildroot}/debuginfo.list debuginfo
%defattr (-, root, root)
%exclude /debuginfo.list
%endif