[PATCH] D50404: [lld-link] Support /DEBUG:NONE
Will Wilson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 7 12:45:40 PDT 2018
lantictac created this revision.
lantictac added reviewers: zturner, ruiu.
lantictac added a project: lld.
Herald added a subscriber: MaskRay.
Support /DEBUG:NONE and correctly handle final argument precedence if multiple /DEBUG arguments are passed on the command-line to match link.exe behavior.
Prevents:
lld-link: error: could not open /DEBUG:NONE: No such file or directory
Repository:
rLLD LLVM Linker
https://reviews.llvm.org/D50404
Files:
COFF/Driver.cpp
COFF/Options.td
test/COFF/pdb-options.test
Index: test/COFF/pdb-options.test
===================================================================
--- test/COFF/pdb-options.test
+++ test/COFF/pdb-options.test
@@ -6,6 +6,11 @@
# RUN: lld-link /pdb:%t.pdb /entry:main /nodefaultlib %t1.obj %t2.obj
# RUN: not ls %t.pdb
+; If /DEBUG:NONE is specified after /DEBUG, /pdb is ignored.
+# RUN: rm -f %t.pdb
+# RUN: lld-link /DEBUG /pdb:%t.pdb /DEBUG:NONE /entry:main /nodefaultlib %t1.obj %t2.obj
+# RUN: not ls %t.pdb
+
; If /DEBUG and /pdb are specified, it uses the specified name.
# RUN: lld-link /DEBUG /pdb:%t.pdb /entry:main /nodefaultlib %t1.obj %t2.obj
# RUN: ls %t.pdb
Index: COFF/Options.td
===================================================================
--- COFF/Options.td
+++ COFF/Options.td
@@ -86,6 +86,7 @@
def debug : F<"debug">, HelpText<"Embed a symbol table in the image">;
def debug_full : F<"debug:full">, Alias<debug>;
+def debug_none : F<"debug:none">;
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
@@ -837,27 +837,32 @@
Config->Force = true;
// Handle /debug
- if (Args.hasArg(OPT_debug, OPT_debug_dwarf, OPT_debug_ghash)) {
- Config->Debug = true;
- Config->Incremental = true;
- if (auto *Arg = Args.getLastArg(OPT_debugtype))
- Config->DebugTypes = parseDebugType(Arg->getValue());
- else
- Config->DebugTypes = getDefaultDebugType(Args);
- }
-
- // Handle /pdb
- bool ShouldCreatePDB = Args.hasArg(OPT_debug, OPT_debug_ghash);
- if (ShouldCreatePDB) {
- if (auto *Arg = Args.getLastArg(OPT_pdb))
- Config->PDBPath = Arg->getValue();
- if (auto *Arg = Args.getLastArg(OPT_pdbaltpath))
- Config->PDBAltPath = Arg->getValue();
- if (Args.hasArg(OPT_natvis))
- Config->NatvisFiles = Args.getAllArgValues(OPT_natvis);
-
- if (auto *Arg = Args.getLastArg(OPT_pdb_source_path))
- Config->PDBSourcePath = Arg->getValue();
+ bool ShouldCreatePDB = false;
+ if (auto *Arg = Args.getLastArg(OPT_debug, OPT_debug_none, OPT_debug_dwarf,
+ OPT_debug_ghash)) {
+ auto OptID = Arg->getOption().getID();
+ if (OptID != OPT_debug_none) {
+ Config->Debug = true;
+ Config->Incremental = true;
+ if (auto *Arg = Args.getLastArg(OPT_debugtype))
+ Config->DebugTypes = parseDebugType(Arg->getValue());
+ else
+ Config->DebugTypes = getDefaultDebugType(Args);
+
+ // Handle /pdb
+ ShouldCreatePDB = OptID == OPT_debug || OptID == OPT_debug_ghash;
+ if (ShouldCreatePDB) {
+ if (auto *Arg = Args.getLastArg(OPT_pdb))
+ Config->PDBPath = Arg->getValue();
+ if (auto *Arg = Args.getLastArg(OPT_pdbaltpath))
+ Config->PDBAltPath = Arg->getValue();
+ if (Args.hasArg(OPT_natvis))
+ Config->NatvisFiles = Args.getAllArgValues(OPT_natvis);
+
+ if (auto *Arg = Args.getLastArg(OPT_pdb_source_path))
+ Config->PDBSourcePath = Arg->getValue();
+ }
+ }
}
// Handle /noentry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50404.159573.patch
Type: text/x-patch
Size: 3230 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180807/3ff6fe13/attachment.bin>
More information about the llvm-commits
mailing list