-
Notifications
You must be signed in to change notification settings - Fork 99
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
Panic handler binary size bloat #41
Comments
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. |
Relevant commit for my use case: cr1901/AT2XT@b6e2992 Notably, embedding unused strings does not happen with |
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 |
I'm hopeful this can be sorted out. Panic handling is a bit painful at the moment. |
Related: |
Is there a solution for this now that RFC-2070 has been closed? |
No solution in stable yet. |
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 simplyabort
the 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_fmt
could be a solution.Reduce footprint of panic messages
When
panic_fmt
is 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
The text was updated successfully, but these errors were encountered: