diff --git a/lld/MinGW/Driver.cpp b/lld/MinGW/Driver.cpp --- a/lld/MinGW/Driver.cpp +++ b/lld/MinGW/Driver.cpp @@ -290,6 +290,11 @@ add("-debug:dwarf"); } + if (args.hasFlag(OPT_fatal_warnings, OPT_no_fatal_warnings, false)) + add("-WX"); + else + add("-WX:no"); + if (args.hasArg(OPT_shared)) add("-dll"); if (args.hasArg(OPT_verbose)) diff --git a/lld/MinGW/Options.td b/lld/MinGW/Options.td --- a/lld/MinGW/Options.td +++ b/lld/MinGW/Options.td @@ -45,6 +45,9 @@ HelpText<"Don't automatically export any symbols">; def export_all_symbols: F<"export-all-symbols">, HelpText<"Export all symbols even if a def file or dllexport attributes are used">; +defm fatal_warnings: B<"fatal-warnings", + "Treat warnings as errors", + "Do not treat warnings as errors (default)">; defm file_alignment: Eq<"file-alignment", "Set file alignment">; defm gc_sections: B<"gc-sections", "Remove unused sections", diff --git a/lld/test/MinGW/driver.test b/lld/test/MinGW/driver.test --- a/lld/test/MinGW/driver.test +++ b/lld/test/MinGW/driver.test @@ -294,3 +294,12 @@ RUN: ld.lld -### -m i386pep foo.o -no-demangle | FileCheck -check-prefix NO-DEMANGLE %s RUN: ld.lld -### -m i386pep foo.o --no-demangle | FileCheck -check-prefix NO-DEMANGLE %s NO-DEMANGLE: -demangle:no + +RUN: ld.lld -### -m i386pep foo.o -fatal-warnings | FileCheck -check-prefix FATAL_WARNINGS %s +RUN: ld.lld -### -m i386pep foo.o --fatal-warnings | FileCheck -check-prefix FATAL_WARNINGS %s +FATAL_WARNINGS: -WX{{ }} + +RUN: ld.lld -### -m i386pep foo.o | FileCheck -check-prefix NO-FATAL_WARNINGS %s +RUN: ld.lld -### -m i386pep foo.o -no-fatal-warnings | FileCheck -check-prefix NO-FATAL_WARNINGS %s +RUN: ld.lld -### -m i386pep foo.o --no-fatal-warnings | FileCheck -check-prefix NO-FATAL_WARNINGS %s +NO-FATAL_WARNINGS: -WX:no