[PATCHv1 1/3] lzma: Add Kconfig options to optimize for size
Tom Rini
trini at konsulko.com
Fri Dec 19 00:30:56 CET 2025
Currently, our LZMA library has an option for optimizing for size,
rather than speed. It is a minimal savings today, and has not been worth
enabling. As this will change in the near future, add options now to
allow disabling it in full U-Boot or in SPL, and enable these on
gardena-smart-gateway-mt7688 which is very close to the size limit
today.
Signed-off-by: Tom Rini <trini at konsulko.com>
---
Cc: Stefan Roese <stefan.roese at mailbox.org>
---
configs/gardena-smart-gateway-mt7688_defconfig | 2 ++
lib/Kconfig | 14 ++++++++++++++
lib/lzma/Makefile | 1 +
3 files changed, 17 insertions(+)
diff --git a/configs/gardena-smart-gateway-mt7688_defconfig b/configs/gardena-smart-gateway-mt7688_defconfig
index 3c2bcc6a3c44..aba8a2ffd1de 100644
--- a/configs/gardena-smart-gateway-mt7688_defconfig
+++ b/configs/gardena-smart-gateway-mt7688_defconfig
@@ -101,4 +101,6 @@ CONFIG_MT7621_SPI=y
CONFIG_WDT=y
CONFIG_WDT_MT7621=y
CONFIG_LZMA=y
+CONFIG_LZMA_SIZE_OPTIMIZATION=y
CONFIG_SPL_LZMA=y
+CONFIG_SPL_LZMA_SIZE_OPTIMIZATION=y
diff --git a/lib/Kconfig b/lib/Kconfig
index fe0b878a206b..96032eaddf95 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -838,6 +838,13 @@ config LZMA
ratio and fairly fast decompression speed. See also
CONFIG_CMD_LZMADEC which provides a decode command.
+config LZMA_SIZE_OPTIMIZATION
+ bool "Optimize the LZMA algorithm for smaller binary size"
+ help
+ This enables building the LZMA library optimized for size, rather
+ than performance. This can be a loss of 15-20% in decompression
+ speed, but a savings of close to two kilobytes in many cases.
+
config LZO
bool "Enable LZO decompression support"
help
@@ -932,6 +939,13 @@ config SPL_LZMA
help
This enables support for LZMA compression algorithm for SPL boot.
+config SPL_LZMA_SIZE_OPTIMIZATION
+ bool "Optimize the LZMA algorithm for smaller binary size in SPL"
+ help
+ This enables building the LZMA library optimized for size, rather
+ than performance. This can be a loss of 15-20% in decompression
+ speed, but a savings of close to two kilobytes in many cases.
+
config TPL_LZMA
bool "Enable LZMA decompression support for TPL build"
depends on TPL
diff --git a/lib/lzma/Makefile b/lib/lzma/Makefile
index c2fd3e494541..b8ad570ab1c2 100644
--- a/lib/lzma/Makefile
+++ b/lib/lzma/Makefile
@@ -7,5 +7,6 @@
# Wolfgang Denk, DENX Software Engineering, wd at denx.de.
ccflags-y += -D_LZMA_PROB32
+ccflags-$(CONFIG_$(PHASE_)LZMA_SIZE_OPTIMIZATION) += -D_LZMA_SIZE_OPT
obj-y += LzmaDec.o LzmaTools.o
--
2.43.0
More information about the U-Boot
mailing list