kbuild: fix broken builds because of GZIP,BZIP2,LZOP variables

Redefine GZIP, BZIP2, LZOP variables as KGZIP, KBZIP2, KLZOP resp.
GZIP, BZIP2, LZOP env variables are reserved by the tools. The original
attempt to redefine them internally doesn't work in makefiles/scripts
intercall scenarios, e.g., "make GZIP=gzip bindeb-pkg" and results in
broken builds. There can be other broken build commands because of this,
so the universal solution is to use non-reserved env variables for the
compression tools.

Fixes: 8dfb61dcba ("kbuild: add variables for compression tools")
Signed-off-by: Denis Efremov <efremov@linux.com>
Tested-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
This commit is contained in:
Denis Efremov 2020-06-08 12:59:44 +03:00 committed by Masahiro Yamada
parent fca5e94921
commit e4a42c82e9
8 changed files with 20 additions and 34 deletions

View File

@ -458,27 +458,13 @@ PYTHON = python
PYTHON3 = python3 PYTHON3 = python3
CHECK = sparse CHECK = sparse
BASH = bash BASH = bash
GZIP = gzip KGZIP = gzip
BZIP2 = bzip2 KBZIP2 = bzip2
LZOP = lzop KLZOP = lzop
LZMA = lzma LZMA = lzma
LZ4 = lz4c LZ4 = lz4c
XZ = xz XZ = xz
# GZIP, BZIP2, LZOP env vars are used by the tools. Support them as the command
# line interface, but use _GZIP, _BZIP2, _LZOP internally.
_GZIP := $(GZIP)
_BZIP2 := $(BZIP2)
_LZOP := $(LZOP)
# Reset GZIP, BZIP2, LZOP in this Makefile
override GZIP=
override BZIP2=
override LZOP=
# Reset GZIP, BZIP2, LZOP in recursive invocations
MAKEOVERRIDES += GZIP= BZIP2= LZOP=
CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \ CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
-Wbitwise -Wno-return-void -Wno-unknown-attribute $(CF) -Wbitwise -Wno-return-void -Wno-unknown-attribute $(CF)
NOSTDINC_FLAGS := NOSTDINC_FLAGS :=
@ -526,7 +512,7 @@ CLANG_FLAGS :=
export ARCH SRCARCH CONFIG_SHELL BASH HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE LD CC export ARCH SRCARCH CONFIG_SHELL BASH HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE LD CC
export CPP AR NM STRIP OBJCOPY OBJDUMP OBJSIZE READELF PAHOLE LEX YACC AWK INSTALLKERNEL export CPP AR NM STRIP OBJCOPY OBJDUMP OBJSIZE READELF PAHOLE LEX YACC AWK INSTALLKERNEL
export PERL PYTHON PYTHON3 CHECK CHECKFLAGS MAKE UTS_MACHINE HOSTCXX export PERL PYTHON PYTHON3 CHECK CHECKFLAGS MAKE UTS_MACHINE HOSTCXX
export _GZIP _BZIP2 _LZOP LZMA LZ4 XZ export KGZIP KBZIP2 KLZOP LZMA LZ4 XZ
export KBUILD_HOSTCXXFLAGS KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS LDFLAGS_MODULE export KBUILD_HOSTCXXFLAGS KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS LDFLAGS_MODULE
export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS KBUILD_LDFLAGS export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS KBUILD_LDFLAGS
@ -1047,7 +1033,7 @@ export mod_strip_cmd
mod_compress_cmd = true mod_compress_cmd = true
ifdef CONFIG_MODULE_COMPRESS ifdef CONFIG_MODULE_COMPRESS
ifdef CONFIG_MODULE_COMPRESS_GZIP ifdef CONFIG_MODULE_COMPRESS_GZIP
mod_compress_cmd = $(_GZIP) -n -f mod_compress_cmd = $(KGZIP) -n -f
endif # CONFIG_MODULE_COMPRESS_GZIP endif # CONFIG_MODULE_COMPRESS_GZIP
ifdef CONFIG_MODULE_COMPRESS_XZ ifdef CONFIG_MODULE_COMPRESS_XZ
mod_compress_cmd = $(XZ) -f mod_compress_cmd = $(XZ) -f

View File

@ -56,7 +56,7 @@ trap 'rm -f "$XIPIMAGE.tmp"; exit 1' 1 2 3
# substitute the data section by a compressed version # substitute the data section by a compressed version
$DD if="$XIPIMAGE" count=$data_start iflag=count_bytes of="$XIPIMAGE.tmp" $DD if="$XIPIMAGE" count=$data_start iflag=count_bytes of="$XIPIMAGE.tmp"
$DD if="$XIPIMAGE" skip=$data_start iflag=skip_bytes | $DD if="$XIPIMAGE" skip=$data_start iflag=skip_bytes |
$_GZIP -9 >> "$XIPIMAGE.tmp" $KGZIP -9 >> "$XIPIMAGE.tmp"
# replace kernel binary # replace kernel binary
mv -f "$XIPIMAGE.tmp" "$XIPIMAGE" mv -f "$XIPIMAGE.tmp" "$XIPIMAGE"

View File

@ -40,7 +40,7 @@ $(error Sorry, you need a newer version of the assember, one that is built from
endif endif
quiet_cmd_gzip = GZIP $@ quiet_cmd_gzip = GZIP $@
cmd_gzip = cat $(real-prereqs) | $(_GZIP) -n -f -9 > $@ cmd_gzip = cat $(real-prereqs) | $(KGZIP) -n -f -9 > $@
quiet_cmd_objcopy = OBJCOPY $@ quiet_cmd_objcopy = OBJCOPY $@
cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@ cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@

View File

@ -135,10 +135,10 @@ vmlinux.gz: vmlinux
ifndef CONFIG_KGDB ifndef CONFIG_KGDB
cp vmlinux vmlinux.tmp cp vmlinux vmlinux.tmp
$(STRIP) vmlinux.tmp $(STRIP) vmlinux.tmp
$(_GZIP) -9c vmlinux.tmp >vmlinux.gz $(KGZIP) -9c vmlinux.tmp >vmlinux.gz
rm vmlinux.tmp rm vmlinux.tmp
else else
$(_GZIP) -9c vmlinux >vmlinux.gz $(KGZIP) -9c vmlinux >vmlinux.gz
endif endif
bzImage: vmlinux.bz2 bzImage: vmlinux.bz2
@ -148,10 +148,10 @@ vmlinux.bz2: vmlinux
ifndef CONFIG_KGDB ifndef CONFIG_KGDB
cp vmlinux vmlinux.tmp cp vmlinux vmlinux.tmp
$(STRIP) vmlinux.tmp $(STRIP) vmlinux.tmp
$(_BZIP2) -1c vmlinux.tmp >vmlinux.bz2 $(KBZIP2) -1c vmlinux.tmp >vmlinux.bz2
rm vmlinux.tmp rm vmlinux.tmp
else else
$(_BZIP2) -1c vmlinux >vmlinux.bz2 $(KBZIP2) -1c vmlinux >vmlinux.bz2
endif endif
archclean: archclean:

View File

@ -162,7 +162,7 @@ vmlinuz: bzImage
$(OBJCOPY) $(boot)/bzImage $@ $(OBJCOPY) $(boot)/bzImage $@
else else
vmlinuz: vmlinux vmlinuz: vmlinux
@$(_GZIP) -cf -9 $< > $@ @$(KGZIP) -cf -9 $< > $@
endif endif
install: install:

View File

@ -244,7 +244,7 @@ cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
quiet_cmd_gzip = GZIP $@ quiet_cmd_gzip = GZIP $@
cmd_gzip = cat $(real-prereqs) | $(_GZIP) -n -f -9 > $@ cmd_gzip = cat $(real-prereqs) | $(KGZIP) -n -f -9 > $@
# DTC # DTC
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
@ -337,7 +337,7 @@ printf "%08x\n" $$dec_size | \
) )
quiet_cmd_bzip2 = BZIP2 $@ quiet_cmd_bzip2 = BZIP2 $@
cmd_bzip2 = { cat $(real-prereqs) | $(_BZIP2) -9; $(size_append); } > $@ cmd_bzip2 = { cat $(real-prereqs) | $(KBZIP2) -9; $(size_append); } > $@
# Lzma # Lzma
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
@ -346,7 +346,7 @@ quiet_cmd_lzma = LZMA $@
cmd_lzma = { cat $(real-prereqs) | $(LZMA) -9; $(size_append); } > $@ cmd_lzma = { cat $(real-prereqs) | $(LZMA) -9; $(size_append); } > $@
quiet_cmd_lzo = LZO $@ quiet_cmd_lzo = LZO $@
cmd_lzo = { cat $(real-prereqs) | $(_LZOP) -9; $(size_append); } > $@ cmd_lzo = { cat $(real-prereqs) | $(KLZOP) -9; $(size_append); } > $@
quiet_cmd_lz4 = LZ4 $@ quiet_cmd_lz4 = LZ4 $@
cmd_lz4 = { cat $(real-prereqs) | $(LZ4) -l -c1 stdin stdout; \ cmd_lz4 = { cat $(real-prereqs) | $(LZ4) -l -c1 stdin stdout; \

View File

@ -45,7 +45,7 @@ if test "$(objtree)" != "$(srctree)"; then \
false; \ false; \
fi ; \ fi ; \
$(srctree)/scripts/setlocalversion --save-scmversion; \ $(srctree)/scripts/setlocalversion --save-scmversion; \
tar -I $(_GZIP) -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); \
rm -f $(objtree)/.scmversion rm -f $(objtree)/.scmversion
@ -127,8 +127,8 @@ util/PERF-VERSION-GEN $(CURDIR)/$(perf-tar)/); \
tar rf $(perf-tar).tar $(perf-tar)/HEAD $(perf-tar)/PERF-VERSION-FILE; \ tar rf $(perf-tar).tar $(perf-tar)/HEAD $(perf-tar)/PERF-VERSION-FILE; \
rm -r $(perf-tar); \ rm -r $(perf-tar); \
$(if $(findstring tar-src,$@),, \ $(if $(findstring tar-src,$@),, \
$(if $(findstring bz2,$@),$(_BZIP2), \ $(if $(findstring bz2,$@),$(KBZIP2), \
$(if $(findstring gz,$@),$(_GZIP), \ $(if $(findstring gz,$@),$(KGZIP), \
$(if $(findstring xz,$@),$(XZ), \ $(if $(findstring xz,$@),$(XZ), \
$(error unknown target $@)))) \ $(error unknown target $@)))) \
-f -9 $(perf-tar).tar) -f -9 $(perf-tar).tar)

View File

@ -28,11 +28,11 @@ case "${1}" in
opts= opts=
;; ;;
targz-pkg) targz-pkg)
opts="-I ${_GZIP}" opts="-I ${KGZIP}"
tarball=${tarball}.gz tarball=${tarball}.gz
;; ;;
tarbz2-pkg) tarbz2-pkg)
opts="-I ${_BZIP2}" opts="-I ${KBZIP2}"
tarball=${tarball}.bz2 tarball=${tarball}.bz2
;; ;;
tarxz-pkg) tarxz-pkg)