[lld] 84306ef - [LLD][MinGW] Add --fatal-warnings and --no-fatal-warnings flags

Martin Storsjö via llvm-commits llvm-commits at lists.llvm.org
Mon May 17 00:47:26 PDT 2021


Author: Mateusz Mikuła
Date: 2021-05-17T10:40:31+03:00
New Revision: 84306ef9c442e335b53c3d87948258a528346e6f

URL: https://github.com/llvm/llvm-project/commit/84306ef9c442e335b53c3d87948258a528346e6f
DIFF: https://github.com/llvm/llvm-project/commit/84306ef9c442e335b53c3d87948258a528346e6f.diff

LOG: [LLD][MinGW] Add --fatal-warnings and --no-fatal-warnings flags

Differential Revision: https://reviews.llvm.org/D102514

Added: 
    

Modified: 
    lld/MinGW/Driver.cpp
    lld/MinGW/Options.td
    lld/test/MinGW/driver.test

Removed: 
    


################################################################################
diff  --git a/lld/MinGW/Driver.cpp b/lld/MinGW/Driver.cpp
index f8eb4e76b7f9f..e6c6efdd2b95a 100644
--- a/lld/MinGW/Driver.cpp
+++ b/lld/MinGW/Driver.cpp
@@ -290,6 +290,11 @@ bool mingw::link(ArrayRef<const char *> argsArr, bool canExitEarly,
     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
index eceee3a4997b1..3a4a40bbe11f7 100644
--- a/lld/MinGW/Options.td
+++ b/lld/MinGW/Options.td
@@ -45,6 +45,9 @@ def exclude_all_symbols: F<"exclude-all-symbols">,
     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
index 33503d45189eb..c8b7e2d12deba 100644
--- a/lld/test/MinGW/driver.test
+++ b/lld/test/MinGW/driver.test
@@ -294,3 +294,12 @@ DEMANGLE: -demangle{{ }}
 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


        


More information about the llvm-commits mailing list