[lld] r320896 - [COFF] Clean up debug option handling
Shoaib Meenai via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 15 16:23:24 PST 2017
Author: smeenai
Date: Fri Dec 15 16:23:24 2017
New Revision: 320896
URL: http://llvm.org/viewvc/llvm-project?rev=320896&view=rev
Log:
[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
Added:
lld/trunk/test/COFF/debug-dwarf.test
Removed:
lld/trunk/test/COFF/nopdb.test
Modified:
lld/trunk/COFF/Driver.cpp
lld/trunk/COFF/Options.td
Modified: lld/trunk/COFF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Driver.cpp?rev=320896&r1=320895&r2=320896&view=diff
==============================================================================
--- lld/trunk/COFF/Driver.cpp (original)
+++ lld/trunk/COFF/Driver.cpp Fri Dec 15 16:23:24 2017
@@ -818,8 +818,10 @@ void LinkerDriver::link(ArrayRef<const c
}
// 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 c
}
// 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();
Modified: lld/trunk/COFF/Options.td
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Options.td?rev=320896&r1=320895&r2=320896&view=diff
==============================================================================
--- lld/trunk/COFF/Options.td (original)
+++ lld/trunk/COFF/Options.td Fri Dec 15 16:23:24 2017
@@ -120,7 +120,6 @@ def help_q : Flag<["/?", "-?"], "">, Ali
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:">;
Added: lld/trunk/test/COFF/debug-dwarf.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/debug-dwarf.test?rev=320896&view=auto
==============================================================================
--- lld/trunk/test/COFF/debug-dwarf.test (added)
+++ lld/trunk/test/COFF/debug-dwarf.test Fri Dec 15 16:23:24 2017
@@ -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
Removed: lld/trunk/test/COFF/nopdb.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/nopdb.test?rev=320895&view=auto
==============================================================================
--- lld/trunk/test/COFF/nopdb.test (original)
+++ lld/trunk/test/COFF/nopdb.test (removed)
@@ -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
More information about the llvm-commits
mailing list