[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
This commit is contained in:
Joseph Huber 2023-07-19 11:00:34 -05:00
parent 805ce9a696
commit 26a1849cca

View File

@ -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)