build(meson): link migrated Rust code into native libraries

Build a configuration-matched Cargo archive from Meson and flatten its object
members into static libzstd.  This gives C consumers one archive even though
the migrated Rust objects and remaining C code refer to each other.

Shared libraries whole-archive the Cargo output to retain Rust-only ABI
exports.  The implementation supports Meson 0.50's generated-archive linking
rules, matching HUF mode and 32-bit configuration, and documents cross-build
target and archiver selection.

Test Plan:
- fresh Meson both-build smoke consumers and invalidDictionaries
- modern static/shared/both, forced-HUF, i686, install, and fuzzer paths
- real Meson 0.50 static and shared smoke builds
- cargo clippy, cargo clippy --benches, cargo clippy --tests, and nightly fmt

Refs: build/meson/README.md archive and cross-build documentation
This commit is contained in:
2026-07-10 22:08:55 +02:00
parent 6a762660b7
commit 3d679116d8
6 changed files with 405 additions and 36 deletions
+13
View File
@@ -34,3 +34,16 @@ option('lzma', type: 'feature', value: 'auto',
description: 'Enable lzma support')
option('lz4', type: 'feature', value: 'auto',
description: 'Enable lz4 support')
# The migrated compatibility modules are compiled by Cargo. A cross build
# needs the corresponding Rust target triple; leave it empty for native
# builds (or 32-bit Linux, which is detected automatically).
option('zstd_rust_target', type: 'string', value: '',
description: 'Cargo target triple for the Rust compatibility archive')
option('zstd_rust_archiver', type: 'string', value: '',
description: 'Archiver used to merge Rust objects into libzstd (default: ar)')
option('huf_force_decompress_x1', type: 'boolean', value: false,
description: 'Force the Huffman X1 decoder in C and Rust')
option('huf_force_decompress_x2', type: 'boolean', value: false,
description: 'Force the Huffman X2 decoder in C and Rust')