From: Yann Collet Date: Wed, 29 Apr 2020 04:18:29 +0000 (-0700) Subject: added test linking user program to multi-threaded libzstd X-Git-Tag: v1.4.5^2~54^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7ea2ae66495854346ae7cd26ab926859f410d492;p=thirdparty%2Fzstd.git added test linking user program to multi-threaded libzstd --- diff --git a/.travis.yml b/.travis.yml index 31fc42571..aeaae7292 100644 --- a/.travis.yml +++ b/.travis.yml @@ -64,6 +64,9 @@ matrix: - CC=gcc-7 CFLAGS=-Werror make -j all - make clean - LDFLAGS=-Wl,--no-undefined make -C lib libzstd-mt + - make -C tests zbufftest-dll + # LDFLAGS=-Wl,--no-undefined : will make the linker fail if dll is underlinked + # zbufftest-dll : test that a user program can link to multi-threaded libzstd without specifying -pthread - name: gcc-8 + ASan + UBSan + Test Zstd # ~6.5mn script: diff --git a/programs/Makefile b/programs/Makefile index 8146732b5..3366c093e 100644 --- a/programs/Makefile +++ b/programs/Makefile @@ -79,6 +79,9 @@ endif # Sort files in alphabetical order for reproducible builds ZSTDLIB_FILES := $(sort $(wildcard $(ZSTD_FILES)) $(wildcard $(ZSTDLEGACY_FILES)) $(wildcard $(ZDICT_FILES))) +ZSTD_CLI_FILES := $(wildcard *.c) +ZSTD_CLI_OBJ := $(patsubst %.c,%.o,$(ZSTD_CLI_FILES)) + # Define *.exe as extension for Windows systems ifneq (,$(filter Windows%,$(OS))) EXT =.exe @@ -172,7 +175,7 @@ zstd : CPPFLAGS += -DZSTD_LEGACY_SUPPORT=$(ZSTD_LEGACY_SUPPORT) ifneq (,$(filter Windows%,$(OS))) zstd : $(RES_FILE) endif -zstd : $(ZSTDLIB_FILES) zstdcli.o util.o timefn.o fileio.o benchfn.o benchzstd.o datagen.o dibio.o +zstd : $(ZSTDLIB_FILES) $(ZSTD_CLI_OBJ) @echo "$(THREAD_MSG)" @echo "$(ZLIB_MSG)" @echo "$(LZMA_MSG)" @@ -190,10 +193,10 @@ zstd32 : CPPFLAGS += -DZSTD_LEGACY_SUPPORT=$(ZSTD_LEGACY_SUPPORT) ifneq (,$(filter Windows%,$(OS))) zstd32 : $(RES32_FILE) endif -zstd32 : $(ZSTDLIB_FILES) zstdcli.c util.c timefn.c fileio.c benchfn.c benchzstd.c datagen.c dibio.c +zstd32 : $(ZSTDLIB_FILES) $(ZSTD_CLI_FILES) $(CC) -m32 $(FLAGS) $^ -o $@$(EXT) -zstd-nolegacy : $(ZSTD_FILES) $(ZDICT_FILES) zstdcli.o util.o fileio.c benchfn.o benchzstd.o timefn.o datagen.o dibio.o +zstd-nolegacy : $(ZSTD_FILES) $(ZDICT_FILES) $(ZSTD_CLI_OBJ) $(CC) $(FLAGS) $^ -o $@$(EXT) $(LDFLAGS) zstd-nomt : THREAD_CPP := @@ -211,6 +214,19 @@ zstd-noxz : LZMALD := zstd-noxz : LZMA_MSG := - xz/lzma support is disabled zstd-noxz : zstd +# note : the following target doesn't build +# because zstd uses non-public symbols from libzstd +# such as XXH64 (for benchmark), +# ZDICT_trainFromBuffer_unsafe_legacy for dictionary builder +# and ZSTD_cycleLog (likely for --patch-from) +# It's unclear at this stage if this is a scenario we want to support +## zstd-dll: zstd executable linked to dynamic library libzstd (must already exist) +.PHONY: zstd-dll +zstd-dll : LDFLAGS+= -L$(ZSTDDIR) -lzstd +zstd-dll : ZSTDLIB_FILES = +zstd-dll : $(ZSTD_CLI_OBJ) + $(CC) $(FLAGS) $^ -o $@$(EXT) $(LDFLAGS) + zstd-pgo : $(MAKE) clean diff --git a/tests/Makefile b/tests/Makefile index 3d0074710..d347a948a 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -91,6 +91,7 @@ allnothread: MULTITHREAD_CPP= allnothread: MULTITHREAD_LD= allnothread: fullbench fuzzer paramgrill datagen decodecorpus +# note : broken : requires symbols unavailable from dynamic library dll: fuzzer-dll zstreamtest-dll PHONY: zstd zstd32 zstd-nolegacy # must be phony, only external makefile knows how to build them, or if they need an update @@ -98,12 +99,15 @@ zstd zstd32 zstd-nolegacy: $(MAKE) -C $(PRGDIR) $@ MOREFLAGS+="$(DEBUGFLAGS)" gzstd: - $(MAKE) -C $(PRGDIR) zstd HAVE_ZLIB=1 MOREFLAGS+="$(DEBUGFLAGS)" + $(MAKE) -C $(PRGDIR) $@ HAVE_ZLIB=1 MOREFLAGS+="$(DEBUGFLAGS)" -.PHONY: zstd-dll -zstd-dll : +.PHONY: libzstd +libzstd : $(MAKE) -C $(ZSTDDIR) libzstd +%-dll : libzstd +%-dll : LDFLAGS+= -L$(ZSTDDIR) -lzstd + .PHONY: zstd-staticLib zstd-staticLib : $(MAKE) -C $(ZSTDDIR) libzstd.a @@ -141,9 +145,7 @@ fullbench-lib : zstd-staticLib fullbench-lib : $(PRGDIR)/datagen.c $(PRGDIR)/util.c $(PRGDIR)/timefn.c $(PRGDIR)/benchfn.c fullbench.c $(CC) $(FLAGS) $(filter %.c,$^) -o $@$(EXT) $(ZSTDDIR)/libzstd.a -# note : broken : requires unavailable symbols -fullbench-dll : zstd-dll -fullbench-dll : LDFLAGS+= -L$(ZSTDDIR) -lzstd +# note : broken : requires symbols unavailable from dynamic library fullbench-dll: $(PRGDIR)/datagen.c $(PRGDIR)/util.c $(PRGDIR)/benchfn.c $(PRGDIR)/timefn.c fullbench.c # $(CC) $(FLAGS) $(filter %.c,$^) -o $@$(EXT) -DZSTD_DLL_IMPORT=1 $(ZSTDDIR)/dll/libzstd.dll $(CC) $(FLAGS) $(filter %.c,$^) -o $@$(EXT) @@ -156,8 +158,7 @@ fuzzer32: $(ZSTD_FILES) fuzzer fuzzer32 : $(ZDICT_FILES) $(PRGDIR)/util.c $(PRGDIR)/timefn.c $(PRGDIR)/datagen.c fuzzer.c $(CC) $(FLAGS) $^ -o $@$(EXT) -fuzzer-dll : zstd-dll -fuzzer-dll : LDFLAGS+= -L$(ZSTDDIR) -lzstd +# note : broken : requires symbols unavailable from dynamic library fuzzer-dll : $(ZSTDDIR)/common/xxhash.c $(PRGDIR)/util.c $(PRGDIR)/timefn.c $(PRGDIR)/datagen.c fuzzer.c $(CC) $(CPPFLAGS) $(CFLAGS) $(filter %.c,$^) $(LDFLAGS) -o $@$(EXT) @@ -167,8 +168,6 @@ zbufftest32 : CFLAGS += -m32 zbufftest zbufftest32 : $(ZSTD_OBJECTS) $(ZBUFF_FILES) $(PRGDIR)/util.c $(PRGDIR)/timefn.c $(PRGDIR)/datagen.c zbufftest.c $(CC) $(FLAGS) $^ -o $@$(EXT) -zbufftest-dll : zstd-dll -zbufftest-dll : LDFLAGS+= -L$(ZSTDDIR) -lzstd zbufftest-dll : $(ZSTDDIR)/common/xxhash.c $(PRGDIR)/util.c $(PRGDIR)/timefn.c $(PRGDIR)/datagen.c zbufftest.c $(CC) $(CPPFLAGS) $(CFLAGS) $(filter %.c,$^) $(LDFLAGS) -o $@$(EXT) @@ -191,8 +190,7 @@ zstreamtest_tsan : CFLAGS += -fsanitize=thread zstreamtest_tsan : $(ZSTREAMFILES) $(CC) $(FLAGS) $(MULTITHREAD) $^ -o $@$(EXT) -zstreamtest-dll : zstd-dll -zstreamtest-dll : LDFLAGS+= -L$(ZSTDDIR) -lzstd +# note : broken : requires symbols unavailable from dynamic library zstreamtest-dll : $(ZSTDDIR)/common/xxhash.c # xxh symbols not exposed from dll zstreamtest-dll : $(ZSTREAM_LOCAL_FILES) $(CC) $(CPPFLAGS) $(CFLAGS) $(filter %.c,$^) $(LDFLAGS) -o $@$(EXT)