Skip to content

Commit f0dd81d

Browse files
committed
Merge tag 'kbuild-fixes-v6.3-3' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild
Pull Kbuild fixes from Masahiro Yamada: - Drop debug info from purgatory objects again - Document that kernel.org provides prebuilt LLVM toolchains - Give up handling untracked files for source package builds - Avoid creating corrupted cpio when KBUILD_BUILD_TIMESTAMP is given with a pre-epoch data. - Change panic_show_mem() to a macro to handle variable-length argument - Compress tarballs on-the-fly again * tag 'kbuild-fixes-v6.3-3' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: kbuild: do not create intermediate *.tar for tar packages kbuild: do not create intermediate *.tar for source tarballs kbuild: merge cmd_archive_linux and cmd_archive_perf init/initramfs: Fix argument forwarding to panic() in panic_show_mem() initramfs: Check negative timestamp to prevent broken cpio archive kbuild: give up untracked files for source package builds Documentation/llvm: Add a note about prebuilt kernel.org toolchains purgatory: fix disabling debug info
2 parents 6586c4d + 3c65a27 commit f0dd81d

File tree

9 files changed

+138
-139
lines changed

9 files changed

+138
-139
lines changed

Documentation/kbuild/llvm.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,10 @@ Getting Help
171171
Getting LLVM
172172
-------------
173173

174+
We provide prebuilt stable versions of LLVM on `kernel.org <https://kernel.org/pub/tools/llvm/>`_.
175+
Below are links that may be useful for building LLVM from source or procuring
176+
it through a distribution's package manager.
177+
174178
- https://releases.llvm.org/download.html
175179
- https://github.com/llvm/llvm-project
176180
- https://llvm.org/docs/GettingStarted.html

arch/riscv/purgatory/Makefile

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,7 @@ CFLAGS_string.o += $(PURGATORY_CFLAGS)
8484
CFLAGS_REMOVE_ctype.o += $(PURGATORY_CFLAGS_REMOVE)
8585
CFLAGS_ctype.o += $(PURGATORY_CFLAGS)
8686

87-
AFLAGS_REMOVE_entry.o += -Wa,-gdwarf-2
88-
AFLAGS_REMOVE_memcpy.o += -Wa,-gdwarf-2
89-
AFLAGS_REMOVE_memset.o += -Wa,-gdwarf-2
90-
AFLAGS_REMOVE_strcmp.o += -Wa,-gdwarf-2
91-
AFLAGS_REMOVE_strlen.o += -Wa,-gdwarf-2
92-
AFLAGS_REMOVE_strncmp.o += -Wa,-gdwarf-2
87+
asflags-remove-y += $(foreach x, -g -gdwarf-4 -gdwarf-5, $(x) -Wa,$(x))
9388

9489
$(obj)/purgatory.ro: $(PURGATORY_OBJS) FORCE
9590
$(call if_changed,ld)

arch/x86/purgatory/Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@ CFLAGS_sha256.o += $(PURGATORY_CFLAGS)
6969
CFLAGS_REMOVE_string.o += $(PURGATORY_CFLAGS_REMOVE)
7070
CFLAGS_string.o += $(PURGATORY_CFLAGS)
7171

72-
AFLAGS_REMOVE_setup-x86_$(BITS).o += -Wa,-gdwarf-2
73-
AFLAGS_REMOVE_entry64.o += -Wa,-gdwarf-2
72+
asflags-remove-y += $(foreach x, -g -gdwarf-4 -gdwarf-5, $(x) -Wa,$(x))
7473

7574
$(obj)/purgatory.ro: $(PURGATORY_OBJS) FORCE
7675
$(call if_changed,ld)

init/initramfs.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,8 @@ static void __init error(char *x)
6060
message = x;
6161
}
6262

63-
static void panic_show_mem(const char *fmt, ...)
64-
{
65-
va_list args;
66-
67-
show_mem(0, NULL);
68-
va_start(args, fmt);
69-
panic(fmt, args);
70-
va_end(args);
71-
}
63+
#define panic_show_mem(fmt, ...) \
64+
({ show_mem(0, NULL); panic(fmt, ##__VA_ARGS__); })
7265

7366
/* link hash */
7467

scripts/Makefile.package

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,6 @@ fi ; \
2727
tar -I $(KGZIP) -c $(RCS_TAR_IGNORE) -f $(2).tar.gz \
2828
--transform 's:^:$(2)/:S' $(TAR_CONTENT) $(3)
2929

30-
# tarball compression
31-
# ---------------------------------------------------------------------------
32-
33-
%.tar.gz: %.tar
34-
$(call cmd,gzip)
35-
36-
%.tar.bz2: %.tar
37-
$(call cmd,bzip2)
38-
39-
%.tar.xz: %.tar
40-
$(call cmd,xzmisc)
41-
42-
%.tar.zst: %.tar
43-
$(call cmd,zstd)
44-
4530
# Git
4631
# ---------------------------------------------------------------------------
4732

@@ -57,16 +42,24 @@ check-git:
5742
false; \
5843
fi
5944

45+
git-config-tar.gz = -c tar.tar.gz.command="$(KGZIP)"
46+
git-config-tar.bz2 = -c tar.tar.bz2.command="$(KBZIP2)"
47+
git-config-tar.xz = -c tar.tar.xz.command="$(XZ)"
48+
git-config-tar.zst = -c tar.tar.zst.command="$(ZSTD)"
49+
50+
quiet_cmd_archive = ARCHIVE $@
51+
cmd_archive = git -C $(srctree) $(git-config-tar$(suffix $@)) archive \
52+
--output=$$(realpath $@) --prefix=$(basename $@)/ $(archive-args)
53+
6054
# Linux source tarball
6155
# ---------------------------------------------------------------------------
6256

63-
quiet_cmd_archive_linux = ARCHIVE $@
64-
cmd_archive_linux = \
65-
git -C $(srctree) archive --output=$$(realpath $@) --prefix=$(basename $@)/ $$(cat $<)
57+
linux-tarballs := $(addprefix linux, .tar.gz)
6658

67-
targets += linux.tar
68-
linux.tar: .tmp_HEAD FORCE
69-
$(call if_changed,archive_linux)
59+
targets += $(linux-tarballs)
60+
$(linux-tarballs): archive-args = $$(cat $<)
61+
$(linux-tarballs): .tmp_HEAD FORCE
62+
$(call if_changed,archive)
7063

7164
# rpm-pkg
7265
# ---------------------------------------------------------------------------
@@ -94,7 +87,7 @@ binrpm-pkg:
9487
$(UTS_MACHINE)-linux -bb $(objtree)/binkernel.spec
9588

9689
quiet_cmd_debianize = GEN $@
97-
cmd_debianize = $(srctree)/scripts/package/mkdebian
90+
cmd_debianize = $(srctree)/scripts/package/mkdebian $(mkdebian-opts)
9891

9992
debian: FORCE
10093
$(call cmd,debianize)
@@ -103,6 +96,7 @@ PHONY += debian-orig
10396
debian-orig: private source = $(shell dpkg-parsechangelog -S Source)
10497
debian-orig: private version = $(shell dpkg-parsechangelog -S Version | sed 's/-[^-]*$$//')
10598
debian-orig: private orig-name = $(source)_$(version).orig.tar.gz
99+
debian-orig: mkdebian-opts = --need-source
106100
debian-orig: linux.tar.gz debian
107101
$(Q)if [ "$(df --output=target .. 2>/dev/null)" = "$(df --output=target $< 2>/dev/null)" ]; then \
108102
ln -f $< ../$(orig-name); \
@@ -145,10 +139,17 @@ tar-install: FORCE
145139
$(Q)$(MAKE) -f $(srctree)/Makefile
146140
+$(Q)$(srctree)/scripts/package/buildtar $@
147141

142+
compress-tar.gz = -I "$(KGZIP)"
143+
compress-tar.bz2 = -I "$(KBZIP2)"
144+
compress-tar.xz = -I "$(XZ)"
145+
compress-tar.zst = -I "$(ZSTD)"
146+
148147
quiet_cmd_tar = TAR $@
149-
cmd_tar = cd $<; tar cf ../$@ --owner=root --group=root --sort=name *
148+
cmd_tar = cd $<; tar cf ../$@ $(compress-tar$(suffix $@)) --owner=root --group=root --sort=name *
150149

151-
linux-$(KERNELRELEASE)-$(ARCH).tar: tar-install
150+
dir-tarballs := $(addprefix linux-$(KERNELRELEASE)-$(ARCH), .tar .tar.gz .tar.bz2 .tar.xz .tar.zst)
151+
152+
$(dir-tarballs): tar-install
152153
$(call cmd,tar)
153154

154155
PHONY += dir-pkg
@@ -180,16 +181,17 @@ quiet_cmd_perf_version_file = GEN $@
180181
.tmp_perf/PERF-VERSION-FILE: .tmp_HEAD $(srctree)/tools/perf/util/PERF-VERSION-GEN | .tmp_perf
181182
$(call cmd,perf_version_file)
182183

183-
quiet_cmd_archive_perf = ARCHIVE $@
184-
cmd_archive_perf = \
185-
git -C $(srctree) archive --output=$$(realpath $@) --prefix=$(basename $@)/ \
186-
--add-file=$$(realpath $(word 2, $^)) \
184+
perf-archive-args = --add-file=$$(realpath $(word 2, $^)) \
187185
--add-file=$$(realpath $(word 3, $^)) \
188186
$$(cat $(word 2, $^))^{tree} $$(cat $<)
189187

190-
targets += perf-$(KERNELVERSION).tar
191-
perf-$(KERNELVERSION).tar: tools/perf/MANIFEST .tmp_perf/HEAD .tmp_perf/PERF-VERSION-FILE FORCE
192-
$(call if_changed,archive_perf)
188+
189+
perf-tarballs := $(addprefix perf-$(KERNELVERSION), .tar .tar.gz .tar.bz2 .tar.xz .tar.zst)
190+
191+
targets += $(perf-tarballs)
192+
$(perf-tarballs): archive-args = $(perf-archive-args)
193+
$(perf-tarballs): tools/perf/MANIFEST .tmp_perf/HEAD .tmp_perf/PERF-VERSION-FILE FORCE
194+
$(call if_changed,archive)
193195

194196
PHONY += perf-tar-src-pkg
195197
perf-tar-src-pkg: perf-$(KERNELVERSION).tar

scripts/package/gen-diff-patch

Lines changed: 27 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,36 @@
11
#!/bin/sh
22
# SPDX-License-Identifier: GPL-2.0-only
33

4-
diff_patch="${1}"
5-
untracked_patch="${2}"
6-
srctree=$(dirname $0)/../..
4+
diff_patch=$1
75

8-
rm -f ${diff_patch} ${untracked_patch}
6+
mkdir -p "$(dirname "${diff_patch}")"
97

10-
if ! ${srctree}/scripts/check-git; then
11-
exit
12-
fi
13-
14-
mkdir -p "$(dirname ${diff_patch})" "$(dirname ${untracked_patch})"
8+
git -C "${srctree:-.}" diff HEAD > "${diff_patch}"
159

16-
git -C "${srctree}" diff HEAD > "${diff_patch}"
17-
18-
if [ ! -s "${diff_patch}" ]; then
19-
rm -f "${diff_patch}"
10+
if [ ! -s "${diff_patch}" ] ||
11+
[ -z "$(git -C "${srctree:-.}" ls-files --other --exclude-standard | head -n1)" ]; then
2012
exit
2113
fi
2214

23-
git -C ${srctree} status --porcelain --untracked-files=all |
24-
while read stat path
25-
do
26-
if [ "${stat}" = '??' ]; then
27-
28-
if ! diff -u /dev/null "${srctree}/${path}" > .tmp_diff &&
29-
! head -n1 .tmp_diff | grep -q "Binary files"; then
30-
{
31-
echo "--- /dev/null"
32-
echo "+++ linux/$path"
33-
cat .tmp_diff | tail -n +3
34-
} >> ${untracked_patch}
35-
fi
36-
fi
37-
done
38-
39-
rm -f .tmp_diff
40-
41-
if [ ! -s "${diff_patch}" ]; then
42-
rm -f "${diff_patch}"
43-
exit
44-
fi
15+
# The source tarball, which is generated by 'git archive', contains everything
16+
# you committed in the repository. If you have local diff ('git diff HEAD'),
17+
# it will go into ${diff_patch}. If untracked files are remaining, the resulting
18+
# source package may not be correct.
19+
#
20+
# Examples:
21+
# - You modified a source file to add #include "new-header.h"
22+
# but forgot to add new-header.h
23+
# - You modified a Makefile to add 'obj-$(CONFIG_FOO) += new-dirver.o'
24+
# but you forgot to add new-driver.c
25+
#
26+
# You need to commit them, or at least stage them by 'git add'.
27+
#
28+
# This script does not take care of untracked files because doing so would
29+
# introduce additional complexity. Instead, print a warning message here if
30+
# untracked files are found.
31+
# If all untracked files are just garbage, you can ignore this warning.
32+
echo >&2 "============================ WARNING ============================"
33+
echo >&2 "Your working tree has diff from HEAD, and also untracked file(s)."
34+
echo >&2 "Please make sure you did 'git add' for all new files you need in"
35+
echo >&2 "the source package."
36+
echo >&2 "================================================================="

scripts/package/mkdebian

Lines changed: 59 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,66 @@ set_debarch() {
8484
fi
8585
}
8686

87+
# Create debian/source/ if it is a source package build
88+
gen_source ()
89+
{
90+
mkdir -p debian/source
91+
92+
echo "3.0 (quilt)" > debian/source/format
93+
94+
{
95+
echo "diff-ignore"
96+
echo "extend-diff-ignore = .*"
97+
} > debian/source/local-options
98+
99+
# Add .config as a patch
100+
mkdir -p debian/patches
101+
{
102+
echo "Subject: Add .config"
103+
echo "Author: ${maintainer}"
104+
echo
105+
echo "--- /dev/null"
106+
echo "+++ linux/.config"
107+
diff -u /dev/null "${KCONFIG_CONFIG}" | tail -n +3
108+
} > debian/patches/config.patch
109+
echo config.patch > debian/patches/series
110+
111+
"${srctree}/scripts/package/gen-diff-patch" debian/patches/diff.patch
112+
if [ -s debian/patches/diff.patch ]; then
113+
sed -i "
114+
1iSubject: Add local diff
115+
1iAuthor: ${maintainer}
116+
1i
117+
" debian/patches/diff.patch
118+
119+
echo diff.patch >> debian/patches/series
120+
else
121+
rm -f debian/patches/diff.patch
122+
fi
123+
}
124+
87125
rm -rf debian
126+
mkdir debian
127+
128+
email=${DEBEMAIL-$EMAIL}
129+
130+
# use email string directly if it contains <email>
131+
if echo "${email}" | grep -q '<.*>'; then
132+
maintainer=${email}
133+
else
134+
# or construct the maintainer string
135+
user=${KBUILD_BUILD_USER-$(id -nu)}
136+
name=${DEBFULLNAME-${user}}
137+
if [ -z "${email}" ]; then
138+
buildhost=${KBUILD_BUILD_HOST-$(hostname -f 2>/dev/null || hostname)}
139+
email="${user}@${buildhost}"
140+
fi
141+
maintainer="${name} <${email}>"
142+
fi
143+
144+
if [ "$1" = --need-source ]; then
145+
gen_source
146+
fi
88147

89148
# Some variables and settings used throughout the script
90149
version=$KERNELRELEASE
@@ -104,22 +163,6 @@ fi
104163
debarch=
105164
set_debarch
106165

107-
email=${DEBEMAIL-$EMAIL}
108-
109-
# use email string directly if it contains <email>
110-
if echo $email | grep -q '<.*>'; then
111-
maintainer=$email
112-
else
113-
# or construct the maintainer string
114-
user=${KBUILD_BUILD_USER-$(id -nu)}
115-
name=${DEBFULLNAME-$user}
116-
if [ -z "$email" ]; then
117-
buildhost=${KBUILD_BUILD_HOST-$(hostname -f 2>/dev/null || hostname)}
118-
email="$user@$buildhost"
119-
fi
120-
maintainer="$name <$email>"
121-
fi
122-
123166
# Try to determine distribution
124167
if [ -n "$KDEB_CHANGELOG_DIST" ]; then
125168
distribution=$KDEB_CHANGELOG_DIST
@@ -132,34 +175,6 @@ else
132175
echo >&2 "Install lsb-release or set \$KDEB_CHANGELOG_DIST explicitly"
133176
fi
134177

135-
mkdir -p debian/source/
136-
echo "3.0 (quilt)" > debian/source/format
137-
138-
{
139-
echo "diff-ignore"
140-
echo "extend-diff-ignore = .*"
141-
} > debian/source/local-options
142-
143-
# Add .config as a patch
144-
mkdir -p debian/patches
145-
{
146-
echo "Subject: Add .config"
147-
echo "Author: ${maintainer}"
148-
echo
149-
echo "--- /dev/null"
150-
echo "+++ linux/.config"
151-
diff -u /dev/null "${KCONFIG_CONFIG}" | tail -n +3
152-
} > debian/patches/config
153-
echo config > debian/patches/series
154-
155-
$(dirname $0)/gen-diff-patch debian/patches/diff.patch debian/patches/untracked.patch
156-
if [ -f debian/patches/diff.patch ]; then
157-
echo diff.patch >> debian/patches/series
158-
fi
159-
if [ -f debian/patches/untracked.patch ]; then
160-
echo untracked.patch >> debian/patches/series
161-
fi
162-
163178
echo $debarch > debian/arch
164179
extra_build_depends=", $(if_enabled_echo CONFIG_UNWINDER_ORC libelf-dev:native)"
165180
extra_build_depends="$extra_build_depends, $(if_enabled_echo CONFIG_SYSTEM_TRUSTED_KEYRING libssl-dev:native)"

scripts/package/mkspec

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ else
1919
mkdir -p rpmbuild/SOURCES
2020
cp linux.tar.gz rpmbuild/SOURCES
2121
cp "${KCONFIG_CONFIG}" rpmbuild/SOURCES/config
22-
$(dirname $0)/gen-diff-patch rpmbuild/SOURCES/diff.patch rpmbuild/SOURCES/untracked.patch
23-
touch rpmbuild/SOURCES/diff.patch rpmbuild/SOURCES/untracked.patch
22+
"${srctree}/scripts/package/gen-diff-patch" rpmbuild/SOURCES/diff.patch
2423
fi
2524

2625
if grep -q CONFIG_MODULES=y include/config/auto.conf; then
@@ -56,7 +55,6 @@ sed -e '/^DEL/d' -e 's/^\t*//' <<EOF
5655
$S Source0: linux.tar.gz
5756
$S Source1: config
5857
$S Source2: diff.patch
59-
$S Source3: untracked.patch
6058
Provides: $PROVIDES
6159
$S BuildRequires: bc binutils bison dwarves
6260
$S BuildRequires: (elfutils-libelf-devel or libelf-devel) flex
@@ -94,12 +92,7 @@ $S$M
9492
$S %prep
9593
$S %setup -q -n linux
9694
$S cp %{SOURCE1} .config
97-
$S if [ -s %{SOURCE2} ]; then
98-
$S patch -p1 < %{SOURCE2}
99-
$S fi
100-
$S if [ -s %{SOURCE3} ]; then
101-
$S patch -p1 < %{SOURCE3}
102-
$S fi
95+
$S patch -p1 < %{SOURCE2}
10396
$S
10497
$S %build
10598
$S $MAKE %{?_smp_mflags} KERNELRELEASE=$KERNELRELEASE KBUILD_BUILD_VERSION=%{release}

0 commit comments

Comments
 (0)