`make all` exercises substantially more than the default zstd binary. It also builds compression-only and decompression-only archives, older contrib tools that compile program C shims directly, and the single-file amalgamations. The Rust migration had changed symbol ownership without updating every one of those feature and link boundaries. The first failure came from `fileio_asyncio`: it is always compiled, but its codec bindings unconditionally referenced both `zstd_compress` and `zstd_decompress`. A compression-only archive therefore required disabled decoder modules, and the decompression-only configuration had the symmetric problem. Gate the concrete codec imports, callback types, helpers, and exports with their Cargo features. Keep the format probe compilable without the legacy decoder predicate when decompression is disabled. Once that boundary compiled, the remaining `make all` paths exposed related integration gaps. Move the C decompression projection declarations out of the compression preprocessor block, while leaving destination callback types shared. Link the Rust CLI helpers archive into zlibWrapper, pzstd, and largeNbDicts, whose util/time/data-generator C files are now declaration shims rather than implementations. The generated single-file C sources also call Rust-owned symbols now. Build and link an appropriately featured Rust archive in their native smoke tests, and include the pool configuration shim in the decoder case. The full amalgamation combines `zstd_lazy.c` and `zstd_opt.c` into one translation unit, so guard their otherwise translation-unit-local dictionary mode enum against duplicate definition. A Rust-backed amalgamation is no longer a standalone Emscripten input. Remove the obsolete emcc/Docker path and report that limitation explicitly; restoring the WebAssembly smoke test requires a Rust WebAssembly archive and a defined cross-language amalgamation contract. Test Plan: - `cargo check --manifest-path rust/Cargo.toml --no-default-features --features compression` -- passed - `cargo check --manifest-path rust/Cargo.toml --no-default-features --features decompression` -- passed - `sh -n build/single_file_libs/build_decoder_test.sh build/single_file_libs/build_library_test.sh` -- passed - `make all` -- passed, including native single-file and seekable-format tests - `git diff --cached --check` -- passed
138 lines
4.8 KiB
Makefile
138 lines
4.8 KiB
Makefile
# Makefile for example of using zstd wrapper for zlib
|
|
#
|
|
# make - compiles examples
|
|
# make MOREFLAGS=-DZWRAP_USE_ZSTD=1 - compiles examples with zstd compression turned on
|
|
# make test - runs examples
|
|
|
|
|
|
# Paths to static and dynamic zlib and zstd libraries
|
|
# Use "make ZLIB_PATH=path/to/zlib ZLIB_LIBRARY=path/to/libz.so" to select a path to library
|
|
ZLIB_LIBRARY ?= -lz
|
|
ZLIB_PATH ?= .
|
|
|
|
ZSTDLIBDIR = ../lib
|
|
ZSTDLIBRARY = $(ZSTDLIBDIR)/libzstd.a
|
|
ZLIBWRAPPER_PATH = .
|
|
GZFILES = gzclose.o gzlib.o gzread.o gzwrite.o
|
|
EXAMPLE_PATH = examples
|
|
PROGRAMS_PATH = ../programs
|
|
TEST_FILE = ../doc/zstd_compression_format.md
|
|
CARGO ?= cargo
|
|
RUST_DIR := ../rust
|
|
RUST_CLI_DIR := $(RUST_DIR)/cli
|
|
RUST_CLI_MANIFEST := $(RUST_CLI_DIR)/Cargo.toml
|
|
RUST_CLI_HELPER_SOURCES := $(RUST_CLI_MANIFEST) $(RUST_CLI_DIR)/Cargo.lock \
|
|
$(RUST_CLI_DIR)/src/lib.rs \
|
|
$(RUST_DIR)/src/timefn.rs $(RUST_DIR)/src/benchfn.rs \
|
|
$(RUST_DIR)/src/datagen.rs $(RUST_DIR)/src/lorem.rs \
|
|
$(RUST_DIR)/src/util.rs
|
|
RUST_CLI_HELPERS_TARGET_DIR := $(RUST_DIR)/target/cli-helpers
|
|
RUST_CLI_HELPERS_STATICLIB := $(RUST_CLI_HELPERS_TARGET_DIR)/release/libzstd_cli_rs.a
|
|
RUST_CLI_HELPERS_CARGO_FLAGS := --manifest-path $(RUST_CLI_MANIFEST) --release \
|
|
--target-dir $(RUST_CLI_HELPERS_TARGET_DIR) \
|
|
--no-default-features --features helpers
|
|
|
|
vpath %.c $(PROGRAMS_PATH) $(EXAMPLE_PATH) $(ZLIBWRAPPER_PATH)
|
|
|
|
|
|
CPPFLAGS += -DXXH_NAMESPACE=ZSTD_ -I$(ZLIB_PATH) -I$(PROGRAMS_PATH) \
|
|
-I$(ZSTDLIBDIR) -I$(ZSTDLIBDIR)/common -I$(ZLIBWRAPPER_PATH)
|
|
STDFLAGS = -std=c89 -pedantic -Wno-long-long -Wno-variadic-macros -Wc++-compat \
|
|
-DNO_snprintf -DNO_vsnprintf # strict ANSI C89 is missing these prototypes
|
|
DEBUGFLAGS= -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow -Wswitch-enum \
|
|
-Wdeclaration-after-statement -Wstrict-prototypes -Wundef \
|
|
-Wstrict-aliasing=1
|
|
CFLAGS ?= -O3
|
|
CFLAGS += $(STDFLAGS) $(DEBUGFLAGS)
|
|
CPPFLAGS += $(MOREFLAGS)
|
|
LDLIBS += $(ZLIB_LIBRARY)
|
|
|
|
# Define *.exe as extension for Windows systems
|
|
ifneq (,$(filter Windows%,$(OS)))
|
|
EXT =.exe
|
|
else
|
|
EXT =
|
|
endif
|
|
|
|
default : release
|
|
|
|
release : STDFLAGS =
|
|
release : DEBUGFLAGS =
|
|
release : all
|
|
|
|
all: fitblk example zwrapbench minigzip
|
|
|
|
test: example fitblk example_zstd fitblk_zstd zwrapbench minigzip minigzip_zstd
|
|
./example
|
|
./example_zstd
|
|
./fitblk 10240 <$(TEST_FILE)
|
|
./fitblk 40960 <$(TEST_FILE)
|
|
./fitblk_zstd 10240 <$(TEST_FILE)
|
|
./fitblk_zstd 40960 <$(TEST_FILE)
|
|
@echo ---- minigzip start ----
|
|
./minigzip_zstd example$(EXT)
|
|
#cp example$(EXT).gz example$(EXT)_zstd.gz
|
|
./minigzip_zstd -d example$(EXT).gz
|
|
./minigzip example$(EXT)
|
|
#cp example$(EXT).gz example$(EXT)_gz.gz
|
|
./minigzip_zstd -d example$(EXT).gz
|
|
@echo ---- minigzip end ----
|
|
./zwrapbench -qi1b3B1K $(TEST_FILE)
|
|
./zwrapbench -rqi1b1e3 ../lib
|
|
|
|
.PHONY: test-valgrind
|
|
#test-valgrind: ZSTDLIBRARY = $(ZSTDLIBDIR)/libzstd.so
|
|
test-valgrind: VALGRIND = LD_LIBRARY_PATH=$(ZSTDLIBDIR) valgrind --track-origins=yes --leak-check=full --error-exitcode=1
|
|
test-valgrind: clean example fitblk example_zstd fitblk_zstd zwrapbench
|
|
@echo "\n ---- valgrind tests ----"
|
|
$(VALGRIND) ./example
|
|
$(VALGRIND) ./example_zstd
|
|
$(VALGRIND) ./fitblk 10240 <$(TEST_FILE)
|
|
$(VALGRIND) ./fitblk 40960 <$(TEST_FILE)
|
|
$(VALGRIND) ./fitblk_zstd 10240 <$(TEST_FILE)
|
|
$(VALGRIND) ./fitblk_zstd 40960 <$(TEST_FILE)
|
|
$(VALGRIND) ./zwrapbench -qi1b3B1K $(TEST_FILE)
|
|
$(VALGRIND) ./zwrapbench -rqi1b1e5 ../lib ../programs ../tests
|
|
|
|
#.c.o:
|
|
# $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
|
|
|
|
minigzip: minigzip.o zstd_zlibwrapper.o $(GZFILES) $(ZSTDLIBRARY)
|
|
|
|
minigzip_zstd: minigzip.o zstdTurnedOn_zlibwrapper.o $(GZFILES) $(ZSTDLIBRARY)
|
|
$(LINK.o) $^ $(LDLIBS) $(OUTPUT_OPTION)
|
|
|
|
example: example.o zstd_zlibwrapper.o $(GZFILES) $(ZSTDLIBRARY)
|
|
|
|
example_zstd: example.o zstdTurnedOn_zlibwrapper.o $(GZFILES) $(ZSTDLIBRARY)
|
|
$(LINK.o) $^ $(LDLIBS) $(OUTPUT_OPTION)
|
|
|
|
fitblk: fitblk.o zstd_zlibwrapper.o $(ZSTDLIBRARY)
|
|
|
|
fitblk_zstd: fitblk.o zstdTurnedOn_zlibwrapper.o $(ZSTDLIBRARY)
|
|
$(LINK.o) $^ $(LDLIBS) $(OUTPUT_OPTION)
|
|
|
|
zwrapbench: zwrapbench.o zstd_zlibwrapper.o util.o timefn.o datagen.o $(ZSTDLIBRARY) $(RUST_CLI_HELPERS_STATICLIB)
|
|
|
|
|
|
zstd_zlibwrapper.o: zstd_zlibwrapper.h
|
|
|
|
zstdTurnedOn_zlibwrapper.o: CPPFLAGS += -DZWRAP_USE_ZSTD=1
|
|
zstdTurnedOn_zlibwrapper.o: zstd_zlibwrapper.c zstd_zlibwrapper.h
|
|
$(COMPILE.c) $< $(OUTPUT_OPTION)
|
|
|
|
|
|
$(ZSTDLIBRARY):
|
|
$(MAKE) -C $(ZSTDLIBDIR) libzstd.a
|
|
|
|
$(RUST_CLI_HELPERS_STATICLIB): $(RUST_CLI_HELPER_SOURCES)
|
|
$(CARGO) build $(RUST_CLI_HELPERS_CARGO_FLAGS)
|
|
|
|
$(ZSTDLIBDIR)/libzstd.so:
|
|
$(MAKE) -C $(ZSTDLIBDIR) libzstd
|
|
|
|
|
|
clean:
|
|
-$(RM) $(ZLIBWRAPPER_PATH)/*.o $(EXAMPLE_PATH)/*.o *.o foo.gz example$(EXT) example_zstd$(EXT) fitblk$(EXT) fitblk_zstd$(EXT) zwrapbench$(EXT) minigzip$(EXT) minigzip_zstd$(EXT)
|
|
@echo Cleaning completed
|