Skip to content
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

split-debuginfo="unpacked" results in executables that still have debug info? #123972

Closed
vlovich opened this issue Apr 15, 2024 · 3 comments
Closed
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) C-bug Category: This is a bug.

Comments

@vlovich
Copy link

vlovich commented Apr 15, 2024

I expected to see this happen: when split-debuginfo="unpacked" or split-debuginfo="packed" implies the debug info lives outside the executable so I'd expect the size to be very similar to strip = "debuginfo". However, the final binary size with strip=debuginfo is >3x smaller which is a pretty significant disparity. Full LTO can lower that to just under 3x but that's still a big pill to swallow. Rusts' strip = "debuginfo" option fully discards the debug info which isn't as nice in CI systems where you'd want to maybe upload the debuginfo to a symbol server (which I was hoping "packed" would be a path for), but that's a different issue.

Instead, this happened:
strip = "debuginfo" => 4.5M executable
split-debuginfo = "packed" => 15M executable
split-debuginfo = "unpacked" => 15M executable

Fat LTO reduces the size from 15M to 12M while the stripped size goes from 4.5M to 3.5M (without LTO the sizes are 18M and 4.6M respectively). This is with LLD or mold by the way - the default linker seems to be worse at eliminating debug information altogether where the ThinLTO size goes from 15M -> 18M although the stripped version goes from 4.5M -> 4.4M).

Meta

Nightly shows identical results.

rustc --version --verbose:

rustc 1.77.0 (aedd173a2 2024-03-17)
rustc 1.78.0-nightly (bb594538f 2024-02-20)
@vlovich vlovich added the C-bug Category: This is a bug. label Apr 15, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 15, 2024
@bjorn3
Copy link
Member

bjorn3 commented Apr 15, 2024

DWARF split debuginfo splits the debuginfo into two parts. A part that is independent of the actual addresses at which each function ends up. This is what ends up in a separate file. And a part which glues the separate file together with the actual addresses of each function after linking. This part ends up in the final executable.

There is another way to do split debuginfo which is slower to link but does end up with all debuginfo in a separate file. This one is currently not supported by rustc. Adding support for this has been accepted, but not yet implemented: rust-lang/compiler-team#721 You can still do it manually by disabling split debuginfo and then using objcopy twice. One with --only-keep-debug to extract the debuginfo into a separate file and once with --strip-debug to remove the debuginfo from the executable.

@bjorn3 bjorn3 added the A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) label Apr 15, 2024
@vlovich
Copy link
Author

vlovich commented Apr 15, 2024

Thanks for the fast explanation! Not sure if you kept this open because you wanted it around as tracking for the implementation but feel free to close it otherwise as I consider my question answered.

@bjorn3
Copy link
Member

bjorn3 commented Apr 15, 2024

#105991 is probably a better issue for tracking this.

@bjorn3 bjorn3 closed this as completed Apr 15, 2024
@jieyouxu jieyouxu removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

4 participants