Build & Inspect Tooling
Beyond cargo build, Linux tooling inspects Rust binaries: size breakdown, symbols, linking mode, and strip policies for deployment.
Search across all documentation pages
Beyond cargo build, Linux tooling inspects Rust binaries: size breakdown, symbols, linking mode, and strip policies for deployment.
cargo build --release --locked
file target/release/my-service
ldd target/release/my-service 2>/dev/null || true
cargo bloat --release -n 20
strip target/release/my-service
ls -lh target/release/my-serviceWhen to reach for this:
cargo install cargo-bloat
cargo bloat --release --crates -n 15
# Inspect symbols
nm -C target/release/my-service | rg "my_service::" | head
# Disassemble hot function (advanced)
objdump -d --demangle target/release/my-service | less# Cargo.toml - release profile
[profile.release]
strip = "symbols"
lto = "thin"
codegen-units = 1What this demonstrates:
cargo bloat attributes size to cratesnm lists mangled/demangled symbolsstrip automates post-link shrink| Command | Purpose |
|---|---|
cargo tree -e features | Why dependency exists |
cargo llvm-lines | LLVM IR size proxy |
cargo audit | Security advisories |
cargo deny check | License and ban policy |
--release.build.rs - native link flags hidden. Fix: read build.rs when inspecting link.
| Alternative | Use When | Don't Use When |
|---|---|---|
samply / perf | Runtime profiling | Static size only |
twiggy | WASM size | Native only |
dwarfdump | Debug info analysis | Quick check |
Stripped release often 2-8 MB depending on deps; investigate if sudden doubling.
bloat measures linked size contribution; tree shows dependency graph only.
Stack versions: This page was written for Rust 1.97.0 (edition 2024), Tokio 1.x, Axum 0.8, serde 1.0, sqlx 0.8, clap 4, and Polars 0.46+.
Reviewed by Chris St. John·Last updated Jul 19, 2026