[clang] Add option -fstdlib-hardening= (PR #78763)

Fangrui Song via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 29 10:51:31 PST 2024


MaskRay wrote:

As mentioned, libstdc++ has `_GLIBCXX_ASSERTIONS`. The documentation is at https://gcc.gnu.org/wiki/LibstdcxxDebugMode https://gcc.gnu.org/onlinedocs/libstdc++/manual/debug_mode.html

> For example, in a next step we should discuss whether it makes sense for `-fstdlib-hardening={extensive,debug}` to turn on `_GLIBCXX_ASSERTIONS` on GCC. 

I am concerned that `-fstdlib-hardening=` may not map to libstdc++ preferred enabling mechanism cleanly.
There is a non-zero probability that GCC folks would not add an option that just passes a `-D...` to cc1.
Then this driver option will feel like a libc++ specific feature using a generic name...

As I mentioned previously, the option is a very shallow layer of extra abstraction that a curious reader has to look through.
I understand that setting a macro starting with an underscore feels less elegant, but a driver option requires thoughts
how to handle `-Wunused-command-line-argument` properly. The current patch emits an error for C input and a warning for assembly input.
There may be other interaction that is worth considering. The complexity all arises from we introducing a driver option.


https://github.com/llvm/llvm-project/pull/78763


More information about the cfe-commits mailing list