Skip to content

Commit e413cf9

Browse files
authored
Document rustc -Zlocation-detail flag (#54)
1 parent 810aa52 commit e413cf9

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

.github/workflows/build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,5 @@ jobs:
4747
working-directory: ${{ matrix.project_dir }}
4848
run: >
4949
rustup component add rust-src;
50-
cargo +nightly build -Z build-std=std,panic_abort --target x86_64-unknown-linux-gnu --release;
50+
RUSTFLAGS="-Zlocation-detail=none" cargo +nightly build -Z build-std=std,panic_abort --target x86_64-unknown-linux-gnu --release;
5151
cargo +nightly build -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort --target x86_64-unknown-linux-gnu --release;

README.md

+17-1
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,22 @@ Enable this in `Cargo.toml`:
137137
panic = "abort"
138138
```
139139

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+
140156
# Optimize `libstd` with `build-std`
141157

142158
![Minimum Rust: Nightly](https://img.shields.io/badge/Minimum%20Rust%20Version-nightly-orange.svg)
@@ -180,7 +196,7 @@ host: x86_64-apple-darwin
180196
# Use that target triple when building with build-std.
181197
# Add the =std,panic_abort to the option to make panic = "abort" Cargo.toml option work.
182198
# 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
184200
```
185201

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

0 commit comments

Comments
 (0)