SPL_ZSTD selects XXHASH, but xxhash.o is built from inside the ifndef CONFIG_XPL_BUILD block, so it never reaches an SPL link. zstd's decompressor calls xxh64_* from code that survives --gc-sections, so today the option only builds because nothing in SPL calls zstd_decompress() and the whole library is discarded. The first caller would fail to link.
Give xxhash its own phase symbol and build rule, the way the other compression libraries already have, and note in the SPL_ZSTD help how much heap the decompressor wants, since that is the other thing which may stop it from working. Signed-off-by: Alexey Charkov <[email protected]> --- lib/Kconfig | 12 +++++++++++- lib/Makefile | 3 ++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/Kconfig b/lib/Kconfig index 6b6b90bc915c..6e6df5b3b191 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -833,6 +833,9 @@ config CRC32C config XXHASH bool +config SPL_XXHASH + bool + endmenu menu "Compression Support" @@ -1011,10 +1014,17 @@ config TPL_ZLIB config SPL_ZSTD bool "Enable Zstandard decompression support in SPL" depends on SPL - select XXHASH + select SPL_XXHASH help This enables Zstandard decompression library in the SPL. + Decompression allocates a 94KB context, and nothing else: the + single-shot API it uses decompresses straight into the caller's + buffer and takes its window from there, so the compression level + does not change what the SPL heap has to hold. With + SPL_SYS_MALLOC_SIMPLE that memory is never returned, as free() does + nothing there. + endmenu config ERRNO_STR diff --git a/lib/Makefile b/lib/Makefile index b7272c6f0cba..ca2b4f5530ef 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -45,7 +45,6 @@ endif obj-$(CONFIG_SMBIOS_PARSER) += smbios-parser.o obj-$(CONFIG_IMAGE_SPARSE) += image-sparse.o obj-y += ldiv.o -obj-$(CONFIG_XXHASH) += xxhash.o obj-y += net_utils.o obj-$(CONFIG_PHYSMEM) += physmem.o obj-y += rc4.o @@ -87,6 +86,8 @@ obj-$(CONFIG_$(PHASE_)SM3) += sm3.o obj-$(CONFIG_CRYPT_PW) += crypt/ obj-$(CONFIG_$(PHASE_)ASN1_DECODER_LEGACY) += asn1_decoder.o +obj-$(CONFIG_$(PHASE_)XXHASH) += xxhash.o + obj-$(CONFIG_$(PHASE_)ZLIB) += zlib/ obj-$(CONFIG_$(PHASE_)ZSTD) += zstd/ obj-$(CONFIG_$(PHASE_)GZIP) += gunzip.o -- 2.55.0
