http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61013

--- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
I don't see why there should be any consistency with -O, it is a very different
option, with a very different usage and history.
The 4.8 behavior was that -g set debug level to 2 if the debug level was 0, so
-g1 -g used to be the same as -g1
-g1 -g0 -g used to be the same as -g2
-g3 -g used to be the same as -g3
-g3 -g0 -g used to be the same as -g2
Now, if you want to change a default for your builds, I'd say you'd just tweak
specs so that -g1 is provided if no -g appears on the command line; either
that can be done by changing the default specs, or you simply add a short specs
file which will do that and change say CC to gcc -specs=whatever.

E.g. in Fedora we use:
-specs=/usr/lib/rpm/redhat/redhat-hardened-cc1
and the specs file ensures that -fPIE is supplied by default if no other option
is used on the command line:
*cc1_options:
+ %{!fpie:%{!fPIE:%{!fpic:%{!fPIC:%{!fno-pic:-fPIE}}}}}

So, my preference would be to revert to the 4.8 and older behavior, or if there
really is consensus that -g1 -g should mean -g2 rather than -g1, at least
change
it so that -g3 -g means -g3 (so revert your change and for *arg == '\0' instead
of the 4.8:
      if (!opts->x_debug_info_level)
        opts->x_debug_info_level = DINFO_LEVEL_NORMAL;
do:
      if (opts->x_debug_info_level < DINFO_LEVEL_NORMAL)
        opts->x_debug_info_level = DINFO_LEVEL_NORMAL;

What I'd say would be helpful would be add support for inline specs overrides
which you could specify on the command line rather than having to resort to
loading a file.  So -specsinline='*cc1_options:\n+
%{!fpie:%{!fPIE:%{!fpic:%{!fPIC:%{!fno-pic:-fPIE}}}}}' or so.

Reply via email to