package/zstd: build multithreaded library if supported

libzstd.so is built without multi-threading support by default.
The 'HAVE_THREAD' flag is not respected by lib/Makefile, only by
programs/Makefile.

Use the %-mt recipe in lib/Makefile to enable multithreading.

Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
This commit is contained in:
Thomas De Schampheleire 2020-12-04 10:57:01 +01:00 committed by Thomas Petazzoni
parent 74ebbe0269
commit 52154e5206

View File

@ -48,6 +48,14 @@ ZSTD_BUILD_LIBS = libzstd.a libzstd
ZSTD_INSTALL_LIBS = install-static install-shared ZSTD_INSTALL_LIBS = install-static install-shared
endif endif
# The HAVE_THREAD flag is read by the 'programs' makefile but not by the 'lib'
# one. Building a multi-threaded binary with a library (which defaults to
# single-threaded) gives a runtime error when compressing files.
# The 'lib' makefile provides specific '%-mt' targets for this purpose.
ifeq ($(BR2_TOOLCHAIN_HAS_THREADS),y)
ZSTD_BUILD_LIBS := $(addsuffix -mt,$(ZSTD_BUILD_LIBS))
endif
define ZSTD_BUILD_CMDS define ZSTD_BUILD_CMDS
$(TARGET_MAKE_ENV) $(TARGET_CONFIGURE_OPTS) $(MAKE) $(ZSTD_OPTS) \ $(TARGET_MAKE_ENV) $(TARGET_CONFIGURE_OPTS) $(MAKE) $(ZSTD_OPTS) \
-C $(@D)/lib $(ZSTD_BUILD_LIBS) -C $(@D)/lib $(ZSTD_BUILD_LIBS)