[libc-commits] [libc] 26a1849 - [libc] Warn on use of global constructors in `libc`
Joseph Huber via libc-commits
libc-commits at lists.llvm.org
Thu Jul 20 09:30:06 PDT 2023
Author: Joseph Huber
Date: 2023-07-20T11:29:58-05:00
New Revision: 26a1849cca4e84feeaac303fba05f8dabca84050
URL: https://github.com/llvm/llvm-project/commit/26a1849cca4e84feeaac303fba05f8dabca84050
DIFF: https://github.com/llvm/llvm-project/commit/26a1849cca4e84feeaac303fba05f8dabca84050.diff
LOG: [libc] Warn on use of global constructors in `libc`
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.
Reviewed By: michaelrj
Differential Revision: https://reviews.llvm.org/D155721
Added:
Modified:
libc/cmake/modules/LLVMLibCObjectRules.cmake
Removed:
################################################################################
diff --git a/libc/cmake/modules/LLVMLibCObjectRules.cmake b/libc/cmake/modules/LLVMLibCObjectRules.cmake
index 2dfa7c09ae9162..5c76cf285e6371 100644
--- a/libc/cmake/modules/LLVMLibCObjectRules.cmake
+++ b/libc/cmake/modules/LLVMLibCObjectRules.cmake
@@ -38,6 +38,7 @@ function(_get_common_compile_options output_var flags)
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)
More information about the libc-commits
mailing list