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

--- Comment #10 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Because -fcompare-debug tells the driver to compile the TU twice, once without
and once with -gtoggle, and compare the result.
So, if there is a difference in the generated IL e.g. for -flto
-ffat-lto-objects, it will detect it.
Just watch
gcc -flto -O1 pr104237.c  -o pr104237 -g -fcompare-debug -v 2>&1 | grep
'cc1\|lto1'
to see that, cc1 is invoked twice, once without -gtoggle, once with it, but
lto1 is invoked just twice, once for wpa and once for ltrans.
Even if you convince the linker plugin to pass -fcompare-debug even to the
driver that invokes lto1, that would again compare lto1 with and without -g but
only
on a single input (depending on whether the original command line has -g with
or without debug stmts in it).
To reproduce this bug, one needs to do a "manual -fcompare-debug", which is
gcc -flto -O1 pr104237.c  -o pr104237 -g // + force lto1 to pass
-fdump-final-insns=1
gcc -flto -O1 pr104237.c  -o pr104237 // + force lto1 to pass
-fdump-final-insns=2
diff -up 1 2
Now, in theory the driver could arrange that, but it would only handle the
trivial case when the compilation and linking are from the same command.
Typically with LTO, compilation is done separately and linking is done
separately, and I don't see how the driver could arrange for that to work, we
need in that case two sets of *.o files with the IL, one with -g0 and one with
-g, link twice and compare the result at the end.

Reply via email to