@@ -137,6 +137,22 @@ Enable this in `Cargo.toml`:
137
137
panic = " abort"
138
138
```
139
139
140
+ # Remove Location Details
141
+
142
+ ![ Minimum Rust: Nightly] ( https://img.shields.io/badge/Minimum%20Rust%20Version-nightly-orange.svg )
143
+
144
+ By default, Rust includes file, line, and column information for ` panic!() ` and ` [track_caller] `
145
+ to provide more useful traceback information. This information requires space in the binary and
146
+ thus increases the size of the compiled binaries.
147
+
148
+ To remove this file, line, and column information, use the unstable
149
+ [ ` rustc ` ` -Zlocation-detail ` ] ( https://github.com/rust-lang/rfcs/blob/master/text/2091-inline-semantic.md#location-detail-control )
150
+ flag:
151
+
152
+ ``` bash
153
+ $ RUSTFLAGS=" -Zlocation-detail=none" cargo +nightly build --release
154
+ ```
155
+
140
156
# Optimize ` libstd ` with ` build-std `
141
157
142
158
![ Minimum Rust: Nightly] ( https://img.shields.io/badge/Minimum%20Rust%20Version-nightly-orange.svg )
@@ -180,7 +196,7 @@ host: x86_64-apple-darwin
180
196
# Use that target triple when building with build-std.
181
197
# Add the =std,panic_abort to the option to make panic = "abort" Cargo.toml option work.
182
198
# See: https://github.com/rust-lang/wg-cargo-std-aware/issues/56
183
- $ cargo +nightly build -Z build-std=std,panic_abort --target x86_64-apple-darwin --release
199
+ $ RUSTFLAGS= " -Zlocation-detail=none " cargo +nightly build -Z build-std=std,panic_abort --target x86_64-apple-darwin --release
184
200
```
185
201
186
202
On macOS, the final stripped binary size is reduced to 51KB.
0 commit comments