[RFC] Hardening in libc++

Quick update on naming: based on the feedback we received so far, our new proposal for the names of hardening modes is none / fast / extensive / debug. Using the compiler flag, this would look like:

  • libc++-hardening-mode=none;
  • libc++-hardening-mode=fast;
  • libc++-hardening-mode=extensive;
  • libc++-hardening-mode=debug.

Similarly, with the CMake variable:

  • LIBCXX_HARDENING_MODE=none;
  • LIBCXX_HARDENING_MODE=fast;
  • LIBCXX_HARDENING_MODE=extensive;
  • LIBCXX_HARDENING_MODE=debug.

And with the macro:

  • _LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_NONE;
  • _LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_FAST;
  • _LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE;
  • _LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG.

none is what is called the unchecked mode in the RFC (in fact, we might still sometimes call it “unchecked” in the docs because “none mode” doesn’t sound right), fast corresponds to hardened and extensive to debug-lite. debug remains unchanged.

I have a patch in flight that uses the new naming scheme: [libc++][hardening] Add tests for the hardened mode with ABI breaks. by var-const · Pull Request #71020 · llvm/llvm-project · GitHub

Please let us know what you think!

1 Like