Build libSupport with -Werror=global-constructors (NFC)
authorMehdi Amini <joker.eph@gmail.com>
Fri, 16 Jul 2021 03:32:59 +0000 (03:32 +0000)
committerMehdi Amini <joker.eph@gmail.com>
Mon, 26 Jul 2021 23:06:15 +0000 (23:06 +0000)
commitbeff86e8ff429f11da6fe37efde86d22ea636ed5
tree6c1fd6e988c1171bf5f847f3e6169e039c7ff4e8
parent71af002d151ef9a162c8a776c22b46893f923af0
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.

The -Werror=global-constructors is only added on platform that have
support for the flag and for which std::mutex does not have a global
destructor. This is ensured by having CMake trying to compile a file
with a global mutex before adding the flag to libSupport.
llvm/lib/Support/CMakeLists.txt