Skip to content

Commit c030adc

Browse files
authored
Add information about the optimize_for_size libstd feature (#64)
1 parent f3da56c commit c030adc

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,11 +204,16 @@ host: x86_64-apple-darwin
204204
# Use that target triple when building with build-std.
205205
# Add the =std,panic_abort to the option to make panic = "abort" Cargo.toml option work.
206206
# See: https://github.com/rust-lang/wg-cargo-std-aware/issues/56
207-
$ RUSTFLAGS="-Zlocation-detail=none" cargo +nightly build -Z build-std=std,panic_abort --target x86_64-apple-darwin --release
207+
$ RUSTFLAGS="-Zlocation-detail=none" cargo +nightly build -Z build-std=std,panic_abort \
208+
-Z build-std-features="std/optimize_for_size" \
209+
--target x86_64-apple-darwin --release
208210
```
209211

210212
On macOS, the final stripped binary size is reduced to 51KB.
211213

214+
The `optimize_for_size` flag provides a hint to libstd that it should try to use algorithms optimized
215+
for binary size. More information about it can be found [here](https://github.com/rust-lang/rust/issues/125612).
216+
212217
# Remove `panic` String Formatting with `panic_immediate_abort`
213218

214219
![Minimum Rust: Nightly](https://img.shields.io/badge/Minimum%20Rust%20Version-nightly-orange.svg)

0 commit comments

Comments
 (0)