[Bug driver/77497] [5/6/7 Regression] Setting DWARF level and debug level together has flag-ordering-dependent results

2016-09-08 Thread torne at google dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77497

--- Comment #2 from torne at google dot com ---
Ah. I can see the logic in "-g1 -g" resulting in -g2 level output (as explained
in that bug), but it seems less ideal here where the second -g is only really
intending to define the DWARF level - especially since there's no other choice
than to do it in two flags because you can't set the debug level and the dwarf
level at once, unlike the other debug formats where you can say -gstabs1 or
similar to set both together.

[Bug driver/77497] New: Setting DWARF level and debug level together has flag-ordering-dependent results

2016-09-06 Thread torne at google dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77497

Bug ID: 77497
   Summary: Setting DWARF level and debug level together has
flag-ordering-dependent results
   Product: gcc
   Version: 6.1.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: driver
  Assignee: unassigned at gcc dot gnu.org
  Reporter: torne at google dot com
  Target Milestone: ---

The -gdwarf-N option appears to confuse a previously set -gN debug level, and
the intended interpretation of the options only applies if you set the DWARF
level first. I compiled the same trivial source file with all combinations of
-g[123] and -gdwarf-[34] in both parameter orders and the file sizes show the
problem pretty clearly:

-rw-r- 1 torne eng  2412 Sep  5 18:04 test-g1-gdwarf-3.o
-rw-r- 1 torne eng  2384 Sep  5 18:04 test-g1-gdwarf-4.o
-rw-r- 1 torne eng  2412 Sep  5 18:04 test-g2-gdwarf-3.o
-rw-r- 1 torne eng  2384 Sep  5 18:04 test-g2-gdwarf-4.o
-rw-r- 1 torne eng 16648 Sep  5 18:04 test-g3-gdwarf-3.o
-rw-r- 1 torne eng 16620 Sep  5 18:04 test-g3-gdwarf-4.o
-rw-r- 1 torne eng  2268 Sep  5 18:04 test-gdwarf-3-g1.o
-rw-r- 1 torne eng  2412 Sep  5 18:04 test-gdwarf-3-g2.o
-rw-r- 1 torne eng 16648 Sep  5 18:04 test-gdwarf-3-g3.o
-rw-r- 1 torne eng  2248 Sep  5 18:04 test-gdwarf-4-g1.o
-rw-r- 1 torne eng  2384 Sep  5 18:04 test-gdwarf-4-g2.o
-rw-r- 1 torne eng 16620 Sep  5 18:04 test-gdwarf-4-g3.o

In the cases where -g1 appears before the DWARF level it appears to be ignored
and the exact same output as -g2 is generated. Weirdly this *doesn't* happen
for -g3?

This appears to have been introduced in gcc 4.9 (I can't repro in 4.8) and is
still happening in 6.1.1. The docs don't appear to state that these flags are
ordering-dependent, and in any case it's somewhat weird (especially that it
doesn't affect -g3, only -g1).