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

Sam James via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 29 08:34:16 PST 2024


thesamesam wrote:

> > I am on the fence whether a driver option is really needed. It is a very shallow layer of extra abstraction that a curious reader has to look through. I guess I'll not object to this, if people really want to add it.
> 
> Setting macros that are reserved names is really unappealing for people. We want to provide a well integrated experience for library hardening and that includes providing a friendly option at the compiler level. Other sanity checking in the driver like erroring out when libc++ isn't in use is also good,

That pre-empts making it work for libstdc++ as suggested above...

>  since it calls out user mistakes early and clearly (otherwise the user might think they are getting hardening when they are > not). Finally, in the future this flag could potentially include more than just the macro. For example, it could potentially > include a few additional warnings.

That'd be the case for `-fhardened`.

> 
> Overall, my opinion is that this flag is required to properly "productize" library hardening and give it a user-friendly "frontend".

That's a fair point - setting a macro with an underscore does feel a bit dirty.


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


More information about the cfe-commits mailing list