[PATCH] D77824: [mlir] Emit errors if global constructors are found within lib/

River Riddle via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 9 13:50:33 PDT 2020


rriddle created this revision.
rriddle added a reviewer: mehdi_amini.
Herald added subscribers: llvm-commits, frgossen, grosul1, Joonsoo, liufengdb, aartbik, lucyrfox, mgester, arpith-jacob, nicolasvasilache, antiagainst, shauheen, burmako, jpienaar, mgorny.
Herald added a project: LLVM.

This avoids adding any additional global constructors, like cl::opt. There is a temporary exception on IR/, which has a few cl::opts that require a bit of plumbing to remove.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77824

Files:
  mlir/lib/CMakeLists.txt
  mlir/lib/IR/CMakeLists.txt


Index: mlir/lib/IR/CMakeLists.txt
===================================================================
--- mlir/lib/IR/CMakeLists.txt
+++ mlir/lib/IR/CMakeLists.txt
@@ -1,3 +1,6 @@
+# TODO: Remove the need for global constructors within IR/
+add_flag_if_supported("-Wno-global-constructors" WNO_GLOBAL_CONSTRUCTOR_MLIR_IR)
+
 file(GLOB globbed *.c *.cpp)
 add_mlir_library(MLIRIR
   ${globbed}
Index: mlir/lib/CMakeLists.txt
===================================================================
--- mlir/lib/CMakeLists.txt
+++ mlir/lib/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Enable errors for any global constructors.
+add_flag_if_supported("-Werror=global-constructors" WERROR_GLOBAL_CONSTRUCTOR)
+
 add_subdirectory(Analysis)
 add_subdirectory(Conversion)
 add_subdirectory(Dialect)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77824.256392.patch
Type: text/x-patch
Size: 777 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200409/e4d85b9d/attachment.bin>


More information about the llvm-commits mailing list