feat(cli): move trace callbacks into Rust

Implement the CLI trace callbacks and CSV logger in Rust, preserving the ZSTD_Trace ABI, timing fields, parameter reporting, mutex-protected writes, and no-op disabled behavior. Add the module to every Rust CLI archive and exclude the duplicate C trace object from Rust-backed program targets.

Test Plan:

- cargo test --manifest-path rust/cli/Cargo.toml (92 passed)

- cargo clippy --manifest-path rust/cli/Cargo.toml --all-targets

- make -B -C programs -j2 zstd

- Rust trace smoke: programs/zstd -q --trace=/tmp/zstd-rust-trace-smoke.csv -c /tmp/levels-input

- make -B -C tests -j2 test-cli-tests (41 passed)
This commit is contained in:
2026-07-18 02:50:25 +02:00
parent 49b3405d63
commit 9f85a7ebd7
3 changed files with 233 additions and 1 deletions
+2 -1
View File
@@ -37,6 +37,7 @@ RUST_CLI_SOURCES := $(RUST_CLI_MANIFEST) $(RUST_CLI_DIR)/Cargo.lock \
$(RUST_DIR)/src/fileio_prefs.rs \
$(RUST_DIR)/src/dibio.rs \
$(RUST_DIR)/src/util.rs \
$(RUST_DIR)/src/zstdcli_trace.rs \
$(RUST_DIR)/src/timefn.rs $(RUST_DIR)/src/benchfn.rs \
$(RUST_DIR)/src/datagen.rs $(RUST_DIR)/src/lorem.rs
@@ -232,7 +233,7 @@ ZSTDLIB_LOCAL_SRC = $(notdir $(ZSTDLIB_FULL_SRC))
ZSTDLIB_LOCAL_OBJ0 := $(ZSTDLIB_LOCAL_SRC:.c=.o)
ZSTDLIB_LOCAL_OBJ := $(ZSTDLIB_LOCAL_OBJ0:.S=.o)
ZSTD_CLI_SRC := $(filter-out benchzstd.c,$(sort $(wildcard *.c)))
ZSTD_CLI_SRC := $(filter-out benchzstd.c zstdcli_trace.c,$(sort $(wildcard *.c)))
ZSTD_CLI_OBJ := $(ZSTD_CLI_SRC:.c=.o)
ZSTD_ALL_SRC = $(ZSTDLIB_LOCAL_SRC) $(ZSTD_CLI_SRC)