public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Future debug options: -f* or -g*?
@ 2020-07-09 19:03 Fangrui Song
  2020-07-09 19:28 ` Fangrui Song
  0 siblings, 1 reply; 8+ messages in thread
From: Fangrui Song @ 2020-07-09 19:03 UTC (permalink / raw)
  To: gcc
  Cc: David Blaikie, Cary Coutant, RichardBienerrichard.guenther,
	EricBotcazoubotcazou, Lubos Lunak

Both GCC and Clang have implemented many debugging options under -f and
-g. Whether options go to -f or -g appears to be pretty arbitrary decisions.

A non-complete list of GCC supported debug options is documented here at
https://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html

I think there options belong to 3 categories:

(a) -f* & doesn't imply -g2: -fdebug-types-section -feliminate-unused-debug-types,
    -fdebug-default-version=5 (this exists in clang purely because -gdwarf-5 implies -g2 & there is need to not imply -g2)
(b) -g* & implies -g2: -gsplit-dwarf (I want to move this one to (c) http://lists.llvm.org/pipermail/cfe-dev/2020-July/066202.html )
                         -gdwarf-5, -ggdb, -gstabs
(c) -g* but does not imply -g2: -ggnu-pubnames, -gcolumn-info, -gstrict-dwarf, -gz, ...
             the list appears to be much longer than (b)

( (b) isn't very good to its non-orthogonality. The interaction with -g0 -g1
   and -g3 can be non-obvious sometimes.)

Cary Coutant kindly shared with me his understanding about debug
options (attached at the end). Many established options can't probably
be fixed now. Some are still fixable (-gsplit-dwarf).

This post is mainly about future debug options. Shall we figure out a
convention for future debug options?

Personally I'd prefer (c) but I won't object to (a).
I'd avoid (b).

> In retrospect, I regret not naming the option -fsplit-dwarf, which
> clearly would not have implied -g, and would have fit in with a few
> other dwarf-related -f options. (I don't know whether Richard's
> objection to it is because there is already -gsplit-dwarf, or if he
> would have objected to it as an alternative-universe spelling.)
> 
> At the time, I thought it was fairly common for all/most -g options
> (except -g0) to imply -g. Perhaps that wasn't true then or is no
> longer true now. If the rest of the community is OK with changing
> -gsplit-dwarf to not imply -g, and no one has said it would cause them
> any hardship, I'm OK with your proposed change.
> 
> I did design it so that you could get the equivalent by simply writing
> "-gsplit-dwarf -g0" at the front of the compiler options (e.g., via an
> environment variable), so that a subsequent -g would not only turn on
> debug but would also enable split-dwarf. We used that fairly regularly
> at Google.
> 
> Regarding how the build system can discover whether or not split dwarf
> is in effect, without parsing all the options presented to gcc, and
> without looking for the side effects (the .dwo files), we dodged that
> in the Google build system by having a higher-level build flag,
> --fission, which would tell the build system to pass -gsplit-dwarf to
> gcc AND look for the .dwo files produced on the side. We simply
> disallowed having the user pass -gsplit-dwarf directly to the
> compiler.
> 
> Feel free to share this.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-09-02 22:33 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-09 19:03 Future debug options: -f* or -g*? Fangrui Song
2020-07-09 19:28 ` Fangrui Song
2020-07-09 19:29   ` David Blaikie
2020-07-10 19:09   ` Nathan Sidwell
2020-07-29 16:46     ` David Blaikie
2020-09-01  3:10       ` David Blaikie
2020-09-02 11:12         ` Mark Wielaard
2020-09-02 22:32           ` David Blaikie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).