diff options
author | Joseph Huber <jhuber6@vols.utk.edu> | 2023-07-19 11:00:34 -0500 |
---|---|---|
committer | Joseph Huber <jhuber6@vols.utk.edu> | 2023-07-20 11:29:58 -0500 |
commit | 26a1849cca4e84feeaac303fba05f8dabca84050 (patch) | |
tree | 54b61ad2d0da3ace13d57c65073635d89c09c441 /libc | |
parent | 805ce9a6962331d209c8d0a2e2ff39d27629beba (diff) | |
download | llvm-26a1849cca4e84feeaac303fba05f8dabca84050.zip llvm-26a1849cca4e84feeaac303fba05f8dabca84050.tar.gz llvm-26a1849cca4e84feeaac303fba05f8dabca84050.tar.bz2 |
[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
Diffstat (limited to 'libc')
-rw-r--r-- | libc/cmake/modules/LLVMLibCObjectRules.cmake | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/libc/cmake/modules/LLVMLibCObjectRules.cmake b/libc/cmake/modules/LLVMLibCObjectRules.cmake index 2dfa7c0..5c76cf2 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) |