ZSTD_LIB_MINIFY is offered only inside "if ZSTD", so a board which
enables zstd for SPL alone gets the full-size library in the phase which
can least afford it.

Add an SPL-scoped variant of this option and key the build flags off that.

Reviewed-by: Tom Rini <[email protected]>
Signed-off-by: Alexey Charkov <[email protected]>
---
 lib/Kconfig       | 12 ++++++++++++
 lib/zstd/Makefile |  2 +-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/lib/Kconfig b/lib/Kconfig
index ec6f162dfb57..1292185e03f8 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -1023,6 +1023,18 @@ config SPL_ZSTD
          buffer and takes its window from there, so the compression level
          does not change what the SPL heap has to hold.
 
+config SPL_ZSTD_LIB_MINIFY
+       bool "Minify Zstandard code in SPL"
+       depends on SPL_ZSTD
+       default y
+       help
+         This disables various optional components and changes the
+         compilation flags to prioritize space-saving.
+
+         For detailed info, see zstd's lib/README.md
+
+         https://github.com/facebook/zstd/blob/dev/lib/README.md
+
 endmenu
 
 config ERRNO_STR
diff --git a/lib/zstd/Makefile b/lib/zstd/Makefile
index c9a7dfe405b4..9d1b4d4a4f72 100644
--- a/lib/zstd/Makefile
+++ b/lib/zstd/Makefile
@@ -11,7 +11,7 @@
 obj-y += zstd_decompress.o
 obj-y += zstd_common.o
 
-ifeq ($(CONFIG_ZSTD_LIB_MINIFY),y)
+ifeq ($(CONFIG_$(PHASE_)ZSTD_LIB_MINIFY),y)
 ccflags-y += -DHUF_FORCE_DECOMPRESS_X1
 ccflags-y += -DZSTD_FORCE_DECOMPRESS_SEQUENCES_SHORT
 ccflags-y += -DZSTD_NO_INLINE

-- 
2.55.0

Reply via email to