[PATCH] D39541: [LLD] [MinGW] Output debug info by default, unless the -s parameter is passed

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 2 14:33:03 PDT 2017


mstorsjo updated this revision to Diff 121381.
mstorsjo retitled this revision from "[LLD] [MinGW] Ignore the -s parameter" to "[LLD] [MinGW] Output debug info by default, unless the -s parameter is passed".
mstorsjo edited the summary of this revision.
mstorsjo added a comment.

Output debug info by default.

Not sure whether it actually works though, because the gdb version I have (which is a tad old admittedly) refuses to load the lld produced exe, saying "not in executable format: File format not recognized". Although maybe the dwarf debug info does work with some other tools?


https://reviews.llvm.org/D39541

Files:
  COFF/Driver.cpp
  COFF/Options.td
  MinGW/Driver.cpp
  MinGW/Options.td
  test/MinGW/driver.test


Index: test/MinGW/driver.test
===================================================================
--- test/MinGW/driver.test
+++ test/MinGW/driver.test
@@ -79,3 +79,9 @@
 
 RUN: ld.lld -### -m i386pep foo.o --output-def out.def | FileCheck -check-prefix OUTPUT-DEF %s
 OUTPUT-DEF: -output-def:out.def
+
+RUN: ld.lld -### -m i386pep foo.o | FileCheck -check-prefix DEBUG %s
+DEBUG: -debug:dwarf
+
+RUN: ld.lld -### -m i386pep foo.o -s | FileCheck -check-prefix STRIP %s
+STRIP-NOT: -debug:dwarf
Index: MinGW/Options.td
===================================================================
--- MinGW/Options.td
+++ MinGW/Options.td
@@ -24,6 +24,7 @@
 def shared: F<"shared">, HelpText<"Build a shared object">;
 def subs: S<"subsystem">, HelpText<"Specify subsystem">;
 def stack: S<"stack">;
+def s: Flag<["-"], "s">, HelpText<"Omit debug info from the output binary">;
 def whole_archive: F<"whole-archive">,
     HelpText<"Include all object files for following archives">;
 def verbose: F<"verbose">, HelpText<"Verbose mode">;
Index: MinGW/Driver.cpp
===================================================================
--- MinGW/Driver.cpp
+++ MinGW/Driver.cpp
@@ -152,6 +152,8 @@
     Add("-verbose");
   if (Args.hasArg(OPT_export_all_symbols))
     Add("-export-all-symbols");
+  if (!Args.hasArg(OPT_s))
+    Add("-debug:dwarf");
 
   if (auto *A = Args.getLastArg(OPT_m)) {
     StringRef S = A->getValue();
Index: COFF/Options.td
===================================================================
--- COFF/Options.td
+++ COFF/Options.td
@@ -71,6 +71,7 @@
     HelpText<"Use module-definition file">;
 
 def debug : F<"debug">, HelpText<"Embed a symbol table in the image">;
+def debug_dwarf : F<"debug:dwarf">;
 def debugtype : P<"debugtype", "Debug Info Options">;
 def dll : F<"dll">, HelpText<"Create a DLL">;
 def driver : P<"driver", "Generate a Windows NT Kernel Mode Driver">;
Index: COFF/Driver.cpp
===================================================================
--- COFF/Driver.cpp
+++ COFF/Driver.cpp
@@ -801,7 +801,7 @@
     Config->Force = true;
 
   // Handle /debug
-  if (Args.hasArg(OPT_debug)) {
+  if (Args.hasArg(OPT_debug) || Args.hasArg(OPT_debug_dwarf)) {
     Config->Debug = true;
     if (auto *Arg = Args.getLastArg(OPT_debugtype))
       Config->DebugTypes = parseDebugType(Arg->getValue());
@@ -1135,7 +1135,7 @@
   }
 
   // Disable PDB generation if the user requested it.
-  if (Args.hasArg(OPT_nopdb))
+  if (Args.hasArg(OPT_nopdb) || Args.hasArg(OPT_debug_dwarf))
     Config->PDBPath = "";
 
   // Set default image base if /base is not given.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39541.121381.patch
Type: text/x-patch
Size: 2589 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171102/e6f86bdc/attachment.bin>


More information about the llvm-commits mailing list