Commit f0dd81db authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'kbuild-fixes-v6.3-3' of...

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
parents 6586c4d4 3c65a270
...@@ -171,6 +171,10 @@ Getting Help ...@@ -171,6 +171,10 @@ Getting Help
Getting LLVM Getting LLVM
------------- -------------
We provide prebuilt stable versions of LLVM on `kernel.org <https://kernel.org/pub/tools/llvm/>`_.
Below are links that may be useful for building LLVM from source or procuring
it through a distribution's package manager.
- https://releases.llvm.org/download.html - https://releases.llvm.org/download.html
- https://github.com/llvm/llvm-project - https://github.com/llvm/llvm-project
- https://llvm.org/docs/GettingStarted.html - https://llvm.org/docs/GettingStarted.html
......
...@@ -84,12 +84,7 @@ CFLAGS_string.o += $(PURGATORY_CFLAGS) ...@@ -84,12 +84,7 @@ CFLAGS_string.o += $(PURGATORY_CFLAGS)
CFLAGS_REMOVE_ctype.o += $(PURGATORY_CFLAGS_REMOVE) CFLAGS_REMOVE_ctype.o += $(PURGATORY_CFLAGS_REMOVE)
CFLAGS_ctype.o += $(PURGATORY_CFLAGS) CFLAGS_ctype.o += $(PURGATORY_CFLAGS)
AFLAGS_REMOVE_entry.o += -Wa,-gdwarf-2 asflags-remove-y += $(foreach x, -g -gdwarf-4 -gdwarf-5, $(x) -Wa,$(x))
AFLAGS_REMOVE_memcpy.o += -Wa,-gdwarf-2
AFLAGS_REMOVE_memset.o += -Wa,-gdwarf-2
AFLAGS_REMOVE_strcmp.o += -Wa,-gdwarf-2
AFLAGS_REMOVE_strlen.o += -Wa,-gdwarf-2
AFLAGS_REMOVE_strncmp.o += -Wa,-gdwarf-2
$(obj)/purgatory.ro: $(PURGATORY_OBJS) FORCE $(obj)/purgatory.ro: $(PURGATORY_OBJS) FORCE
$(call if_changed,ld) $(call if_changed,ld)
......
...@@ -69,8 +69,7 @@ CFLAGS_sha256.o += $(PURGATORY_CFLAGS) ...@@ -69,8 +69,7 @@ CFLAGS_sha256.o += $(PURGATORY_CFLAGS)
CFLAGS_REMOVE_string.o += $(PURGATORY_CFLAGS_REMOVE) CFLAGS_REMOVE_string.o += $(PURGATORY_CFLAGS_REMOVE)
CFLAGS_string.o += $(PURGATORY_CFLAGS) CFLAGS_string.o += $(PURGATORY_CFLAGS)
AFLAGS_REMOVE_setup-x86_$(BITS).o += -Wa,-gdwarf-2 asflags-remove-y += $(foreach x, -g -gdwarf-4 -gdwarf-5, $(x) -Wa,$(x))
AFLAGS_REMOVE_entry64.o += -Wa,-gdwarf-2
$(obj)/purgatory.ro: $(PURGATORY_OBJS) FORCE $(obj)/purgatory.ro: $(PURGATORY_OBJS) FORCE
$(call if_changed,ld) $(call if_changed,ld)
......
...@@ -60,15 +60,8 @@ static void __init error(char *x) ...@@ -60,15 +60,8 @@ static void __init error(char *x)
message = x; message = x;
} }
static void panic_show_mem(const char *fmt, ...) #define panic_show_mem(fmt, ...) \
{ ({ show_mem(0, NULL); panic(fmt, ##__VA_ARGS__); })
va_list args;
show_mem(0, NULL);
va_start(args, fmt);
panic(fmt, args);
va_end(args);
}
/* link hash */ /* link hash */
......
...@@ -27,21 +27,6 @@ fi ; \ ...@@ -27,21 +27,6 @@ fi ; \
tar -I $(KGZIP) -c $(RCS_TAR_IGNORE) -f $(2).tar.gz \ tar -I $(KGZIP) -c $(RCS_TAR_IGNORE) -f $(2).tar.gz \
--transform 's:^:$(2)/:S' $(TAR_CONTENT) $(3) --transform 's:^:$(2)/:S' $(TAR_CONTENT) $(3)
# tarball compression
# ---------------------------------------------------------------------------
%.tar.gz: %.tar
$(call cmd,gzip)
%.tar.bz2: %.tar
$(call cmd,bzip2)
%.tar.xz: %.tar
$(call cmd,xzmisc)
%.tar.zst: %.tar
$(call cmd,zstd)
# Git # Git
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
...@@ -57,16 +42,24 @@ check-git: ...@@ -57,16 +42,24 @@ check-git:
false; \ false; \
fi fi
git-config-tar.gz = -c tar.tar.gz.command="$(KGZIP)"
git-config-tar.bz2 = -c tar.tar.bz2.command="$(KBZIP2)"
git-config-tar.xz = -c tar.tar.xz.command="$(XZ)"
git-config-tar.zst = -c tar.tar.zst.command="$(ZSTD)"
quiet_cmd_archive = ARCHIVE $@
cmd_archive = git -C $(srctree) $(git-config-tar$(suffix $@)) archive \
--output=$$(realpath $@) --prefix=$(basename $@)/ $(archive-args)
# Linux source tarball # Linux source tarball
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
quiet_cmd_archive_linux = ARCHIVE $@ linux-tarballs := $(addprefix linux, .tar.gz)
cmd_archive_linux = \
git -C $(srctree) archive --output=$$(realpath $@) --prefix=$(basename $@)/ $$(cat $<)
targets += linux.tar targets += $(linux-tarballs)
linux.tar: .tmp_HEAD FORCE $(linux-tarballs): archive-args = $$(cat $<)
$(call if_changed,archive_linux) $(linux-tarballs): .tmp_HEAD FORCE
$(call if_changed,archive)
# rpm-pkg # rpm-pkg
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
...@@ -94,7 +87,7 @@ binrpm-pkg: ...@@ -94,7 +87,7 @@ binrpm-pkg:
$(UTS_MACHINE)-linux -bb $(objtree)/binkernel.spec $(UTS_MACHINE)-linux -bb $(objtree)/binkernel.spec
quiet_cmd_debianize = GEN $@ quiet_cmd_debianize = GEN $@
cmd_debianize = $(srctree)/scripts/package/mkdebian cmd_debianize = $(srctree)/scripts/package/mkdebian $(mkdebian-opts)
debian: FORCE debian: FORCE
$(call cmd,debianize) $(call cmd,debianize)
...@@ -103,6 +96,7 @@ PHONY += debian-orig ...@@ -103,6 +96,7 @@ PHONY += debian-orig
debian-orig: private source = $(shell dpkg-parsechangelog -S Source) debian-orig: private source = $(shell dpkg-parsechangelog -S Source)
debian-orig: private version = $(shell dpkg-parsechangelog -S Version | sed 's/-[^-]*$$//') debian-orig: private version = $(shell dpkg-parsechangelog -S Version | sed 's/-[^-]*$$//')
debian-orig: private orig-name = $(source)_$(version).orig.tar.gz debian-orig: private orig-name = $(source)_$(version).orig.tar.gz
debian-orig: mkdebian-opts = --need-source
debian-orig: linux.tar.gz debian debian-orig: linux.tar.gz debian
$(Q)if [ "$(df --output=target .. 2>/dev/null)" = "$(df --output=target $< 2>/dev/null)" ]; then \ $(Q)if [ "$(df --output=target .. 2>/dev/null)" = "$(df --output=target $< 2>/dev/null)" ]; then \
ln -f $< ../$(orig-name); \ ln -f $< ../$(orig-name); \
...@@ -145,10 +139,17 @@ tar-install: FORCE ...@@ -145,10 +139,17 @@ tar-install: FORCE
$(Q)$(MAKE) -f $(srctree)/Makefile $(Q)$(MAKE) -f $(srctree)/Makefile
+$(Q)$(srctree)/scripts/package/buildtar $@ +$(Q)$(srctree)/scripts/package/buildtar $@
compress-tar.gz = -I "$(KGZIP)"
compress-tar.bz2 = -I "$(KBZIP2)"
compress-tar.xz = -I "$(XZ)"
compress-tar.zst = -I "$(ZSTD)"
quiet_cmd_tar = TAR $@ quiet_cmd_tar = TAR $@
cmd_tar = cd $<; tar cf ../$@ --owner=root --group=root --sort=name * cmd_tar = cd $<; tar cf ../$@ $(compress-tar$(suffix $@)) --owner=root --group=root --sort=name *
linux-$(KERNELRELEASE)-$(ARCH).tar: tar-install dir-tarballs := $(addprefix linux-$(KERNELRELEASE)-$(ARCH), .tar .tar.gz .tar.bz2 .tar.xz .tar.zst)
$(dir-tarballs): tar-install
$(call cmd,tar) $(call cmd,tar)
PHONY += dir-pkg PHONY += dir-pkg
...@@ -180,16 +181,17 @@ quiet_cmd_perf_version_file = GEN $@ ...@@ -180,16 +181,17 @@ quiet_cmd_perf_version_file = GEN $@
.tmp_perf/PERF-VERSION-FILE: .tmp_HEAD $(srctree)/tools/perf/util/PERF-VERSION-GEN | .tmp_perf .tmp_perf/PERF-VERSION-FILE: .tmp_HEAD $(srctree)/tools/perf/util/PERF-VERSION-GEN | .tmp_perf
$(call cmd,perf_version_file) $(call cmd,perf_version_file)
quiet_cmd_archive_perf = ARCHIVE $@ perf-archive-args = --add-file=$$(realpath $(word 2, $^)) \
cmd_archive_perf = \
git -C $(srctree) archive --output=$$(realpath $@) --prefix=$(basename $@)/ \
--add-file=$$(realpath $(word 2, $^)) \
--add-file=$$(realpath $(word 3, $^)) \ --add-file=$$(realpath $(word 3, $^)) \
$$(cat $(word 2, $^))^{tree} $$(cat $<) $$(cat $(word 2, $^))^{tree} $$(cat $<)
targets += perf-$(KERNELVERSION).tar
perf-$(KERNELVERSION).tar: tools/perf/MANIFEST .tmp_perf/HEAD .tmp_perf/PERF-VERSION-FILE FORCE perf-tarballs := $(addprefix perf-$(KERNELVERSION), .tar .tar.gz .tar.bz2 .tar.xz .tar.zst)
$(call if_changed,archive_perf)
targets += $(perf-tarballs)
$(perf-tarballs): archive-args = $(perf-archive-args)
$(perf-tarballs): tools/perf/MANIFEST .tmp_perf/HEAD .tmp_perf/PERF-VERSION-FILE FORCE
$(call if_changed,archive)
PHONY += perf-tar-src-pkg PHONY += perf-tar-src-pkg
perf-tar-src-pkg: perf-$(KERNELVERSION).tar perf-tar-src-pkg: perf-$(KERNELVERSION).tar
......
#!/bin/sh #!/bin/sh
# SPDX-License-Identifier: GPL-2.0-only # SPDX-License-Identifier: GPL-2.0-only
diff_patch="${1}" diff_patch=$1
untracked_patch="${2}"
srctree=$(dirname $0)/../..
rm -f ${diff_patch} ${untracked_patch} mkdir -p "$(dirname "${diff_patch}")"
if ! ${srctree}/scripts/check-git; then git -C "${srctree:-.}" diff HEAD > "${diff_patch}"
exit
fi
mkdir -p "$(dirname ${diff_patch})" "$(dirname ${untracked_patch})"
git -C "${srctree}" diff HEAD > "${diff_patch}" if [ ! -s "${diff_patch}" ] ||
[ -z "$(git -C "${srctree:-.}" ls-files --other --exclude-standard | head -n1)" ]; then
if [ ! -s "${diff_patch}" ]; then
rm -f "${diff_patch}"
exit exit
fi fi
git -C ${srctree} status --porcelain --untracked-files=all | # The source tarball, which is generated by 'git archive', contains everything
while read stat path # you committed in the repository. If you have local diff ('git diff HEAD'),
do # it will go into ${diff_patch}. If untracked files are remaining, the resulting
if [ "${stat}" = '??' ]; then # source package may not be correct.
#
if ! diff -u /dev/null "${srctree}/${path}" > .tmp_diff && # Examples:
! head -n1 .tmp_diff | grep -q "Binary files"; then # - You modified a source file to add #include "new-header.h"
{ # but forgot to add new-header.h
echo "--- /dev/null" # - You modified a Makefile to add 'obj-$(CONFIG_FOO) += new-dirver.o'
echo "+++ linux/$path" # but you forgot to add new-driver.c
cat .tmp_diff | tail -n +3 #
} >> ${untracked_patch} # You need to commit them, or at least stage them by 'git add'.
fi #
fi # This script does not take care of untracked files because doing so would
done # introduce additional complexity. Instead, print a warning message here if
# untracked files are found.
rm -f .tmp_diff # If all untracked files are just garbage, you can ignore this warning.
echo >&2 "============================ WARNING ============================"
if [ ! -s "${diff_patch}" ]; then echo >&2 "Your working tree has diff from HEAD, and also untracked file(s)."
rm -f "${diff_patch}" echo >&2 "Please make sure you did 'git add' for all new files you need in"
exit echo >&2 "the source package."
fi echo >&2 "================================================================="
...@@ -84,7 +84,66 @@ set_debarch() { ...@@ -84,7 +84,66 @@ set_debarch() {
fi fi
} }
# Create debian/source/ if it is a source package build
gen_source ()
{
mkdir -p debian/source
echo "3.0 (quilt)" > debian/source/format
{
echo "diff-ignore"
echo "extend-diff-ignore = .*"
} > debian/source/local-options
# Add .config as a patch
mkdir -p debian/patches
{
echo "Subject: Add .config"
echo "Author: ${maintainer}"
echo
echo "--- /dev/null"
echo "+++ linux/.config"
diff -u /dev/null "${KCONFIG_CONFIG}" | tail -n +3
} > debian/patches/config.patch
echo config.patch > debian/patches/series
"${srctree}/scripts/package/gen-diff-patch" debian/patches/diff.patch
if [ -s debian/patches/diff.patch ]; then
sed -i "
1iSubject: Add local diff
1iAuthor: ${maintainer}
1i
" debian/patches/diff.patch
echo diff.patch >> debian/patches/series
else
rm -f debian/patches/diff.patch
fi
}
rm -rf debian rm -rf debian
mkdir debian
email=${DEBEMAIL-$EMAIL}
# use email string directly if it contains <email>
if echo "${email}" | grep -q '<.*>'; then
maintainer=${email}
else
# or construct the maintainer string
user=${KBUILD_BUILD_USER-$(id -nu)}
name=${DEBFULLNAME-${user}}
if [ -z "${email}" ]; then
buildhost=${KBUILD_BUILD_HOST-$(hostname -f 2>/dev/null || hostname)}
email="${user}@${buildhost}"
fi
maintainer="${name} <${email}>"
fi
if [ "$1" = --need-source ]; then
gen_source
fi
# Some variables and settings used throughout the script # Some variables and settings used throughout the script
version=$KERNELRELEASE version=$KERNELRELEASE
...@@ -104,22 +163,6 @@ fi ...@@ -104,22 +163,6 @@ fi
debarch= debarch=
set_debarch set_debarch
email=${DEBEMAIL-$EMAIL}
# use email string directly if it contains <email>
if echo $email | grep -q '<.*>'; then
maintainer=$email
else
# or construct the maintainer string
user=${KBUILD_BUILD_USER-$(id -nu)}
name=${DEBFULLNAME-$user}
if [ -z "$email" ]; then
buildhost=${KBUILD_BUILD_HOST-$(hostname -f 2>/dev/null || hostname)}
email="$user@$buildhost"
fi
maintainer="$name <$email>"
fi
# Try to determine distribution # Try to determine distribution
if [ -n "$KDEB_CHANGELOG_DIST" ]; then if [ -n "$KDEB_CHANGELOG_DIST" ]; then
distribution=$KDEB_CHANGELOG_DIST distribution=$KDEB_CHANGELOG_DIST
...@@ -132,34 +175,6 @@ else ...@@ -132,34 +175,6 @@ else
echo >&2 "Install lsb-release or set \$KDEB_CHANGELOG_DIST explicitly" echo >&2 "Install lsb-release or set \$KDEB_CHANGELOG_DIST explicitly"
fi fi
mkdir -p debian/source/
echo "3.0 (quilt)" > debian/source/format
{
echo "diff-ignore"
echo "extend-diff-ignore = .*"
} > debian/source/local-options
# Add .config as a patch
mkdir -p debian/patches
{
echo "Subject: Add .config"
echo "Author: ${maintainer}"
echo
echo "--- /dev/null"
echo "+++ linux/.config"
diff -u /dev/null "${KCONFIG_CONFIG}" | tail -n +3
} > debian/patches/config
echo config > debian/patches/series
$(dirname $0)/gen-diff-patch debian/patches/diff.patch debian/patches/untracked.patch
if [ -f debian/patches/diff.patch ]; then
echo diff.patch >> debian/patches/series
fi
if [ -f debian/patches/untracked.patch ]; then
echo untracked.patch >> debian/patches/series
fi
echo $debarch > debian/arch echo $debarch > debian/arch
extra_build_depends=", $(if_enabled_echo CONFIG_UNWINDER_ORC libelf-dev:native)" extra_build_depends=", $(if_enabled_echo CONFIG_UNWINDER_ORC libelf-dev:native)"
extra_build_depends="$extra_build_depends, $(if_enabled_echo CONFIG_SYSTEM_TRUSTED_KEYRING libssl-dev:native)" extra_build_depends="$extra_build_depends, $(if_enabled_echo CONFIG_SYSTEM_TRUSTED_KEYRING libssl-dev:native)"
......
...@@ -19,8 +19,7 @@ else ...@@ -19,8 +19,7 @@ else
mkdir -p rpmbuild/SOURCES mkdir -p rpmbuild/SOURCES
cp linux.tar.gz rpmbuild/SOURCES cp linux.tar.gz rpmbuild/SOURCES
cp "${KCONFIG_CONFIG}" rpmbuild/SOURCES/config cp "${KCONFIG_CONFIG}" rpmbuild/SOURCES/config
$(dirname $0)/gen-diff-patch rpmbuild/SOURCES/diff.patch rpmbuild/SOURCES/untracked.patch "${srctree}/scripts/package/gen-diff-patch" rpmbuild/SOURCES/diff.patch
touch rpmbuild/SOURCES/diff.patch rpmbuild/SOURCES/untracked.patch
fi fi
if grep -q CONFIG_MODULES=y include/config/auto.conf; then if grep -q CONFIG_MODULES=y include/config/auto.conf; then
...@@ -56,7 +55,6 @@ sed -e '/^DEL/d' -e 's/^\t*//' <<EOF ...@@ -56,7 +55,6 @@ sed -e '/^DEL/d' -e 's/^\t*//' <<EOF
$S Source0: linux.tar.gz $S Source0: linux.tar.gz
$S Source1: config $S Source1: config
$S Source2: diff.patch $S Source2: diff.patch
$S Source3: untracked.patch
Provides: $PROVIDES Provides: $PROVIDES
$S BuildRequires: bc binutils bison dwarves $S BuildRequires: bc binutils bison dwarves
$S BuildRequires: (elfutils-libelf-devel or libelf-devel) flex $S BuildRequires: (elfutils-libelf-devel or libelf-devel) flex
...@@ -94,12 +92,7 @@ $S$M ...@@ -94,12 +92,7 @@ $S$M
$S %prep $S %prep
$S %setup -q -n linux $S %setup -q -n linux
$S cp %{SOURCE1} .config $S cp %{SOURCE1} .config
$S if [ -s %{SOURCE2} ]; then $S patch -p1 < %{SOURCE2}
$S patch -p1 < %{SOURCE2}
$S fi
$S if [ -s %{SOURCE3} ]; then
$S patch -p1 < %{SOURCE3}
$S fi
$S $S
$S %build $S %build
$S $MAKE %{?_smp_mflags} KERNELRELEASE=$KERNELRELEASE KBUILD_BUILD_VERSION=%{release} $S $MAKE %{?_smp_mflags} KERNELRELEASE=$KERNELRELEASE KBUILD_BUILD_VERSION=%{release}
......
...@@ -353,6 +353,12 @@ static int cpio_mkfile(const char *name, const char *location, ...@@ -353,6 +353,12 @@ static int cpio_mkfile(const char *name, const char *location,
buf.st_mtime = 0xffffffff; buf.st_mtime = 0xffffffff;
} }
if (buf.st_mtime < 0) {
fprintf(stderr, "%s: Timestamp negative, clipping.\n",
location);
buf.st_mtime = 0;
}
if (buf.st_size > 0xffffffff) { if (buf.st_size > 0xffffffff) {
fprintf(stderr, "%s: Size exceeds maximum cpio file size\n", fprintf(stderr, "%s: Size exceeds maximum cpio file size\n",
location); location);
...@@ -602,10 +608,10 @@ int main (int argc, char *argv[]) ...@@ -602,10 +608,10 @@ int main (int argc, char *argv[])
/* /*
* Timestamps after 2106-02-07 06:28:15 UTC have an ascii hex time_t * Timestamps after 2106-02-07 06:28:15 UTC have an ascii hex time_t
* representation that exceeds 8 chars and breaks the cpio header * representation that exceeds 8 chars and breaks the cpio header
* specification. * specification. Negative timestamps similarly exceed 8 chars.
*/ */
if (default_mtime > 0xffffffff) { if (default_mtime > 0xffffffff || default_mtime < 0) {
fprintf(stderr, "ERROR: Timestamp too large for cpio format\n"); fprintf(stderr, "ERROR: Timestamp out of range for cpio format\n");
exit(1); exit(1);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment