[PATCH] D46628: [ELF] Add --strip-debug-non-line option

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 25 03:04:40 PDT 2019


MaskRay added a comment.

In D46628#1555491 <https://reviews.llvm.org/D46628#1555491>, @luciang wrote:

> > prebuilt .o with full debug info - (eg. prebuilt external third-party code managed by an *inflexible* tp management system).
>
> Let's assume `.o` will continue to have no-nline debug info due to the inflexible tp management system -- properly supporting -gmlt this would much delay adoption of lld.
>
> > You can link it once and then postprocess the program with another tool.
>
> There are a few aspects for which we chose doing this in lld
>
> - RAM use reduction: debug section are processed and reduced before creating the output file and the `ReducedDebugData` are small (from 2-3GiB -> tens of MiB).
> - inefficiency: wasted IO / time: writing huge binaries twice
> - complexity of integrating binary shrinking into the build system


If you do the following before:

  # compile once
  clang -g -c a.c
  # link twice
  clang a.o -o a.full
  clang a.o -Wl,--strip-debug-non-line -o a.line  # will be changed

I wonder if you can change the second link to `reduce-tool a.full -o a.line`.

If you do:

  # compile twice
  clang -g -c a.c -o a.full.o
  clang -g1 -c a.c -o a.line.o
  # link twice
  clang a.full.o -o a.full
  clang a.line.o -o a.line   # no -Wl,--strip-debug-non-line is necessary

In neither case a linker option is necessary.

If the tp management system is so inflexible that it can't even change -g to -g1, then you can add a -g1 to override the debug level of -g:

  clang -g a.c -o a.line.o -g1   # the debug level is decided by the last -g*

On the GCC side, GCC started to emit minimum line tables at -g1 with this patch https://github.com/gcc-mirror/gcc/commit/7fa9fa16198d84fe9354a1adc644c84b3b4dba79
I think it is included in GCC 4.9 though it is not included in the release log.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D46628/new/

https://reviews.llvm.org/D46628





More information about the llvm-commits mailing list