On Wed, Jul 13, 2011 at 09:56:58AM -0400, Jason Merrill wrote:
> On 07/12/2011 07:46 PM, Jakub Jelinek wrote:
> >The aim is to include just (or primarily) code generation affecting options
> >explicitly passed on the command line.  So that the merging actually works,
> >options or arguments which include filenames or paths shouldn't be added,
> >on Roland's request -D*/-U* options aren't added either (that should be
> >covered by .debug_macinfo)
> 
> ...but only with -g3.

Sure.  But if we put -D*/-U* into DW_AT_producer, -D_FORTIFY_SOURCE=2
on the command line acts the same as #define _FORTIFY_SOURCE 2
before including the first header and the latter wouldn't be recorded.
I'm working on smaller .debug_macinfo right now.

> >Ideally we'd just include explicitly passed options from command line that
> >haven't been overridden by other command line options, and would sort them,
> >so that there are higher chances of DW_AT_producer strings being merged
> >(e.g. -O2 -ffast-math vs. -ffast-math -O2 are now different strings, and
> >similarly -O2 vs. -O3 -O2 vs. -O0 -O1 -Ofast -O2), but I'm not sure if it is
> >easily possible using current option handling framework.
> 
> Why not?  Sorting sounds pretty straightforward to me, though you
> might want to copy the array first.

If the command line options contain options that override each other, then
sorting would drop important information what comes last and thus overrides
other options.  If we would have only options which weren't overridden,
we could sort.  Otherwise -O2 -O0 would be sorted as -O0 -O2 and we'd think
the code was optimized when it wasn't.

> On the other hand, it probably isn't worthwhile; presumably most
> relocatables being linked together will share the same CFLAGS, so
> you'll get a high degree of merging without any sorting.
> 
> >--- gcc/testsuite/lib/dg-pch.exp.jj  2011-01-03 18:58:03.000000000 +0100
> >+++ gcc/testsuite/lib/dg-pch.exp     2011-07-12 23:13:50.943670171 +0200
> >-    dg-test -keep-output "./$bname$suffix" "$otherflags $flags" ""
> >+    dg-test -keep-output "./$bname$suffix" "-gno-record-gcc-switches 
> >$otherflags $flags" ""
> 
> Why is this necessary?

It is only necessary if somebody wants to make -grecord-gcc-switches
the default (for bootstrap/regtest I've tweaked common.opt to do that
to test it better).  PCH is a big mess and screws debuginfo in many ways,
in this case it was just small differences in DW_AT_producer, but
we have e.g. ICEs with PCH and -feliminate-dwarf-dups etc.

        Jakub

Reply via email to