Skip to content

Commit 2c52ddf

Browse files
committed
[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 llvm-svn: 361014
1 parent ef9b8e0 commit 2c52ddf

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

lld/MinGW/Driver.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,9 @@ bool mingw::link(ArrayRef<const char *> ArgsArr, raw_ostream &Diag) {
165165

166166
if (auto *A = Args.getLastArg(OPT_pdb)) {
167167
Add("-debug");
168-
Add("-pdb:" + StringRef(A->getValue()));
168+
StringRef V = A->getValue();
169+
if (!V.empty())
170+
Add("-pdb:" + V);
169171
} else if (Args.hasArg(OPT_strip_debug)) {
170172
Add("-debug:symtab");
171173
} else if (!Args.hasArg(OPT_strip_all)) {

lld/MinGW/Options.td

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ def _HASH_HASH_HASH : Flag<["-"], "###">,
5757
HelpText<"Print (but do not run) the commands to run for this compilation">;
5858
def appcontainer: F<"appcontainer">, HelpText<"Set the appcontainer flag in the executable">;
5959
def mllvm: S<"mllvm">;
60-
def pdb: S<"pdb">, HelpText<"Specify output PDB debug information file">;
60+
def pdb: S<"pdb">, HelpText<"Specify output PDB debug information file. "
61+
"Defaults to the output filename, with a pdb suffix, if given an empty argument">;
62+
def pdb_eq: J<"pdb=">, Alias<pdb>;
6163
def Xlink : J<"Xlink=">, MetaVarName<"<arg>">,
6264
HelpText<"Pass <arg> to the COFF linker">;
6365

lld/test/MinGW/driver.test

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,14 @@ STRIP-DEBUG: -debug:symtab
9999
STRIP-DEBUG-NOT: -debug:dwarf
100100

101101
RUN: ld.lld -### -m i386pep foo.o -pdb out.pdb | FileCheck -check-prefix PDB %s
102+
RUN: ld.lld -### -m i386pep foo.o -pdb=out.pdb | FileCheck -check-prefix PDB %s
102103
PDB: -debug -pdb:out.pdb
103104
PDB-NOT: -debug:dwarf
104105

106+
RUN: ld.lld -### -m i386pep foo.o -pdb= | FileCheck -check-prefix PDB-DEFAULT %s
107+
PDB-DEFAULT: -debug
108+
PDB-DEFAULT-NOT: -pdb:{{.*}}
109+
105110
RUN: ld.lld -### -m i386pep foo.o --large-address-aware | FileCheck -check-prefix LARGE-ADDRESS-AWARE %s
106111
LARGE-ADDRESS-AWARE: -largeaddressaware
107112

0 commit comments

Comments
 (0)