https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96417

            Bug ID: 96417
           Summary: c++ `using` causes massive debug-info bloat
                    (debug-info is kept for types/symbols)
           Product: gcc
           Version: 9.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
          Assignee: unassigned at gcc dot gnu.org
          Reporter: sagebar at web dot de
  Target Milestone: ---

Created attachment 48982
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48982&action=edit
Compile me with and without -DNO_USING

It appears as though the c++ `using` keyword prevents
  - `-feliminate-unused-debug-symbols` and
  - `-feliminate-unused-debug-types`
from working for the associated symbol/type. As such, any use of c++'s `using`
causes debug information to be generated, even if (in the case of symbols) the
associated object doesn't appears as an addressible entity in generated object
files, or are ever even used.

As a demonstration, you may compile the attached file as:
  $ g++ -g -S -o - demo.cc | grep imported_
        .string "_ZN1a17imported_functionEi"
        .string "imported_function"
        .string "imported_type"
  $ g++ -g -S -o - demo.cc -DNO_USING | grep imported_
        <no output>

Note that only `using ns::symbol;` is affected by this, but `using namespace
ns;` works just fine.

In addition to g++9.3.0, I was also able to reproduce the same problem on
g++9.1.0 and g++5.4.0, meaning that this must have been going on for ages. - So
long as a matter of fact that I'm wondering if there's some ABI mandate that
requires this kind of behavior???
In case there is some kind of weird, non-sensical ABI requirement that requires
debug information to always be generated for c++ using declarations, I'd like
to request a commandline option to work around this, as I'm working on a
program that's currently 4MiB actual text+data, and 6MiB debug info (and that
is with already using -gz=zlib)

Reply via email to