[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
This commit is contained in:
Shoaib Meenai 2017-12-16 00:23:24 +00:00
parent 81bbf74265
commit a1f6fba4d1
4 changed files with 24 additions and 22 deletions

View File

@ -818,8 +818,10 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) {
}
// Handle /pdb
if (auto *Arg = Args.getLastArg(OPT_pdb))
Config->PDBPath = Arg->getValue();
bool ShouldCreatePDB = Args.hasArg(OPT_debug, OPT_debug_ghash);
if (ShouldCreatePDB)
if (auto *Arg = Args.getLastArg(OPT_pdb))
Config->PDBPath = Arg->getValue();
// Handle /noentry
if (Args.hasArg(OPT_noentry)) {
@ -1145,15 +1147,11 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) {
}
// Put the PDB next to the image if no /pdb flag was passed.
if (Config->Debug && Config->PDBPath.empty()) {
if (ShouldCreatePDB && Config->PDBPath.empty()) {
Config->PDBPath = Config->OutputFile;
sys::path::replace_extension(Config->PDBPath, ".pdb");
}
// Disable PDB generation if the user requested it.
if (Args.hasArg(OPT_nopdb, OPT_debug_dwarf))
Config->PDBPath = "";
// Set default image base if /base is not given.
if (Config->ImageBase == uint64_t(-1))
Config->ImageBase = getDefaultImageBase();

View File

@ -120,7 +120,6 @@ def help_q : Flag<["/?", "-?"], "">, Alias<help>;
def debug_ghash : F<"debug:ghash">;
def debug_dwarf : F<"debug:dwarf">;
def export_all_symbols : F<"export-all-symbols">;
def nopdb : F<"nopdb">, HelpText<"Disable PDB generation for DWARF users">;
def lldmingw : F<"lldmingw">;
def msvclto : F<"msvclto">;
def output_def : Joined<["/", "-"], "output-def:">;

View File

@ -0,0 +1,19 @@
# Check that /debug creates %t.pdb.
# RUN: rm -f %t.pdb
# RUN: lld-link /debug /entry:main /out:%t.exe %p/Inputs/ret42.obj
# RUN: ls %t.pdb
# Check that /debug:dwarf does not create %t.pdb.
# RUN: rm -f %t.pdb
# RUN: lld-link /debug:dwarf /entry:main /out:%t.exe %p/Inputs/ret42.obj
# RUN: not ls %t.pdb
# Check that /debug:dwarf /debug creates %t.pdb.
# RUN: rm -f %t.pdb
# RUN: lld-link /debug:dwarf /debug /entry:main /out:%t.exe %p/Inputs/ret42.obj
# RUN: ls %t.pdb
# Check that /debug:dwarf /pdb:%t.pdb does not create %t.pdb.
# RUN: rm -f %t.pdb
# RUN: lld-link /debug:dwarf /pdb:%t.pdb /entry:main /out:%t.exe %p/Inputs/ret42.obj
# RUN: not ls %t.pdb

View File

@ -1,14 +0,0 @@
# Check that /debug creates %t.pdb.
# RUN: rm -f %t.pdb
# RUN: lld-link /debug /entry:main /out:%t.exe %p/Inputs/ret42.obj
# RUN: ls %t.pdb
# Check that /debug /nopdb does not create %t.pdb.
# RUN: rm -f %t.pdb
# RUN: lld-link /debug /nopdb /entry:main /out:%t.exe %p/Inputs/ret42.obj
# RUN: not ls %t.pdb
# Check that /debug /nopdb /pdb:%t.pdb does not create %t.pdb.
# RUN: rm -f %t.pdb
# RUN: lld-link /debug /nopdb /pdb:%t.pdb /entry:main /out:%t.exe %p/Inputs/ret42.obj
# RUN: not ls %t.pdb