> ## Documentation Index
> Fetch the complete documentation index at: https://whatsapp-rust.jlucaso.com/llms.txt
> Use this file to discover all available pages before exploring further.

# June 11, 2026 — Docker image: share-generics, build-std, multi-arch

> Reduces the release binary .text section by ~15% cumulatively through -Zshare-generics=y and -Zbuild-std, and enables native multi-arch docker buildx builds.

## Performance

**Dockerfile: `-Zshare-generics`, `build-std`, and explicit target ([#845](https://github.com/oxidezap/whatsapp-rust/pull/845))**

The Docker image build gains three related changes that reduce binary size and improve reproducibility.

**`-Zshare-generics=y`** tells the nightly compiler to reuse upstream crate monomorphizations instead of re-codegening them per downstream crate. Cross-crate duplicate-symbol waste drops from 1414 KiB to 475 KiB; consumer-crate reinstantiation drops from 1484 KiB to 531 KiB. Measured impact on the release binary: `.text` shrinks by **666 KiB (−5.6%)**.

**`-Zbuild-std`** (via `CARGO_UNSTABLE_BUILD_STD=std,panic_abort`) recompiles the standard library with the release profile so it participates in fat LTO and dead-code elimination instead of linking the prebuilt rustup `std`. This was measured separately in the same audit series as an additional −303 KiB.

Combined with the library-level deduplication in #842–#844, the cumulative reduction since the audit began is **13.03 MiB → 11.00 MiB (−15.6%)** on `.text`.

**Explicit target triple.** The Dockerfile now detects the host triple at build time via `rustc -vV` and passes it explicitly to both `cargo chef cook` and `cargo build`. This is required by `-Zbuild-std`, and as a side effect it makes `docker buildx build --platform linux/arm64` produce correct native binaries without Dockerfile changes.

**Pinned `cargo-chef`.** `cargo-chef` is now installed at a fixed version (`0.1.77 --locked`) so image rebuilds are deterministic rather than tracking the latest crates.io release.

Both `-Zshare-generics` and `-Zbuild-std` are nightly-only flags. They apply only inside the Docker image, which already pins the nightly toolchain via `rust-toolchain.toml`. Stable consumers and local `cargo build` invocations are unaffected. With `lto = "fat"` the historical downside of `share-generics` (lost cross-crate inlining of shared instantiations) does not apply — fat LTO sees all bitcode and re-inlines freely.

Downstream images building on the same pinned nightly (e.g. Veloz) can apply the same `RUSTFLAGS` and `CARGO_UNSTABLE_BUILD_STD` variables for identical gains.
