From: Mehdi Amini Date: Fri, 16 Jul 2021 03:32:59 +0000 (+0000) Subject: Build libSupport with -Werror=global-constructors (NFC) X-Git-Tag: llvmorg-14-init~319 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5eb2e9aa64b7be7cd8ed7f36de19c2c9bdf1977c;p=platform%2Fupstream%2Fllvm.git 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. --- diff --git a/llvm/lib/Support/CMakeLists.txt b/llvm/lib/Support/CMakeLists.txt index 2242b0e..57058c6 100644 --- a/llvm/lib/Support/CMakeLists.txt +++ b/llvm/lib/Support/CMakeLists.txt @@ -1,5 +1,11 @@ include(GetLibraryName) +# 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. +add_flag_if_supported("-Werror=global-constructors" WERROR_GLOBAL_CONSTRUCTOR) + if(LLVM_ENABLE_ZLIB) set(imported_libs ZLIB::ZLIB) endif()