Index: COFF/Driver.cpp =================================================================== --- COFF/Driver.cpp +++ COFF/Driver.cpp @@ -801,7 +801,7 @@ Config->Force = true; // Handle /debug - if (Args.hasArg(OPT_debug)) { + if (Args.hasArg(OPT_debug) || Args.hasArg(OPT_debug_dwarf)) { Config->Debug = true; if (auto *Arg = Args.getLastArg(OPT_debugtype)) Config->DebugTypes = parseDebugType(Arg->getValue()); @@ -1135,7 +1135,7 @@ } // Disable PDB generation if the user requested it. - if (Args.hasArg(OPT_nopdb)) + if (Args.hasArg(OPT_nopdb) || Args.hasArg(OPT_debug_dwarf)) Config->PDBPath = ""; // Set default image base if /base is not given. Index: COFF/Options.td =================================================================== --- COFF/Options.td +++ COFF/Options.td @@ -71,6 +71,7 @@ HelpText<"Use module-definition file">; def debug : F<"debug">, HelpText<"Embed a symbol table in the image">; +def debug_dwarf : F<"debug:dwarf">; 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: MinGW/Driver.cpp =================================================================== --- MinGW/Driver.cpp +++ MinGW/Driver.cpp @@ -152,6 +152,8 @@ Add("-verbose"); if (Args.hasArg(OPT_export_all_symbols)) Add("-export-all-symbols"); + if (!Args.hasArg(OPT_s)) + Add("-debug:dwarf"); if (auto *A = Args.getLastArg(OPT_m)) { StringRef S = A->getValue(); Index: MinGW/Options.td =================================================================== --- MinGW/Options.td +++ MinGW/Options.td @@ -24,6 +24,7 @@ def shared: F<"shared">, HelpText<"Build a shared object">; def subs: S<"subsystem">, HelpText<"Specify subsystem">; def stack: S<"stack">; +def s: Flag<["-"], "s">, HelpText<"Omit debug info from the output binary">; def whole_archive: F<"whole-archive">, HelpText<"Include all object files for following archives">; def verbose: F<"verbose">, HelpText<"Verbose mode">; Index: test/MinGW/driver.test =================================================================== --- test/MinGW/driver.test +++ test/MinGW/driver.test @@ -79,3 +79,9 @@ RUN: ld.lld -### -m i386pep foo.o --output-def out.def | FileCheck -check-prefix OUTPUT-DEF %s OUTPUT-DEF: -output-def:out.def + +RUN: ld.lld -### -m i386pep foo.o | FileCheck -check-prefix DEBUG %s +DEBUG: -debug:dwarf + +RUN: ld.lld -### -m i386pep foo.o -s | FileCheck -check-prefix STRIP %s +STRIP-NOT: -debug:dwarf