fix(build): gate CLI dictionary builder by feature

Keep dictionary-training code out of compressor-only and decompressor-only CLI
archives, where its ZDICT symbols are intentionally absent. Add a dedicated
Rust CLI archive for zstd-dictBuilder, enable the builder feature only for the
full and dictionary-builder programs, and make reduced-feature help use the
feature-independent max-level helper.

Test Plan:
- cargo test --manifest-path rust/cli/Cargo.toml --lib -- --test-threads=1 (158 passed)
- cargo test --manifest-path rust/cli/Cargo.toml --no-default-features --features cli,compression,dict-builder --lib -- --test-threads=1 (124 passed)
- cargo clippy --manifest-path rust/cli/Cargo.toml --lib -- -D warnings
- cargo clippy --manifest-path rust/cli/Cargo.toml --no-default-features --features cli,compression,dict-builder --lib -- -D warnings
- make -C programs -j2 zstd zstd-small zstd-frugal zstd-decompress zstd-compress zstd-dictBuilder
- git diff --check
This commit is contained in:
2026-07-18 17:36:24 +02:00
parent f7a2576761
commit e557549ff4
4 changed files with 20 additions and 8 deletions
+12 -2
View File
@@ -125,7 +125,7 @@ RUST_CLI_STATICLIB := $(RUST_CLI_TARGET_DIR)/release/libzstd_cli_rs.a
RUST_CLI_STATICLIB_32 := $(RUST_CLI_TARGET_DIR)/$(RUST_TARGET_32)/release/libzstd_cli_rs.a
RUST_CLI_CARGO_FLAGS := --manifest-path $(RUST_CLI_MANIFEST) --release \
--target-dir $(RUST_CLI_TARGET_DIR) \
--no-default-features --features cli,compression,decompression,benchmark
--no-default-features --features cli,compression,decompression,benchmark,dict-builder
$(RUST_CLI_STATICLIB): $(RUST_CLI_SOURCES)
$(CARGO) build $(RUST_CLI_CARGO_FLAGS)
@@ -206,6 +206,16 @@ RUST_COMPRESS_CLI_CARGO_FLAGS := --manifest-path $(RUST_CLI_MANIFEST) --release
$(RUST_COMPRESS_CLI_STATICLIB): $(RUST_CLI_SOURCES)
$(CARGO) build $(RUST_COMPRESS_CLI_CARGO_FLAGS)
RUST_DICTBUILDER_CLI_BUILD_CONFIG := cli-c1-d0-dictbuilder-$(RUST_HUF_MODE)
RUST_DICTBUILDER_CLI_TARGET_DIR := $(RUST_DIR)/target/$(RUST_DICTBUILDER_CLI_BUILD_CONFIG)
RUST_DICTBUILDER_CLI_STATICLIB := $(RUST_DICTBUILDER_CLI_TARGET_DIR)/release/libzstd_cli_rs.a
RUST_DICTBUILDER_CLI_CARGO_FLAGS := --manifest-path $(RUST_CLI_MANIFEST) --release \
--target-dir $(RUST_DICTBUILDER_CLI_TARGET_DIR) \
--no-default-features --features cli,compression,dict-builder
$(RUST_DICTBUILDER_CLI_STATICLIB): $(RUST_CLI_SOURCES)
$(CARGO) build $(RUST_DICTBUILDER_CLI_CARGO_FLAGS)
# Most program objects use a configuration-hashed directory, but the compact
# direct-source variants below do not. Give their C outputs an independent
# mode stamp so they cannot outlive a different Rust HUF archive selection.
@@ -479,7 +489,7 @@ zstd-compress: $(ZSTDLIB_COMMON_SRC) $(ZSTDLIB_COMPRESS_SRC) zstdcli.c util.c ti
## zstd-dictBuilder: executable supporting dictionary creation and compression (only)
CLEAN += zstd-dictBuilder
zstd-dictBuilder: $(ZSTDLIB_COMMON_SRC) $(ZSTDLIB_COMPRESS_SRC) $(ZDICT_SRC) zstdcli.c util.c timefn.c fileio.c fileio_asyncio.c dibio.c $(RUST_DICTBUILDER_STATICLIB) $(RUST_COMPRESS_CLI_STATICLIB)
zstd-dictBuilder: $(ZSTDLIB_COMMON_SRC) $(ZSTDLIB_COMPRESS_SRC) $(ZDICT_SRC) zstdcli.c util.c timefn.c fileio.c fileio_asyncio.c dibio.c $(RUST_DICTBUILDER_STATICLIB) $(RUST_DICTBUILDER_CLI_STATICLIB)
$(CC) $(FLAGS) -DZSTD_NOBENCH -DZSTD_NODECOMPRESS -DZSTD_NOTRACE $^ -o $@$(EXT)
RUST_DIRECT_LINK_TARGETS := zstd32 zstd-nolegacy zstd-small zstd-frugal \