package/zstd: build multithreaded library if supported
authorThomas De Schampheleire <thomas.de_schampheleire@nokia.com>
Fri, 4 Dec 2020 09:57:01 +0000 (10:57 +0100)
committerThomas Petazzoni <thomas.petazzoni@bootlin.com>
Sun, 17 Jan 2021 14:29:58 +0000 (15:29 +0100)
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>
package/zstd/zstd.mk

index e26e67f46b6fab5701d93ff1d18e236b0c81bc6f..c3af9bd58c00777e8ba06dd85dbead9d9696bdd6 100644 (file)
@@ -48,6 +48,14 @@ ZSTD_BUILD_LIBS = libzstd.a libzstd
 ZSTD_INSTALL_LIBS = install-static install-shared
 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
        $(TARGET_MAKE_ENV) $(TARGET_CONFIGURE_OPTS) $(MAKE) $(ZSTD_OPTS) \
                -C $(@D)/lib $(ZSTD_BUILD_LIBS)