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 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; +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: 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