Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upPanic handler binary size bloat #41
Comments
japaric
added
the
upstream
label
Feb 21, 2018
This comment has been minimized.
This comment has been minimized.
nagisa
commented
Feb 21, 2018
•
|
I wrote down my ideas on how we should fix the underlying issue. I still am going to write a separate issue for the underlying issue, of course. |
This comment has been minimized.
This comment has been minimized.
cr1901
commented
Feb 21, 2018
|
Relevant commit for my use case: cr1901/AT2XT@b6e2992 Notably, embedding unused strings does not happen with |
fitzgen
referenced this issue
Feb 21, 2018
Open
It is way too hard to avoid including panicking and formatting infrastructure code #19
This comment has been minimized.
This comment has been minimized.
fitzgen
commented
Feb 21, 2018
This comment has been minimized.
This comment has been minimized.
|
Update: we discussed this during Rust All Hands. Here's a summary by @nagisa (originally posted in rust-lang/rust#44489 (comment))
Where "this design" = RFC 2070 |
This comment has been minimized.
This comment has been minimized.
|
I'm hopeful this can be sorted out. Panic handling is a bit painful at the moment. |
This comment has been minimized.
This comment has been minimized.
|
Related: |
japaric commentedFeb 21, 2018
•
edited
There are two issues here. The first one I consider a (compiler) bug and the second one a missing
feature.
Panic strings kept in the binary
Even when
panic_fmt(the panic handler) is defined to simplyabortthe compiler still producesmachine code that passes the (unused) arguments (panic message, file name, line number and column
number) to that function at runtime. This causes the arguments to be stored in the program which
takes up a sizable amount of non volatile memory (.rodata).
Here's @nagisa's description of the issue.
@nagisa was looking into this and they may have found the root of the problem.
They'll open an issueHere's @nagisa proposed solution.in the rust-lang/rust repo with more details.
This is also a problem on WASM land; see rust-lang-nursery/rust-wasm#19. If this can't be fixed in
the compiler then this RFC (rust-lang/rfcs#2305) for optionally removing the arguments of
panic_fmtcould be a solution.Reduce footprint of panic messages
When
panic_fmtis defined to print / log panic messages complete strings are stored in the binary.This takes up precious space in non volatile memory (.rodata).
It would be great to be able to store the strings, along with file position data, in a table in
debuginfo, which is not flashed into the device, and store only the address to each table entry
in the binary. A external tool would be required to turn that address back into a panic location.
A related RFC has been proposed: rust-lang/rfcs#2154
cc @cr1901 @pftbest