[build] Add support for ASM files in Make + CMake
* Extract out common portion of `lib/Makefile` into `lib/libzstd.mk`. Most relevantly, the way we find library files. * Use `lib/libzstd.mk` in the other Makefiles instead of repeating the same code. * Add a test `tests/test-variants.sh` that checks that the builds of `make -C programs allVariants` are correct, and run it in Actions. * Adds support for ASM files in the CMake build. The Meson build is not updated because it lists every file in zstd, and supports ASM off the bat, so the Huffman ASM commit will just add the ASM file to the list. The Visual Studios build is not updated because I'm not adding ASM support to Visual Studios yet.
This commit is contained in:
+28
-24
@@ -1,4 +1,5 @@
|
||||
# ################################################################
|
||||
|
||||
# ################################################################
|
||||
# Copyright (c) Yann Collet, Facebook, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
@@ -19,46 +20,43 @@
|
||||
# zstreamtest32: Same as zstreamtest, but forced to compile in 32-bits mode
|
||||
# ##########################################################################
|
||||
|
||||
ZSTDDIR = ../lib
|
||||
LIBZSTD = ../lib
|
||||
|
||||
ZSTD_LEGACY_SUPPORT ?= 0
|
||||
|
||||
DEBUGLEVEL ?= 2
|
||||
export DEBUGLEVEL # transmit value to sub-makefiles
|
||||
|
||||
include $(LIBZSTD)/libzstd.mk
|
||||
|
||||
ZSTDDIR = $(LIBZSTD)
|
||||
PRGDIR = ../programs
|
||||
PYTHON ?= python3
|
||||
TESTARTEFACT := versionsTest
|
||||
|
||||
DEBUGLEVEL ?= 2
|
||||
export DEBUGLEVEL # transmit value to sub-makefiles
|
||||
DEBUGFLAGS = -g -DDEBUGLEVEL=$(DEBUGLEVEL)
|
||||
DEBUGFLAGS += -g -Wno-c++-compat
|
||||
CPPFLAGS += -I$(ZSTDDIR) -I$(ZSTDDIR)/common -I$(ZSTDDIR)/compress \
|
||||
-I$(ZSTDDIR)/dictBuilder -I$(ZSTDDIR)/deprecated -I$(PRGDIR) \
|
||||
-DZSTD_WINDOW_OVERFLOW_CORRECT_FREQUENTLY=1
|
||||
ifeq ($(OS),Windows_NT) # MinGW assumed
|
||||
CPPFLAGS += -D__USE_MINGW_ANSI_STDIO # compatibility with %zu formatting
|
||||
endif
|
||||
CFLAGS ?= -O3
|
||||
CFLAGS += -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow \
|
||||
-Wstrict-aliasing=1 -Wswitch-enum -Wdeclaration-after-statement \
|
||||
-Wstrict-prototypes -Wundef \
|
||||
-Wvla -Wformat=2 -Winit-self -Wfloat-equal -Wwrite-strings \
|
||||
-Wredundant-decls -Wmissing-prototypes -Wno-deprecated-declarations
|
||||
CFLAGS += $(DEBUGFLAGS)
|
||||
CPPFLAGS += $(MOREFLAGS)
|
||||
|
||||
|
||||
ZSTDCOMMON_FILES := $(ZSTDDIR)/common/*.c
|
||||
ZSTDCOMP_FILES := $(ZSTDDIR)/compress/*.c
|
||||
ZSTDDECOMP_FILES := $(ZSTDDIR)/decompress/*.c
|
||||
ZSTDCOMMON_FILES := $(sort $(ZSTD_COMMON_FILES))
|
||||
ZSTDCOMP_FILES := $(sort $(ZSTD_COMPRESS_FILES))
|
||||
ZSTDDECOMP_FILES := $(sort $(ZSTD_DECOMPRESS_FILES))
|
||||
ZSTD_FILES := $(ZSTDDECOMP_FILES) $(ZSTDCOMMON_FILES) $(ZSTDCOMP_FILES)
|
||||
ZDICT_FILES := $(ZSTDDIR)/dictBuilder/*.c
|
||||
ZDICT_FILES := $(sort $(ZSTD_DICTBUILDER_FILES))
|
||||
|
||||
ZSTD_F1 := $(wildcard $(ZSTD_FILES))
|
||||
ZSTD_OBJ1 := $(subst $(ZSTDDIR)/common/,zstdm_,$(ZSTD_F1))
|
||||
ZSTD_OBJ2 := $(subst $(ZSTDDIR)/compress/,zstdc_,$(ZSTD_OBJ1))
|
||||
ZSTD_OBJ3 := $(subst $(ZSTDDIR)/decompress/,zstdd_,$(ZSTD_OBJ2))
|
||||
ZSTD_OBJECTS := $(ZSTD_OBJ3:.c=.o)
|
||||
ZSTD_OBJ4 := $(ZSTD_OBJ3:.c=.o)
|
||||
ZSTD_OBJECTS := $(ZSTD_OBJ4:.S=.o)
|
||||
|
||||
ZSTDMT_OBJ1 := $(subst $(ZSTDDIR)/common/,zstdmt_m_,$(ZSTD_F1))
|
||||
ZSTDMT_OBJ2 := $(subst $(ZSTDDIR)/compress/,zstdmt_c_,$(ZSTDMT_OBJ1))
|
||||
ZSTDMT_OBJ3 := $(subst $(ZSTDDIR)/decompress/,zstdmt_d_,$(ZSTDMT_OBJ2))
|
||||
ZSTDMT_OBJECTS := $(ZSTDMT_OBJ3:.c=.o)
|
||||
ZSTDMT_OBJ4 := $(ZSTDMT_OBJ3:.c=.o)
|
||||
ZSTDMT_OBJECTS := $(ZSTDMT_OBJ4:.S=.o)
|
||||
|
||||
# Define *.exe as extension for Windows systems
|
||||
ifneq (,$(filter Windows%,$(OS)))
|
||||
@@ -119,6 +117,9 @@ zstdc_%.o : $(ZSTDDIR)/compress/%.c
|
||||
zstdd_%.o : $(ZSTDDIR)/decompress/%.c
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@
|
||||
|
||||
zstdd_%.o : $(ZSTDDIR)/decompress/%.S
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@
|
||||
|
||||
zstdmt%.o : CPPFLAGS += $(MULTITHREAD_CPP)
|
||||
|
||||
zstdmt_m_%.o : $(ZSTDDIR)/common/%.c
|
||||
@@ -130,6 +131,9 @@ zstdmt_c_%.o : $(ZSTDDIR)/compress/%.c
|
||||
zstdmt_d_%.o : $(ZSTDDIR)/decompress/%.c
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@
|
||||
|
||||
zstdmt_d_%.o : $(ZSTDDIR)/decompress/%.S
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@
|
||||
|
||||
fullbench32: CPPFLAGS += -m32
|
||||
fullbench fullbench32 : CPPFLAGS += $(MULTITHREAD_CPP) -Wno-deprecated-declarations
|
||||
fullbench fullbench32 : LDFLAGS += $(MULTITHREAD_LD)
|
||||
@@ -201,7 +205,7 @@ bigdict: $(ZSTDMT_OBJECTS) $(PRGDIR)/datagen.c bigdict.c
|
||||
|
||||
invalidDictionaries : $(ZSTD_OBJECTS) invalidDictionaries.c
|
||||
|
||||
legacy : CPPFLAGS += -I$(ZSTDDIR)/legacy -DZSTD_LEGACY_SUPPORT=4
|
||||
legacy : CPPFLAGS += -I$(ZSTDDIR)/legacy -UZSTD_LEGACY_SUPPORT -DZSTD_LEGACY_SUPPORT=4
|
||||
legacy : $(ZSTD_FILES) $(wildcard $(ZSTDDIR)/legacy/*.c) legacy.c
|
||||
|
||||
decodecorpus : LDLIBS += -lm
|
||||
|
||||
+22
-8
@@ -23,6 +23,12 @@ else
|
||||
endif
|
||||
CORPORA_URL_PREFIX:=https://github.com/facebook/zstd/releases/download/fuzz-corpora/
|
||||
|
||||
LIBZSTD = ../../lib
|
||||
DEBUGLEVEL ?= 2
|
||||
ZSTD_LEGACY_SUPPORT ?= 1
|
||||
|
||||
include $(LIBZSTD)/libzstd.mk
|
||||
|
||||
ZSTDDIR = ../../lib
|
||||
PRGDIR = ../../programs
|
||||
CONTRIBDIR = ../../contrib
|
||||
@@ -34,7 +40,7 @@ FUZZ_EXTRA_FLAGS := -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow \
|
||||
-Wstrict-aliasing=1 -Wswitch-enum -Wdeclaration-after-statement \
|
||||
-Wstrict-prototypes -Wundef \
|
||||
-Wvla -Wformat=2 -Winit-self -Wfloat-equal -Wwrite-strings \
|
||||
-Wredundant-decls \
|
||||
-Wredundant-decls -Wno-deprecated-declarations \
|
||||
-g -fno-omit-frame-pointer
|
||||
FUZZ_CFLAGS := $(FUZZ_EXTRA_FLAGS) $(CFLAGS)
|
||||
FUZZ_CXXFLAGS := $(FUZZ_EXTRA_FLAGS) -std=c++11 $(CXXFLAGS)
|
||||
@@ -50,11 +56,11 @@ FUZZ_SRC := $(PRGDIR)/util.c ./fuzz_helpers.c ./zstd_helpers.c ./fuzz_data_produ
|
||||
SEEKABLE_HEADERS = $(CONTRIBDIR)/seekable_format/zstd_seekable.h
|
||||
SEEKABLE_OBJS = $(CONTRIBDIR)/seekable_format/zstdseek_compress.c $(CONTRIBDIR)/seekable_format/zstdseek_decompress.c
|
||||
|
||||
ZSTDCOMMON_SRC := $(ZSTDDIR)/common/*.c
|
||||
ZSTDCOMP_SRC := $(ZSTDDIR)/compress/*.c
|
||||
ZSTDDECOMP_SRC := $(ZSTDDIR)/decompress/*.c
|
||||
ZSTDDICT_SRC := $(ZSTDDIR)/dictBuilder/*.c
|
||||
ZSTDLEGACY_SRC := $(ZSTDDIR)/legacy/*.c
|
||||
ZSTDCOMMON_SRC := $(ZSTD_COMMON_FILES)
|
||||
ZSTDCOMP_SRC := $(ZSTD_COMPRESS_FILES)
|
||||
ZSTDDECOMP_SRC := $(ZSTD_DECOMPRESS_FILES)
|
||||
ZSTDDICT_SRC := $(ZSTD_DICTBUILDER_FILES)
|
||||
ZSTDLEGACY_SRC := $(ZSTD_LEGACY_FILES)
|
||||
FUZZ_SRC := \
|
||||
$(FUZZ_SRC) \
|
||||
$(ZSTDDECOMP_SRC) \
|
||||
@@ -71,7 +77,8 @@ FUZZ_D_OBJ4 := $(subst $(ZSTDDIR)/dictBuilder/,d_lib_dictBuilder_,$(FUZZ_D_OBJ3)
|
||||
FUZZ_D_OBJ5 := $(subst $(ZSTDDIR)/legacy/,d_lib_legacy_,$(FUZZ_D_OBJ4))
|
||||
FUZZ_D_OBJ6 := $(subst $(PRGDIR)/,d_prg_,$(FUZZ_D_OBJ5))
|
||||
FUZZ_D_OBJ7 := $(subst $\./,d_fuzz_,$(FUZZ_D_OBJ6))
|
||||
FUZZ_DECOMPRESS_OBJ := $(FUZZ_D_OBJ7:.c=.o)
|
||||
FUZZ_D_OBJ8 := $(FUZZ_D_OBJ7:.c=.o)
|
||||
FUZZ_DECOMPRESS_OBJ := $(FUZZ_D_OBJ8:.S=.o)
|
||||
|
||||
FUZZ_RT_OBJ1 := $(subst $(ZSTDDIR)/common/,rt_lib_common_,$(FUZZ_SRC))
|
||||
FUZZ_RT_OBJ2 := $(subst $(ZSTDDIR)/compress/,rt_lib_compress_,$(FUZZ_RT_OBJ1))
|
||||
@@ -80,7 +87,8 @@ FUZZ_RT_OBJ4 := $(subst $(ZSTDDIR)/dictBuilder/,rt_lib_dictBuilder_,$(FUZZ_RT_OB
|
||||
FUZZ_RT_OBJ5 := $(subst $(ZSTDDIR)/legacy/,rt_lib_legacy_,$(FUZZ_RT_OBJ4))
|
||||
FUZZ_RT_OBJ6 := $(subst $(PRGDIR)/,rt_prg_,$(FUZZ_RT_OBJ5))
|
||||
FUZZ_RT_OBJ7 := $(subst $\./,rt_fuzz_,$(FUZZ_RT_OBJ6))
|
||||
FUZZ_ROUND_TRIP_OBJ := $(FUZZ_RT_OBJ7:.c=.o)
|
||||
FUZZ_RT_OBJ8 := $(FUZZ_RT_OBJ7:.c=.o)
|
||||
FUZZ_ROUND_TRIP_OBJ := $(FUZZ_RT_OBJ8:.S=.o)
|
||||
|
||||
.PHONY: default all clean cleanall
|
||||
|
||||
@@ -117,6 +125,9 @@ rt_lib_compress_%.o: $(ZSTDDIR)/compress/%.c
|
||||
rt_lib_decompress_%.o: $(ZSTDDIR)/decompress/%.c
|
||||
$(CC) $(FUZZ_CPPFLAGS) $(FUZZ_CFLAGS) $(FUZZ_ROUND_TRIP_FLAGS) $< -c -o $@
|
||||
|
||||
rt_lib_decompress_%.o: $(ZSTDDIR)/decompress/%.S
|
||||
$(CC) $(FUZZ_CPPFLAGS) $(FUZZ_CFLAGS) $(FUZZ_ROUND_TRIP_FLAGS) $< -c -o $@
|
||||
|
||||
rt_lib_dictBuilder_%.o: $(ZSTDDIR)/dictBuilder/%.c
|
||||
$(CC) $(FUZZ_CPPFLAGS) $(FUZZ_CFLAGS) $(FUZZ_ROUND_TRIP_FLAGS) $< -c -o $@
|
||||
|
||||
@@ -138,6 +149,9 @@ d_lib_compress_%.o: $(ZSTDDIR)/compress/%.c
|
||||
d_lib_decompress_%.o: $(ZSTDDIR)/decompress/%.c
|
||||
$(CC) $(FUZZ_CPPFLAGS) $(FUZZ_CFLAGS) $< -c -o $@
|
||||
|
||||
d_lib_decompress_%.o: $(ZSTDDIR)/decompress/%.S
|
||||
$(CC) $(FUZZ_CPPFLAGS) $(FUZZ_CFLAGS) $< -c -o $@
|
||||
|
||||
d_lib_dictBuilder_%.o: $(ZSTDDIR)/dictBuilder/%.c
|
||||
$(CC) $(FUZZ_CPPFLAGS) $(FUZZ_CFLAGS) $< -c -o $@
|
||||
|
||||
|
||||
+1
-1
@@ -1528,7 +1528,7 @@ static int basicUnitTests(U32 const seed, double compressibility)
|
||||
|
||||
DISPLAYLEVEL(3, "test%3i : resize context to full CCtx size : ", testNb++);
|
||||
staticCCtx = ZSTD_initStaticCStream(staticCCtxBuffer, staticCCtxSize);
|
||||
DISPLAYLEVEL(4, "staticCCtxBuffer = %p, staticCCtx = %p , ", staticCCtxBuffer, staticCCtx);
|
||||
DISPLAYLEVEL(4, "staticCCtxBuffer = %p, staticCCtx = %p , ", staticCCtxBuffer, (void*)staticCCtx);
|
||||
if (staticCCtx == NULL) goto _output_error;
|
||||
DISPLAYLEVEL(3, "OK \n");
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@ result.o: result.c result.h
|
||||
test.o: test.c data.h config.h method.h
|
||||
$(CC) $(REGRESSION_CFLAGS) $(REGRESSION_CPPFLAGS) $< -c -o $@
|
||||
|
||||
.PHONY: libzstd.a
|
||||
libzstd.a:
|
||||
$(MAKE) -C $(LIBDIR) libzstd.a-mt
|
||||
cp $(LIBDIR)/libzstd.a .
|
||||
|
||||
Executable
+115
@@ -0,0 +1,115 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
set -u
|
||||
set -x
|
||||
|
||||
|
||||
SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
|
||||
PROG_DIR="$SCRIPT_DIR/../programs"
|
||||
|
||||
ZSTD="$PROG_DIR/zstd"
|
||||
ZSTD_COMPRESS="$PROG_DIR/zstd-compress"
|
||||
ZSTD_DECOMPRESS="$PROG_DIR/zstd-decompress"
|
||||
ZSTD_NOLEGACY="$PROG_DIR/zstd-nolegacy"
|
||||
ZSTD_DICTBUILDER="$PROG_DIR/zstd-dictBuilder"
|
||||
ZSTD_FRUGAL="$PROG_DIR/zstd-frugal"
|
||||
ZSTD_NOMT="$PROG_DIR/zstd-nomt"
|
||||
|
||||
println() {
|
||||
printf '%b\n' "${*}"
|
||||
}
|
||||
|
||||
die() {
|
||||
println "$@" 1>&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
symbol_present() {
|
||||
(nm $1 || echo "symbol_present $@ failed") | grep $2
|
||||
}
|
||||
|
||||
symbol_not_present() {
|
||||
symbol_present $@ && die "Binary '$1' mistakenly contains symbol '$2'" ||:
|
||||
}
|
||||
|
||||
compress_not_present() {
|
||||
symbol_not_present "$1" ZSTD_compress
|
||||
}
|
||||
|
||||
decompress_not_present() {
|
||||
symbol_not_present "$1" ZSTD_decompress
|
||||
}
|
||||
|
||||
dict_not_present() {
|
||||
symbol_not_present "$1" ZDICT_
|
||||
symbol_not_present "$1" COVER_
|
||||
}
|
||||
|
||||
cliextra_not_present() {
|
||||
symbol_not_present "$1" TRACE_
|
||||
symbol_not_present "$1" BMK_
|
||||
}
|
||||
|
||||
legacy_not_present() {
|
||||
symbol_not_present "$1" ZSTDv0
|
||||
}
|
||||
|
||||
test_help() {
|
||||
"$1" --help | grep -- "$2"
|
||||
}
|
||||
|
||||
test_no_help() {
|
||||
test_help $@ && die "'$1' supports '$2' when it shouldn't" ||:
|
||||
}
|
||||
|
||||
extras_not_present() {
|
||||
dict_not_present $@
|
||||
legacy_not_present $@
|
||||
cliextra_not_present $@
|
||||
test_no_help $@ "--train"
|
||||
test_no_help $@ "-b#"
|
||||
}
|
||||
|
||||
test_compress() {
|
||||
echo "hello" | "$1" | "$ZSTD" -t
|
||||
}
|
||||
|
||||
test_decompress() {
|
||||
echo "hello" | "$ZSTD" | "$1" -t
|
||||
}
|
||||
|
||||
test_zstd() {
|
||||
test_compress $@
|
||||
test_decompress $@
|
||||
}
|
||||
|
||||
extras_not_present "$ZSTD_FRUGAL"
|
||||
extras_not_present "$ZSTD_COMPRESS"
|
||||
extras_not_present "$ZSTD_DECOMPRESS"
|
||||
|
||||
compress_not_present "$ZSTD_DECOMPRESS"
|
||||
|
||||
decompress_not_present "$ZSTD_COMPRESS"
|
||||
decompress_not_present "$ZSTD_DICTBUILDER"
|
||||
|
||||
cliextra_not_present "$ZSTD_DICTBUILDER"
|
||||
|
||||
legacy_not_present "$ZSTD_DICTBUILDER"
|
||||
legacy_not_present "$ZSTD_NOLEGACY"
|
||||
|
||||
symbol_not_present "$ZSTD" ZSTDv01
|
||||
symbol_not_present "$ZSTD" ZSTDv02
|
||||
symbol_not_present "$ZSTD" ZSTDv03
|
||||
symbol_not_present "$ZSTD" ZSTDv04
|
||||
|
||||
test_compress "$ZSTD_COMPRESS"
|
||||
test_decompress "$ZSTD_DECOMPRESS"
|
||||
|
||||
test_zstd "$ZSTD_FRUGAL"
|
||||
test_zstd "$ZSTD_NOLEGACY"
|
||||
|
||||
test_help "$ZSTD" '-b#'
|
||||
test_help "$ZSTD" --train
|
||||
test_help "$ZSTD_DICTBUILDER" --train
|
||||
|
||||
println "Success!"
|
||||
Reference in New Issue
Block a user