[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
This commit is contained in:
Martin Storsjo 2019-05-17 11:07:33 +00:00
parent ef9b8e03fd
commit 2c52ddf31f
3 changed files with 11 additions and 2 deletions

View File

@ -165,7 +165,9 @@ bool mingw::link(ArrayRef<const char *> ArgsArr, raw_ostream &Diag) {
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)) {

View File

@ -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">;

View File

@ -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