[PATCH] D21969: [ELF] - Implemented --fatal-warnings option.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 4 06:50:31 PDT 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL274504: [ELF] - Implemented --fatal-warnings option. (authored by grimar).

Changed prior to commit:
  http://reviews.llvm.org/D21969?vs=62672&id=62678#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D21969

Files:
  lld/trunk/ELF/Config.h
  lld/trunk/ELF/Driver.cpp
  lld/trunk/ELF/Error.cpp
  lld/trunk/ELF/Options.td
  lld/trunk/test/ELF/fatal-warnings.s

Index: lld/trunk/ELF/Config.h
===================================================================
--- lld/trunk/ELF/Config.h
+++ lld/trunk/ELF/Config.h
@@ -81,6 +81,7 @@
   bool EhFrameHdr;
   bool EnableNewDtags;
   bool ExportDynamic;
+  bool FatalWarnings;
   bool GcSections;
   bool GnuHash = false;
   bool ICF;
Index: lld/trunk/ELF/Driver.cpp
===================================================================
--- lld/trunk/ELF/Driver.cpp
+++ lld/trunk/ELF/Driver.cpp
@@ -344,6 +344,7 @@
   Config->EhFrameHdr = Args.hasArg(OPT_eh_frame_hdr);
   Config->EnableNewDtags = !Args.hasArg(OPT_disable_new_dtags);
   Config->ExportDynamic = Args.hasArg(OPT_export_dynamic);
+  Config->FatalWarnings = Args.hasArg(OPT_fatal_warnings);
   Config->GcSections = Args.hasArg(OPT_gc_sections);
   Config->ICF = Args.hasArg(OPT_icf);
   Config->NoGnuUnique = Args.hasArg(OPT_no_gnu_unique);
Index: lld/trunk/ELF/Options.td
===================================================================
--- lld/trunk/ELF/Options.td
+++ lld/trunk/ELF/Options.td
@@ -66,6 +66,9 @@
 def export_dynamic_symbol: S<"export-dynamic-symbol">,
   HelpText<"Put a symbol in the dynamic symbol table">;
 
+def fatal_warnings: F<"fatal-warnings">,
+  HelpText<"Treat warnings as errors">;
+
 def fini: S<"fini">, MetaVarName<"<symbol>">,
   HelpText<"Specify a finalizer function">;
 
@@ -232,7 +235,6 @@
 def allow_shlib_undefined: F<"allow-shlib-undefined">;
 def define_common: F<"define-common">;
 def detect_odr_violations: F<"detect-odr-violations">;
-def fatal_warnings: F<"fatal-warnings">;
 def no_add_needed: F<"no-add-needed">;
 def no_allow_shlib_undefined: F<"no-allow-shlib-undefined">;
 def no_copy_dt_needed_entries: F<"no-copy-dt-needed-entries">,
Index: lld/trunk/ELF/Error.cpp
===================================================================
--- lld/trunk/ELF/Error.cpp
+++ lld/trunk/ELF/Error.cpp
@@ -24,7 +24,12 @@
     llvm::outs() << Msg << "\n";
 }
 
-void warning(const Twine &Msg) { llvm::errs() << Msg << "\n"; }
+void warning(const Twine &Msg) {
+  if (Config->FatalWarnings)
+    error(Msg);
+  else
+    llvm::errs() << Msg << "\n";
+}
 
 void error(const Twine &Msg) {
   *ErrorOS << Msg << "\n";
Index: lld/trunk/test/ELF/fatal-warnings.s
===================================================================
--- lld/trunk/test/ELF/fatal-warnings.s
+++ lld/trunk/test/ELF/fatal-warnings.s
@@ -0,0 +1,16 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t1.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/warn-common.s -o %t2.o
+
+# RUN: ld.lld --warn-common %t1.o %t2.o -o %t1.out 2>&1 | \
+# RUN:   FileCheck -check-prefix=ERR %s
+# ERR: multiple common of
+
+# RUN: not ld.lld --warn-common --fatal-warnings %t1.o %t2.o -o %t2.out 2>&1 | \
+# RUN:   FileCheck -check-prefix=ERR %s
+
+.globl _start
+_start:
+
+.type arr, at object
+.comm arr,4,4


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21969.62678.patch
Type: text/x-patch
Size: 2898 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160704/8cea5849/attachment.bin>


More information about the llvm-commits mailing list