[PATCH] D105959: Use ManagedStatic and lazy initialization of cl::opt in libSupport to make it free of global initializer

Mehdi AMINI via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 13 22:07:35 PDT 2021


mehdi_amini created this revision.
Herald added subscribers: frasercrmck, dexonsmith, jdoerfert, cmtice, luismarques, apazos, sameer.abuasal, s.egerton, Jim, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, hiraditya, mgorny.
Herald added a reviewer: jhenderson.
mehdi_amini requested review of this revision.
Herald added subscribers: llvm-commits, MaskRay.
Herald added a project: LLVM.

We can build it with -Werror=global-constructors now. This helps
in situation where libSupport is embedded as a shared library,
potential with dlopen/dlclose scenario, and when command-line
parsing or other facilities may not be involved. Avoiding the
implicit construction of these cl::opt can avoid double-registration
issues and other kind of behavior.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105959

Files:
  llvm/include/llvm/Support/CommandLine.h
  llvm/include/llvm/Support/ScopedPrinter.h
  llvm/include/llvm/Support/WithColor.h
  llvm/lib/Support/ARMBuildAttrs.cpp
  llvm/lib/Support/CMakeLists.txt
  llvm/lib/Support/CommandLine.cpp
  llvm/lib/Support/Debug.cpp
  llvm/lib/Support/DebugCounter.cpp
  llvm/lib/Support/DebugOptions.h
  llvm/lib/Support/ELFAttributeParser.cpp
  llvm/lib/Support/GraphWriter.cpp
  llvm/lib/Support/RISCVAttributes.cpp
  llvm/lib/Support/RandomNumberGenerator.cpp
  llvm/lib/Support/Signals.cpp
  llvm/lib/Support/Statistic.cpp
  llvm/lib/Support/TimeProfiler.cpp
  llvm/lib/Support/Timer.cpp
  llvm/lib/Support/TypeSize.cpp
  llvm/lib/Support/WithColor.cpp
  llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
  llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp
  llvm/unittests/Support/CommandLineTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105959.358513.patch
Type: text/x-patch
Size: 48550 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210714/8d20b67e/attachment.bin>


More information about the llvm-commits mailing list