[PATCH] D145249: [TargetParser] Disallow Global Constructors

Sam Elliott via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 10 07:53:47 PST 2023


This revision was automatically updated to reflect the committed changes.
Closed by commit rGcddc1b6b2783: [TargetParser] Disallow Global Constructors (authored by lenary).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145249/new/

https://reviews.llvm.org/D145249

Files:
  llvm/lib/TargetParser/CMakeLists.txt


Index: llvm/lib/TargetParser/CMakeLists.txt
===================================================================
--- llvm/lib/TargetParser/CMakeLists.txt
+++ llvm/lib/TargetParser/CMakeLists.txt
@@ -1,3 +1,13 @@
+# Ensure that libLLVMTargetParser does not carry any static global initializer.
+# ManagedStatic can be used to enable lazy-initialization of globals.
+#
+# HAS_WERROR_GLOBAL_CTORS and LLVM_HAS_NOGLOBAL_CTOR_MUTEX should have been set
+# by llvm/lib/Support/CMakeLists.txt (which provides the required Support
+# dependency).
+if (HAS_WERROR_GLOBAL_CTORS AND NOT LLVM_HAS_NOGLOBAL_CTOR_MUTEX)
+  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=global-constructors")
+endif()
+
 add_llvm_component_library(LLVMTargetParser
   AArch64TargetParser.cpp
   ARMTargetParserCommon.cpp


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D145249.504153.patch
Type: text/x-patch
Size: 790 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230310/6482dd7b/attachment.bin>


More information about the llvm-commits mailing list