This is an archive of the discontinued LLVM Phabricator instance.

[COFF] Clean up debug option handling
ClosedPublic

Authored by smeenai on Dec 15 2017, 1:40 PM.

Details

Summary

/debug and /debug:dwarf are orthogonal. An object file can contain both
CodeView and DWARF debug info, so the combination of /debug:dwarf and
/debug should generate both DWARF and a PDB, rather than /debug:dwarf
always suppressing PDB creation.

/nopdb is now redundant and can be removed. /debug /nopdb was previously
used to support DWARF, but specifying /debug:dwarf is entirely
equivalent to that combination now.

Diff Detail

Repository
rL LLVM

Event Timeline

smeenai created this revision.Dec 15 2017, 1:40 PM
ruiu accepted this revision.Dec 15 2017, 1:42 PM

I think this change makes sense. LGTM

This revision is now accepted and ready to land.Dec 15 2017, 1:42 PM

Is there any reason to have more than one option that begins with /DEBUG? Maybe they should all be mutually exclusive.

ruiu added a comment.Dec 15 2017, 1:45 PM

Conceptually, an executable that has both DAWRF and PDB debug info is valid, no?

@zturner I do agree that /debug and /debug:dwarf is a bit confusing. We have to keep /debug for link.exe compatibility, so perhaps /debug:dwarf could be renamed to something else? Any suggestions?

In D41310#957239, @ruiu wrote:

Conceptually, an executable that has both DAWRF and PDB debug info is valid, no?

That's true in theory, but the current implementation assumes they're mutually exclusive (e.g. PDBs aren't generated for /debug:dwarf).

I don't know how much utility there is for DWARF + PDB. I also though clang could only generate one or the other (i.e. if you specify -gcodeview you'll only get CodeView and not DWARF), though I may be mistaken there.

@zturner I do agree that /debug and /debug:dwarf is a bit confusing. We have to keep /debug for link.exe compatibility, so perhaps /debug:dwarf could be renamed to something else? Any suggestions?

Sorry, I didn't mean the linker shouldn't support more than one option, I just meant it shouldn't supporting using them at the same time. This agrees with what you were saying about /debug and /debug:dwarf not making sense when used together, but actually goes one step further. Do any two /DEBUG option variants make sense together?

ruiu added a comment.Dec 15 2017, 1:50 PM

I don't find /debug:dwarf that odd. link.exe accepts /debug:{full,fastlink,none}, and some of them collide (e.g. /debug vs. /debug:none), some are not (e.g. /debug vs. /debug:full).

So it looks like clang produces both CodeView and DWARF in the same object file if you pass both -gcodeview and -gdwarf. I haven't verified the debug info is sensible, but the object file at least contains both CodeView and DWARF debug sections.

With that in mind, I think the following makes sense:

  1. /debug by itself produces a PDB (this is unchanged).
  2. /debug:dwarf by itself produces DWARF (this is unchanged).
  3. /debug and /debug:dwarf produce both a PDB and DWARF (this is different from today, where /debug:dwarf always prevents a PDB from being created).
  4. /nopdb can still be deleted; just don't specify /debug if you don't want a PDB (or perhaps we can add /debug:none to cancel out /debug, but then it's confusing as to whether it should also cancel out /debug:dwarf ...)

Does this sound good to everyone?

smeenai updated this revision to Diff 127201.Dec 15 2017, 4:05 PM
smeenai retitled this revision from [COFF] Remove /nopdb option to [COFF] Clean up debug option handling.
smeenai edited the summary of this revision. (Show Details)
smeenai added a reviewer: zturner.
smeenai removed a subscriber: zturner.

Update after discussion

smeenai requested review of this revision.Dec 15 2017, 4:05 PM

This has changed significantly since the last iteration.

ruiu added inline comments.Dec 15 2017, 4:09 PM
test/COFF/debug-dwarf.test
4 ↗(On Diff #127201)

Is it guaranteed that ls exits with a non-zero value if a given file does not exist?

smeenai added inline comments.Dec 15 2017, 4:17 PM
test/COFF/debug-dwarf.test
4 ↗(On Diff #127201)

I'm basing this on the existing nopdb.test. The same pattern is also used in pdb-options.test.

ruiu accepted this revision.Dec 15 2017, 4:18 PM

LGTM

test/COFF/debug-dwarf.test
4 ↗(On Diff #127201)

Thanks. Then it should be fine as it's already tested.

This revision is now accepted and ready to land.Dec 15 2017, 4:18 PM
This revision was automatically updated to reflect the committed changes.
lld/trunk/COFF/Options.td