package/zstd: fix dynamic build without threads

Dynamic build without threads is broken since bump to version 1.5.0 in
commit aad8bbf588

Indeed, dynamic library is built with threads support since
91465e23b2

To fix this build failure, add -nomt if needed however libzstd-nomt is a
"special target that builds a library in single-thread mode _and_
without zstdmt_compress.c". For an unknown reason, this target fails to
build and don't create any symlinks so replace libzstd-{mt,nomt} by
lib-{mt,nomt} even if this will have the side effect of building a
shared and a static version of the library.

Move the existing HAVE_THREAD setting in the same condition.

While at it, also replace "libzstd.a libzstd" by "lib"

Fixes:
 - http://autobuild.buildroot.org/results/e609601a0fc91c44d88a12c35b29ce937381462f

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
[Arnout: move HAVE_THREAD in the same condition]
Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
This commit is contained in:
Fabrice Fontaine 2021-07-01 21:29:59 +02:00 committed by Arnout Vandecappelle (Essensium/Mind)
parent 25d602a6a6
commit 8dfd7a1f90

View File

@ -12,12 +12,6 @@ ZSTD_LICENSE_FILES = LICENSE COPYING
ZSTD_CPE_ID_VENDOR = facebook
ZSTD_CPE_ID_PRODUCT = zstandard
ifeq ($(BR2_TOOLCHAIN_HAS_THREADS),y)
ZSTD_OPTS += HAVE_THREAD=1
else
ZSTD_OPTS += HAVE_THREAD=0
endif
ifeq ($(BR2_PACKAGE_ZLIB),y)
ZSTD_DEPENDENCIES += zlib
ZSTD_OPTS += HAVE_ZLIB=1
@ -43,19 +37,24 @@ ifeq ($(BR2_STATIC_LIBS),y)
ZSTD_BUILD_LIBS = libzstd.a
ZSTD_INSTALL_LIBS = install-static
else ifeq ($(BR2_SHARED_LIBS),y)
ZSTD_BUILD_LIBS = libzstd
ZSTD_BUILD_LIBS = lib
ZSTD_INSTALL_LIBS = install-shared
else
ZSTD_BUILD_LIBS = libzstd.a libzstd
ZSTD_BUILD_LIBS = lib
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.
# one. Building a multi-threaded binary with a static library (which defaults
# to single-threaded) gives a runtime error when compressing files.
# The 'lib' makefile provides specific '%-mt' and '%-nomt' targets for this
# purpose.
ifeq ($(BR2_TOOLCHAIN_HAS_THREADS),y)
ZSTD_OPTS += HAVE_THREAD=1
ZSTD_BUILD_LIBS := $(addsuffix -mt,$(ZSTD_BUILD_LIBS))
else
ZSTD_OPTS += HAVE_THREAD=0
ZSTD_BUILD_LIBS := $(addsuffix -nomt,$(ZSTD_BUILD_LIBS))
endif
define ZSTD_BUILD_CMDS