]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
fix libzstd-mt underlinking issue
authorYann Collet <cyan@fb.com>
Wed, 29 Apr 2020 01:29:20 +0000 (18:29 -0700)
committerYann Collet <cyan@fb.com>
Wed, 29 Apr 2020 01:29:20 +0000 (18:29 -0700)
fix #2045
When compiling `libzstd` in multithreading mode,
the `libzstd-mt` recipe would not include `-pthread`,
resulting in an underlinked dynamic library.

Added a test on Travis to check that the library is fully linked.

This makes it possible, in some future release,
to build a multi-threaded `libzstd` dynamic library by default
as it would no longer impact the build script of user programs.

.travis.yml
lib/Makefile

index e4e455602602751db72e840bd3b92a0bf7e52651..31fc42571cc47f12640d49fd6b5c405686a99b34 100644 (file)
@@ -56,12 +56,14 @@ matrix:
         # DEVNULLRIGHTS : will request sudo rights to test permissions on /dev/null
         - DEVNULLRIGHTS=test make test
 
-    - name: gcc-6 + gcc-7 compilation   # ~ 3mn
+    - name: gcc-6 + gcc-7 + libzstdmt compilation   # ~ 6mn
       script:
         - make gcc6install gcc7install
         - CC=gcc-6 CFLAGS=-Werror make -j all
         - make clean
         - CC=gcc-7 CFLAGS=-Werror make -j all
+        - make clean
+        - LDFLAGS=-Wl,--no-undefined make -C lib libzstd-mt
 
     - name: gcc-8 + ASan + UBSan + Test Zstd   # ~6.5mn
       script:
index fc7daf0804e580e00485fb4e950f99139a5a5303..7a05b158d99aa224c51b1fa396d903c6a9ea25c0 100644 (file)
@@ -154,9 +154,6 @@ libzstd.a: $(ZSTD_OBJ)
        @echo compiling static library
        @$(AR) $(ARFLAGS) $@ $^
 
-libzstd.a-mt: CPPFLAGS += -DZSTD_MULTITHREAD
-libzstd.a-mt: libzstd.a
-
 ifneq (,$(filter Windows%,$(OS)))
 
 LIBZSTD = dll\libzstd.dll
@@ -180,17 +177,20 @@ endif
 
 libzstd : $(LIBZSTD)
 
-libzstd-mt : CPPFLAGS += -DZSTD_MULTITHREAD
+lib : libzstd.a libzstd
+
+%-mt : CPPFLAGS += -DZSTD_MULTITHREAD
+%-mt : LDFLAGS  += -pthread
+
 libzstd-mt : libzstd
 
-lib: libzstd.a libzstd
+libzstd.a-mt: libzstd.a
 
-lib-mt: CPPFLAGS += -DZSTD_MULTITHREAD
-lib-mt: lib
+lib-mt : lib
 
-lib-release lib-release-mt: DEBUGFLAGS :=
+%-release : DEBUGFLAGS :=
 lib-release: lib
-lib-release-mt: lib-mt
+lib-mt-release : lib-mt
 
 # Special case : building library in single-thread mode _and_ without zstdmt_compress.c
 ZSTDMT_FILES = compress/zstdmt_compress.c