Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 37432a83 authored by Denis Efremov's avatar Denis Efremov Committed by Greg Kroah-Hartman
Browse files

kbuild: add variables for compression tools



commit 8dfb61dcbaceb19a5ded5e9c9dcf8d05acc32294 upstream.

Allow user to use alternative implementations of compression tools,
such as pigz, pbzip2, pxz. For example, multi-threaded tools to
speed up the build:
$ make GZIP=pigz BZIP2=pbzip2

Variables _GZIP, _BZIP2, _LZOP are used internally because original env
vars are reserved by the tools. The use of GZIP in gzip tool is obsolete
since 2015. However, alternative implementations (e.g., pigz) still rely
on it. BZIP2, BZIP, LZOP vars are not obsolescent.

The credit goes to @grsecurity.

As a sidenote, for multi-threaded lzma, xz compression one can use:
$ export XZ_OPT="--threads=0"

Signed-off-by: default avatarDenis Efremov <efremov@linux.com>
Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
Signed-off-by: default avatarMatthias Maennich <maennich@google.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 47a41f65
Loading
Loading
Loading
Loading
+23 −2
Original line number Diff line number Diff line
@@ -442,6 +442,26 @@ PYTHON = python
PYTHON3		= python3
CHECK		= sparse
BASH		= bash
GZIP		= gzip
BZIP2		= bzip2
LZOP		= lzop
LZMA		= lzma
LZ4		= lz4c
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__ \
		  -Wbitwise -Wno-return-void -Wno-unknown-attribute $(CF)
@@ -490,6 +510,7 @@ CLANG_FLAGS :=
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 PERL PYTHON PYTHON3 CHECK CHECKFLAGS MAKE UTS_MACHINE HOSTCXX
export _GZIP _BZIP2 _LZOP LZMA LZ4 XZ
export KBUILD_HOSTCXXFLAGS KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS LDFLAGS_MODULE

export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS KBUILD_LDFLAGS
@@ -997,10 +1018,10 @@ export mod_strip_cmd
mod_compress_cmd = true
ifdef CONFIG_MODULE_COMPRESS
  ifdef CONFIG_MODULE_COMPRESS_GZIP
    mod_compress_cmd = gzip -n -f
    mod_compress_cmd = $(_GZIP) -n -f
  endif # CONFIG_MODULE_COMPRESS_GZIP
  ifdef CONFIG_MODULE_COMPRESS_XZ
    mod_compress_cmd = xz -f
    mod_compress_cmd = $(XZ) -f
  endif # CONFIG_MODULE_COMPRESS_XZ
endif # CONFIG_MODULE_COMPRESS
export mod_compress_cmd
+1 −1
Original line number Diff line number Diff line
@@ -56,7 +56,7 @@ trap 'rm -f "$XIPIMAGE.tmp"; exit 1' 1 2 3
# substitute the data section by a compressed version
$DD if="$XIPIMAGE" count=$data_start iflag=count_bytes of="$XIPIMAGE.tmp"
$DD if="$XIPIMAGE"  skip=$data_start iflag=skip_bytes |
gzip -9 >> "$XIPIMAGE.tmp"
$_GZIP -9 >> "$XIPIMAGE.tmp"

# replace kernel binary
mv -f "$XIPIMAGE.tmp" "$XIPIMAGE"
+1 −1
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ $(error Sorry, you need a newer version of the assember, one that is built from
endif

quiet_cmd_gzip = GZIP    $@
cmd_gzip = cat $(real-prereqs) | gzip -n -f -9 > $@
cmd_gzip = cat $(real-prereqs) | $(_GZIP) -n -f -9 > $@

quiet_cmd_objcopy = OBJCOPY $@
cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@
+4 −4
Original line number Diff line number Diff line
@@ -135,10 +135,10 @@ vmlinux.gz: vmlinux
ifndef CONFIG_KGDB
	cp vmlinux vmlinux.tmp
	$(STRIP) vmlinux.tmp
	gzip -9c vmlinux.tmp >vmlinux.gz
	$(_GZIP) -9c vmlinux.tmp >vmlinux.gz
	rm vmlinux.tmp
else
	gzip -9c vmlinux >vmlinux.gz
	$(_GZIP) -9c vmlinux >vmlinux.gz
endif

bzImage: vmlinux.bz2
@@ -148,10 +148,10 @@ vmlinux.bz2: vmlinux
ifndef CONFIG_KGDB
	cp vmlinux vmlinux.tmp
	$(STRIP) vmlinux.tmp
	bzip2 -1c vmlinux.tmp >vmlinux.bz2
	$(_BZIP2) -1c vmlinux.tmp >vmlinux.bz2
	rm vmlinux.tmp
else
	bzip2 -1c vmlinux >vmlinux.bz2
	$(_BZIP2) -1c vmlinux >vmlinux.bz2
endif

archclean:
+1 −1
Original line number Diff line number Diff line
@@ -156,7 +156,7 @@ vmlinuz: bzImage
	$(OBJCOPY) $(boot)/bzImage $@
else
vmlinuz: vmlinux
	@gzip -cf -9 $< > $@
	@$(_GZIP) -cf -9 $< > $@
endif

install:
Loading