[libc++] Remove _LIBCPP_ENABLE_ASSERTIONS, which had been deprecated (#113592)

This commit is contained in:
Louis Dionne 2024-10-29 10:48:18 -04:00 committed by GitHub
parent 80a09735ac
commit c9d9dc9c24
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 7 additions and 58 deletions

View File

@ -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)

View File

@ -64,8 +64,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
@ -91,12 +92,6 @@ Deprecations and Removals
Upcoming Deprecations and Removals
----------------------------------
LLVM 20
~~~~~~~
- TODO
LLVM 21
~~~~~~~

View File

@ -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:

View File

@ -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;
}