Bug 57238 - GCC passes --gdwarf2 to assembler despite -gdwarf-4 on command line
Summary: GCC passes --gdwarf2 to assembler despite -gdwarf-4 on command line
Status: RESOLVED WONTFIX
Alias: None
Product: gcc
Classification: Unclassified
Component: driver (show other bugs)
Version: unknown
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-05-10 15:12 UTC by Paul Pluzhnikov
Modified: 2013-05-10 18:40 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Pluzhnikov 2013-05-10 15:12:19 UTC
I noticed that compiling t.c with '-gdwarf-4', I get:

  <15>   DW_AT_comp_dir    : (indirect string, offset: 0x4e): /tmp

But compiling t.s, I get:

  <24>   DW_AT_comp_dir    : /tmp

Looking at 'as' invocation, t.c build results in:

  as -v --64 -o t.o /tmp/ccSXi0lI.s

while t.s results in:

  as --gdwarf2 -v --64 -o t.o t.s

Given that dwarf-4 is now the default, passing --gdwarf2 to as is the wrong thing to do, especially given -gdwarf-4 on command line.

This was with trunk GCC built @r198709, native Linux/x86_64 build, configured with:

  --enable-linker-build-id --disable-lto --with-linker-hash-style=gnu --enable-languages=c,c++,go
Comment 1 Paul Pluzhnikov 2013-05-10 15:18:04 UTC
Hmm, it appears that the current binutils 'as' doesn't know how to generate -gdwarf-4, so it should be fixed first.

Cary?
Comment 2 Andrew Pinski 2013-05-10 16:21:40 UTC
I don't see how this is wrong.  Mixing dwarf4 and dwarf2 should be ok.
Comment 3 Paul Pluzhnikov 2013-05-10 16:43:09 UTC
(In reply to Andrew Pinski from comment #2)
> I don't see how this is wrong.

It's wrong to emit dwarf2 because I asked for dwarf4 explicitly.

> Mixing dwarf4 and dwarf2 should be ok.

Ok for what?

One of the reasons I ask for dwarf4 is to save on repeated DW_AT_comp_dir strings (which could be quite long). Currently, I do get them merged for all .c and .cc compoilation units, but not for any .s units. That seems broken to me.
Comment 4 Cary Coutant 2013-05-10 18:33:26 UTC
There's no reason to expect that -gdwarf-4 will automatically get you an indirect string here -- DW_FORM_strp was just as valid in DWARF 2 and 3 as it is in DWARF 4. Here the assembler is simply making the choice to put the string inline. I'm not sure if that's because there's no support for indirect strings at all in the assembler or because it doesn't expect the comp_dir string to be duplicated.

I think what you're really asking for is to have the assembler generate indirect strings. That can be done without upgrading to DWARF 4.

While I do agree that the assembler ought to be able to generate DWARF 4 by now, for the kind of debug output that the assembler generates, I don't think it's really all that important.

-cary
Comment 5 Paul Pluzhnikov 2013-05-10 18:40:20 UTC
(In reply to Cary Coutant from comment #4)
 
> I think what you're really asking for is to have the assembler generate
> indirect strings. That can be done without upgrading to DWARF 4.

Yes.

> While I do agree that the assembler ought to be able to generate DWARF 4 by
> now, for the kind of debug output that the assembler generates, I don't
> think it's really all that important.

True.

I've opened binutils http://sourceware.org/bugzilla/show_bug.cgi?id=15457

Closing this one.