-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Enable strip in release mode by default #4122
Comments
I think this should only change if |
@cedenday I don't see an issue with backtraces being wiped in |
Thanks for the report! I think this is mostly due to the addition of debuginfo into the standard library a few versions ago, so the lion's share of |
@alexcrichton maybe LLVM's For ld/lld |
@mati865 we have a nightly rustc flag for that: rust-lang/rust#49212. I think the idea is, eventually, to enable stripping for |
@matklad that's nice but it would be even better if there was option to use |
Hello. When this will be solved? |
cc #3483 |
Should this be closed now that See: #3483 (comment) |
I think not. --release flag is explicit. |
FYI: With Rust 1.59.0, this can be specified in
and this will strip them in the compile process, rather than needing to explicitly call Ref: https://blog.rust-lang.org/2022/02/24/Rust-1.59.0.html#creating-stripped-binaries |
Should this issue be renamed to be |
seems acceptable for me. |
Gotchu :) |
Note that there are plans to shrink the amount of debug info by default, see #11958 for some talk of this. |
I would like to propose to change Cargo defaults so that MotivationCurrently, when This means that every binary built by Cargo with its default profile options will contain the stdlib debug symbols, which take about 3-4 MiB on x64 Linux. So, today, no Rust (Linux) binary built with the default profile options can be smaller than 4 MiB! Of course, the symbols can be removed via stripping, but not everyone knows about this. Notably, when someone new to Rust tries to build a helloworld binary in release mode and then finds out that it takes more than 4 MiB, they might be discouraged and consider Rust binaries to be "bloated". An example using the latest (
That's a big difference! Defaults do matter. What exactly is being proposedWhen a Cargo profile should not produce
profile.strip = profile.strip.or_else(|| if profile.debug == "0" { Some("debuginfo") } else { None }); Here is a proposed implementation. Note that this would also apply to proc macros and build scripts, not just binaries (unless we explicitly do this only for binaries). Advantages
Disadvantages
Unresolved questions/concerns
[dependencies]
serde_json = "1.0.108"
[profile.release]
debug = 1
[profile.release.package.serde_json]
debug = 0 then debug symbols were generated for |
Thank you, @Kobzol. Going to kick off an FCP. @rfcbot fcp merge Propose to accept this proposal #4122 (comment) for all platforms. For concerns on macOS, we had issues like #11641, which shows the symptom of incompatible |
Team member @weihanglo has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
Implementation PR: #13257. |
Attempts to follow the cargo proposal linked below to remove debug info for release builds. Furthermore this should uphold the expected behavior of bazel for cc builds which automatically strips debug symbols for optimized builds. rust-lang/cargo#4122 (comment)
Attempts to follow the cargo proposal linked below to remove debug info for release builds. Furthermore this should uphold the expected behavior of bazel for cc builds which automatically strips debug symbols for optimized builds. rust-lang/cargo#4122 (comment)
Attempts to follow the cargo proposal linked below to remove debug info for release builds. Furthermore this should uphold the expected behavior of bazel for cc builds which automatically strips debug symbols for optimized builds. rust-lang/cargo#4122 (comment)
Attempts to follow the cargo proposal linked below to remove debug info for release builds. Furthermore this should uphold the expected behavior of bazel for cc builds which automatically strips debug symbols for optimized builds. rust-lang/cargo#4122 (comment)
Attempts to follow the cargo proposal linked below to remove debug info for release builds. Furthermore this should uphold the expected behavior of bazel for cc builds which automatically strips debug symbols for optimized builds. rust-lang/cargo#4122 (comment)
Attempts to follow the cargo proposal linked below to remove debug info for release builds. Furthermore this should uphold the expected behavior of bazel for cc builds which automatically strips debug symbols for optimized builds. rust-lang/cargo#4122 (comment)
I consider it to be a process failure that this was proposed and implemented without a single consideration or mention of Windows. That something so dependent on toolchain specifics could go through without even considering all tier1 platforms is embarrassing. |
The problem with backtraces wasn't caused by this change, it only exposed a pre-existing issue, which has been existing in Rust for a long time (4 years, rust-lang/rust@a6c2f73). It's just that no one has noticed it until now, since it started appearing more often. That probably means that not many people use
I think that's unnecessarily strong wording :) We have a lot of tests for tier 1 platforms, of course, but we didn't have a test for this specific situation. |
Nobody on Windows MSVC should ever have a reason to consider stripping as binary files never contain debuginfo to begin with. That PR from 4 years ago was definitely wrong to have stripping affect PDB file generation given we previously made the decision to always generate PDB files regardless of whether debuginfo is enabled.
Then we should definitely add tests to ensure backtraces work on Windows MSVC in cargo release builds. |
Yeah, we should add tests to rust-lang/rust#115120. |
Porting backtrace-rs tests (which would have caught this if backtrace's CI ran nightly Windows... it's not clear why we weren't, given the CI files had comments about "we only test Windows on nightly") to always run in rustc's test suite is: I fully intend to prevent this regression from happening ever again. I am also recommending the Rust teams investigate shipping our own |
backtrace-rs will now also be running Windows CI on nightly. |
Attempts to follow the cargo proposal linked below to remove debug info for release builds. Furthermore this should uphold the expected behavior of bazel for cc builds which automatically strips debug symbols for optimized builds. rust-lang/cargo#4122 (comment)
Attempts to follow the cargo proposal linked below to remove debug info for release builds. Furthermore this should uphold the expected behavior of bazel for cc builds which automatically strips debug symbols for optimized builds. rust-lang/cargo#4122 (comment)
Attempts to follow the cargo proposal linked below to remove debug info for release builds. Furthermore this should uphold the expected behavior of bazel for cc builds which automatically strips debug symbols for optimized builds. rust-lang/cargo#4122 (comment)
Attempts to follow the cargo proposal linked below to remove debug info for release builds. Furthermore this should uphold the expected behavior of bazel for cc builds which automatically strips debug symbols for optimized builds. rust-lang/cargo#4122 (comment)
Attempts to follow the cargo proposal linked below to remove debug info for release builds. Furthermore this should uphold the expected behavior of bazel for cc builds which automatically strips debug symbols for optimized builds. rust-lang/cargo#4122 (comment)
Attempts to follow the cargo proposal linked below to remove debug info for release builds. Furthermore this should uphold the expected behavior of bazel for cc builds which automatically strips debug symbols for optimized builds. rust-lang/cargo#4122 (comment)
I'd expect
build --release
to apply all optimisations, and one of them would be file size.I tried two programs, a trivial "hello rust" and a trivial "hello panic". Both of their sizes were 3.8M which is pretty crazy for something that is supposed to be optimised... So I tried
strip --strip-all
ing the executables.Hello rust went to 372K
Hello panic went to 364K
That's a pretty huge change... The only difference in functionality I found is that
RUST_BACKTRACE=1
shows a lot of<unknown>
s onstrip
ed files which is to be expected, but I think that's not a real issue because the whole point of--release
is that it's not supposed to be debugged, there is the normalbuild
for that...For now I will be
strip --strip-all
ing all of my released executables but I really don't see a reason whybuild --release
doesn't do it. I'd be happy to be enlightened if I missed anything though!The text was updated successfully, but these errors were encountered: