Bug 367491

Summary: -feliminate-dwarf2-dups generates _larger_ output
Product: [Fedora] Fedora Reporter: Jan Kratochvil <jan.kratochvil>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: low Docs Contact:
Priority: low    
Version: rawhideCC: aoliva
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2007-11-25 21:55:30 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
.tar.gz containing: ooo-dups.patch, dup0.c + dup1.c + dup.h none

Description Jan Kratochvil 2007-11-05 21:17:19 UTC
Description of problem:
Used -feliminate-dwarf2-dups to reduce debuginfo but it got much larger instead.

Version-Release number of selected component (if applicable):
gcc-4.1.2-33.x86_64

How reproducible:
Always.

Steps to Reproduce:
1. patch fedora/openoffice.org/devel/openoffice.org.spec with ooo-dups.patch.
2. koji-build it: http://koji.fedoraproject.org/koji/taskinfo?taskID=225515

Actual results:
After removing the constant src files:
  rm -rf `find -name src`
The sum of bytes:
orig:  1313604736
built: 2452898960 (187% size of the original!)

There is still a lot of `DW.*' symbols like:
   54: 0000000000000085      0 NOTYPE  LOCAL  DEFAULT       29 DW.dup.h.d6c8bc4d.0
They can be harmlessly stripped by:
  strip -w -N "DW.*" *.debug

DW.*-stripped: 1442298539 (110% size of the original!)

Expected results:
<=100% size of the original.

Additional info:
I saw there also duplicite Compilation Units (not in the attached dup* example
but in the openoffice.org build):
  Compilation Unit @ offset 0x0:
   Length:        476
   Version:       2
   Abbrev Offset: 0
   Pointer Size:  8
 <0><b>: Abbrev Number: 10 (DW_TAG_compile_unit)
     DW_AT_stmt_list   : 0
     DW_AT_high_pc     : 0x758
     DW_AT_low_pc      : 0x710
     DW_AT_producer    : (indirect string, offset: 0x75): GNU C++ 4.1.2 20070925
(Red Hat 4.1.2-33)
     DW_AT_language    : 4      (C++)
     DW_AT_name        : (indirect string, offset: 0x43):
../../../unxlngx6.pro/misc/dict_zh.cxx
     DW_AT_comp_dir    : (indirect string, offset: 0x12d):
/usr/src/debug/OOG680_m6/i18npool/source/breakiterator/data

and in the same file:

  Compilation Unit @ offset 0x1e0:
   Length:        270
   Version:       2
   Abbrev Offset: 0
   Pointer Size:  8
 <0><1eb>: Abbrev Number: 1 (DW_TAG_compile_unit)
     DW_AT_language    : 4      (C++)
     DW_AT_producer    : (indirect string, offset: 0x75): GNU C++ 4.1.2 20070925
(Red Hat 4.1.2-33)
     DW_AT_comp_dir    : (indirect string, offset: 0x12d):
/usr/src/debug/OOG680_m6/i18npool/source/breakiterator/data
     DW_AT_name        : (indirect string, offset: 0x43):
../../../unxlngx6.pro/misc/dict_zh.cxx

Unaware if this Compilation Units duplication counts for those whole 10% of the
overhead.

The duplication-removal itself appears to be working there.

Not tested any other GCC version.
Going to update it but any comments are welcome.

Attached:
ooo-dups.patch: openoffice.org .src.rpm patch for -feliminate-dwarf2-dups.

dup0.c + dup1.c + dup.h: Simple testcase:
  Reproduces the bogus DW.* symbol(s).
  The size of -feliminate-dwarf2-dups binary really gets smaller there, though.
  There are no duplicite Compilation Units seen.

orig{,.dump} vs. eliminated{,.dump}: Files extracted from the openoffice.org
build - the smallest files which grew using the options.
  Reproduces the bogus DW.* symbols.
  The size of -feliminate-dwarf2-dups binary gets larger than the original.
  There are duplicite Compilation Units seen.

Comment 1 Jan Kratochvil 2007-11-05 21:17:19 UTC
Created attachment 248621 [details]
.tar.gz containing: ooo-dups.patch, dup0.c + dup1.c + dup.h

Comment 2 Jan Kratochvil 2007-11-25 21:55:30 UTC
# They can be harmlessly stripped by:
#   strip -w -N "DW.*" *.debug

This is wrong as DWARF3 specifies:

# A debugging information entry that may be referenced by another compilation
# must have a global symbolic name.

Anyway closing this Bug - Nick Clifton started working on this general issue at
the elfutils branch com.redhat.elfutils.nickc.dwarftool.