On Sep 3, 2009, Diego Novillo wrote: > With your VTA merge, you added the -gtoggle switch. Not really: gcc/ChangeLog: 2009-06-08 Alexandre Oliva ^^^^^^^^^^ * common.opt (fcompare-debug=, fcompare-debug-second): New. (fdump-final-insns=, gtoggle): New. * doc/invoke.texi: Document them. While looking into this, I realized I messed up the ChangeLog for the latest config/bootstrap-debug-*.mk changes (wrong ChangeLog dir), fixed with the patch below. > I've read the documentation for it and while I can parse what it says, > I have no idea what this flag is useful for. It's mostly useful as one of the options for -fcompare-debug testing. Say, you can set GCC_COMPARE_DEBUG=-gtoggle in your environment, and from then on, anything you compile with a -fcompare-debug-capable compiler will be compiled twice, with and without -g, and compared to check for codegen differences. Having -gtoggle means you can set it once, rather than having to figure out whether a compilation would be performed with -g, and should thus be recompiled with -g0, or vice-versa. In theory, a wrapper could implement this, but it would have to duplicate all the complex -g* handling that GCC performs, emulating all the overriding, overlapping and even the extraneous -g* flags that GNAT uses for purposes unrelated with -g. Sure enough, this is not the only use for -fcompare-debug, otherwise we could do away with the -gtoggle option and just use -fcompare-debug-second for this purpose. But there is -fvar-tracking-assignments-toggle, and one could use various other debug-info-related options (debug info level, kind, etc) or even other debug info-unrelated options (say warnings), to check for codegen stability, or even nothing whatsoever (to check for stability against randomized address spaces). > I've seen it used during bootstraps and the documentation claims > something about -fcompare-debug. But I cannot imagine this being > useful in general. Imagine you're trying to debug an optimized program. You had no debug info at first, and it failed. So you recompile, and then you can't duplicate the problem any more. This shouldn't happen, because GDB is supposed to generate the same code with and without -g. However, we've neglected this property for too long. Now, -fcompare-debug=-gtoggle provides you with a way to pinpoint exactly where the bug in GCC is that causes codegen differences, that presumably hide the bug you're looking into. Once you know that, besides filing a GCC bug report, you might have better luck tracking your own bug down. > If it's really useful, could you add a rationale in the documentation? Would the above serve as motivation for -fcompare-debug (and thus for -gtoggle)?