Add a /nopdb flag to disable PDB generation

This will be used in the sanitizer test suite, which wants to use DWARF
line tables.

At some point we should reconsider how LLD handles the long section
names required by DWARF debug sections.

llvm-svn: 298544
This commit is contained in:
Reid Kleckner 2017-03-22 19:49:12 +00:00
parent 174f483990
commit 77d3aa476e
3 changed files with 19 additions and 0 deletions

View File

@ -896,6 +896,10 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) {
sys::path::replace_extension(Config->PDBPath, ".pdb");
}
// Disable PDB generation if the user requested it.
if (Args.hasArg(OPT_nopdb))
Config->PDBPath = "";
// Set default image base if /base is not given.
if (Config->ImageBase == uint64_t(-1))
Config->ImageBase = getDefaultImageBase();

View File

@ -93,6 +93,7 @@ def help : F<"help">;
def help_q : Flag<["/?", "-?"], "">, Alias<help>;
// LLD extensions
def nopdb : F<"nopdb">, HelpText<"Disable PDB generation for DWARF users">;
def nosymtab : F<"nosymtab">;
def msvclto : F<"msvclto">;

14
lld/test/COFF/nopdb.test Normal file
View File

@ -0,0 +1,14 @@
# 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