build(rust): select archives by target and HUF mode

Derive the Rust static-library configuration from the effective C HUF decoder
flags and place each mode in its own Cargo target directory. This prevents a
forced X1/X2 C build from silently reusing the default Rust archive.

The test and program makefiles now also build and link an i686 Rust archive
for their 32-bit targets, including zstd32. zstd-small retains its existing
default configuration while preserving an explicitly requested HUF mode.

Test Plan:
- cargo clippy; cargo clippy --benches; cargo clippy --tests
- cargo +nightly fmt, then repeat the Clippy checks
- cargo test --all-targets for default, forced X1, and forced X2 modes
- cargo build --release --target i686-unknown-linux-gnu for each mode
- make -n checks for default, forced, direct -D, and 32-bit test/CLI targets

Refs: rust/README.md
This commit is contained in:
2026-07-10 20:46:23 +02:00
parent 58a50db413
commit d89ebb31e3
4 changed files with 109 additions and 11 deletions
+5
View File
@@ -6,5 +6,10 @@ edition = "2021"
[lib]
crate-type = ["staticlib"]
[features]
default = []
huf-force-decompress-x1 = []
huf-force-decompress-x2 = []
[dependencies]
libc = "0.2"
+5 -4
View File
@@ -41,10 +41,11 @@ source file whose implementation has moved to Rust remains in the original
makefile source list as a small shim so header configuration and platform
preprocessor behavior stay available during the transition.
The test and program makefiles make `target/release/libzstd_rs.a` a normal
link prerequisite. They rebuild the Rust archive and relink the executable
when a Rust source changes, so original C tests do not accidentally use a stale
implementation.
The test and program makefiles select an archive directory for the active C
configuration: default, forced HUF X1/X2, and the matching Rust target for
32-bit C binaries. They rebuild the selected archive and relink the executable
when a Rust source changes, so original C tests do not accidentally use a
stale or configuration-incompatible implementation.
## Validation