Bug 25612 - -gdwarf-{3,4,5} command line arguments
Summary: -gdwarf-{3,4,5} command line arguments
Alias: None
Product: binutils
Classification: Unclassified
Component: gas (show other bugs)
Version: 2.35
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Depends on:
Reported: 2020-02-28 21:52 UTC by Nick Desaulniers
Modified: 2020-03-06 17:14 UTC (History)
1 user (show)

See Also:
Last reconfirmed:


Note You need to log in before you can comment on or make changes to this bug.
Description Nick Desaulniers 2020-02-28 21:52:56 UTC
Playing around with dwarf-5, I notices that GNU as has the command line flag -gdwarf-2, but no equivalents for DWARF 3, 4, or 5.  It looks like `gcc -gwarf-5` will set the second value in the .debug_info section to the dwarf version?  I haven't put thought into what version should be preferred if BOTH the command line version AND assembly specify differing versions.

The Linux kernel has a lot of out of line assembly, and I'm not sure it sets the dwarf version correctly, though maybe that's something just to be fixed per file than via global assembler flag.

Thoughts on implementing -gdwarf-{3,4,5} in GNU as?  This would match the behavior of `gcc -gdwarf-{3,4,5}` and `clang -gdwarf-{3,4,5}`.
Comment 1 Nick Desaulniers 2020-02-28 22:56:01 UTC
See also: https://bugs.llvm.org/show_bug.cgi?id=45040
Comment 2 Nick Clifton 2020-03-03 13:29:29 UTC
Hi Nick,

> Thoughts on implementing -gdwarf-{3,4,5} in GNU as?  This would match the
> behavior of `gcc -gdwarf-{3,4,5}` and `clang -gdwarf-{3,4,5}`.

I think that it would make sense to support this, and to ensure that setting one of these options would set the relevant version value in any debug information generated by the assembler.  We should be careful however to ensure that the documentation clearly states that using a higher dwarf version value will not necessarily cause any extra debug information to be generated.  (Well not until such generation is available).

Are you offering to develop a patch ?

Comment 3 cvs-commit@gcc.gnu.org 2020-03-06 14:53:27 UTC
The master branch has been updated by Nick Clifton <nickc@sourceware.org>:


commit 31bf18645d98b4d3d7357353be840e320649a67d
Author: Nick Clifton <nickc@redhat.com>
Date:   Fri Mar 6 14:52:14 2020 +0000

    Add support for --dwarf-[3|4|5] to assembler command line.
    	PR 25612
    	* as.c (dwarf_level): Define.
    	(show_usage): Add --gdwarf-3, --gdwarf-4 and --gdwarf-5.
    	(parse_args): Add support for the new options.
    	as.h (dwarf_level): Prototype.
    	* dwarf2dbg.c (DWARF2_VERSION): Use dwarf_level as default version
    	* config/tc-ia64.h (DWARF2_VERISION): Update definition.
    	(DWARF2_LINE_VERSION): Remove definition.
    	* doc/as.texi: Document the new options.
Comment 4 Nick Clifton 2020-03-06 14:56:28 UTC
I have gone ahead and created a patch to add support for these command line options.  They do not do anything more than setting the version value stored in the header of the .debug_info section.  At least for now.
Comment 5 Nick Desaulniers 2020-03-06 16:53:23 UTC
Great, thanks Nick!
Comment 6 cvs-commit@gcc.gnu.org 2020-03-06 17:14:27 UTC
The master branch has been updated by Nick Clifton <nickc@sourceware.org>:


commit 84d9ab33f3dc542c5f20abb9026240cfd48ccd97
Author: Nick Clifton <nickc@redhat.com>
Date:   Fri Mar 6 17:13:22 2020 +0000

    Add support for a ".file 0" directive if supporting DWARF 5 or higher.
    	PR 25614
    	* dwarf2dbg.c (dwarf2_directive_filename): Allow a file number of
    	0 if the dwarf_level is 5 or more.  Complain if a filename follows
    	a file 0.
    	* testsuite/gas/elf/dwarf-5-file0.s: New test.
    	* testsuite/gas/elf/dwarf-5-file0.d: New test driver.
    	* testsuite/gas/elf/elf.exp: Run the new test.
    	PR 25612
    	* config/tc-ia64.h (DWARF2_VERISION): Fix typo.
    	* doc/as.texi: Fix another typo.