Skip to content

Commit a1f6fba

Browse files
committedDec 16, 2017
[COFF] Clean up debug option handling
/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. Differential Revision: https://reviews.llvm.org/D41310 llvm-svn: 320896
1 parent 81bbf74 commit a1f6fba

File tree

4 files changed

+24
-22
lines changed

4 files changed

+24
-22
lines changed
 

‎lld/COFF/Driver.cpp

+5-7
Original file line numberDiff line numberDiff line change
@@ -818,8 +818,10 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) {
818818
}
819819

820820
// Handle /pdb
821-
if (auto *Arg = Args.getLastArg(OPT_pdb))
822-
Config->PDBPath = Arg->getValue();
821+
bool ShouldCreatePDB = Args.hasArg(OPT_debug, OPT_debug_ghash);
822+
if (ShouldCreatePDB)
823+
if (auto *Arg = Args.getLastArg(OPT_pdb))
824+
Config->PDBPath = Arg->getValue();
823825

824826
// Handle /noentry
825827
if (Args.hasArg(OPT_noentry)) {
@@ -1145,15 +1147,11 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) {
11451147
}
11461148

11471149
// Put the PDB next to the image if no /pdb flag was passed.
1148-
if (Config->Debug && Config->PDBPath.empty()) {
1150+
if (ShouldCreatePDB && Config->PDBPath.empty()) {
11491151
Config->PDBPath = Config->OutputFile;
11501152
sys::path::replace_extension(Config->PDBPath, ".pdb");
11511153
}
11521154

1153-
// Disable PDB generation if the user requested it.
1154-
if (Args.hasArg(OPT_nopdb, OPT_debug_dwarf))
1155-
Config->PDBPath = "";
1156-
11571155
// Set default image base if /base is not given.
11581156
if (Config->ImageBase == uint64_t(-1))
11591157
Config->ImageBase = getDefaultImageBase();

‎lld/COFF/Options.td

-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ def help_q : Flag<["/?", "-?"], "">, Alias<help>;
120120
def debug_ghash : F<"debug:ghash">;
121121
def debug_dwarf : F<"debug:dwarf">;
122122
def export_all_symbols : F<"export-all-symbols">;
123-
def nopdb : F<"nopdb">, HelpText<"Disable PDB generation for DWARF users">;
124123
def lldmingw : F<"lldmingw">;
125124
def msvclto : F<"msvclto">;
126125
def output_def : Joined<["/", "-"], "output-def:">;

‎lld/test/COFF/debug-dwarf.test

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Check that /debug creates %t.pdb.
2+
# RUN: rm -f %t.pdb
3+
# RUN: lld-link /debug /entry:main /out:%t.exe %p/Inputs/ret42.obj
4+
# RUN: ls %t.pdb
5+
6+
# Check that /debug:dwarf does not create %t.pdb.
7+
# RUN: rm -f %t.pdb
8+
# RUN: lld-link /debug:dwarf /entry:main /out:%t.exe %p/Inputs/ret42.obj
9+
# RUN: not ls %t.pdb
10+
11+
# Check that /debug:dwarf /debug creates %t.pdb.
12+
# RUN: rm -f %t.pdb
13+
# RUN: lld-link /debug:dwarf /debug /entry:main /out:%t.exe %p/Inputs/ret42.obj
14+
# RUN: ls %t.pdb
15+
16+
# Check that /debug:dwarf /pdb:%t.pdb does not create %t.pdb.
17+
# RUN: rm -f %t.pdb
18+
# RUN: lld-link /debug:dwarf /pdb:%t.pdb /entry:main /out:%t.exe %p/Inputs/ret42.obj
19+
# RUN: not ls %t.pdb

‎lld/test/COFF/nopdb.test

-14
This file was deleted.

0 commit comments

Comments
 (0)