Skip to content

Commit

Permalink
kbuild: add support for zstd compressed modules
Browse files Browse the repository at this point in the history
kmod 28 supports modules compressed in zstd format so let's add this
possibility to kernel.

Signed-off-by: Piotr Gorski <lucjan.lucjanov@gmail.com>
Reviewed-by: Oleksandr Natalenko <oleksandr@natalenko.name>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
  • Loading branch information
sirlucjan authored and masahir0y committed Apr 24, 2021
1 parent d4bbe94 commit c3d7ef3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
8 changes: 7 additions & 1 deletion init/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2242,7 +2242,7 @@ choice

Please note that the tool used to load modules needs to support the
corresponding algorithm. module-init-tools MAY support gzip, and kmod
MAY support gzip and xz.
MAY support gzip, xz and zstd.

Your build system needs to provide the appropriate compression tool
to compress the modules.
Expand All @@ -2267,6 +2267,12 @@ config MODULE_COMPRESS_XZ
Compress modules with XZ. The installed modules are suffixed
with .ko.xz.

config MODULE_COMPRESS_ZSTD
bool "ZSTD"
help
Compress modules with ZSTD. The installed modules are suffixed
with .ko.zst.

endchoice

config MODULE_ALLOW_MISSING_NAMESPACE_IMPORTS
Expand Down
6 changes: 6 additions & 0 deletions scripts/Makefile.modinst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ endif
suffix-y :=
suffix-$(CONFIG_MODULE_COMPRESS_GZIP) := .gz
suffix-$(CONFIG_MODULE_COMPRESS_XZ) := .xz
suffix-$(CONFIG_MODULE_COMPRESS_ZSTD) := .zst

modules := $(patsubst $(extmod_prefix)%, $(dst)/%$(suffix-y), $(modules))

Expand Down Expand Up @@ -95,13 +96,18 @@ quiet_cmd_gzip = GZIP $@
cmd_gzip = $(KGZIP) -n -f $<
quiet_cmd_xz = XZ $@
cmd_xz = $(XZ) --lzma2=dict=2MiB -f $<
quiet_cmd_zstd = ZSTD $@
cmd_zstd = $(ZSTD) -T0 --rm -f -q $<

$(dst)/%.ko.gz: $(dst)/%.ko FORCE
$(call cmd,gzip)

$(dst)/%.ko.xz: $(dst)/%.ko FORCE
$(call cmd,xz)

$(dst)/%.ko.zst: $(dst)/%.ko FORCE
$(call cmd,zstd)

PHONY += FORCE
FORCE:

Expand Down

0 comments on commit c3d7ef3

Please sign in to comment.