From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail8.parnet.fi (mail8.parnet.fi [77.234.108.134]) by sourceware.org (Postfix) with ESMTPS id B91EB385840C for ; Mon, 24 Oct 2022 11:08:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B91EB385840C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=martin.st Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=martin.st Received: from mail9.parnet.fi (mail9.parnet.fi [77.234.108.21]) by mail8.parnet.fi with ESMTP id 29OB8Gn7014443-29OB8Gn8014443; Mon, 24 Oct 2022 14:08:16 +0300 Received: from foo.martin.st (host-97-187.parnet.fi [77.234.97.187]) by mail9.parnet.fi (Postfix) with ESMTPS id 7B8DAA1428; Mon, 24 Oct 2022 14:08:16 +0300 (EEST) Date: Mon, 24 Oct 2022 14:08:15 +0300 (EEST) From: =?ISO-8859-15?Q?Martin_Storsj=F6?= To: Mark Harmstone cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH] Add -gcodeview option In-Reply-To: <20221024002828.28861-1-mark@harmstone.com> Message-ID: References: <20221024002828.28861-1-mark@harmstone.com> MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset=US-ASCII X-FE-Policy-ID: 3:14:2:SYSTEM X-Spam-Status: No, score=-3.6 required=5.0 tests=BAYES_00,JMQ_SPF_NEUTRAL,KAM_DMARC_STATUS,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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/gcc.cc | 4 ++++ > gcc/opts.cc | 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