As of Rust 1.59, the cargo
command is now able to strip a binary. This can be enabled in your Cargo.toml
in the following way:
[package]
# ...
[profile.release]
strip="debuginfo"
A cargo subcommand that reduces the size of Rust binaries using the strip
command.
Run the following command:
cargo install --force cargo-strip
Simply strip your binary with:
cargo strip
When cross-compiling, the --target
could be used to strip the binary, such as:
cargo strip --target armv7-unknown-linux-gnueabihf