public inbox for
 help / color / mirror / Atom feed
From: "Martin Storsjö" <>
To: Mark Harmstone <>
Subject: Re: [PATCH] Add -gcodeview option
Date: Mon, 24 Oct 2022 14:08:15 +0300 (EEST)	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

On Mon, 24 Oct 2022, Mark Harmstone wrote:

> Both current lld and the next version of ld have an option -pdb, which
> creates a PDB file which Microsoft's debuggers can use. This patch adds
> a -gcodeview option, which passes this to the linker.
> I do intend to expand this so it also creates the .debug$S and .debug$T
> sections which would make this useful - I submitted patches for this a
> while back, but they need to be rewritten to parse the DWARF DIEs rather
> than using debug_hooks.
> Clang also has -gcodeview, but AFAICS only uses it for .debug$S and
> .debug$T, and doesn't use it for linker options (though IMO it probably
> should).

That's true - in Clang, this option doesn't affect linking, it only 
affects code generation.

(FWIW, if I understand it correctly, Clang also does support generating 
both DWARF and CodeView at the same time - I think that would require 
passing something like "-g -gdwarf-4 -gcodeview" at the same time - but I 
don't have experience with playing with such setups.)

Another vague oddity in how this option is handled in Clang, is that if I 
only pass "-gcodeview" to the compiler, it doesn't actually generate any 
debug info (it just changes preference, in case I would request debug info 
separately), while one has to pass e.g. "-g -gcodeview" for it to do 
what's expected. I'm not sure if this is the same with dwarf, or if 
passing "-gdwarf-4" is enough for actually enabling generating dwarf debug 
info too. In any case, I don't think this aspect needs to be matched 
closely (unless dwarf does the same), as any existing users of PDB 
generation do use "-g -gcodeview", so as long as that case works, there 
shouldn't be any interop issues.

> ---
> gcc/common.opt      | 4 ++++
> gcc/doc/invoke.texi | 7 +++++++
> gcc/          | 4 ++++
> gcc/         | 3 +++
> 4 files changed, 18 insertions(+)
> @@ -4608,6 +4608,10 @@ driver_handle_option (struct gcc_options *opts,
>       do_save = false;
>       break;
> +    case OPT_gcodeview:
> +      add_infile ("-pdb=", "*");
> +      break;

Hmm, what does this end up passing to the linker in the end - does it just 
pass "-pdb="? (What does the "*" parameter do here?) If that's the case - 
that sounds reasonable - assuming that if a user passes an extra 
-Wl,--pdb,myspecificname.pdb, that would take precedence (i.e. be passed 
after the compiler's default one).

// Martin

  reply	other threads:[~2022-10-24 11:08 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-24  0:28 Mark Harmstone
2022-10-24 11:08 ` Martin Storsjö [this message]
2022-10-24 23:20   ` Mark Harmstone
2022-10-25  8:21     ` Martin Storsjö
2022-10-27  3:36       ` Mark Harmstone

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).