Skip to content

Commit 5eb2e9a

Browse files
committed
Build libSupport with -Werror=global-constructors (NFC)
Ensure that libSupport does not carry any static global initializer. libSupport can be embedded in use cases where we don't want to load all cl::opt unless we want to parse the command line. ManagedStatic can be used to enable lazy-initialization of globals.
1 parent 7d9a2c7 commit 5eb2e9a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

llvm/lib/Support/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
include(GetLibraryName)
22

3+
# Ensure that libSupport does not carry any static global initializer.
4+
# libSupport can be embedded in use cases where we don't want to load all
5+
# cl::opt unless we want to parse the command line.
6+
# ManagedStatic can be used to enable lazy-initialization of globals.
7+
add_flag_if_supported("-Werror=global-constructors" WERROR_GLOBAL_CONSTRUCTOR)
8+
39
if(LLVM_ENABLE_ZLIB)
410
set(imported_libs ZLIB::ZLIB)
511
endif()

0 commit comments

Comments
 (0)