[Lldb-commits] [PATCH] D54747: Discard debuginfo for object files empty after GC

Robert O'Callahan via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Nov 20 03:02:59 PST 2018


rocallahan created this revision.
rocallahan added a reviewer: ruiu.
rocallahan added a project: lld.
Herald added subscribers: llvm-commits, MaskRay, JDevlieghere, arichardson, emaste.
Herald added a reviewer: espindola.

Rust projects tend to link in all object files from all dependent libraries and rely on --gc-sections to strip unused code and data. Unfortunately --gc-sections doesn't currently strip any debuginfo associated with GC'ed sections, so lld links in the full debuginfo from all dependencies even if almost all that code has been discarded. See https://github.com/rust-lang/rust/issues/56068 for some details.

Properly stripping debuginfo for discarded sections would be difficult, but a simple approach that helps significantly is to mark debuginfo sections as live only if their associated object file has at least one live code/data section. This patch does that. In a (contrived but not totally artificial) Rust testcase linked above, it reduces the final binary size from 41MB to 6.1MB.


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D54747

Files:
  lld/ELF/Driver.cpp
  lld/ELF/InputFiles.h
  lld/ELF/InputSection.cpp
  lld/ELF/InputSection.h
  lld/ELF/MarkLive.cpp
  lld/test/ELF/linkerscript/comdat-gc.s
  lld/test/ELF/linkerscript/debuginfo-gc.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54747.174739.patch
Type: text/x-patch
Size: 10454 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20181120/2973e141/attachment.bin>


More information about the lldb-commits mailing list