Major Causes of Rust Binary Bloat

The primary factors contributing to Rust's larger binary sizes include: 1. **Monomorphization of generics:** Each unique type used with a generic function or struct results in a specialized copy of the code, leading to code duplication. 2. **Static linking:** Rust binaries typically statically link almost everything, including the standard library, embedding most dependencies directly into the executable. 3. **Debug symbols and panic machinery:** Even in release builds, Rust often includes debug information and extensive panic handling code by default, which adds significant size unless explicitly stripped or configured otherwise.

Sources

Open the full topic