diff options
-rw-r--r-- | lld/COFF/Driver.cpp | 12 | ||||
-rw-r--r-- | lld/COFF/Options.td | 1 | ||||
-rw-r--r-- | lld/test/COFF/debug-dwarf.test | 19 | ||||
-rw-r--r-- | lld/test/COFF/nopdb.test | 14 |
4 files changed, 24 insertions, 22 deletions
diff --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp index 6098a49a29f..0e7db7b6ae3 100644 --- a/lld/COFF/Driver.cpp +++ b/lld/COFF/Driver.cpp @@ -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(); diff --git a/lld/COFF/Options.td b/lld/COFF/Options.td index f6387fb6549..0e7a79730fa 100644 --- a/lld/COFF/Options.td +++ b/lld/COFF/Options.td @@ -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:">; diff --git a/lld/test/COFF/debug-dwarf.test b/lld/test/COFF/debug-dwarf.test new file mode 100644 index 00000000000..156b2f58f64 --- /dev/null +++ b/lld/test/COFF/debug-dwarf.test @@ -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 diff --git a/lld/test/COFF/nopdb.test b/lld/test/COFF/nopdb.test deleted file mode 100644 index 29797bbf931..00000000000 --- a/lld/test/COFF/nopdb.test +++ /dev/null @@ -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 |