From 3db57d14ecf55efd86cd3007dc755d27669e7828 Mon Sep 17 00:00:00 2001 From: River Riddle Date: Fri, 10 Apr 2020 12:57:18 -0700 Subject: [PATCH] [mlir] Emit errors if global constructors are found within lib/ Summary: 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. Differential Revision: https://reviews.llvm.org/D77824 --- mlir/lib/CMakeLists.txt | 3 +++ mlir/lib/IR/CMakeLists.txt | 3 +++ 2 files changed, 6 insertions(+) diff --git a/mlir/lib/CMakeLists.txt b/mlir/lib/CMakeLists.txt index c51e780..c139231 100644 --- a/mlir/lib/CMakeLists.txt +++ b/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) diff --git a/mlir/lib/IR/CMakeLists.txt b/mlir/lib/IR/CMakeLists.txt index 64998e4..c5dc2d2 100644 --- a/mlir/lib/IR/CMakeLists.txt +++ b/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} -- 2.7.4