[libcxx-commits] [libcxx] [libc++] Deprecate _LIBCPP_ENABLE_ASSERTIONS & friends (PR #98364)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Jul 12 07:10:14 PDT 2024
https://github.com/ldionne updated https://github.com/llvm/llvm-project/pull/98364
>From f29dba619b24372db8a891ec2dfd8a4793991584 Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Wed, 10 Jul 2024 14:15:52 -0400
Subject: [PATCH 1/3] [libc++] Deprecate _LIBCPP_ENABLE_ASSERTIONS & friends
In LLVM 19, the old xxx_ENABLE_ASSERTIONS settings should be deprecated
with the goal of removing them entirely in LLVM 20.
---
libcxx/CMakeLists.txt | 2 +-
libcxx/docs/ReleaseNotes/19.rst | 2 +-
libcxx/include/__config | 4 ++--
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index e098bd574eec7..190a97db9462f 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -784,8 +784,8 @@ config_define_if_not(LIBCXX_ENABLE_WIDE_CHARACTERS _LIBCPP_HAS_NO_WIDE_CHARACTER
config_define_if_not(LIBCXX_ENABLE_TIME_ZONE_DATABASE _LIBCPP_HAS_NO_TIME_ZONE_DATABASE)
config_define_if_not(LIBCXX_ENABLE_VENDOR_AVAILABILITY_ANNOTATIONS _LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS)
-# TODO(LLVM 19): Produce a deprecation warning.
if (LIBCXX_ENABLE_ASSERTIONS)
+ message(DEPRECATION "LIBCXX_ENABLE_ASSERTIONS is deprecated and will be removed in LLVM 20. Please use LIBCXX_HARDENING_MODE instead.")
set(LIBCXX_HARDENING_MODE "extensive")
endif()
if (LIBCXX_HARDENING_MODE STREQUAL "none")
diff --git a/libcxx/docs/ReleaseNotes/19.rst b/libcxx/docs/ReleaseNotes/19.rst
index 893e418d32d1d..a72a583ffb0be 100644
--- a/libcxx/docs/ReleaseNotes/19.rst
+++ b/libcxx/docs/ReleaseNotes/19.rst
@@ -85,7 +85,7 @@ Deprecations and Removals
This decision is based on LEWGs discussion on `P3122 <https://wg21.link/P3122>` and `P3162 <https://wg21.link/P3162>`
to not use ``[[nodiscard]]`` in the standard.
-- TODO: The ``LIBCXX_ENABLE_ASSERTIONS`` CMake variable that was used to enable the safe mode has been deprecated and setting
+- The ``LIBCXX_ENABLE_ASSERTIONS`` CMake variable that was used to enable the safe mode has been deprecated and setting
it triggers an error; use the ``LIBCXX_HARDENING_MODE`` CMake variable with the value ``extensive`` instead. Similarly,
the ``_LIBCPP_ENABLE_ASSERTIONS`` macro has been deprecated (setting it to ``1`` still enables the extensive mode in
the LLVM 19 release while also issuing a deprecation warning). See :ref:`the hardening documentation
diff --git a/libcxx/include/__config b/libcxx/include/__config
index dfb14fd6a380c..91bc6fc21df8e 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -38,10 +38,10 @@
// HARDENING {
-// TODO(hardening): deprecate this in LLVM 19.
// This is for backward compatibility -- make enabling `_LIBCPP_ENABLE_ASSERTIONS` (which predates hardening modes)
-// equivalent to setting the extensive mode.
+// equivalent to setting the extensive mode. This is deprecated and will be removed in LLVM 20.
# ifdef _LIBCPP_ENABLE_ASSERTIONS
+# warning "_LIBCPP_ENABLE_ASSERTIONS is deprecated, please use _LIBCPP_HARDENING_MODE instead"
# if _LIBCPP_ENABLE_ASSERTIONS != 0 && _LIBCPP_ENABLE_ASSERTIONS != 1
# error "_LIBCPP_ENABLE_ASSERTIONS must be set to 0 or 1"
# endif
>From 86c169357172f700c5f0fe38b51b63b41fd4a428 Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Thu, 11 Jul 2024 10:19:46 -0400
Subject: [PATCH 2/3] Fix test
---
.../modes/enabling_assertions_enables_extensive_mode.pass.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libcxx/test/libcxx/assertions/modes/enabling_assertions_enables_extensive_mode.pass.cpp b/libcxx/test/libcxx/assertions/modes/enabling_assertions_enables_extensive_mode.pass.cpp
index d4dad8b71fe92..d35cada115eec 100644
--- a/libcxx/test/libcxx/assertions/modes/enabling_assertions_enables_extensive_mode.pass.cpp
+++ b/libcxx/test/libcxx/assertions/modes/enabling_assertions_enables_extensive_mode.pass.cpp
@@ -19,7 +19,7 @@
// HWASAN replaces TRAP with abort or error exit code.
// XFAIL: hwasan
// Note that GCC doesn't support `-Wno-macro-redefined`.
-// ADDITIONAL_COMPILE_FLAGS: -U_LIBCPP_HARDENING_MODE -D_LIBCPP_ENABLE_ASSERTIONS=1
+// ADDITIONAL_COMPILE_FLAGS: -U_LIBCPP_HARDENING_MODE -D_LIBCPP_ENABLE_ASSERTIONS=1 -Wno-#warnings
#include <cassert>
#include "check_assertion.h"
>From f84c427cc4660cf789afdb8b17e694a037b3caa4 Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Fri, 12 Jul 2024 10:10:01 -0400
Subject: [PATCH 3/3] Fix warning on GCC
---
.../modes/enabling_assertions_enables_extensive_mode.pass.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libcxx/test/libcxx/assertions/modes/enabling_assertions_enables_extensive_mode.pass.cpp b/libcxx/test/libcxx/assertions/modes/enabling_assertions_enables_extensive_mode.pass.cpp
index d35cada115eec..c496fc32dc939 100644
--- a/libcxx/test/libcxx/assertions/modes/enabling_assertions_enables_extensive_mode.pass.cpp
+++ b/libcxx/test/libcxx/assertions/modes/enabling_assertions_enables_extensive_mode.pass.cpp
@@ -19,7 +19,7 @@
// HWASAN replaces TRAP with abort or error exit code.
// XFAIL: hwasan
// Note that GCC doesn't support `-Wno-macro-redefined`.
-// ADDITIONAL_COMPILE_FLAGS: -U_LIBCPP_HARDENING_MODE -D_LIBCPP_ENABLE_ASSERTIONS=1 -Wno-#warnings
+// ADDITIONAL_COMPILE_FLAGS: -U_LIBCPP_HARDENING_MODE -D_LIBCPP_ENABLE_ASSERTIONS=1 -Wno-#warnings -Wno-cpp
#include <cassert>
#include "check_assertion.h"
More information about the libcxx-commits
mailing list