[lld] r361014 - [MinGW] Allow requesting PDB output without giving a file name

Martin Storsjo via llvm-commits llvm-commits at lists.llvm.org
Fri May 17 04:07:34 PDT 2019


Author: mstorsjo
Date: Fri May 17 04:07:33 2019
New Revision: 361014

URL: http://llvm.org/viewvc/llvm-project?rev=361014&view=rev
Log:
[MinGW] Allow requesting PDB output without giving a file name

When integrating PDB output in mingw targeting build systems, it
might be a lot of extra work to specify unique file names for
the pdb output. Therefore allow omitting the actual file name
and let it implicitly be the same name as the linker output, with
a pdb extension.

As the current form of the pdb option takes a separate parameter value,
e.g. "-pdb out.pdb", it is impractical to leave out the parameter value.

Therefore, introduce a second syntax for the option, with an equals
sign, like -pdb=out.pdb, where the value easily can be omitted.

The form -pdb= for requesting pdb files with an implicit name should
work fine, even though it looks a bit unconventional in that form.

Differential Revision: https://reviews.llvm.org/D62004

Modified:
    lld/trunk/MinGW/Driver.cpp
    lld/trunk/MinGW/Options.td
    lld/trunk/test/MinGW/driver.test

Modified: lld/trunk/MinGW/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/MinGW/Driver.cpp?rev=361014&r1=361013&r2=361014&view=diff
==============================================================================
--- lld/trunk/MinGW/Driver.cpp (original)
+++ lld/trunk/MinGW/Driver.cpp Fri May 17 04:07:33 2019
@@ -165,7 +165,9 @@ bool mingw::link(ArrayRef<const char *>
 
   if (auto *A = Args.getLastArg(OPT_pdb)) {
     Add("-debug");
-    Add("-pdb:" + StringRef(A->getValue()));
+    StringRef V = A->getValue();
+    if (!V.empty())
+      Add("-pdb:" + V);
   } else if (Args.hasArg(OPT_strip_debug)) {
     Add("-debug:symtab");
   } else if (!Args.hasArg(OPT_strip_all)) {

Modified: lld/trunk/MinGW/Options.td
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/MinGW/Options.td?rev=361014&r1=361013&r2=361014&view=diff
==============================================================================
--- lld/trunk/MinGW/Options.td (original)
+++ lld/trunk/MinGW/Options.td Fri May 17 04:07:33 2019
@@ -57,7 +57,9 @@ def _HASH_HASH_HASH : Flag<["-"], "###">
     HelpText<"Print (but do not run) the commands to run for this compilation">;
 def appcontainer: F<"appcontainer">, HelpText<"Set the appcontainer flag in the executable">;
 def mllvm: S<"mllvm">;
-def pdb: S<"pdb">, HelpText<"Specify output PDB debug information file">;
+def pdb: S<"pdb">, HelpText<"Specify output PDB debug information file. "
+                            "Defaults to the output filename, with a pdb suffix, if given an empty argument">;
+def pdb_eq: J<"pdb=">, Alias<pdb>;
 def Xlink : J<"Xlink=">, MetaVarName<"<arg>">,
     HelpText<"Pass <arg> to the COFF linker">;
 

Modified: lld/trunk/test/MinGW/driver.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/MinGW/driver.test?rev=361014&r1=361013&r2=361014&view=diff
==============================================================================
--- lld/trunk/test/MinGW/driver.test (original)
+++ lld/trunk/test/MinGW/driver.test Fri May 17 04:07:33 2019
@@ -99,9 +99,14 @@ STRIP-DEBUG: -debug:symtab
 STRIP-DEBUG-NOT: -debug:dwarf
 
 RUN: ld.lld -### -m i386pep foo.o -pdb out.pdb | FileCheck -check-prefix PDB %s
+RUN: ld.lld -### -m i386pep foo.o -pdb=out.pdb | FileCheck -check-prefix PDB %s
 PDB: -debug -pdb:out.pdb
 PDB-NOT: -debug:dwarf
 
+RUN: ld.lld -### -m i386pep foo.o -pdb= | FileCheck -check-prefix PDB-DEFAULT %s
+PDB-DEFAULT: -debug
+PDB-DEFAULT-NOT: -pdb:{{.*}}
+
 RUN: ld.lld -### -m i386pep foo.o --large-address-aware | FileCheck -check-prefix LARGE-ADDRESS-AWARE %s
 LARGE-ADDRESS-AWARE: -largeaddressaware
 




More information about the llvm-commits mailing list