Skip to content

Commit 956b9cb

Browse files
committed
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 62089b8 ("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
2 parents fa2827e + f947112 commit 956b9cb

6 files changed

Lines changed: 104 additions & 15 deletions

File tree

Makefile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1497,6 +1497,15 @@ ifneq ($(wildcard $(resolve_btfids_O)),)
14971497
$(Q)$(MAKE) -sC $(srctree)/tools/bpf/resolve_btfids O=$(resolve_btfids_O) clean
14981498
endif
14991499

1500+
PHONY += objtool_clean
1501+
1502+
objtool_O = $(abspath $(objtree))/tools/objtool
1503+
1504+
objtool_clean:
1505+
ifneq ($(wildcard $(objtool_O)),)
1506+
$(Q)$(MAKE) -sC $(abs_srctree)/tools/objtool O=$(objtool_O) srctree=$(abs_srctree) clean
1507+
endif
1508+
15001509
tools/: FORCE
15011510
$(Q)mkdir -p $(objtree)/tools
15021511
$(Q)$(MAKE) O=$(abspath $(objtree)) subdir=tools -C $(srctree)/tools/
@@ -1666,7 +1675,7 @@ vmlinuxclean:
16661675
$(Q)$(CONFIG_SHELL) $(srctree)/scripts/link-vmlinux.sh clean
16671676
$(Q)$(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) clean)
16681677

1669-
clean: archclean vmlinuxclean resolve_btfids_clean
1678+
clean: archclean vmlinuxclean resolve_btfids_clean objtool_clean
16701679

16711680
# mrproper - Delete all generated files, including .config
16721681
#

scripts/cc-can-link.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ cat << "END" | $@ -Werror -Wl,--fatal-warnings -x c - -o /dev/null >/dev/null 2>
55
#include <stdio.h>
66
int main(void)
77
{
8-
printf("");
8+
printf("\n");
99
return 0;
1010
}
1111
END

scripts/make_fit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
'bzip2': CompTool('.bz2', 'pbzip2,bzip2'),
5555
'gzip': CompTool('.gz', 'pigz,gzip'),
5656
'lz4': CompTool('.lz4', 'lz4'),
57-
'lzma': CompTool('.lzma', 'plzip,lzma'),
57+
'lzma': CompTool('.lzma', 'lzma'),
5858
'lzo': CompTool('.lzo', 'lzop'),
5959
'xz': CompTool('.xz', 'xz'),
6060
'zstd': CompTool('.zstd', 'zstd'),

scripts/package/kernel.spec

Lines changed: 55 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
%{!?_arch: %define _arch dummy}
33
%{!?make: %define make make}
44
%define makeflags %{?_smp_mflags} ARCH=%{ARCH}
5-
%define __spec_install_post /usr/lib/rpm/brp-compress || :
6-
%define debug_package %{nil}
75

86
Name: kernel
97
Summary: The Linux Kernel
@@ -47,13 +45,49 @@ This package provides kernel headers and makefiles sufficient to build modules
4745
against the %{version} kernel package.
4846
%endif
4947

50-
%if %{with_debuginfo}
48+
%if %{with_debuginfo_manual}
5149
%package debuginfo
5250
Summary: Debug information package for the Linux kernel
51+
Group: Development/Debug
52+
AutoReq: 0
53+
AutoProv: 1
5354
%description debuginfo
5455
This package provides debug information for the kernel image and modules from the
5556
%{version} package.
57+
%define install_mod_strip 1
58+
%endif
59+
60+
%if %{with_debuginfo_rpm}
61+
# list of debuginfo-related options taken from distribution kernel.spec
62+
# files
63+
%undefine _include_minidebuginfo
64+
%undefine _find_debuginfo_dwz_opts
65+
%undefine _unique_build_ids
66+
%undefine _unique_debug_names
67+
%undefine _unique_debug_srcs
68+
%undefine _debugsource_packages
69+
%undefine _debuginfo_subpackages
70+
%global _find_debuginfo_opts -r
71+
%global _missing_build_ids_terminate_build 1
72+
%global _no_recompute_build_ids 1
73+
%{debug_package}
74+
75+
# later, we make all modules executable so that find-debuginfo.sh strips
76+
# them up. but they don't actually need to be executable, so remove the
77+
# executable bit, taking care to do it _after_ find-debuginfo.sh has run
78+
%define __spec_install_post \
79+
%{?__debug_package:%{__debug_install_post}} \
80+
%{__arch_install_post} \
81+
%{__os_install_post} \
82+
find %{buildroot}/lib/modules/%{KERNELRELEASE} -name "*.ko" -type f \\\
83+
| xargs --no-run-if-empty chmod u-x
84+
%else
85+
%define __spec_install_post /usr/lib/rpm/brp-compress || :
5686
%endif
87+
# some (but not all) versions of rpmbuild emit %%debug_package with
88+
# %%install. since we've already emitted it manually, that would cause
89+
# a package redefinition error. ensure that doesn't happen
90+
%define debug_package %{nil}
5791

5892
%prep
5993
%setup -q -n linux
@@ -67,7 +101,7 @@ patch -p1 < %{SOURCE2}
67101
mkdir -p %{buildroot}/lib/modules/%{KERNELRELEASE}
68102
cp $(%{make} %{makeflags} -s image_name) %{buildroot}/lib/modules/%{KERNELRELEASE}/vmlinuz
69103
# DEPMOD=true makes depmod no-op. We do not package depmod-generated files.
70-
%{make} %{makeflags} INSTALL_MOD_PATH=%{buildroot} INSTALL_MOD_STRIP=1 DEPMOD=true modules_install
104+
%{make} %{makeflags} INSTALL_MOD_PATH=%{buildroot} %{?install_mod_strip:INSTALL_MOD_STRIP=1} DEPMOD=true modules_install
71105
%{make} %{makeflags} INSTALL_HDR_PATH=%{buildroot}/usr headers_install
72106
cp System.map %{buildroot}/lib/modules/%{KERNELRELEASE}
73107
cp .config %{buildroot}/lib/modules/%{KERNELRELEASE}/config
@@ -98,22 +132,30 @@ ln -fns /usr/src/kernels/%{KERNELRELEASE} %{buildroot}/lib/modules/%{KERNELRELEA
98132
echo "%exclude /lib/modules/%{KERNELRELEASE}/build"
99133
} > %{buildroot}/kernel.list
100134

101-
%if %{with_debuginfo}
135+
%if 0%{with_debuginfo_manual}%{with_debuginfo_rpm} > 0
102136
# copying vmlinux directly to the debug directory means it will not get
103137
# stripped (but its source paths will still be collected + fixed up)
104138
mkdir -p %{buildroot}/usr/lib/debug/lib/modules/%{KERNELRELEASE}
105139
cp vmlinux %{buildroot}/usr/lib/debug/lib/modules/%{KERNELRELEASE}
140+
%endif
106141

107-
echo /usr/lib/debug/lib/modules/%{KERNELRELEASE}/vmlinux > %{buildroot}/debuginfo.list
142+
%if %{with_debuginfo_rpm}
143+
# make modules executable so that find-debuginfo.sh strips them. this
144+
# will be undone later in %%__spec_install_post
145+
find %{buildroot}/lib/modules/%{KERNELRELEASE} -name "*.ko" -type f \
146+
| xargs --no-run-if-empty chmod u+x
147+
%endif
108148

149+
%if %{with_debuginfo_manual}
150+
echo /usr/lib/debug/lib/modules/%{KERNELRELEASE}/vmlinux > %{buildroot}/debuginfo.list
109151
while read -r mod; do
110152
mod="${mod%.o}.ko"
111153
dbg="%{buildroot}/usr/lib/debug/lib/modules/%{KERNELRELEASE}/kernel/${mod}"
112-
buildid=$("${READELF}" -n "${mod}" | sed -n 's@^.*Build ID: \(..\)\(.*\)@\1/\2@p')
154+
buildid=$("${READELF:-readelf}" -n "${mod}" | sed -n 's@^.*Build ID: \(..\)\(.*\)@\1/\2@p')
113155
link="%{buildroot}/usr/lib/debug/.build-id/${buildid}.debug"
114156

115157
mkdir -p "${dbg%/*}" "${link%/*}"
116-
"${OBJCOPY}" --only-keep-debug "${mod}" "${dbg}"
158+
"${OBJCOPY:-objcopy}" --only-keep-debug "${mod}" "${dbg}"
117159
ln -sf --relative "${dbg}" "${link}"
118160

119161
echo "${dbg#%{buildroot}}" >> %{buildroot}/debuginfo.list
@@ -123,6 +165,10 @@ done < modules.order
123165

124166
%clean
125167
rm -rf %{buildroot}
168+
%if %{with_debuginfo_rpm}
169+
rm -f debugfiles.list debuglinks.list debugsourcefiles.list debugsources.list \
170+
elfbins.list
171+
%endif
126172

127173
%post
128174
if [ -x /usr/bin/kernel-install ]; then
@@ -162,7 +208,7 @@ fi
162208
/lib/modules/%{KERNELRELEASE}/build
163209
%endif
164210

165-
%if %{with_debuginfo}
211+
%if %{with_debuginfo_manual}
166212
%files -f %{buildroot}/debuginfo.list debuginfo
167213
%defattr (-, root, root)
168214
%exclude /debuginfo.list

scripts/package/mkspec

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,47 @@ else
2323
echo '%define with_devel 0'
2424
fi
2525

26+
# use %{debug_package} machinery to generate -debuginfo
27+
with_debuginfo_rpm=0
28+
# manually generate -debuginfo package
29+
with_debuginfo_manual=0
2630
# debuginfo package generation uses find-debuginfo.sh under the hood,
2731
# which only works on uncompressed modules that contain debuginfo
2832
if grep -q CONFIG_DEBUG_INFO=y include/config/auto.conf &&
2933
(! grep -q CONFIG_MODULE_COMPRESS=y include/config/auto.conf) &&
3034
(! grep -q CONFIG_DEBUG_INFO_SPLIT=y include/config/auto.conf); then
31-
echo '%define with_debuginfo %{?_without_debuginfo: 0} %{?!_without_debuginfo: 1}'
32-
else
33-
echo '%define with_debuginfo 0'
35+
# If module signing is enabled (which may be required to boot with
36+
# lockdown enabled), the find-debuginfo.sh machinery cannot be used
37+
# because the signatures will be stripped off the modules. However, due
38+
# to an rpm bug in versions prior to 4.20.0
39+
#
40+
# https://github.com/rpm-software-management/rpm/issues/3057
41+
# https://github.com/rpm-software-management/rpm/commit/49f906998f3cf1f4152162ca61ac0869251c380f
42+
#
43+
# We cannot provide our own debuginfo package because it does not listen
44+
# to our custom files list, failing the build due to unpackaged files.
45+
# Manually generate the debug info package if using rpm 4.20.0. If not
46+
# using rpm 4.20.0, avoid generating a -debuginfo package altogether,
47+
# as it is not safe.
48+
if grep -q CONFIG_MODULE_SIG=y include/config/auto.conf; then
49+
rpm_ver_str=$(rpm --version 2>/dev/null)
50+
# Split the version on spaces
51+
IFS=' '
52+
set -- $rpm_ver_str
53+
if [ "${1:-}" = RPM -a "${2:-}" = version ]; then
54+
IFS=.
55+
set -- $3
56+
rpm_ver=$(( 1000000 * $1 + 10000 * $2 + 100 * $3 + ${4:-0} ))
57+
if [ "$rpm_ver" -ge 4200000 ]; then
58+
with_debuginfo_manual='%{?_without_debuginfo:0}%{?!_without_debuginfo:1}'
59+
fi
60+
fi
61+
else
62+
with_debuginfo_rpm='%{?_without_debuginfo:0}%{?!_without_debuginfo:1}'
63+
fi
3464
fi
65+
echo "%define with_debuginfo_manual $with_debuginfo_manual"
66+
echo "%define with_debuginfo_rpm $with_debuginfo_rpm"
3567

3668
cat<<EOF
3769
%define ARCH ${ARCH}

tools/objtool/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ srctree := $(patsubst %/,%,$(dir $(CURDIR)))
2929
srctree := $(patsubst %/,%,$(dir $(srctree)))
3030
endif
3131

32+
RM ?= rm -f
33+
3234
LIBSUBCMD_DIR = $(srctree)/tools/lib/subcmd/
3335
ifneq ($(OUTPUT),)
3436
LIBSUBCMD_OUTPUT = $(abspath $(OUTPUT))/libsubcmd

0 commit comments

Comments
 (0)