[libcxx] [llvm] [libc++][hardening] Rework macros for enabling the hardening mode. (PR #70575)

Louis Dionne via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 31 13:51:04 PDT 2023


================
@@ -287,17 +287,18 @@ def getStdFlag(cfg, std):
     ),
     Parameter(
         name="hardening_mode",
-        choices=["unchecked", "hardened", "safe", "debug"],
+        choices=["unchecked", "hardened", "debug_lite", "debug"],
         type=str,
         default="unchecked",
         help="Whether to enable one of the hardening modes when compiling the test suite. This is only "
         "meaningful when running the tests against libc++.",
         actions=lambda hardening_mode: filter(
             None,
             [
-                AddCompileFlag("-D_LIBCPP_ENABLE_HARDENED_MODE=1") if hardening_mode == "hardened" else None,
-                AddCompileFlag("-D_LIBCPP_ENABLE_SAFE_MODE=1")     if hardening_mode == "safe" else None,
-                AddCompileFlag("-D_LIBCPP_ENABLE_DEBUG_MODE=1")    if hardening_mode == "debug" else None,
+                AddCompileFlag("-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_HARDENED")   if hardening_mode == "hardened" else None,
+                AddCompileFlag("-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG_LITE") if hardening_mode == "debug_lite" else None,
+                AddCompileFlag("-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG")      if hardening_mode == "debug" else None,
+                AddCompileFlag("-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_UNCHECKED")  if hardening_mode == "unchecked" else None,
----------------
ldionne wrote:

This looks correct to me.

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


More information about the llvm-commits mailing list