https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86964
Bug ID: 86964
Summary: Too many debug symbols included, especially for extern
globals
Product: gcc
Version: 6.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: debug
Assignee: unassigned at gcc dot gnu.org
Reporter: znerol at gmail dot com
Target Milestone: ---
Created attachment 44544
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44544&action=edit
Sample code
When compiling with gcc -g using gcc 4.9, the debug symbols included,
especially for externally declared global variables, is at an expected and
familiar amount. When switching to gcc 6.3, the amount of debug symbols
included seems excessive and superfluous. Attempts at using flags such as:
-feliminate-unused-debug-symbols
-feliminate-unused-debug-types
-femit-struct-debug-baseonly
have yielded no difference. This creates a problem when working with a very
large codebase that yields large library archives that end up being several
orders of magnitude larger (file size) with the newer compiler vs. the older
one.
I've attached sources and test Makefile for a small program to illustrate what
I'm talking about. Below I include the difference in output between the 2
versions. In both cases, the symbols included in the final prog executable are
a summation of those in each of the object files - as expected - so I don't
think that behavior is wrong. But the key difference is in each of the object
files. With the older version, you only have symbols included that are relevant
to the module. With the newer version, you get every symbol for every variable
externally declared, even if it's not used or referenced in that module. This
has a multiplicative effect in the final executable's amount of debug info.
The attached sample program is mimicking source code structure seen in a very
large 3rd party SDK being worked with. The net effect of this problem results
in library archive files that are several orders of magnitude larger than
before. What used to be a few MB are now a few GB. What I'm looking for is a
flag or option that will make the newer version behave like the older version
with regard to the included debug info.
Result with gcc 4.9
$ make
gcc -g -feliminate-unused-debug-symbols -c -o a.o a.c
gcc -g -feliminate-unused-debug-symbols -c -o b.o b.c
gcc -g -feliminate-unused-debug-symbols -c -o c.o c.c
gcc -g -feliminate-unused-debug-symbols -o prog a.o b.o c.o
a.o
DW_AT_name: (indirect string, offset: 0xb4): big_time
0x00b0 696e7400 6269675f 74696d65 00756e73 int.big_time.uns
b.o
<1e> DW_AT_name: (indirect string, offset: 0x9): big_time
<40> DW_AT_name: (indirect string, offset: 0x0): big_mama
0x 6269675f 6d616d61 00626967 5f74696d big_mama.big_tim
c.o
<1e> DW_AT_name: (indirect string, offset: 0x9): big_stuf
<40> DW_AT_name: (indirect string, offset: 0x0): big_leee
0x 6269675f 6c656565 00626967 5f737475 big_leee.big_stu
prog
DW_AT_name: (indirect string, offset: 0x95): big_time
DW_AT_name: (indirect string, offset: 0x95): big_time
DW_AT_name: (indirect string, offset: 0xd7): big_mama
<123> DW_AT_name: (indirect string, offset: 0xe9): big_stuf
<145> DW_AT_name: (indirect string, offset: 0xe0): big_leee
0x0090 20696e74 00626967 5f74696d 6500756e int.big_time.un
0x00d0 7a657479 70650062 69675f6d 616d6100 zetype.big_mama.
0x00e0 6269675f 6c656565 00626967 5f737475 big_leee.big_stu
-
Result with gcc 6.3
$ make
gcc -g -feliminate-unused-debug-symbols -c -o a.o a.c
gcc -g -feliminate-unused-debug-symbols -c -o b.o b.c
gcc -g -feliminate-unused-debug-symbols -c -o c.o c.c
gcc -g -feliminate-unused-debug-symbols -o prog a.o b.o c.o
a.o
<312> DW_AT_name: (indirect string, offset: 0x20e): big_time
<31d> DW_AT_name: (indirect string, offset: 0x1eb): big_mama
<328> DW_AT_name: (indirect string, offset: 0x286): big_stuf
<333> DW_AT_name: (indirect string, offset: 0x90): big_leee
0x0090 6269675f 6c656565 006c6f6e 6720696e big_leee.long in
0x01e0 74005f49 4f5f4649 4c450062 69675f6d t._IO_FILE.big_m
0x0280 6636345f 74006269 675f7374 7566005f f64_t.big_stuf._
b.o
<1e> DW_AT_name: (indirect string, offset: 0x9): big_time
<36> DW_AT_name: (indirect string, offset: 0x0): big_mama
<41> DW_AT_name: (indirect string, offset: 0x12): big_stuf
<4c> DW_AT_name: (indirect string, offset: 0x1b): big_leee
0x 6269675f 6d616d61 00626967 5f74696d big_mama.big_tim
0x