fix(build): rebuild C outputs on HUF mode changes
Mode-specific Rust archives exposed the test makefiles' flat C-object cache:
switching from default to forced HUF mode could relink stale default C objects
with a newly built forced Rust archive. That hybrid has incompatible decoder
table expectations and can corrupt dictionary decompression.
Track each makefile's effective HUF mode with an empty archive stamp. It is a
safe normal linker prerequisite, and every mode transition advances its mtime
so cached C objects and direct-source binaries rebuild while unchanged modes
remain incremental.
Test Plan:
- cargo clippy; cargo clippy --benches; cargo clippy --tests
- cargo +nightly fmt, then repeat the Clippy checks
- cargo test --all-targets
- Default -> forced-X1 -> default fuzzer builds without -B, each running
./fuzzer -s5346 -i1 --no-big-tests
- Equivalent zstd-small default/forced/default rebuild and --version checks
Refs: rust/README.md
Fixes: d89ebb31
This commit is contained in:
@@ -77,6 +77,25 @@ $(RUST_STATICLIB): $(RUST_SOURCES)
|
||||
$(RUST_STATICLIB_32): $(RUST_SOURCES)
|
||||
$(CARGO) build $(RUST_CARGO_FLAGS) --target $(RUST_TARGET_32)
|
||||
|
||||
# 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.
|
||||
# The stamp is an empty archive, so normal linker `$^` recipes can consume it.
|
||||
RUST_HUF_C_MODE_FILE := $(RUST_DIR)/target/.huf-c-mode-programs
|
||||
RUST_HUF_C_MODE_STAMP := $(RUST_DIR)/target/.huf-c-mode-programs.a
|
||||
.PHONY: FORCE_RUST_HUF_C_MODE
|
||||
FORCE_RUST_HUF_C_MODE:
|
||||
$(RUST_HUF_C_MODE_STAMP): FORCE_RUST_HUF_C_MODE
|
||||
@mkdir -p $(@D)
|
||||
@if test ! -r $(RUST_HUF_C_MODE_FILE) \
|
||||
|| test "$$(cat $(RUST_HUF_C_MODE_FILE))" != "$(RUST_BUILD_CONFIG)" \
|
||||
|| test ! -f $@; then \
|
||||
printf '%s\n' "$(RUST_BUILD_CONFIG)" > $(RUST_HUF_C_MODE_FILE); \
|
||||
$(AR) rcs $@; \
|
||||
touch $@; \
|
||||
fi
|
||||
CLEAN += $(RUST_HUF_C_MODE_FILE) $(RUST_HUF_C_MODE_STAMP)
|
||||
|
||||
ifeq ($(shell $(CC) -v 2>&1 | $(GREP) -c "gcc version "), 1)
|
||||
ALIGN_LOOP = -falign-loops=32
|
||||
else
|
||||
@@ -328,6 +347,10 @@ 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_STATICLIB)
|
||||
$(CC) $(FLAGS) -DZSTD_NOBENCH -DZSTD_NODECOMPRESS -DZSTD_NOTRACE $^ -o $@$(EXT)
|
||||
|
||||
RUST_DIRECT_LINK_TARGETS := zstd32 zstd-nolegacy zstd-small zstd-frugal \
|
||||
zstd-decompress zstd-compress zstd-dictBuilder
|
||||
$(RUST_DIRECT_LINK_TARGETS): $(RUST_HUF_C_MODE_STAMP)
|
||||
|
||||
CLEAN += zstdmt
|
||||
zstdmt: zstd
|
||||
ln -sf zstd zstdmt
|
||||
|
||||
Reference in New Issue
Block a user