-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow backtrace information to be optional #1417
Comments
👍 Always bothered me. |
What backtrace information? We use the symbol names or debug info, just like C and C++. |
It would make sense to provide a way to compile it without the symbol names & debug info. Futhermore, panics will show file name and line number (though this is not rustc, but libstd). |
@ticki To compile without debug info: remove Compiling without symbol names doesn't make sense: they're certainly mandatory for libraries, and executables cannot drop symbol names until linking has finished. EDIT: |
That'll still show line number and file name when panicking.
Yeah, that was what I thought of. It |
Panics are not "backtrace information", they're |
Also, if you want a solution now for the "strip symbols part", you can use |
Yes, you're right. They're not backtrace information, they're debug information. These could be removed in release mode (by using |
Update: The crates in rust-lang/rust has been Cargo-ified. I have a lightly tested fork of rust-lang/rust that makes the backtraces (RUST_BACKTRACE / libbacktrace) optional via a Cargo feature (only usable with the newer "rustbuild" build system). But even if that lands upstream, it won't be super easy to use because (a) our binary releases would still ship with backtraces enabled, (b) even if you are OK with bootstrapping rustc along with the std crate, rustbuild doesn't expose (AFAIK cc @alexcrichton) an easy way to customize the Cargo features of the std crate and (c) trying to directly build the TL;DR To implement this we have to decide how to expose this (optional) feature to end users. |
Actually, there is a config.toml that rustbuild can use. I've send a PR implementing optional backtraces and exposing them via that config.toml: rust-lang/rust#35051 |
rustbuild: make backtraces (RUST_BACKTRACE) optional but keep them enabled by default to maintain the status quo. When disabled shaves ~56KB off every x86_64-unknown-linux-gnu binary. To disable backtraces you have to use a config.toml (see src/bootstrap/config.toml.example for details) when building rustc/std: $ python bootstrap.py --config=config.toml --- r? @alexcrichton cc rust-lang/rfcs#1417
What's the current status of this? |
There's one more good reason for this, that hasn't been mentioned yet. I want to disable the message because re-running the panicking binary is not always a good thing to suggest to end-users. |
You can use a panic hook to disable that message, right? |
Panic hook won't remove the unwanted data from the executable. |
There appears to be no way to disable backtrace information embedding into a program. There are some cases where bundling filenames and other information needed for backtraces is not desired. Two cases I can think of immediately is wanting to provide as little information as possible in proprietary products. The other case is where you need the final binary to be as small as possible.
There is an old set of patches that added this that seem to be stale now.. Maybe they can be used as a starting point? https://github.com/japaric/std-with-cargo And there was also some discussion about this on the rust-internals IRC, but nothing seemed to come out of it: https://botbot.me/mozilla/rust-internals/2015-08-20/?msg=47709853&page=4
The text was updated successfully, but these errors were encountered: