[libcxx-commits] [libcxx] [libc++][hardening] Check that `_LIBCPP_HARDENING_MODE_DEFAULT` is defined (PR #80353)
Konstantin Varlamov via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Feb 1 14:23:12 PST 2024
https://github.com/var-const updated https://github.com/llvm/llvm-project/pull/80353
>From bc75091f1807d915b933e5adae4e440adf61400b Mon Sep 17 00:00:00 2001
From: Konstantin Varlamov <varconsteq at gmail.com>
Date: Thu, 1 Feb 2024 14:02:12 -0800
Subject: [PATCH 1/2] [libc++][hardening] Check that
`_LIBCPP_HARDENING_MODE_DEFAULT` is defined
If the `_LIBCPP_HARDENING_MODE_DEFAULT` macro is not defined,
`_LIBCPP_HARDENING_MODE` will be considered defined but fail the check
for a valid hardening mode, resulting in a slightly less understandable
error (that error is really meant more to prevent users from passing
incorrect values such as `0` or `1` directly rather than catching
configuration issues).
---
libcxx/include/__config | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/libcxx/include/__config b/libcxx/include/__config
index d356960e9e62b..2101490c3a8c5 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -325,6 +325,11 @@
// clang-format on
# ifndef _LIBCPP_HARDENING_MODE
+
+# ifndef _LIBCPP_HARDENING_MODE_DEFAULT
+# error _LIBCPP_HARDENING_MODE_DEFAULT is not defined.
+# endif
+
# define _LIBCPP_HARDENING_MODE _LIBCPP_HARDENING_MODE_DEFAULT
# endif
>From 6373036bcaf37414f1b2772048ecb9da0ee95a1c Mon Sep 17 00:00:00 2001
From: Konstantin Varlamov <varconsteq at gmail.com>
Date: Thu, 1 Feb 2024 14:22:59 -0800
Subject: [PATCH 2/2] Feedback
---
libcxx/include/__config | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/libcxx/include/__config b/libcxx/include/__config
index 2101490c3a8c5..0797880cb2f5d 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -327,7 +327,8 @@
# ifndef _LIBCPP_HARDENING_MODE
# ifndef _LIBCPP_HARDENING_MODE_DEFAULT
-# error _LIBCPP_HARDENING_MODE_DEFAULT is not defined.
+# error _LIBCPP_HARDENING_MODE_DEFAULT is not defined. This definition should be set at configuration time in the \
+`__config_site` header, please make sure your installation of libc++ is not broken.
# endif
# define _LIBCPP_HARDENING_MODE _LIBCPP_HARDENING_MODE_DEFAULT
More information about the libcxx-commits
mailing list