[libcxx-commits] [libcxx] [libc++] Remove _LIBCPP_ENABLE_ASSERTIONS, which had been deprecated (PR #113592)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Oct 24 09:52:34 PDT 2024
https://github.com/ldionne created https://github.com/llvm/llvm-project/pull/113592
None
>From 1f86a1054c62552acae288d1a9f431650cc7b297 Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Thu, 24 Oct 2024 12:51:41 -0400
Subject: [PATCH] [libc++] Remove _LIBCPP_ENABLE_ASSERTIONS, which had been
deprecated
---
libcxx/CMakeLists.txt | 8 ++---
libcxx/docs/ReleaseNotes/20.rst | 11 ++----
libcxx/include/__config | 11 ++----
...assertions_enables_extensive_mode.pass.cpp | 35 -------------------
4 files changed, 7 insertions(+), 58 deletions(-)
delete mode 100644 libcxx/test/libcxx/assertions/modes/enabling_assertions_enables_extensive_mode.pass.cpp
diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index 574b262018cd3a..95a7d10f055ea7 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -45,10 +45,6 @@ include(CMakeDependentOption)
include(HandleCompilerRT)
# Basic options ---------------------------------------------------------------
-option(LIBCXX_ENABLE_ASSERTIONS
- "Enable assertions inside the compiled library, and at the same time make it the
- default when compiling user code. Note that assertions can be enabled or disabled
- by users in their own code regardless of this option." OFF)
option(LIBCXX_ENABLE_SHARED "Build libc++ as a shared library." ON)
option(LIBCXX_ENABLE_STATIC "Build libc++ as a static library." ON)
option(LIBCXX_ENABLE_FILESYSTEM
@@ -759,9 +755,9 @@ 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: Remove in LLVM 21. We're leaving an error to make this fail explicitly.
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")
+ message(FATAL_ERROR "LIBCXX_ENABLE_ASSERTIONS has been removed. Please use LIBCXX_HARDENING_MODE instead.")
endif()
if (LIBCXX_HARDENING_MODE STREQUAL "none")
config_define(2 _LIBCPP_HARDENING_MODE_DEFAULT)
diff --git a/libcxx/docs/ReleaseNotes/20.rst b/libcxx/docs/ReleaseNotes/20.rst
index 39546493ae8d6f..91da1bfe59c785 100644
--- a/libcxx/docs/ReleaseNotes/20.rst
+++ b/libcxx/docs/ReleaseNotes/20.rst
@@ -63,8 +63,9 @@ Improvements and New Features
Deprecations and Removals
-------------------------
-- TODO: The ``LIBCXX_ENABLE_ASSERTIONS`` CMake variable and the ``_LIBCPP_ENABLE_ASSERTIONS`` macro that were used to
- enable the safe mode will be removed in LLVM 20.
+- The ``LIBCXX_ENABLE_ASSERTIONS`` CMake variable and the ``_LIBCPP_ENABLE_ASSERTIONS`` macro that were used to
+ enable the safe mode have been removed in LLVM 20. Please use :ref:`support for hardening <using-hardening-modes>`
+ instead.
- Support for the C++20 synchronization library (``<barrier>``, ``<latch>``, ``atomic::wait``, etc.) has been
removed in language modes prior to C++20. If you are using these features prior to C++20, you will need to
@@ -90,12 +91,6 @@ Deprecations and Removals
Upcoming Deprecations and Removals
----------------------------------
-LLVM 20
-~~~~~~~
-
-- TODO
-
-
LLVM 21
~~~~~~~
diff --git a/libcxx/include/__config b/libcxx/include/__config
index 4155fd33dabc44..618e60446b6a7b 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -39,16 +39,9 @@
// HARDENING {
-// This is for backward compatibility -- make enabling `_LIBCPP_ENABLE_ASSERTIONS` (which predates hardening modes)
-// equivalent to setting the extensive mode. This is deprecated and will be removed in LLVM 20.
+// TODO: Remove in LLVM 21. We're making this an error to catch folks who might not have migrated.
# 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
-# if _LIBCPP_ENABLE_ASSERTIONS
-# define _LIBCPP_HARDENING_MODE _LIBCPP_HARDENING_MODE_EXTENSIVE
-# endif
+# error "_LIBCPP_ENABLE_ASSERTIONS has been removed, please use _LIBCPP_HARDENING_MODE instead"
# endif
// The library provides the macro `_LIBCPP_HARDENING_MODE` which can be set to one of the following values:
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
deleted file mode 100644
index c496fc32dc939f..00000000000000
--- a/libcxx/test/libcxx/assertions/modes/enabling_assertions_enables_extensive_mode.pass.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-// TODO(hardening): remove in LLVM 20.
-// This test ensures that enabling assertions with the legacy `_LIBCPP_ENABLE_ASSERTIONS` now enables the extensive
-// hardening mode.
-
-// `check_assertion.h` is only available starting from C++11 and requires Unix headers and regex support.
-// REQUIRES: has-unix-headers
-// UNSUPPORTED: c++03, no-localization
-// The ability to set a custom abort message is required to compare the assertion message (which only happens in the
-// debug mode).
-// XFAIL: libcpp-hardening-mode=debug && availability-verbose_abort-missing
-// 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 -Wno-cpp
-
-#include <cassert>
-#include "check_assertion.h"
-
-int main(int, char**) {
- static_assert(_LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_EXTENSIVE,
- "The extensive hardening mode should be implicitly enabled");
-
- _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(true, "Should not fire");
- TEST_LIBCPP_ASSERT_FAILURE([] { _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(false, "Should fire"); }(), "Should fire");
-
- return 0;
-}
More information about the libcxx-commits
mailing list