[libc-commits] [PATCH] D155721: [libc] Warn on use of global constructors in `libc`
Joseph Huber via Phabricator via libc-commits
libc-commits at lists.llvm.org
Wed Jul 19 09:02:26 PDT 2023
jhuber6 created this revision.
jhuber6 added reviewers: sivachandra, lntue, michaelrj, JonChesterfield.
Herald added projects: libc-project, All.
Herald added a subscriber: libc-commits.
jhuber6 requested review of this revision.
Clang supports the `-Wglobal-constructors` flag which will indicate if a
global constructor is being used. The current goal in `libc` is to make
the constructors `constexpr` to prevent this from happening with
straight construction. However, there are many other cases where we can
emit a constructor that this won't catch. This should give warning if
someone accidentally introduces a global constructor.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D155721
Files:
libc/cmake/modules/LLVMLibCObjectRules.cmake
Index: libc/cmake/modules/LLVMLibCObjectRules.cmake
===================================================================
--- libc/cmake/modules/LLVMLibCObjectRules.cmake
+++ libc/cmake/modules/LLVMLibCObjectRules.cmake
@@ -38,6 +38,7 @@
list(APPEND compile_options "-Wnonportable-system-include-path")
list(APPEND compile_options "-Wstrict-prototypes")
list(APPEND compile_options "-Wthread-safety")
+ list(APPEND compile_options "-Wglobal-constructors")
endif()
if(ADD_FMA_FLAG)
if(LIBC_TARGET_ARCHITECTURE_IS_X86)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D155721.542056.patch
Type: text/x-patch
Size: 558 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20230719/2ac67956/attachment.bin>
More information about the libc-commits
mailing list