[libc] Warn on use of global constructors in `libc`
authorJoseph Huber <jhuber6@vols.utk.edu>
Wed, 19 Jul 2023 16:00:34 +0000 (11:00 -0500)
committerJoseph Huber <jhuber6@vols.utk.edu>
Thu, 20 Jul 2023 16:29:58 +0000 (11:29 -0500)
commit26a1849cca4e84feeaac303fba05f8dabca84050
tree54b61ad2d0da3ace13d57c65073635d89c09c441
parent805ce9a6962331d209c8d0a2e2ff39d27629beba
[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
libc/cmake/modules/LLVMLibCObjectRules.cmake