Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[libc++] Deprecate _LIBCPP_ENABLE_ASSERTIONS & friends #98364

Merged
merged 3 commits into from
Jul 12, 2024

Conversation

ldionne
Copy link
Member

@ldionne ldionne commented Jul 10, 2024

In LLVM 19, the old xxx_ENABLE_ASSERTIONS settings should be deprecated with the goal of removing them entirely in LLVM 20.

@ldionne ldionne added the hardening Issues related to the hardening effort label Jul 10, 2024
@ldionne ldionne requested a review from var-const July 10, 2024 18:17
@ldionne ldionne requested a review from a team as a code owner July 10, 2024 18:17
@ldionne ldionne added this to the LLVM 19.X Release milestone Jul 10, 2024
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Jul 10, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented Jul 10, 2024

@llvm/pr-subscribers-libcxx

Author: Louis Dionne (ldionne)

Changes

In LLVM 19, the old xxx_ENABLE_ASSERTIONS settings should be deprecated with the goal of removing them entirely in LLVM 20.


Full diff: https://github.com/llvm/llvm-project/pull/98364.diff

3 Files Affected:

  • (modified) libcxx/CMakeLists.txt (+1)
  • (modified) libcxx/docs/ReleaseNotes/19.rst (+1-1)
  • (modified) libcxx/include/__config (+2-2)
diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index e098bd574eec7..7d0b8d12674bd 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -786,6 +786,7 @@ config_define_if_not(LIBCXX_ENABLE_VENDOR_AVAILABILITY_ANNOTATIONS _LIBCPP_HAS_N
 
 # 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

In LLVM 19, the old xxx_ENABLE_ASSERTIONS settings should be deprecated
with the goal of removing them entirely in LLVM 20.
@ldionne ldionne force-pushed the review/harden-deprecate-ENABLE_ASSERTIONS branch from 30be2e5 to f29dba6 Compare July 10, 2024 18:19
@ldionne ldionne merged commit 9bd575d into llvm:main Jul 12, 2024
58 checks passed
@ldionne ldionne deleted the review/harden-deprecate-ENABLE_ASSERTIONS branch July 12, 2024 20:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hardening Issues related to the hardening effort libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants