[libcxx-commits] [libcxx] f0dfe68 - [libc++][hardening] Deprecate `_LIBCPP_ENABLE_ASSERTIONS`.

via libcxx-commits libcxx-commits at lists.llvm.org
Fri Jul 14 16:59:03 PDT 2023


Author: varconst
Date: 2023-07-14T16:58:47-07:00
New Revision: f0dfe682bca0b39d1fd64845f1576243d00c9d59

URL: https://github.com/llvm/llvm-project/commit/f0dfe682bca0b39d1fd64845f1576243d00c9d59
DIFF: https://github.com/llvm/llvm-project/commit/f0dfe682bca0b39d1fd64845f1576243d00c9d59.diff

LOG: [libc++][hardening] Deprecate `_LIBCPP_ENABLE_ASSERTIONS`.

`_LIBCPP_ENABLE_ASSERTIONS` was used to enable the "safe" mode in
libc++. Libc++ now provides the hardened mode and the debug mode that
replace the safe mode.

For backward compatibility, enabling `_LIBCPP_ENABLE_ASSERTIONS` now
enables the hardened mode. Note that the hardened mode provides
a narrower set of checks than the previous "safe" mode (only
security-critical checks that are performant enough to be used in
production).

Differential Revision: https://reviews.llvm.org/D154997

Added: 
    libcxx/test/libcxx/assertions/modes/enabling_assertions_enables_hardened_mode.pass.cpp
    libcxx/test/libcxx/assertions/single_expression.pass.cpp

Modified: 
    libcxx/CMakeLists.txt
    libcxx/cmake/caches/AIX.cmake
    libcxx/cmake/caches/Apple.cmake
    libcxx/cmake/caches/FreeBSD.cmake
    libcxx/docs/BuildingLibcxx.rst
    libcxx/docs/HardenedMode.rst
    libcxx/docs/ReleaseNotes.rst
    libcxx/docs/UsingLibcxx.rst
    libcxx/include/__assert
    libcxx/include/__config
    libcxx/include/__config_site.in
    libcxx/test/CMakeLists.txt
    libcxx/test/libcxx/algorithms/alg.sorting/assert.min.max.pass.cpp
    libcxx/test/libcxx/algorithms/alg.sorting/assert.sort.invalid_comparator.pass.cpp
    libcxx/test/libcxx/assertions/customize_verbose_abort.compile-time.pass.cpp
    libcxx/test/libcxx/assertions/customize_verbose_abort.link-time.pass.cpp
    libcxx/test/libcxx/assertions/default_verbose_abort.pass.cpp
    libcxx/test/libcxx/assertions/deprecated-link-time-custom-handler.pass.cpp
    libcxx/test/libcxx/assertions/modes/debug_mode_disabled_in_tu.pass.cpp
    libcxx/test/libcxx/assertions/modes/debug_mode_enabled_in_tu.pass.cpp
    libcxx/test/libcxx/assertions/modes/hardened.pass.cpp
    libcxx/test/libcxx/assertions/modes/hardened_mode_disabled_in_tu.pass.cpp
    libcxx/test/libcxx/assertions/modes/unchecked.pass.cpp
    libcxx/test/libcxx/containers/sequences/array/array.zero/assert.back.pass.cpp
    libcxx/test/libcxx/containers/sequences/array/array.zero/assert.front.pass.cpp
    libcxx/test/libcxx/containers/sequences/array/array.zero/assert.subscript.pass.cpp
    libcxx/test/libcxx/containers/sequences/deque/assert.pop_back.empty.pass.cpp
    libcxx/test/libcxx/containers/sequences/list/list.modifiers/assert.erase_iter.end.pass.cpp
    libcxx/test/libcxx/containers/sequences/list/list.modifiers/assert.pop_back.empty.pass.cpp
    libcxx/test/libcxx/containers/sequences/vector/assert.back.empty.pass.cpp
    libcxx/test/libcxx/containers/sequences/vector/assert.cback.empty.pass.cpp
    libcxx/test/libcxx/containers/sequences/vector/assert.cfront.empty.pass.cpp
    libcxx/test/libcxx/containers/sequences/vector/assert.cindex.oob.pass.cpp
    libcxx/test/libcxx/containers/sequences/vector/assert.front.empty.pass.cpp
    libcxx/test/libcxx/containers/sequences/vector/assert.index.oob.pass.cpp
    libcxx/test/libcxx/containers/sequences/vector/assert.pop_back.empty.pass.cpp
    libcxx/test/libcxx/containers/unord/unord.map/assert.bucket.pass.cpp
    libcxx/test/libcxx/containers/unord/unord.map/assert.bucket_size.pass.cpp
    libcxx/test/libcxx/containers/unord/unord.map/assert.max_load_factor.pass.cpp
    libcxx/test/libcxx/containers/unord/unord.multimap/assert.bucket.pass.cpp
    libcxx/test/libcxx/containers/unord/unord.multimap/assert.bucket_size.pass.cpp
    libcxx/test/libcxx/containers/unord/unord.multimap/assert.max_load_factor.pass.cpp
    libcxx/test/libcxx/containers/unord/unord.multiset/assert.bucket.pass.cpp
    libcxx/test/libcxx/containers/unord/unord.multiset/assert.bucket_size.pass.cpp
    libcxx/test/libcxx/containers/unord/unord.multiset/assert.max_load_factor.pass.cpp
    libcxx/test/libcxx/containers/unord/unord.set/assert.bucket.pass.cpp
    libcxx/test/libcxx/containers/unord/unord.set/assert.bucket_size.pass.cpp
    libcxx/test/libcxx/containers/unord/unord.set/assert.max_load_factor.pass.cpp
    libcxx/test/libcxx/containers/views/views.span/span.cons/assert.iter_sent.pass.cpp
    libcxx/test/libcxx/containers/views/views.span/span.cons/assert.iter_size.pass.cpp
    libcxx/test/libcxx/containers/views/views.span/span.cons/assert.other_span.pass.cpp
    libcxx/test/libcxx/containers/views/views.span/span.cons/assert.range.pass.cpp
    libcxx/test/libcxx/containers/views/views.span/span.elem/assert.back.pass.cpp
    libcxx/test/libcxx/containers/views/views.span/span.elem/assert.front.pass.cpp
    libcxx/test/libcxx/containers/views/views.span/span.elem/assert.op_idx.pass.cpp
    libcxx/test/libcxx/containers/views/views.span/span.sub/assert.first.pass.cpp
    libcxx/test/libcxx/containers/views/views.span/span.sub/assert.last.pass.cpp
    libcxx/test/libcxx/containers/views/views.span/span.sub/assert.subspan.pass.cpp
    libcxx/test/libcxx/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/assert.deallocate.pass.cpp
    libcxx/test/libcxx/experimental/memory/memory.resource.adaptor/memory.resource.adaptor.mem/assert.deallocate.pass.cpp
    libcxx/test/libcxx/input.output/filesystems/class.path/path.itr/assert.iterator.pass.cpp
    libcxx/test/libcxx/iterators/assert.advance.pass.cpp
    libcxx/test/libcxx/iterators/assert.next.pass.cpp
    libcxx/test/libcxx/iterators/assert.prev.pass.cpp
    libcxx/test/libcxx/iterators/bounded_iter/dereference.pass.cpp
    libcxx/test/libcxx/ranges/range.adaptors/range.drop.while/assert.begin.pass.cpp
    libcxx/test/libcxx/ranges/range.adaptors/range.lazy.split/range.lazy.split.inner/assert.equal.pass.cpp
    libcxx/test/libcxx/ranges/range.adaptors/range.lazy.split/range.lazy.split.outer/assert.equal.pass.cpp
    libcxx/test/libcxx/strings/basic.string/string.access/assert.back.pass.cpp
    libcxx/test/libcxx/strings/basic.string/string.access/assert.cback.pass.cpp
    libcxx/test/libcxx/strings/basic.string/string.access/assert.cfront.pass.cpp
    libcxx/test/libcxx/strings/basic.string/string.access/assert.cindex.pass.cpp
    libcxx/test/libcxx/strings/basic.string/string.access/assert.front.pass.cpp
    libcxx/test/libcxx/strings/basic.string/string.access/assert.index.pass.cpp
    libcxx/test/libcxx/strings/basic.string/string.modifiers/assert.erase_iter.null.pass.cpp
    libcxx/test/libcxx/strings/basic.string/string.modifiers/assert.pop_back.pass.cpp
    libcxx/test/libcxx/strings/string.view/assert.ctor.length.pass.cpp
    libcxx/test/libcxx/strings/string.view/assert.ctor.pointer.pass.cpp
    libcxx/test/libcxx/thread/futures/futures.promise/assert.set_exception.pass.cpp
    libcxx/test/libcxx/thread/futures/futures.promise/assert.set_exception_at_thread_exit.pass.cpp
    libcxx/test/libcxx/thread/thread.latch/assert.arrive_and_wait.pass.cpp
    libcxx/test/libcxx/thread/thread.latch/assert.count_down.pass.cpp
    libcxx/test/libcxx/thread/thread.latch/assert.ctor.pass.cpp
    libcxx/test/libcxx/utilities/assert.exception_guard.no_exceptions.pass.cpp
    libcxx/test/libcxx/utilities/expected/expected.expected/assert.arrow.pass.cpp
    libcxx/test/libcxx/utilities/expected/expected.expected/assert.deref.pass.cpp
    libcxx/test/libcxx/utilities/expected/expected.expected/assert.error.pass.cpp
    libcxx/test/libcxx/utilities/expected/expected.void/assert.deref.pass.cpp
    libcxx/test/libcxx/utilities/expected/expected.void/assert.error.pass.cpp
    libcxx/test/libcxx/utilities/optional/optional.object/optional.object.observe/assert.dereference.pass.cpp
    libcxx/test/libcxx/utilities/optional/optional.object/optional.object.observe/assert.op_arrow.pass.cpp
    libcxx/test/std/algorithms/alg.sorting/alg.clamp/assert.ranges_clamp.pass.cpp
    libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/assert.pop_heap.pass.cpp
    libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/assert.ranges_pop_heap.pass.cpp
    libcxx/test/std/containers/views/mdspan/extents/assert.conversion.pass.cpp
    libcxx/test/std/containers/views/mdspan/extents/assert.ctor_from_array.pass.cpp
    libcxx/test/std/containers/views/mdspan/extents/assert.ctor_from_integral.pass.cpp
    libcxx/test/std/containers/views/mdspan/extents/assert.ctor_from_span.pass.cpp
    libcxx/test/std/containers/views/mdspan/extents/assert.obs.pass.cpp
    libcxx/test/std/containers/views/mdspan/layout_left/assert.conversion.pass.cpp
    libcxx/test/std/containers/views/mdspan/layout_left/assert.ctor.extents.pass.cpp
    libcxx/test/std/containers/views/mdspan/layout_left/assert.ctor.layout_right.pass.cpp
    libcxx/test/std/containers/views/mdspan/layout_left/assert.index_operator.pass.cpp
    libcxx/test/std/containers/views/mdspan/layout_left/assert.stride.pass.cpp
    libcxx/test/std/containers/views/mdspan/layout_right/assert.conversion.pass.cpp
    libcxx/test/std/containers/views/mdspan/layout_right/assert.ctor.extents.pass.cpp
    libcxx/test/std/containers/views/mdspan/layout_right/assert.ctor.layout_left.pass.cpp
    libcxx/test/std/containers/views/mdspan/layout_right/assert.index_operator.pass.cpp
    libcxx/test/std/containers/views/mdspan/layout_right/assert.stride.pass.cpp
    libcxx/test/std/utilities/utility/utility.unreachable/assert.unreachable.pass.cpp
    libcxx/test/support/test.support/test_check_assertion.pass.cpp
    libcxx/utils/ci/buildkite-pipeline.yml
    libcxx/utils/ci/run-buildbot
    libcxx/utils/libcxx/test/params.py

Removed: 
    libcxx/cmake/caches/Generic-assertions.cmake
    libcxx/test/libcxx/assertions/assertions_disabled.pass.cpp
    libcxx/test/libcxx/assertions/modes/debug_no_assertions.pass.cpp
    libcxx/test/libcxx/assertions/modes/hardened_no_assertions.pass.cpp
    libcxx/test/libcxx/assertions/single_expression.sh.cpp
    libcxx/test/libcxx/debug/debug.assertions-enabled.compile.pass.cpp


################################################################################
diff  --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index 2660e80f31d06a..0aac34198cc755 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -48,10 +48,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
@@ -777,11 +773,6 @@ config_define_if_not(LIBCXX_ENABLE_LOCALIZATION _LIBCPP_HAS_NO_LOCALIZATION)
 config_define_if_not(LIBCXX_ENABLE_UNICODE _LIBCPP_HAS_NO_UNICODE)
 config_define_if_not(LIBCXX_ENABLE_WIDE_CHARACTERS _LIBCPP_HAS_NO_WIDE_CHARACTERS)
 config_define_if_not(LIBCXX_ENABLE_VENDOR_AVAILABILITY_ANNOTATIONS _LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS)
-if (LIBCXX_ENABLE_ASSERTIONS)
-  config_define(1 _LIBCPP_ENABLE_ASSERTIONS_DEFAULT)
-else()
-  config_define(0 _LIBCPP_ENABLE_ASSERTIONS_DEFAULT)
-endif()
 if (LIBCXX_HARDENING_MODE STREQUAL "hardened")
   config_define(1 _LIBCPP_ENABLE_HARDENED_MODE_DEFAULT)
   config_define(0 _LIBCPP_ENABLE_DEBUG_MODE_DEFAULT)
@@ -792,6 +783,11 @@ elseif (LIBCXX_HARDENING_MODE STREQUAL "unchecked")
   config_define(0 _LIBCPP_ENABLE_HARDENED_MODE_DEFAULT)
   config_define(0 _LIBCPP_ENABLE_DEBUG_MODE_DEFAULT)
 endif()
+# TODO(LLVM 18): Remove this after branching for LLVM 17, this is a simple
+# courtesy for vendors to be notified about this change.
+if (LIBCXX_ENABLE_ASSERTIONS)
+  message(FATAL_ERROR "LIBCXX_ENABLE_ASSERTIONS has been replaced by LIBCXX_HARDENING_MODE=hardened")
+endif()
 
 if (LIBCXX_PSTL_CPU_BACKEND STREQUAL "serial")
   config_define(1 _LIBCPP_PSTL_CPU_BACKEND_SERIAL)

diff  --git a/libcxx/cmake/caches/AIX.cmake b/libcxx/cmake/caches/AIX.cmake
index 76cf1779130112..31d9a2d4b72751 100644
--- a/libcxx/cmake/caches/AIX.cmake
+++ b/libcxx/cmake/caches/AIX.cmake
@@ -6,7 +6,6 @@ set(CMAKE_SHARED_LINKER_FLAGS "-Wl,-G -Wl,-bcdtors:all:-2147483548:s" CACHE STRI
 set(CMAKE_AR "/usr/bin/ar" CACHE FILEPATH "")
 
 set(LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
-set(LIBCXX_ENABLE_ASSERTIONS OFF CACHE BOOL "")
 set(LIBCXX_ABI_VERSION "1" CACHE STRING "")
 set(LIBCXX_ENABLE_ABI_LINKER_SCRIPT OFF CACHE BOOL "")
 set(LIBCXX_ENABLE_SHARED ON CACHE BOOL "")

diff  --git a/libcxx/cmake/caches/Apple.cmake b/libcxx/cmake/caches/Apple.cmake
index 099b5387478f53..32aae6d4a98457 100644
--- a/libcxx/cmake/caches/Apple.cmake
+++ b/libcxx/cmake/caches/Apple.cmake
@@ -2,7 +2,6 @@ set(CMAKE_BUILD_TYPE MinSizeRel CACHE STRING "")
 set(CMAKE_POSITION_INDEPENDENT_CODE OFF CACHE BOOL "")
 
 set(LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
-set(LIBCXX_ENABLE_ASSERTIONS OFF CACHE BOOL "")
 set(LIBCXX_ABI_VERSION "1" CACHE STRING "")
 set(LIBCXX_ENABLE_STATIC ON CACHE BOOL "")
 set(LIBCXX_ENABLE_SHARED ON CACHE BOOL "")

diff  --git a/libcxx/cmake/caches/FreeBSD.cmake b/libcxx/cmake/caches/FreeBSD.cmake
index 9e66e379864b66..7a7d917922b536 100644
--- a/libcxx/cmake/caches/FreeBSD.cmake
+++ b/libcxx/cmake/caches/FreeBSD.cmake
@@ -1,7 +1,6 @@
 set(CMAKE_BUILD_TYPE Release CACHE STRING "")
 set(CMAKE_POSITION_INDEPENDENT_CODE ON CACHE BOOL "")
 
-set(LIBCXX_ENABLE_ASSERTIONS OFF CACHE BOOL "")
 set(LIBCXX_ABI_VERSION "1" CACHE STRING "")
 set(LIBCXX_ENABLE_STATIC ON CACHE BOOL "")
 set(LIBCXX_ENABLE_SHARED ON CACHE BOOL "")

diff  --git a/libcxx/cmake/caches/Generic-assertions.cmake b/libcxx/cmake/caches/Generic-assertions.cmake
deleted file mode 100644
index a1d348ea9b331a..00000000000000
--- a/libcxx/cmake/caches/Generic-assertions.cmake
+++ /dev/null
@@ -1,2 +0,0 @@
-set(LIBCXX_ENABLE_ASSERTIONS ON CACHE BOOL "")
-set(LIBCXXABI_ENABLE_ASSERTIONS ON CACHE BOOL "")

diff  --git a/libcxx/docs/BuildingLibcxx.rst b/libcxx/docs/BuildingLibcxx.rst
index 3a4e4790631b4c..f62b0ba7a04652 100644
--- a/libcxx/docs/BuildingLibcxx.rst
+++ b/libcxx/docs/BuildingLibcxx.rst
@@ -211,15 +211,6 @@ libc++ specific options
 
   Toggle the installation of the libc++ headers.
 
-.. option:: LIBCXX_ENABLE_ASSERTIONS:BOOL
-
-  **Default**: ``OFF``
-
-  Build libc++ with assertions enabled in the compiled library, and enable assertions
-  by default when building user code as well. Assertions can be turned off by users
-  by defining ``_LIBCPP_ENABLE_ASSERTIONS=0``. For details, see
-  :ref:`the documentation <assertions-mode>`.
-
 .. option:: LIBCXX_ENABLE_SHARED:BOOL
 
   **Default**: ``ON``

diff  --git a/libcxx/docs/HardenedMode.rst b/libcxx/docs/HardenedMode.rst
index eb53e7c4fd060c..c006c1f86ecf78 100644
--- a/libcxx/docs/HardenedMode.rst
+++ b/libcxx/docs/HardenedMode.rst
@@ -20,21 +20,34 @@ contains all the checks from the hardened mode and additionally more expensive
 checks that may affect the complexity of algorithms. The debug mode is intended
 to be used for testing, not in production.
 
-Vendors can set the default hardened mode by using the ``LIBCXX_HARDENING_MODE``
-CMake variable. Setting ``LIBCXX_HARDENING_MODE`` to ``hardened`` enables the
-hardened mode, and similarly setting the variable to ``debug`` enables the debug
-mode. The default value is ``unchecked`` which doesn't enable the hardened mode.
-Users can control whether the hardened mode or the debug mode is enabled
-on a per translation unit basis by setting the ``_LIBCPP_ENABLE_HARDENED_MODE``
-or ``_LIBCPP_ENABLE_DEBUG_MODE`` macro to ``1``.
-
-The hardened mode requires ``LIBCXX_ENABLE_ASSERTIONS`` to work. If
-``LIBCXX_ENABLE_ASSERTIONS`` was not set explicitly, enabling the hardened mode
-(or the debug mode) will implicitly enable ``LIBCXX_ENABLE_ASSERTIONS``. If
-``LIBCXX_ENABLE_ASSERTIONS`` was explicitly disabled, this will effectively
-disable the hardened mode.
-
-Enabling the hardened mode (or the debug mode) has no impact on the ABI.
+Vendors can set the default hardening mode by using the
+``LIBCXX_HARDENING_MODE`` variable at CMake configuration time. Setting
+``LIBCXX_HARDENING_MODE`` to ``hardened`` enables the hardened mode, and
+similarly setting the variable to ``debug`` enables the debug mode. The default
+value is ``unchecked`` which doesn't enable any hardening.
+
+When hardening is enabled, the compiled library is built with the corresponding
+mode enabled, **and** user code will be built with the same mode enabled by
+default. If the mode is set to "unchecked" at the CMake configuration time, the
+compiled library will not contain any assertions and the default when building
+user code will be to have assertions disabled. As a user, you can consult your
+vendor to know which level of hardening is enabled by default.
+
+Furthermore, independently of any vendor-selected default, users can always
+control which level of hardening is enabled in their code by defining
+``_LIBCPP_ENABLE_HARDENED_MODE=0|1`` (or ``_LIBCPP_ENABLE_DEBUG_MODE=0|1``)
+before including any libc++ header (we recommend passing
+``-D_LIBCPP_ENABLE_HARDENED_MODE=X`` or ``-D_LIBCPP_ENABLE_DEBUG_MODE=X`` to the
+compiler). Note that if the compiled library was built by the vendor in the
+unchecked mode, functions compiled inside the static or shared library won't
+have any hardening enabled even if the user compiles with hardening enabled (the
+same is true for the inverse case where the static or shared library was
+compiled **with** hardening enabled but the user tries to disable it). However,
+most of the code in libc++ is in the headers, so the user-selected value for
+``_LIBCPP_ENABLE_HARDENED_MODE`` or ``_LIBCPP_ENABLE_DEBUG_MODE`` (if any) will
+usually be respected.
+
+Enabling hardening has no impact on the ABI.
 
 Iterator bounds checking
 ------------------------

diff  --git a/libcxx/docs/ReleaseNotes.rst b/libcxx/docs/ReleaseNotes.rst
index 2e9f0ea0644150..f258308b35b9ae 100644
--- a/libcxx/docs/ReleaseNotes.rst
+++ b/libcxx/docs/ReleaseNotes.rst
@@ -88,6 +88,11 @@ Improvements and New Features
 Deprecations and Removals
 -------------------------
 
+- The "safe" mode is replaced by the hardened mode in this release. The ``LIBCXX_ENABLE_ASSERTIONS`` CMake variable is
+  deprecated and setting it will trigger an error; use ``LIBCXX_HARDENING_MODE`` instead. Similarly, the
+  ``_LIBCPP_ENABLE_ASSERTIONS`` macro is deprecated and setting it to ``1`` now enables the hardened mode. See
+  ``libcxx/docs/HardenedMode.rst`` for more details.
+
 - The legacy debug mode has been removed in this release. Setting the macro ``_LIBCPP_ENABLE_DEBUG_MODE`` to ``1`` now
   enables the new debug mode which is part of hardening (see the "Improvements and New Features" section above). The
   ``LIBCXX_ENABLE_DEBUG_MODE`` CMake variable has been removed. For additional context, refer to the `Discourse post

diff  --git a/libcxx/docs/UsingLibcxx.rst b/libcxx/docs/UsingLibcxx.rst
index 4cc649d1ccb114..c07d49ab7d6268 100644
--- a/libcxx/docs/UsingLibcxx.rst
+++ b/libcxx/docs/UsingLibcxx.rst
@@ -138,53 +138,32 @@ IWYU, you should run the tool like so:
 If you would prefer to not use that flag, then you can replace ``/path/to/include-what-you-use/share/libcxx.imp```
 file with the libc++-provided ``libcxx.imp`` file.
 
-.. _assertions-mode:
-
-Enabling the "safe libc++" mode
-===============================
-
-Libc++ contains a number of assertions whose goal is to catch undefined behavior in the
-library, usually caused by precondition violations. Those assertions do not aim to be
-exhaustive -- instead they aim to provide a good balance between safety and performance.
-In particular, these assertions do not change the complexity of algorithms. However, they
-might, in some cases, interfere with compiler optimizations.
-
-By default, these assertions are turned off. Vendors can decide to turn them on while building
-the compiled library by defining ``LIBCXX_ENABLE_ASSERTIONS=ON`` at CMake configuration time.
-When ``LIBCXX_ENABLE_ASSERTIONS`` is used, the compiled library will be built with assertions
-enabled, **and** user code will be built with assertions enabled by default. If
-``LIBCXX_ENABLE_ASSERTIONS=OFF`` at CMake configure time, the compiled library will not contain
-assertions and the default when building user code will be to have assertions disabled.
-As a user, you can consult your vendor to know whether assertions are enabled by default.
-
-Furthermore, independently of any vendor-selected default, users can always control whether
-assertions are enabled in their code by defining ``_LIBCPP_ENABLE_ASSERTIONS=0|1`` before
-including any libc++ header (we recommend passing ``-D_LIBCPP_ENABLE_ASSERTIONS=X`` to the
-compiler). Note that if the compiled library was built by the vendor without assertions,
-functions compiled inside the static or shared library won't have assertions enabled even
-if the user defines ``_LIBCPP_ENABLE_ASSERTIONS=1`` (the same is true for the inverse case
-where the static or shared library was compiled **with** assertions but the user tries to
-disable them). However, most of the code in libc++ is in the headers, so the user-selected
-value for ``_LIBCPP_ENABLE_ASSERTIONS`` (if any) will usually be respected.
-
-When an assertion fails, the program is aborted through a special verbose termination function. The
-library provides a default function that prints an error message and calls ``std::abort()``. Note
-that this function is provided by the static or shared library, so it is only available when deploying
-to a platform where the compiled library is sufficiently recent. On older platforms, the program will
-terminate in an unspecified unsuccessful manner, but the quality of diagnostics won't be great.
+.. _termination-handler:
+
+Overriding the default termination handler
+==========================================
+
+When the library wants to terminate due to an unforeseen condition (such as a hardening assertion
+failure), the program is aborted through a special verbose termination function. The library provides
+a default function that prints an error message and calls ``std::abort()``. Note that this function is
+provided by the static or shared library, so it is only available when deploying to a platform where
+the compiled library is sufficiently recent. On older platforms, the program will terminate in an
+unspecified unsuccessful manner, but the quality of diagnostics won't be great.
+
 However, users can also override that mechanism at two 
diff erent levels. First, the mechanism can be
-overridden at compile-time by defining the ``_LIBCPP_VERBOSE_ABORT(format, args...)`` variadic macro.
+overridden at compile time by defining the ``_LIBCPP_VERBOSE_ABORT(format, args...)`` variadic macro.
 When that macro is defined, it will be called with a format string as the first argument, followed by
 a series of arguments to format using printf-style formatting. Compile-time customization may be
-interesting to get precise control over code generation, however it is also inconvenient to use in
+useful to get precise control over code generation, however it is also inconvenient to use in
 some cases. Indeed, compile-time customization of the verbose termination function requires that all
 translation units be compiled with a consistent definition for ``_LIBCPP_VERBOSE_ABORT`` to avoid ODR
 violations, which can add complexity in the build system of users.
 
 Otherwise, if compile-time customization is not necessary, link-time customization of the handler is also
 possible, similarly to how replacing ``operator new`` works. This mechanism trades off fine-grained control
-over the call site where the termination is initiated in exchange for more ergonomics. Link-time customization
-is done by simply defining the following function in exactly one translation unit of your program:
+over the call site where the termination is initiated in exchange for better ergonomics. Link-time
+customization is done by simply defining the following function in exactly one translation unit of your
+program:
 
 .. code-block:: cpp
 
@@ -212,7 +191,7 @@ and ``operator delete``. For example:
 
   int main() {
     std::vector<int> v;
-    int& x = v[0]; // Your termination function will be called here if _LIBCPP_ENABLE_ASSERTIONS=1
+    int& x = v[0]; // Your termination function will be called here if hardening is enabled.
   }
 
 Also note that the verbose termination function should never return. Since assertions in libc++
@@ -227,14 +206,20 @@ Libc++ Configuration Macros
 ===========================
 
 Libc++ provides a number of configuration macros which can be used to enable
-or disable extended libc++ behavior, including enabling "debug mode" or
-thread safety annotations.
+or disable extended libc++ behavior, including enabling hardening or thread
+safety annotations.
 
 **_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS**:
   This macro is used to enable -Wthread-safety annotations on libc++'s
   ``std::mutex`` and ``std::lock_guard``. By default, these annotations are
   disabled and must be manually enabled by the user.
 
+**_LIBCPP_ENABLE_HARDENED_MODE**:
+  This macro is used to enable the :ref:`hardened mode <using-hardened-mode>`.
+
+**_LIBCPP_ENABLE_DEBUG_MODE**:
+  This macro is used to enable the :ref:`debug mode <using-hardened-mode>`.
+
 **_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS**:
   This macro is used to disable all visibility annotations inside libc++.
   Defining this macro and then building libc++ with hidden visibility gives a

diff  --git a/libcxx/include/__assert b/libcxx/include/__assert
index 8c9415f021e4f2..d4af7e6c7192ab 100644
--- a/libcxx/include/__assert
+++ b/libcxx/include/__assert
@@ -17,31 +17,21 @@
 #  pragma GCC system_header
 #endif
 
-#ifndef _LIBCPP_ENABLE_ASSERTIONS
-#  define _LIBCPP_ENABLE_ASSERTIONS _LIBCPP_ENABLE_ASSERTIONS_DEFAULT
-#endif
-
-#if _LIBCPP_ENABLE_ASSERTIONS != 0 && _LIBCPP_ENABLE_ASSERTIONS != 1
-#  error "_LIBCPP_ENABLE_ASSERTIONS must be set to 0 or 1"
-#endif
+#define _LIBCPP_ASSERT(expression, message)                                                                            \
+  (__builtin_expect(static_cast<bool>(expression), 1)                                                                  \
+       ? (void)0                                                                                                       \
+       : _LIBCPP_VERBOSE_ABORT(                                                                                        \
+             "%s:%d: assertion %s failed: %s\n", __builtin_FILE(), __builtin_LINE(), #expression, message))
 
-#if _LIBCPP_ENABLE_ASSERTIONS
-#  define _LIBCPP_ASSERT(expression, message)                                                                          \
-    (__builtin_expect(static_cast<bool>(expression), 1)                                                                \
-         ? (void)0                                                                                                     \
-         : _LIBCPP_VERBOSE_ABORT(                                                                                      \
-               "%s:%d: assertion %s failed: %s\n", __builtin_FILE(), __builtin_LINE(), #expression, message))
 // TODO: __builtin_assume can currently inhibit optimizations. Until this has been fixed and we can add
 //       assumptions without a clear optimization intent, disable that to avoid worsening the code generation.
 //       See https://discourse.llvm.org/t/llvm-assume-blocks-optimization/71609 for a discussion.
-#elif 0 && __has_builtin(__builtin_assume)
-#  define _LIBCPP_ASSERT(expression, message)                                                                          \
+#if 0 && __has_builtin(__builtin_assume)
+#  define _LIBCPP_ASSUME(expression)                                                                                   \
     (_LIBCPP_DIAGNOSTIC_PUSH _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wassume")                                              \
          __builtin_assume(static_cast<bool>(expression)) _LIBCPP_DIAGNOSTIC_POP)
 #else
-#  define _LIBCPP_ASSERT(expression, message) ((void)0)
+#  define _LIBCPP_ASSUME(expression) ((void)0)
 #endif
 
-#define _LIBCPP_ASSERT_UNCATEGORIZED(expression, message) _LIBCPP_ASSERT(expression, message)
-
 #endif // _LIBCPP___ASSERT

diff  --git a/libcxx/include/__config b/libcxx/include/__config
index 4091d18da03dff..5aa56bfb5a0c46 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -208,6 +208,19 @@
 
 // HARDENING {
 
+// TODO(hardening): remove this in LLVM 18.
+// This is for backward compatibility -- make enabling `_LIBCPP_ENABLE_ASSERTIONS` (which predates hardening modes)
+// equivalent to setting the hardened mode.
+#  ifdef _LIBCPP_ENABLE_ASSERTIONS
+#    warning "_LIBCPP_ENABLE_ASSERTIONS is deprecated, please use _LIBCPP_ENABLE_HARDENED_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_ENABLE_HARDENED_MODE 1
+#    endif
+#  endif
+
 // Enables the hardened mode which consists of all checks intended to be used in production. Hardened mode prioritizes
 // security-critical checks that can be done with relatively little overhead in constant time. Mutually exclusive with
 // `_LIBCPP_ENABLE_DEBUG_MODE`.
@@ -245,26 +258,21 @@
 // Hardened mode checks.
 #  if _LIBCPP_ENABLE_HARDENED_MODE
 
-// Automatically enable assertions in hardened mode (unless the user explicitly turned them off).
-#    ifndef _LIBCPP_ENABLE_ASSERTIONS
-#      define _LIBCPP_ENABLE_ASSERTIONS 1
-#    endif
-
+// TODO(hardening): Once we categorize assertions, only enable the ones that we really want here.
+#    define _LIBCPP_ASSERT_UNCATEGORIZED(expression, message) _LIBCPP_ASSERT(expression, message)
 // TODO(hardening): more checks to be added here...
 
 // Debug mode checks.
 #  elif _LIBCPP_ENABLE_DEBUG_MODE
 
-// Automatically enable assertions in debug mode (unless the user explicitly turned them off).
-#    ifndef _LIBCPP_ENABLE_ASSERTIONS
-#      define _LIBCPP_ENABLE_ASSERTIONS 1
-#    endif
-
+// TODO(hardening): Once we categorize assertions, only enable the ones that we really want here.
+#    define _LIBCPP_ASSERT_UNCATEGORIZED(expression, message) _LIBCPP_ASSERT(expression, message)
 // TODO(hardening): more checks to be added here...
 
 // Disable all checks if neither the hardened mode nor the debug mode is enabled.
 #  else
 
+#    define _LIBCPP_ASSERT_UNCATEGORIZED(expression, message) _LIBCPP_ASSUME(expression)
 // TODO: more checks to be added here...
 
 #  endif // _LIBCPP_ENABLE_HARDENED_MODE

diff  --git a/libcxx/include/__config_site.in b/libcxx/include/__config_site.in
index 0d500718b801db..8602e0b91f6dcf 100644
--- a/libcxx/include/__config_site.in
+++ b/libcxx/include/__config_site.in
@@ -28,7 +28,6 @@
 #cmakedefine _LIBCPP_HAS_NO_RANDOM_DEVICE
 #cmakedefine _LIBCPP_HAS_NO_LOCALIZATION
 #cmakedefine _LIBCPP_HAS_NO_WIDE_CHARACTERS
-#cmakedefine01 _LIBCPP_ENABLE_ASSERTIONS_DEFAULT
 
 // PSTL backends
 #cmakedefine _LIBCPP_PSTL_CPU_BACKEND_SERIAL

diff  --git a/libcxx/test/CMakeLists.txt b/libcxx/test/CMakeLists.txt
index 306d610567feee..54cc485470a510 100644
--- a/libcxx/test/CMakeLists.txt
+++ b/libcxx/test/CMakeLists.txt
@@ -24,10 +24,6 @@ if (NOT LIBCXX_ENABLE_RTTI)
   serialize_lit_param(enable_rtti False)
 endif()
 
-if (LIBCXX_ENABLE_ASSERTIONS)
-  serialize_lit_param(enable_assertions True)
-endif()
-
 serialize_lit_param(hardening_mode "\"${LIBCXX_HARDENING_MODE}\"")
 
 if (CMAKE_CXX_COMPILER_TARGET)

diff  --git a/libcxx/test/libcxx/algorithms/alg.sorting/assert.min.max.pass.cpp b/libcxx/test/libcxx/algorithms/alg.sorting/assert.min.max.pass.cpp
index bb8dccca70978d..1c8632974e1019 100644
--- a/libcxx/test/libcxx/algorithms/alg.sorting/assert.min.max.pass.cpp
+++ b/libcxx/test/libcxx/algorithms/alg.sorting/assert.min.max.pass.cpp
@@ -10,8 +10,8 @@
 
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03, c++11, c++14, c++17
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 #include <algorithm>
 #include <array>

diff  --git a/libcxx/test/libcxx/algorithms/alg.sorting/assert.sort.invalid_comparator.pass.cpp b/libcxx/test/libcxx/algorithms/alg.sorting/assert.sort.invalid_comparator.pass.cpp
index 47ae97935b9eb5..00b435ed8fa7ff 100644
--- a/libcxx/test/libcxx/algorithms/alg.sorting/assert.sort.invalid_comparator.pass.cpp
+++ b/libcxx/test/libcxx/algorithms/alg.sorting/assert.sort.invalid_comparator.pass.cpp
@@ -10,8 +10,9 @@
 
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03, c++11, c++14, c++17
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1 -D_LIBCPP_DEBUG_STRICT_WEAK_ORDERING_CHECK
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG_STRICT_WEAK_ORDERING_CHECK
 // When the debug mode is enabled, this test fails because we actually catch on the fly that the comparator is not
 // a strict-weak ordering before we catch that we'd dereference out-of-bounds inside std::sort, which leads to 
diff erent
 // errors than the ones tested below.

diff  --git a/libcxx/test/libcxx/assertions/assertions_disabled.pass.cpp b/libcxx/test/libcxx/assertions/assertions_disabled.pass.cpp
deleted file mode 100644
index 5ec5f12fc28544..00000000000000
--- a/libcxx/test/libcxx/assertions/assertions_disabled.pass.cpp
+++ /dev/null
@@ -1,24 +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
-//
-//===----------------------------------------------------------------------===//
-
-// Test that _LIBCPP_ASSERT doesn't do anything when assertions are disabled.
-// We need to use -Wno-macro-redefined because the test suite defines
-// _LIBCPP_ENABLE_ASSERTIONS=1 under some configurations.
-
-// ADDITIONAL_COMPILE_FLAGS: -Wno-macro-redefined -D_LIBCPP_ENABLE_ASSERTIONS=0
-
-#include <cassert>
-
-bool executed_condition = false;
-bool f() { executed_condition = true; return false; }
-
-int main(int, char**) {
-  _LIBCPP_ASSERT(f(), "message"); // should not execute anything
-  assert(!executed_condition); // really make sure we did not execute anything at all
-  return 0;
-}

diff  --git a/libcxx/test/libcxx/assertions/customize_verbose_abort.compile-time.pass.cpp b/libcxx/test/libcxx/assertions/customize_verbose_abort.compile-time.pass.cpp
index 1ea6c362971b89..3c0329cdd0c961 100644
--- a/libcxx/test/libcxx/assertions/customize_verbose_abort.compile-time.pass.cpp
+++ b/libcxx/test/libcxx/assertions/customize_verbose_abort.compile-time.pass.cpp
@@ -13,7 +13,7 @@
 // defining _LIBCPP_VERBOSE_ABORT ourselves. Note that this does not have any
 // deployment target requirements.
 
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1 -D_LIBCPP_VERBOSE_ABORT(...)=my_abort(__VA_ARGS__)
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_VERBOSE_ABORT(...)=my_abort(__VA_ARGS__)
 
 #include <cstdlib>
 

diff  --git a/libcxx/test/libcxx/assertions/customize_verbose_abort.link-time.pass.cpp b/libcxx/test/libcxx/assertions/customize_verbose_abort.link-time.pass.cpp
index 233e974f4e356d..219c43874e77db 100644
--- a/libcxx/test/libcxx/assertions/customize_verbose_abort.link-time.pass.cpp
+++ b/libcxx/test/libcxx/assertions/customize_verbose_abort.link-time.pass.cpp
@@ -8,8 +8,6 @@
 
 // Test that we can set a custom verbose termination function at link-time.
 
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
-
 // We flag uses of the verbose termination function in older dylibs at compile-time to avoid runtime
 // failures when back-deploying.
 // XFAIL: availability-verbose_abort-missing

diff  --git a/libcxx/test/libcxx/assertions/default_verbose_abort.pass.cpp b/libcxx/test/libcxx/assertions/default_verbose_abort.pass.cpp
index 79d26c8c484762..870f43da4b8f02 100644
--- a/libcxx/test/libcxx/assertions/default_verbose_abort.pass.cpp
+++ b/libcxx/test/libcxx/assertions/default_verbose_abort.pass.cpp
@@ -8,8 +8,6 @@
 
 // Test that the default verbose termination function aborts the program.
 
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
-
 #include <csignal>
 #include <cstdlib>
 

diff  --git a/libcxx/test/libcxx/assertions/deprecated-link-time-custom-handler.pass.cpp b/libcxx/test/libcxx/assertions/deprecated-link-time-custom-handler.pass.cpp
index 9365bd245b518d..47cb53c7a8786a 100644
--- a/libcxx/test/libcxx/assertions/deprecated-link-time-custom-handler.pass.cpp
+++ b/libcxx/test/libcxx/assertions/deprecated-link-time-custom-handler.pass.cpp
@@ -11,7 +11,7 @@
 // Make sure that we still support _LIBCPP_AVAILABILITY_CUSTOM_VERBOSE_ABORT_PROVIDED for folks
 // who customize the verbose termination function at link-time in back-deployment environments.
 
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1 -D_LIBCPP_AVAILABILITY_CUSTOM_VERBOSE_ABORT_PROVIDED
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_AVAILABILITY_CUSTOM_VERBOSE_ABORT_PROVIDED
 
 // We emit a #warning about the deprecation of this setting, so make sure we don't turn that into an error.
 // ADDITIONAL_COMPILE_FLAGS: -Wno-error

diff  --git a/libcxx/test/libcxx/assertions/modes/debug_mode_disabled_in_tu.pass.cpp b/libcxx/test/libcxx/assertions/modes/debug_mode_disabled_in_tu.pass.cpp
index 8873754b95583a..5e7314e1093f2e 100644
--- a/libcxx/test/libcxx/assertions/modes/debug_mode_disabled_in_tu.pass.cpp
+++ b/libcxx/test/libcxx/assertions/modes/debug_mode_disabled_in_tu.pass.cpp
@@ -8,9 +8,7 @@
 
 // This test ensures that we can disable the debug mode on a per-TU basis regardless of how the library was built.
 
-// TODO(hardening): currently, explicitly enabling assertions enables all uncategorized assertions and overrides
-// disabling the debug mode.
-// UNSUPPORTED: libcpp-has-hardened-mode, libcpp-has-assertions
+// UNSUPPORTED: libcpp-has-hardened-mode
 // ADDITIONAL_COMPILE_FLAGS: -Wno-macro-redefined -D_LIBCPP_ENABLE_DEBUG_MODE=0
 
 #include <cassert>

diff  --git a/libcxx/test/libcxx/assertions/modes/debug_mode_enabled_in_tu.pass.cpp b/libcxx/test/libcxx/assertions/modes/debug_mode_enabled_in_tu.pass.cpp
index 11627920b3b7f3..131836dd20f015 100644
--- a/libcxx/test/libcxx/assertions/modes/debug_mode_enabled_in_tu.pass.cpp
+++ b/libcxx/test/libcxx/assertions/modes/debug_mode_enabled_in_tu.pass.cpp
@@ -10,10 +10,8 @@
 
 // Hardened mode would additionally trigger the error that hardened and debug modes are mutually exclusive.
 // UNSUPPORTED: libcpp-has-hardened-mode
-// `check_assertion.h` is only available starting from C++11.
-// UNSUPPORTED: c++03
-// `check_assertion.h` requires Unix headers.
-// REQUIRES: has-unix-headers
+// `check_assertion.h` is only available starting from C++11 and requires Unix headers.
+// UNSUPPORTED: c++03, !has-unix-headers
 // The ability to set a custom abort message is required to compare the assertion message.
 // XFAIL: availability-verbose_abort-missing
 // ADDITIONAL_COMPILE_FLAGS: -Wno-macro-redefined -D_LIBCPP_ENABLE_DEBUG_MODE=1

diff  --git a/libcxx/test/libcxx/assertions/modes/debug_no_assertions.pass.cpp b/libcxx/test/libcxx/assertions/modes/debug_no_assertions.pass.cpp
deleted file mode 100644
index 496b1b9a678827..00000000000000
--- a/libcxx/test/libcxx/assertions/modes/debug_no_assertions.pass.cpp
+++ /dev/null
@@ -1,21 +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
-//
-//===----------------------------------------------------------------------===//
-
-// Test that we can override whether assertions are enabled regardless of the hardening mode in use.
-
-// UNSUPPORTED: !libcpp-has-debug-mode
-// ADDITIONAL_COMPILE_FLAGS: -Wno-macro-redefined -D_LIBCPP_ENABLE_ASSERTIONS=0
-
-#include <cassert>
-
-int main(int, char**) {
-  _LIBCPP_ASSERT_UNCATEGORIZED(true, "Should not fire");
-  _LIBCPP_ASSERT_UNCATEGORIZED(false, "Also should not fire");
-
-  return 0;
-}

diff  --git a/libcxx/test/libcxx/assertions/modes/enabling_assertions_enables_hardened_mode.pass.cpp b/libcxx/test/libcxx/assertions/modes/enabling_assertions_enables_hardened_mode.pass.cpp
new file mode 100644
index 00000000000000..d98f7540841140
--- /dev/null
+++ b/libcxx/test/libcxx/assertions/modes/enabling_assertions_enables_hardened_mode.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 18.
+// This test ensures that enabling assertions now enables the hardened mode.
+
+// `check_assertion.h` is only available starting from C++11 and requires Unix headers.
+// UNSUPPORTED: c++03, !has-unix-headers
+// The ability to set a custom abort message is required to compare the assertion message.
+// XFAIL: availability-verbose_abort-missing
+// Debug mode is mutually exclusive with hardened mode.
+// UNSUPPORTED: libcpp-has-debug-mode
+// Ignore the warning about `_LIBCPP_ENABLE_ASSERTIONS` being deprecated.
+// ADDITIONAL_COMPILE_FLAGS: -Wno-error -D_LIBCPP_ENABLE_ASSERTIONS=1
+
+#include <cassert>
+#include "check_assertion.h"
+
+int main(int, char**) {
+  static_assert(_LIBCPP_ENABLE_HARDENED_MODE == 1, "Hardened mode should be implicitly enabled");
+
+  _LIBCPP_ASSERT_UNCATEGORIZED(true, "Should not fire");
+  TEST_LIBCPP_ASSERT_FAILURE([] {
+    _LIBCPP_ASSERT_UNCATEGORIZED(false, "Should fire");
+  }(), "Should fire");
+
+  return 0;
+}

diff  --git a/libcxx/test/libcxx/assertions/modes/hardened.pass.cpp b/libcxx/test/libcxx/assertions/modes/hardened.pass.cpp
index 643e8d9470d458..1564815cb28aa3 100644
--- a/libcxx/test/libcxx/assertions/modes/hardened.pass.cpp
+++ b/libcxx/test/libcxx/assertions/modes/hardened.pass.cpp
@@ -14,6 +14,7 @@
 // UNSUPPORTED: c++03
 // `check_assertion.h` requires Unix headers.
 // REQUIRES: has-unix-headers
+// XFAIL: availability-verbose_abort-missing
 
 #include <cassert>
 #include "check_assertion.h"

diff  --git a/libcxx/test/libcxx/assertions/modes/hardened_mode_disabled_in_tu.pass.cpp b/libcxx/test/libcxx/assertions/modes/hardened_mode_disabled_in_tu.pass.cpp
index 6634d86a9a0965..50cbbe87e25a11 100644
--- a/libcxx/test/libcxx/assertions/modes/hardened_mode_disabled_in_tu.pass.cpp
+++ b/libcxx/test/libcxx/assertions/modes/hardened_mode_disabled_in_tu.pass.cpp
@@ -8,9 +8,7 @@
 
 // This test ensures that we can disable the hardened mode on a per-TU basis regardless of how the library was built.
 
-// TODO(hardening): currently, explicitly enabling assertions enables all uncategorized assertions and overrides
-// disabling the hardened mode.
-// UNSUPPORTED: libcpp-has-debug-mode, libcpp-has-assertions
+// UNSUPPORTED: libcpp-has-debug-mode
 // ADDITIONAL_COMPILE_FLAGS: -Wno-macro-redefined -D_LIBCPP_ENABLE_HARDENED_MODE=0
 
 #include <cassert>

diff  --git a/libcxx/test/libcxx/assertions/modes/hardened_no_assertions.pass.cpp b/libcxx/test/libcxx/assertions/modes/hardened_no_assertions.pass.cpp
deleted file mode 100644
index 704757c1138cfc..00000000000000
--- a/libcxx/test/libcxx/assertions/modes/hardened_no_assertions.pass.cpp
+++ /dev/null
@@ -1,21 +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
-//
-//===----------------------------------------------------------------------===//
-
-// Test that we can override whether assertions are enabled regardless of the hardening mode in use.
-
-// UNSUPPORTED: !libcpp-has-hardened-mode
-// ADDITIONAL_COMPILE_FLAGS: -Wno-macro-redefined -D_LIBCPP_ENABLE_ASSERTIONS=0
-
-#include <cassert>
-
-int main(int, char**) {
-  _LIBCPP_ASSERT_UNCATEGORIZED(true, "Should not fire");
-  _LIBCPP_ASSERT_UNCATEGORIZED(false, "Also should not fire");
-
-  return 0;
-}

diff  --git a/libcxx/test/libcxx/assertions/modes/unchecked.pass.cpp b/libcxx/test/libcxx/assertions/modes/unchecked.pass.cpp
index 905011df8be502..a8ebaf2801b052 100644
--- a/libcxx/test/libcxx/assertions/modes/unchecked.pass.cpp
+++ b/libcxx/test/libcxx/assertions/modes/unchecked.pass.cpp
@@ -13,12 +13,14 @@
 
 #include <cassert>
 
+bool executed_condition = false;
+bool f() { executed_condition = true; return false; }
+
 int main(int, char**) {
-  // TODO(hardening): remove the `#if` guard once `_LIBCPP_ENABLE_ASSERTIONS` no longer affects hardening modes.
-#if !_LIBCPP_ENABLE_ASSERTIONS
   _LIBCPP_ASSERT_UNCATEGORIZED(true, "Should not fire");
   _LIBCPP_ASSERT_UNCATEGORIZED(false, "Also should not fire");
-#endif
+  _LIBCPP_ASSERT_UNCATEGORIZED(f(), "Should not execute anything");
+  assert(!executed_condition); // Really make sure we did not execute anything.
 
   return 0;
 }

diff  --git a/libcxx/test/libcxx/assertions/single_expression.sh.cpp b/libcxx/test/libcxx/assertions/single_expression.pass.cpp
similarity index 55%
rename from libcxx/test/libcxx/assertions/single_expression.sh.cpp
rename to libcxx/test/libcxx/assertions/single_expression.pass.cpp
index 60847f3eef74fc..13253e4cb6ef5a 100644
--- a/libcxx/test/libcxx/assertions/single_expression.sh.cpp
+++ b/libcxx/test/libcxx/assertions/single_expression.pass.cpp
@@ -6,17 +6,9 @@
 //
 //===----------------------------------------------------------------------===//
 
-// Make sure that _LIBCPP_ASSERT is a single expression. This is useful so we can use
-// it in places that require an expression, such as in a constructor initializer list.
-
-// RUN: %{build} -Wno-macro-redefined -D_LIBCPP_ENABLE_ASSERTIONS=1
-// RUN: %{run}
-
-// RUN: %{build} -Wno-macro-redefined -D_LIBCPP_ENABLE_ASSERTIONS=0
-// RUN: %{run}
-
-// RUN: %{build} -Wno-macro-redefined -D_LIBCPP_ENABLE_ASSERTIONS=0 -D_LIBCPP_ASSERTIONS_DISABLE_ASSUME
-// RUN: %{run}
+// Make sure that `_LIBCPP_ASSERT` and `_LIBCPP_ASSUME` are each a single expression.
+// This is useful so we can use them  in places that require an expression, such as
+// in a constructor initializer list.
 
 #include <__assert>
 #include <cassert>
@@ -27,7 +19,14 @@ void f() {
   return _LIBCPP_ASSERT(true, "message");
 }
 
+void g() {
+  int i = (_LIBCPP_ASSUME(true), 3);
+  assert(i == 3);
+  return _LIBCPP_ASSUME(true);
+}
+
 int main(int, char**) {
   f();
+  g();
   return 0;
 }

diff  --git a/libcxx/test/libcxx/containers/sequences/array/array.zero/assert.back.pass.cpp b/libcxx/test/libcxx/containers/sequences/array/array.zero/assert.back.pass.cpp
index 467f6cd9982b2e..331f5ad7dfcfd2 100644
--- a/libcxx/test/libcxx/containers/sequences/array/array.zero/assert.back.pass.cpp
+++ b/libcxx/test/libcxx/containers/sequences/array/array.zero/assert.back.pass.cpp
@@ -8,8 +8,8 @@
 
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 // test that array<T, 0>::back() triggers an assertion
 

diff  --git a/libcxx/test/libcxx/containers/sequences/array/array.zero/assert.front.pass.cpp b/libcxx/test/libcxx/containers/sequences/array/array.zero/assert.front.pass.cpp
index a0045e1bc754c3..6bf1390b9871be 100644
--- a/libcxx/test/libcxx/containers/sequences/array/array.zero/assert.front.pass.cpp
+++ b/libcxx/test/libcxx/containers/sequences/array/array.zero/assert.front.pass.cpp
@@ -8,8 +8,8 @@
 
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 // test that array<T, 0>::back() triggers an assertion
 

diff  --git a/libcxx/test/libcxx/containers/sequences/array/array.zero/assert.subscript.pass.cpp b/libcxx/test/libcxx/containers/sequences/array/array.zero/assert.subscript.pass.cpp
index a114fb74bba971..d4ea030955ca87 100644
--- a/libcxx/test/libcxx/containers/sequences/array/array.zero/assert.subscript.pass.cpp
+++ b/libcxx/test/libcxx/containers/sequences/array/array.zero/assert.subscript.pass.cpp
@@ -8,8 +8,8 @@
 
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 // test that array<T, 0>::operator[] triggers an assertion
 

diff  --git a/libcxx/test/libcxx/containers/sequences/deque/assert.pop_back.empty.pass.cpp b/libcxx/test/libcxx/containers/sequences/deque/assert.pop_back.empty.pass.cpp
index 7537053099d210..8be0b3e5b11a0e 100644
--- a/libcxx/test/libcxx/containers/sequences/deque/assert.pop_back.empty.pass.cpp
+++ b/libcxx/test/libcxx/containers/sequences/deque/assert.pop_back.empty.pass.cpp
@@ -12,8 +12,8 @@
 
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 #include <deque>
 

diff  --git a/libcxx/test/libcxx/containers/sequences/list/list.modifiers/assert.erase_iter.end.pass.cpp b/libcxx/test/libcxx/containers/sequences/list/list.modifiers/assert.erase_iter.end.pass.cpp
index 22847b1ee001e7..dd41f2d250fae6 100644
--- a/libcxx/test/libcxx/containers/sequences/list/list.modifiers/assert.erase_iter.end.pass.cpp
+++ b/libcxx/test/libcxx/containers/sequences/list/list.modifiers/assert.erase_iter.end.pass.cpp
@@ -12,8 +12,8 @@
 
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 #include <list>
 

diff  --git a/libcxx/test/libcxx/containers/sequences/list/list.modifiers/assert.pop_back.empty.pass.cpp b/libcxx/test/libcxx/containers/sequences/list/list.modifiers/assert.pop_back.empty.pass.cpp
index 4519725878e4b0..8d1a069d04b145 100644
--- a/libcxx/test/libcxx/containers/sequences/list/list.modifiers/assert.pop_back.empty.pass.cpp
+++ b/libcxx/test/libcxx/containers/sequences/list/list.modifiers/assert.pop_back.empty.pass.cpp
@@ -12,8 +12,8 @@
 
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 #include <list>
 #include <cassert>

diff  --git a/libcxx/test/libcxx/containers/sequences/vector/assert.back.empty.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/assert.back.empty.pass.cpp
index 42fd9bc8b8f00d..e59c03077c767b 100644
--- a/libcxx/test/libcxx/containers/sequences/vector/assert.back.empty.pass.cpp
+++ b/libcxx/test/libcxx/containers/sequences/vector/assert.back.empty.pass.cpp
@@ -12,8 +12,8 @@
 
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 #include <vector>
 #include <cassert>

diff  --git a/libcxx/test/libcxx/containers/sequences/vector/assert.cback.empty.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/assert.cback.empty.pass.cpp
index 7d8f6e3c3fc9f0..45e1d590e95e32 100644
--- a/libcxx/test/libcxx/containers/sequences/vector/assert.cback.empty.pass.cpp
+++ b/libcxx/test/libcxx/containers/sequences/vector/assert.cback.empty.pass.cpp
@@ -12,8 +12,8 @@
 
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 #include <vector>
 

diff  --git a/libcxx/test/libcxx/containers/sequences/vector/assert.cfront.empty.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/assert.cfront.empty.pass.cpp
index 5dc486711366a1..6ea07195396796 100644
--- a/libcxx/test/libcxx/containers/sequences/vector/assert.cfront.empty.pass.cpp
+++ b/libcxx/test/libcxx/containers/sequences/vector/assert.cfront.empty.pass.cpp
@@ -12,8 +12,8 @@
 
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 #include <vector>
 

diff  --git a/libcxx/test/libcxx/containers/sequences/vector/assert.cindex.oob.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/assert.cindex.oob.pass.cpp
index b25c766dc59ee8..4a04df1c0bf26c 100644
--- a/libcxx/test/libcxx/containers/sequences/vector/assert.cindex.oob.pass.cpp
+++ b/libcxx/test/libcxx/containers/sequences/vector/assert.cindex.oob.pass.cpp
@@ -12,8 +12,8 @@
 
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 #include <vector>
 #include <cassert>

diff  --git a/libcxx/test/libcxx/containers/sequences/vector/assert.front.empty.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/assert.front.empty.pass.cpp
index 0b3b3803441479..e0b18bb453503f 100644
--- a/libcxx/test/libcxx/containers/sequences/vector/assert.front.empty.pass.cpp
+++ b/libcxx/test/libcxx/containers/sequences/vector/assert.front.empty.pass.cpp
@@ -12,8 +12,8 @@
 
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 #include <vector>
 #include <cassert>

diff  --git a/libcxx/test/libcxx/containers/sequences/vector/assert.index.oob.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/assert.index.oob.pass.cpp
index 12ad7a2f0193ed..480b6a311c871a 100644
--- a/libcxx/test/libcxx/containers/sequences/vector/assert.index.oob.pass.cpp
+++ b/libcxx/test/libcxx/containers/sequences/vector/assert.index.oob.pass.cpp
@@ -12,8 +12,8 @@
 
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 #include <vector>
 #include <cassert>

diff  --git a/libcxx/test/libcxx/containers/sequences/vector/assert.pop_back.empty.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/assert.pop_back.empty.pass.cpp
index 5a7a90ead40ad4..54f08dcd5a563c 100644
--- a/libcxx/test/libcxx/containers/sequences/vector/assert.pop_back.empty.pass.cpp
+++ b/libcxx/test/libcxx/containers/sequences/vector/assert.pop_back.empty.pass.cpp
@@ -12,8 +12,8 @@
 
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 #include <vector>
 

diff  --git a/libcxx/test/libcxx/containers/unord/unord.map/assert.bucket.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.map/assert.bucket.pass.cpp
index e581b0871aec96..04c15b43d1706a 100644
--- a/libcxx/test/libcxx/containers/unord/unord.map/assert.bucket.pass.cpp
+++ b/libcxx/test/libcxx/containers/unord/unord.map/assert.bucket.pass.cpp
@@ -12,8 +12,8 @@
 
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 #include <unordered_map>
 #include <string>

diff  --git a/libcxx/test/libcxx/containers/unord/unord.map/assert.bucket_size.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.map/assert.bucket_size.pass.cpp
index 4a94b87b339371..49e256ecd2c5d6 100644
--- a/libcxx/test/libcxx/containers/unord/unord.map/assert.bucket_size.pass.cpp
+++ b/libcxx/test/libcxx/containers/unord/unord.map/assert.bucket_size.pass.cpp
@@ -16,8 +16,8 @@
 
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 #include <unordered_map>
 #include <string>

diff  --git a/libcxx/test/libcxx/containers/unord/unord.map/assert.max_load_factor.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.map/assert.max_load_factor.pass.cpp
index 22b7a6e49b28ac..1aac93761b5989 100644
--- a/libcxx/test/libcxx/containers/unord/unord.map/assert.max_load_factor.pass.cpp
+++ b/libcxx/test/libcxx/containers/unord/unord.map/assert.max_load_factor.pass.cpp
@@ -17,8 +17,8 @@
 
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 #include <unordered_map>
 #include <string>

diff  --git a/libcxx/test/libcxx/containers/unord/unord.multimap/assert.bucket.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multimap/assert.bucket.pass.cpp
index f1b315169c3497..c77ce27680ba84 100644
--- a/libcxx/test/libcxx/containers/unord/unord.multimap/assert.bucket.pass.cpp
+++ b/libcxx/test/libcxx/containers/unord/unord.multimap/assert.bucket.pass.cpp
@@ -16,8 +16,8 @@
 
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 #include <unordered_map>
 #include <string>

diff  --git a/libcxx/test/libcxx/containers/unord/unord.multimap/assert.bucket_size.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multimap/assert.bucket_size.pass.cpp
index a1edf04838b63b..4d11e812de5f36 100644
--- a/libcxx/test/libcxx/containers/unord/unord.multimap/assert.bucket_size.pass.cpp
+++ b/libcxx/test/libcxx/containers/unord/unord.multimap/assert.bucket_size.pass.cpp
@@ -16,8 +16,8 @@
 
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 #include <unordered_map>
 #include <string>

diff  --git a/libcxx/test/libcxx/containers/unord/unord.multimap/assert.max_load_factor.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multimap/assert.max_load_factor.pass.cpp
index 0d721531b3b358..1a374f3ff47311 100644
--- a/libcxx/test/libcxx/containers/unord/unord.multimap/assert.max_load_factor.pass.cpp
+++ b/libcxx/test/libcxx/containers/unord/unord.multimap/assert.max_load_factor.pass.cpp
@@ -17,8 +17,8 @@
 
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 #include <unordered_map>
 #include <string>

diff  --git a/libcxx/test/libcxx/containers/unord/unord.multiset/assert.bucket.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multiset/assert.bucket.pass.cpp
index 4d2d9ebc6faf2d..f652e46b46a151 100644
--- a/libcxx/test/libcxx/containers/unord/unord.multiset/assert.bucket.pass.cpp
+++ b/libcxx/test/libcxx/containers/unord/unord.multiset/assert.bucket.pass.cpp
@@ -16,8 +16,8 @@
 
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 #include <unordered_set>
 

diff  --git a/libcxx/test/libcxx/containers/unord/unord.multiset/assert.bucket_size.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multiset/assert.bucket_size.pass.cpp
index da9902ee835b98..61da50f9e88f1a 100644
--- a/libcxx/test/libcxx/containers/unord/unord.multiset/assert.bucket_size.pass.cpp
+++ b/libcxx/test/libcxx/containers/unord/unord.multiset/assert.bucket_size.pass.cpp
@@ -16,8 +16,8 @@
 
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 #include <unordered_set>
 

diff  --git a/libcxx/test/libcxx/containers/unord/unord.multiset/assert.max_load_factor.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multiset/assert.max_load_factor.pass.cpp
index 191a5149803ffb..0574334853abe5 100644
--- a/libcxx/test/libcxx/containers/unord/unord.multiset/assert.max_load_factor.pass.cpp
+++ b/libcxx/test/libcxx/containers/unord/unord.multiset/assert.max_load_factor.pass.cpp
@@ -17,8 +17,8 @@
 
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 #include <unordered_set>
 

diff  --git a/libcxx/test/libcxx/containers/unord/unord.set/assert.bucket.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.set/assert.bucket.pass.cpp
index 69d473a45aed5a..4cee10bf0b0db2 100644
--- a/libcxx/test/libcxx/containers/unord/unord.set/assert.bucket.pass.cpp
+++ b/libcxx/test/libcxx/containers/unord/unord.set/assert.bucket.pass.cpp
@@ -16,8 +16,8 @@
 
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 #include <unordered_set>
 

diff  --git a/libcxx/test/libcxx/containers/unord/unord.set/assert.bucket_size.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.set/assert.bucket_size.pass.cpp
index 4a1788e839a34e..3192221a536e82 100644
--- a/libcxx/test/libcxx/containers/unord/unord.set/assert.bucket_size.pass.cpp
+++ b/libcxx/test/libcxx/containers/unord/unord.set/assert.bucket_size.pass.cpp
@@ -16,8 +16,8 @@
 
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 #include <unordered_set>
 

diff  --git a/libcxx/test/libcxx/containers/unord/unord.set/assert.max_load_factor.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.set/assert.max_load_factor.pass.cpp
index e1afe2613253ea..77ec1557fd1255 100644
--- a/libcxx/test/libcxx/containers/unord/unord.set/assert.max_load_factor.pass.cpp
+++ b/libcxx/test/libcxx/containers/unord/unord.set/assert.max_load_factor.pass.cpp
@@ -17,8 +17,8 @@
 
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 #include <unordered_set>
 

diff  --git a/libcxx/test/libcxx/containers/views/views.span/span.cons/assert.iter_sent.pass.cpp b/libcxx/test/libcxx/containers/views/views.span/span.cons/assert.iter_sent.pass.cpp
index 3ca24707e84003..bfcf7cbddf938d 100644
--- a/libcxx/test/libcxx/containers/views/views.span/span.cons/assert.iter_sent.pass.cpp
+++ b/libcxx/test/libcxx/containers/views/views.span/span.cons/assert.iter_sent.pass.cpp
@@ -19,8 +19,8 @@
 // Check that we ensure that `[it, sent)` is a valid range.
 
 // REQUIRES: has-unix-headers
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 #include <array>
 #include <span>

diff  --git a/libcxx/test/libcxx/containers/views/views.span/span.cons/assert.iter_size.pass.cpp b/libcxx/test/libcxx/containers/views/views.span/span.cons/assert.iter_size.pass.cpp
index f48c1860d1ab50..ae7594c4733098 100644
--- a/libcxx/test/libcxx/containers/views/views.span/span.cons/assert.iter_size.pass.cpp
+++ b/libcxx/test/libcxx/containers/views/views.span/span.cons/assert.iter_size.pass.cpp
@@ -16,8 +16,8 @@
 // dynamic_extent version.
 
 // REQUIRES: has-unix-headers
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 #include <array>
 #include <span>

diff  --git a/libcxx/test/libcxx/containers/views/views.span/span.cons/assert.other_span.pass.cpp b/libcxx/test/libcxx/containers/views/views.span/span.cons/assert.other_span.pass.cpp
index ab9c12fd23dd11..09a743f3f5d233 100644
--- a/libcxx/test/libcxx/containers/views/views.span/span.cons/assert.other_span.pass.cpp
+++ b/libcxx/test/libcxx/containers/views/views.span/span.cons/assert.other_span.pass.cpp
@@ -14,8 +14,8 @@
 // Check that we ensure `other.size() == Extent`.
 
 // REQUIRES: has-unix-headers
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 #include <array>
 #include <span>

diff  --git a/libcxx/test/libcxx/containers/views/views.span/span.cons/assert.range.pass.cpp b/libcxx/test/libcxx/containers/views/views.span/span.cons/assert.range.pass.cpp
index 2236de65505f4e..3ba57546a8b256 100644
--- a/libcxx/test/libcxx/containers/views/views.span/span.cons/assert.range.pass.cpp
+++ b/libcxx/test/libcxx/containers/views/views.span/span.cons/assert.range.pass.cpp
@@ -14,8 +14,8 @@
 // Check that we ensure `size(r) == Extent`.
 
 // REQUIRES: has-unix-headers
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 #include <span>
 #include <vector>

diff  --git a/libcxx/test/libcxx/containers/views/views.span/span.elem/assert.back.pass.cpp b/libcxx/test/libcxx/containers/views/views.span/span.elem/assert.back.pass.cpp
index 95cc55842a506c..e0c8f04e3a6174 100644
--- a/libcxx/test/libcxx/containers/views/views.span/span.elem/assert.back.pass.cpp
+++ b/libcxx/test/libcxx/containers/views/views.span/span.elem/assert.back.pass.cpp
@@ -14,8 +14,8 @@
 // Make sure that accessing a span out-of-bounds triggers an assertion.
 
 // REQUIRES: has-unix-headers
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 #include <array>
 #include <span>

diff  --git a/libcxx/test/libcxx/containers/views/views.span/span.elem/assert.front.pass.cpp b/libcxx/test/libcxx/containers/views/views.span/span.elem/assert.front.pass.cpp
index df750a7689cea4..27b5940d65a1a8 100644
--- a/libcxx/test/libcxx/containers/views/views.span/span.elem/assert.front.pass.cpp
+++ b/libcxx/test/libcxx/containers/views/views.span/span.elem/assert.front.pass.cpp
@@ -14,8 +14,8 @@
 // Make sure that accessing a span out-of-bounds triggers an assertion.
 
 // REQUIRES: has-unix-headers
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 #include <array>
 #include <span>

diff  --git a/libcxx/test/libcxx/containers/views/views.span/span.elem/assert.op_idx.pass.cpp b/libcxx/test/libcxx/containers/views/views.span/span.elem/assert.op_idx.pass.cpp
index 12a8b2372e9842..659e1ff97bae45 100644
--- a/libcxx/test/libcxx/containers/views/views.span/span.elem/assert.op_idx.pass.cpp
+++ b/libcxx/test/libcxx/containers/views/views.span/span.elem/assert.op_idx.pass.cpp
@@ -14,8 +14,8 @@
 // Make sure that accessing a span out-of-bounds triggers an assertion.
 
 // REQUIRES: has-unix-headers
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 #include <array>
 #include <span>

diff  --git a/libcxx/test/libcxx/containers/views/views.span/span.sub/assert.first.pass.cpp b/libcxx/test/libcxx/containers/views/views.span/span.sub/assert.first.pass.cpp
index 733f9fd54fd304..4a960667e8f197 100644
--- a/libcxx/test/libcxx/containers/views/views.span/span.sub/assert.first.pass.cpp
+++ b/libcxx/test/libcxx/containers/views/views.span/span.sub/assert.first.pass.cpp
@@ -14,8 +14,8 @@
 // Make sure that creating a sub-span with an incorrect number of elements triggers an assertion.
 
 // REQUIRES: has-unix-headers
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 #include <array>
 #include <span>

diff  --git a/libcxx/test/libcxx/containers/views/views.span/span.sub/assert.last.pass.cpp b/libcxx/test/libcxx/containers/views/views.span/span.sub/assert.last.pass.cpp
index 6ec90ad4ed1a34..113bcfddf2fdd7 100644
--- a/libcxx/test/libcxx/containers/views/views.span/span.sub/assert.last.pass.cpp
+++ b/libcxx/test/libcxx/containers/views/views.span/span.sub/assert.last.pass.cpp
@@ -14,8 +14,8 @@
 // Make sure that creating a sub-span with an incorrect number of elements triggers an assertion.
 
 // REQUIRES: has-unix-headers
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 #include <array>
 #include <span>

diff  --git a/libcxx/test/libcxx/containers/views/views.span/span.sub/assert.subspan.pass.cpp b/libcxx/test/libcxx/containers/views/views.span/span.sub/assert.subspan.pass.cpp
index f7f17365fec1aa..7f0728b131704e 100644
--- a/libcxx/test/libcxx/containers/views/views.span/span.sub/assert.subspan.pass.cpp
+++ b/libcxx/test/libcxx/containers/views/views.span/span.sub/assert.subspan.pass.cpp
@@ -22,8 +22,8 @@
 // Make sure that creating a sub-span with an incorrect number of elements triggers an assertion.
 
 // REQUIRES: has-unix-headers
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 #include <array>
 #include <span>

diff  --git a/libcxx/test/libcxx/debug/debug.assertions-enabled.compile.pass.cpp b/libcxx/test/libcxx/debug/debug.assertions-enabled.compile.pass.cpp
deleted file mode 100644
index 21d4c50920efce..00000000000000
--- a/libcxx/test/libcxx/debug/debug.assertions-enabled.compile.pass.cpp
+++ /dev/null
@@ -1,17 +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
-//
-//===----------------------------------------------------------------------===//
-
-// This test ensures that assertions are enabled by default when the debug mode is enabled.
-
-// REQUIRES: libcpp-has-legacy-debug-mode
-
-#include <version>
-
-#if !defined(_LIBCPP_ENABLE_ASSERTIONS) || _LIBCPP_ENABLE_ASSERTIONS == 0
-#   error "Assertions should be enabled automatically when the debug mode is enabled"
-#endif

diff  --git a/libcxx/test/libcxx/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/assert.deallocate.pass.cpp b/libcxx/test/libcxx/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/assert.deallocate.pass.cpp
index c68e6a3bee5446..7a650c79fc5bf5 100644
--- a/libcxx/test/libcxx/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/assert.deallocate.pass.cpp
+++ b/libcxx/test/libcxx/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/assert.deallocate.pass.cpp
@@ -14,9 +14,8 @@
 
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
-
 // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
 
 #include <experimental/memory_resource>

diff  --git a/libcxx/test/libcxx/experimental/memory/memory.resource.adaptor/memory.resource.adaptor.mem/assert.deallocate.pass.cpp b/libcxx/test/libcxx/experimental/memory/memory.resource.adaptor/memory.resource.adaptor.mem/assert.deallocate.pass.cpp
index a2dc95a9e51a03..d2163b0f7dfa84 100644
--- a/libcxx/test/libcxx/experimental/memory/memory.resource.adaptor/memory.resource.adaptor.mem/assert.deallocate.pass.cpp
+++ b/libcxx/test/libcxx/experimental/memory/memory.resource.adaptor/memory.resource.adaptor.mem/assert.deallocate.pass.cpp
@@ -14,9 +14,8 @@
 
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
-
 // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
 
 #include <experimental/memory_resource>

diff  --git a/libcxx/test/libcxx/input.output/filesystems/class.path/path.itr/assert.iterator.pass.cpp b/libcxx/test/libcxx/input.output/filesystems/class.path/path.itr/assert.iterator.pass.cpp
index c397f23fc07337..28b72ba6f8a6b5 100644
--- a/libcxx/test/libcxx/input.output/filesystems/class.path/path.itr/assert.iterator.pass.cpp
+++ b/libcxx/test/libcxx/input.output/filesystems/class.path/path.itr/assert.iterator.pass.cpp
@@ -8,8 +8,8 @@
 
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 // <filesystem>
 

diff  --git a/libcxx/test/libcxx/iterators/assert.advance.pass.cpp b/libcxx/test/libcxx/iterators/assert.advance.pass.cpp
index b455767b024ae0..611109814e49fb 100644
--- a/libcxx/test/libcxx/iterators/assert.advance.pass.cpp
+++ b/libcxx/test/libcxx/iterators/assert.advance.pass.cpp
@@ -8,8 +8,8 @@
 
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 // <list>
 

diff  --git a/libcxx/test/libcxx/iterators/assert.next.pass.cpp b/libcxx/test/libcxx/iterators/assert.next.pass.cpp
index 992a406cdce890..2388f50542af77 100644
--- a/libcxx/test/libcxx/iterators/assert.next.pass.cpp
+++ b/libcxx/test/libcxx/iterators/assert.next.pass.cpp
@@ -7,9 +7,8 @@
 //===----------------------------------------------------------------------===//
 
 // REQUIRES: has-unix-headers
-// UNSUPPORTED: c++03
+// UNSUPPORTED: c++03, !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 // <list>
 

diff  --git a/libcxx/test/libcxx/iterators/assert.prev.pass.cpp b/libcxx/test/libcxx/iterators/assert.prev.pass.cpp
index f1903cbe156111..1feaf8b2470e8e 100644
--- a/libcxx/test/libcxx/iterators/assert.prev.pass.cpp
+++ b/libcxx/test/libcxx/iterators/assert.prev.pass.cpp
@@ -8,8 +8,8 @@
 
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 // <list>
 

diff  --git a/libcxx/test/libcxx/iterators/bounded_iter/dereference.pass.cpp b/libcxx/test/libcxx/iterators/bounded_iter/dereference.pass.cpp
index 04761fa91fdeb3..51a5eab842c920 100644
--- a/libcxx/test/libcxx/iterators/bounded_iter/dereference.pass.cpp
+++ b/libcxx/test/libcxx/iterators/bounded_iter/dereference.pass.cpp
@@ -13,8 +13,8 @@
 
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 #include <iterator>
 

diff  --git a/libcxx/test/libcxx/ranges/range.adaptors/range.drop.while/assert.begin.pass.cpp b/libcxx/test/libcxx/ranges/range.adaptors/range.drop.while/assert.begin.pass.cpp
index 10d96a623c7b87..887fa41c3d57eb 100644
--- a/libcxx/test/libcxx/ranges/range.adaptors/range.drop.while/assert.begin.pass.cpp
+++ b/libcxx/test/libcxx/ranges/range.adaptors/range.drop.while/assert.begin.pass.cpp
@@ -13,8 +13,8 @@
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03, c++11, c++14, c++17
 // UNSUPPORTED: no-exceptions
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 #include <ranges>
 

diff  --git a/libcxx/test/libcxx/ranges/range.adaptors/range.lazy.split/range.lazy.split.inner/assert.equal.pass.cpp b/libcxx/test/libcxx/ranges/range.adaptors/range.lazy.split/range.lazy.split.inner/assert.equal.pass.cpp
index 81843cf8961693..a181350a86cfa9 100644
--- a/libcxx/test/libcxx/ranges/range.adaptors/range.lazy.split/range.lazy.split.inner/assert.equal.pass.cpp
+++ b/libcxx/test/libcxx/ranges/range.adaptors/range.lazy.split/range.lazy.split.inner/assert.equal.pass.cpp
@@ -7,8 +7,9 @@
 //===----------------------------------------------------------------------===//
 
 // REQUIRES: has-unix-headers
-// UNSUPPORTED: c++03, c++11, c++14, c++17, !libcpp-has-legacy-debug-mode
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
+// XFAIL: availability-verbose_abort-missing
 
 // <ranges>
 

diff  --git a/libcxx/test/libcxx/ranges/range.adaptors/range.lazy.split/range.lazy.split.outer/assert.equal.pass.cpp b/libcxx/test/libcxx/ranges/range.adaptors/range.lazy.split/range.lazy.split.outer/assert.equal.pass.cpp
index d584ba5c9fa91d..c03ee8649d9462 100644
--- a/libcxx/test/libcxx/ranges/range.adaptors/range.lazy.split/range.lazy.split.outer/assert.equal.pass.cpp
+++ b/libcxx/test/libcxx/ranges/range.adaptors/range.lazy.split/range.lazy.split.outer/assert.equal.pass.cpp
@@ -7,8 +7,9 @@
 //===----------------------------------------------------------------------===//
 
 // REQUIRES: has-unix-headers
-// UNSUPPORTED: c++03, c++11, c++14, c++17, !libcpp-has-legacy-debug-mode
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
+// XFAIL: availability-verbose_abort-missing
 
 // <ranges>
 

diff  --git a/libcxx/test/libcxx/strings/basic.string/string.access/assert.back.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.access/assert.back.pass.cpp
index 522f606bbc407d..3e5d5b2f141625 100644
--- a/libcxx/test/libcxx/strings/basic.string/string.access/assert.back.pass.cpp
+++ b/libcxx/test/libcxx/strings/basic.string/string.access/assert.back.pass.cpp
@@ -12,8 +12,8 @@
 
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 #include <string>
 

diff  --git a/libcxx/test/libcxx/strings/basic.string/string.access/assert.cback.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.access/assert.cback.pass.cpp
index 94a4351342cb16..45415b988c66de 100644
--- a/libcxx/test/libcxx/strings/basic.string/string.access/assert.cback.pass.cpp
+++ b/libcxx/test/libcxx/strings/basic.string/string.access/assert.cback.pass.cpp
@@ -12,8 +12,8 @@
 
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 #include <string>
 

diff  --git a/libcxx/test/libcxx/strings/basic.string/string.access/assert.cfront.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.access/assert.cfront.pass.cpp
index 5dd987b4a358b1..e4c7fe9935f07c 100644
--- a/libcxx/test/libcxx/strings/basic.string/string.access/assert.cfront.pass.cpp
+++ b/libcxx/test/libcxx/strings/basic.string/string.access/assert.cfront.pass.cpp
@@ -12,8 +12,8 @@
 
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 #include <string>
 

diff  --git a/libcxx/test/libcxx/strings/basic.string/string.access/assert.cindex.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.access/assert.cindex.pass.cpp
index 9f583fc06c70b9..d9d3230f905cbf 100644
--- a/libcxx/test/libcxx/strings/basic.string/string.access/assert.cindex.pass.cpp
+++ b/libcxx/test/libcxx/strings/basic.string/string.access/assert.cindex.pass.cpp
@@ -12,8 +12,8 @@
 
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 #include <string>
 #include <cassert>

diff  --git a/libcxx/test/libcxx/strings/basic.string/string.access/assert.front.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.access/assert.front.pass.cpp
index c7c8c8d9064d3b..a09dea537a144e 100644
--- a/libcxx/test/libcxx/strings/basic.string/string.access/assert.front.pass.cpp
+++ b/libcxx/test/libcxx/strings/basic.string/string.access/assert.front.pass.cpp
@@ -12,8 +12,8 @@
 
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 #include <string>
 #include <cassert>

diff  --git a/libcxx/test/libcxx/strings/basic.string/string.access/assert.index.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.access/assert.index.pass.cpp
index 9a3e6b2c21d715..2660bf42d2b154 100644
--- a/libcxx/test/libcxx/strings/basic.string/string.access/assert.index.pass.cpp
+++ b/libcxx/test/libcxx/strings/basic.string/string.access/assert.index.pass.cpp
@@ -12,8 +12,8 @@
 
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 #include <string>
 #include <cassert>

diff  --git a/libcxx/test/libcxx/strings/basic.string/string.modifiers/assert.erase_iter.null.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.modifiers/assert.erase_iter.null.pass.cpp
index 582986cb741e87..7622b653271cb4 100644
--- a/libcxx/test/libcxx/strings/basic.string/string.modifiers/assert.erase_iter.null.pass.cpp
+++ b/libcxx/test/libcxx/strings/basic.string/string.modifiers/assert.erase_iter.null.pass.cpp
@@ -12,8 +12,8 @@
 
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 #include <string>
 

diff  --git a/libcxx/test/libcxx/strings/basic.string/string.modifiers/assert.pop_back.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.modifiers/assert.pop_back.pass.cpp
index 8fb734c6b62da4..a67ea588149d79 100644
--- a/libcxx/test/libcxx/strings/basic.string/string.modifiers/assert.pop_back.pass.cpp
+++ b/libcxx/test/libcxx/strings/basic.string/string.modifiers/assert.pop_back.pass.cpp
@@ -12,8 +12,8 @@
 
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 #include <string>
 

diff  --git a/libcxx/test/libcxx/strings/string.view/assert.ctor.length.pass.cpp b/libcxx/test/libcxx/strings/string.view/assert.ctor.length.pass.cpp
index 7d7ea07389880b..8a4e832b263091 100644
--- a/libcxx/test/libcxx/strings/string.view/assert.ctor.length.pass.cpp
+++ b/libcxx/test/libcxx/strings/string.view/assert.ctor.length.pass.cpp
@@ -9,8 +9,8 @@
 // REQUIRES: has-unix-headers
 
 // UNSUPPORTED: c++03, c++11
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 // Construct a string_view from an invalid length
 // constexpr basic_string_view( const _CharT* s, size_type len )

diff  --git a/libcxx/test/libcxx/strings/string.view/assert.ctor.pointer.pass.cpp b/libcxx/test/libcxx/strings/string.view/assert.ctor.pointer.pass.cpp
index 16acfd6a1072d7..bc4ce88973f10c 100644
--- a/libcxx/test/libcxx/strings/string.view/assert.ctor.pointer.pass.cpp
+++ b/libcxx/test/libcxx/strings/string.view/assert.ctor.pointer.pass.cpp
@@ -7,11 +7,9 @@
 //===----------------------------------------------------------------------===//
 
 // REQUIRES: has-unix-headers
-// UNSUPPORTED: c++11, c++14
-
-// UNSUPPORTED: c++03
+// UNSUPPORTED: c++03, c++11, c++14
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 // Construct a string_view from a null pointer
 // constexpr basic_string_view( const CharT* s );

diff  --git a/libcxx/test/libcxx/thread/futures/futures.promise/assert.set_exception.pass.cpp b/libcxx/test/libcxx/thread/futures/futures.promise/assert.set_exception.pass.cpp
index f9a97d5c0a53c7..f4ae915b57964c 100644
--- a/libcxx/test/libcxx/thread/futures/futures.promise/assert.set_exception.pass.cpp
+++ b/libcxx/test/libcxx/thread/futures/futures.promise/assert.set_exception.pass.cpp
@@ -8,8 +8,8 @@
 
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03, no-threads
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 // <future>
 

diff  --git a/libcxx/test/libcxx/thread/futures/futures.promise/assert.set_exception_at_thread_exit.pass.cpp b/libcxx/test/libcxx/thread/futures/futures.promise/assert.set_exception_at_thread_exit.pass.cpp
index de397342f34038..1570474cd99397 100644
--- a/libcxx/test/libcxx/thread/futures/futures.promise/assert.set_exception_at_thread_exit.pass.cpp
+++ b/libcxx/test/libcxx/thread/futures/futures.promise/assert.set_exception_at_thread_exit.pass.cpp
@@ -8,8 +8,8 @@
 
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03, no-threads
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 // <future>
 

diff  --git a/libcxx/test/libcxx/thread/thread.latch/assert.arrive_and_wait.pass.cpp b/libcxx/test/libcxx/thread/thread.latch/assert.arrive_and_wait.pass.cpp
index d00540cb9cdab7..128f1a718aee56 100644
--- a/libcxx/test/libcxx/thread/thread.latch/assert.arrive_and_wait.pass.cpp
+++ b/libcxx/test/libcxx/thread/thread.latch/assert.arrive_and_wait.pass.cpp
@@ -17,8 +17,8 @@
 // Make sure that calling arrive_and_wait with a negative value triggers an assertion.
 
 // REQUIRES: has-unix-headers
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 #include <latch>
 

diff  --git a/libcxx/test/libcxx/thread/thread.latch/assert.count_down.pass.cpp b/libcxx/test/libcxx/thread/thread.latch/assert.count_down.pass.cpp
index abd16017983eb4..eff5a66fa28a49 100644
--- a/libcxx/test/libcxx/thread/thread.latch/assert.count_down.pass.cpp
+++ b/libcxx/test/libcxx/thread/thread.latch/assert.count_down.pass.cpp
@@ -18,8 +18,8 @@
 // higher than the internal counter triggers an assertion.
 
 // REQUIRES: has-unix-headers
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 #include <latch>
 

diff  --git a/libcxx/test/libcxx/thread/thread.latch/assert.ctor.pass.cpp b/libcxx/test/libcxx/thread/thread.latch/assert.ctor.pass.cpp
index dbd582f6e36d87..ba55cf302f80f0 100644
--- a/libcxx/test/libcxx/thread/thread.latch/assert.ctor.pass.cpp
+++ b/libcxx/test/libcxx/thread/thread.latch/assert.ctor.pass.cpp
@@ -17,8 +17,8 @@
 // Make sure that calling latch with a negative value triggers an assertion
 
 // REQUIRES: has-unix-headers
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 #include <latch>
 

diff  --git a/libcxx/test/libcxx/utilities/assert.exception_guard.no_exceptions.pass.cpp b/libcxx/test/libcxx/utilities/assert.exception_guard.no_exceptions.pass.cpp
index 7b3951dd70701c..9e4eba901f1122 100644
--- a/libcxx/test/libcxx/utilities/assert.exception_guard.no_exceptions.pass.cpp
+++ b/libcxx/test/libcxx/utilities/assert.exception_guard.no_exceptions.pass.cpp
@@ -6,12 +6,11 @@
 //
 //===----------------------------------------------------------------------===//
 
-// UNSUPPORTED: c++03
-
 // REQUIRES: has-unix-headers
+// UNSUPPORTED: c++03
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -fno-exceptions -D_LIBCPP_ENABLE_ASSERTIONS=1
-
+// ADDITIONAL_COMPILE_FLAGS: -fno-exceptions
 // ADDITIONAL_COMPILE_FLAGS: -Wno-private-header
 
 #include <__utility/exception_guard.h>

diff  --git a/libcxx/test/libcxx/utilities/expected/expected.expected/assert.arrow.pass.cpp b/libcxx/test/libcxx/utilities/expected/expected.expected/assert.arrow.pass.cpp
index 3dd1ed6b4b6d8d..fc065a4591357f 100644
--- a/libcxx/test/libcxx/utilities/expected/expected.expected/assert.arrow.pass.cpp
+++ b/libcxx/test/libcxx/utilities/expected/expected.expected/assert.arrow.pass.cpp
@@ -8,8 +8,8 @@
 
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 // constexpr const T* operator->() const noexcept;
 // constexpr T* operator->() noexcept;

diff  --git a/libcxx/test/libcxx/utilities/expected/expected.expected/assert.deref.pass.cpp b/libcxx/test/libcxx/utilities/expected/expected.expected/assert.deref.pass.cpp
index 04f1a7dfd8cce2..4b36f8bf7f9157 100644
--- a/libcxx/test/libcxx/utilities/expected/expected.expected/assert.deref.pass.cpp
+++ b/libcxx/test/libcxx/utilities/expected/expected.expected/assert.deref.pass.cpp
@@ -8,8 +8,8 @@
 
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 // constexpr const T& operator*() const & noexcept;
 // constexpr T& operator*() & noexcept;

diff  --git a/libcxx/test/libcxx/utilities/expected/expected.expected/assert.error.pass.cpp b/libcxx/test/libcxx/utilities/expected/expected.expected/assert.error.pass.cpp
index 274e207ab4dce1..af9c02a32f5558 100644
--- a/libcxx/test/libcxx/utilities/expected/expected.expected/assert.error.pass.cpp
+++ b/libcxx/test/libcxx/utilities/expected/expected.expected/assert.error.pass.cpp
@@ -8,8 +8,8 @@
 
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 // constexpr const E& error() const & noexcept;
 // constexpr E& error() & noexcept;

diff  --git a/libcxx/test/libcxx/utilities/expected/expected.void/assert.deref.pass.cpp b/libcxx/test/libcxx/utilities/expected/expected.void/assert.deref.pass.cpp
index 90757f3a527cef..574c2d828391f6 100644
--- a/libcxx/test/libcxx/utilities/expected/expected.void/assert.deref.pass.cpp
+++ b/libcxx/test/libcxx/utilities/expected/expected.void/assert.deref.pass.cpp
@@ -8,8 +8,8 @@
 
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 // constexpr void operator*() const noexcept;
 //

diff  --git a/libcxx/test/libcxx/utilities/expected/expected.void/assert.error.pass.cpp b/libcxx/test/libcxx/utilities/expected/expected.void/assert.error.pass.cpp
index 211635dae1bf26..43eb517858490f 100644
--- a/libcxx/test/libcxx/utilities/expected/expected.void/assert.error.pass.cpp
+++ b/libcxx/test/libcxx/utilities/expected/expected.void/assert.error.pass.cpp
@@ -8,8 +8,8 @@
 
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 // constexpr const E& error() const & noexcept;
 // constexpr E& error() & noexcept;

diff  --git a/libcxx/test/libcxx/utilities/optional/optional.object/optional.object.observe/assert.dereference.pass.cpp b/libcxx/test/libcxx/utilities/optional/optional.object/optional.object.observe/assert.dereference.pass.cpp
index 0bca838f15f29c..75be42ae9be8f8 100644
--- a/libcxx/test/libcxx/utilities/optional/optional.object/optional.object.observe/assert.dereference.pass.cpp
+++ b/libcxx/test/libcxx/utilities/optional/optional.object/optional.object.observe/assert.dereference.pass.cpp
@@ -15,8 +15,8 @@
 
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03, c++11, c++14
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 #include <optional>
 

diff  --git a/libcxx/test/libcxx/utilities/optional/optional.object/optional.object.observe/assert.op_arrow.pass.cpp b/libcxx/test/libcxx/utilities/optional/optional.object/optional.object.observe/assert.op_arrow.pass.cpp
index f0c2cf1a6d56cb..96a8da00ad4aea 100644
--- a/libcxx/test/libcxx/utilities/optional/optional.object/optional.object.observe/assert.op_arrow.pass.cpp
+++ b/libcxx/test/libcxx/utilities/optional/optional.object/optional.object.observe/assert.op_arrow.pass.cpp
@@ -13,8 +13,8 @@
 
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03, c++11, c++14
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 #include <optional>
 

diff  --git a/libcxx/test/std/algorithms/alg.sorting/alg.clamp/assert.ranges_clamp.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.clamp/assert.ranges_clamp.pass.cpp
index 9756a6f2fc0d61..cc49e39c32a6ef 100644
--- a/libcxx/test/std/algorithms/alg.sorting/alg.clamp/assert.ranges_clamp.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.sorting/alg.clamp/assert.ranges_clamp.pass.cpp
@@ -8,8 +8,8 @@
 
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03, c++11, c++14, c++17
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 // <algorithm>
 

diff  --git a/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/assert.pop_heap.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/assert.pop_heap.pass.cpp
index cc10d058e0428f..2cc0262cbf8cf4 100644
--- a/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/assert.pop_heap.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/assert.pop_heap.pass.cpp
@@ -8,8 +8,8 @@
 
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 // <algorithm>
 

diff  --git a/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/assert.ranges_pop_heap.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/assert.ranges_pop_heap.pass.cpp
index 3820b67629769f..7674f78b1f2963 100644
--- a/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/assert.ranges_pop_heap.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/assert.ranges_pop_heap.pass.cpp
@@ -8,8 +8,8 @@
 
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03, c++11, c++14, c++17
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 // <algorithm>
 

diff  --git a/libcxx/test/std/containers/views/mdspan/extents/assert.conversion.pass.cpp b/libcxx/test/std/containers/views/mdspan/extents/assert.conversion.pass.cpp
index 1ca4e2ec178ace..3496f69d5dc89b 100644
--- a/libcxx/test/std/containers/views/mdspan/extents/assert.conversion.pass.cpp
+++ b/libcxx/test/std/containers/views/mdspan/extents/assert.conversion.pass.cpp
@@ -6,8 +6,8 @@
 //===----------------------------------------------------------------------===//
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 // <mdspan>
 

diff  --git a/libcxx/test/std/containers/views/mdspan/extents/assert.ctor_from_array.pass.cpp b/libcxx/test/std/containers/views/mdspan/extents/assert.ctor_from_array.pass.cpp
index b5e74df97ca2a1..bef448aa609ed6 100644
--- a/libcxx/test/std/containers/views/mdspan/extents/assert.ctor_from_array.pass.cpp
+++ b/libcxx/test/std/containers/views/mdspan/extents/assert.ctor_from_array.pass.cpp
@@ -6,8 +6,8 @@
 //===----------------------------------------------------------------------===//
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 // <mdspan>
 

diff  --git a/libcxx/test/std/containers/views/mdspan/extents/assert.ctor_from_integral.pass.cpp b/libcxx/test/std/containers/views/mdspan/extents/assert.ctor_from_integral.pass.cpp
index 69f8436f5653e0..17c29707a51378 100644
--- a/libcxx/test/std/containers/views/mdspan/extents/assert.ctor_from_integral.pass.cpp
+++ b/libcxx/test/std/containers/views/mdspan/extents/assert.ctor_from_integral.pass.cpp
@@ -6,8 +6,8 @@
 //===----------------------------------------------------------------------===//
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 // <mdspan>
 

diff  --git a/libcxx/test/std/containers/views/mdspan/extents/assert.ctor_from_span.pass.cpp b/libcxx/test/std/containers/views/mdspan/extents/assert.ctor_from_span.pass.cpp
index 0375ca43054a60..785720bf9b8900 100644
--- a/libcxx/test/std/containers/views/mdspan/extents/assert.ctor_from_span.pass.cpp
+++ b/libcxx/test/std/containers/views/mdspan/extents/assert.ctor_from_span.pass.cpp
@@ -6,8 +6,8 @@
 //===----------------------------------------------------------------------===//
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 // Test construction from span:
 //

diff  --git a/libcxx/test/std/containers/views/mdspan/extents/assert.obs.pass.cpp b/libcxx/test/std/containers/views/mdspan/extents/assert.obs.pass.cpp
index acf09bdc0c5acc..e20146f9ea5181 100644
--- a/libcxx/test/std/containers/views/mdspan/extents/assert.obs.pass.cpp
+++ b/libcxx/test/std/containers/views/mdspan/extents/assert.obs.pass.cpp
@@ -6,8 +6,8 @@
 //===----------------------------------------------------------------------===//
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 // <mdspan>
 

diff  --git a/libcxx/test/std/containers/views/mdspan/layout_left/assert.conversion.pass.cpp b/libcxx/test/std/containers/views/mdspan/layout_left/assert.conversion.pass.cpp
index 288855708d6af2..d4aea962f19a0b 100644
--- a/libcxx/test/std/containers/views/mdspan/layout_left/assert.conversion.pass.cpp
+++ b/libcxx/test/std/containers/views/mdspan/layout_left/assert.conversion.pass.cpp
@@ -8,8 +8,8 @@
 
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 // <mdspan>
 

diff  --git a/libcxx/test/std/containers/views/mdspan/layout_left/assert.ctor.extents.pass.cpp b/libcxx/test/std/containers/views/mdspan/layout_left/assert.ctor.extents.pass.cpp
index d970c1ee997cc8..4a122e09040849 100644
--- a/libcxx/test/std/containers/views/mdspan/layout_left/assert.ctor.extents.pass.cpp
+++ b/libcxx/test/std/containers/views/mdspan/layout_left/assert.ctor.extents.pass.cpp
@@ -8,8 +8,8 @@
 
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 // <mdspan>
 

diff  --git a/libcxx/test/std/containers/views/mdspan/layout_left/assert.ctor.layout_right.pass.cpp b/libcxx/test/std/containers/views/mdspan/layout_left/assert.ctor.layout_right.pass.cpp
index 0d4e829e12cd98..3750d71bd6dcc9 100644
--- a/libcxx/test/std/containers/views/mdspan/layout_left/assert.ctor.layout_right.pass.cpp
+++ b/libcxx/test/std/containers/views/mdspan/layout_left/assert.ctor.layout_right.pass.cpp
@@ -8,8 +8,8 @@
 
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 // <mdspan>
 

diff  --git a/libcxx/test/std/containers/views/mdspan/layout_left/assert.index_operator.pass.cpp b/libcxx/test/std/containers/views/mdspan/layout_left/assert.index_operator.pass.cpp
index 779e38cbb0f507..1d10310f42e164 100644
--- a/libcxx/test/std/containers/views/mdspan/layout_left/assert.index_operator.pass.cpp
+++ b/libcxx/test/std/containers/views/mdspan/layout_left/assert.index_operator.pass.cpp
@@ -8,8 +8,8 @@
 
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 // <mdspan>
 

diff  --git a/libcxx/test/std/containers/views/mdspan/layout_left/assert.stride.pass.cpp b/libcxx/test/std/containers/views/mdspan/layout_left/assert.stride.pass.cpp
index ed558c598f4892..6fe792d5170fd4 100644
--- a/libcxx/test/std/containers/views/mdspan/layout_left/assert.stride.pass.cpp
+++ b/libcxx/test/std/containers/views/mdspan/layout_left/assert.stride.pass.cpp
@@ -8,8 +8,8 @@
 
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 // <mdspan>
 

diff  --git a/libcxx/test/std/containers/views/mdspan/layout_right/assert.conversion.pass.cpp b/libcxx/test/std/containers/views/mdspan/layout_right/assert.conversion.pass.cpp
index 2aa4f139374845..d44598b6282df5 100644
--- a/libcxx/test/std/containers/views/mdspan/layout_right/assert.conversion.pass.cpp
+++ b/libcxx/test/std/containers/views/mdspan/layout_right/assert.conversion.pass.cpp
@@ -8,8 +8,8 @@
 
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 // <mdspan>
 

diff  --git a/libcxx/test/std/containers/views/mdspan/layout_right/assert.ctor.extents.pass.cpp b/libcxx/test/std/containers/views/mdspan/layout_right/assert.ctor.extents.pass.cpp
index a0cd07f76183b3..a460a3a27b943a 100644
--- a/libcxx/test/std/containers/views/mdspan/layout_right/assert.ctor.extents.pass.cpp
+++ b/libcxx/test/std/containers/views/mdspan/layout_right/assert.ctor.extents.pass.cpp
@@ -8,8 +8,8 @@
 
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 // <mdspan>
 

diff  --git a/libcxx/test/std/containers/views/mdspan/layout_right/assert.ctor.layout_left.pass.cpp b/libcxx/test/std/containers/views/mdspan/layout_right/assert.ctor.layout_left.pass.cpp
index 941ae6fc21a4e0..5f437e22b208a8 100644
--- a/libcxx/test/std/containers/views/mdspan/layout_right/assert.ctor.layout_left.pass.cpp
+++ b/libcxx/test/std/containers/views/mdspan/layout_right/assert.ctor.layout_left.pass.cpp
@@ -8,8 +8,8 @@
 
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 // <mdspan>
 

diff  --git a/libcxx/test/std/containers/views/mdspan/layout_right/assert.index_operator.pass.cpp b/libcxx/test/std/containers/views/mdspan/layout_right/assert.index_operator.pass.cpp
index 923bef8fe1c61b..4a9c4ee780d658 100644
--- a/libcxx/test/std/containers/views/mdspan/layout_right/assert.index_operator.pass.cpp
+++ b/libcxx/test/std/containers/views/mdspan/layout_right/assert.index_operator.pass.cpp
@@ -8,8 +8,8 @@
 
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 // <mdspan>
 

diff  --git a/libcxx/test/std/containers/views/mdspan/layout_right/assert.stride.pass.cpp b/libcxx/test/std/containers/views/mdspan/layout_right/assert.stride.pass.cpp
index cea67cc5d88a22..01b2891d93d770 100644
--- a/libcxx/test/std/containers/views/mdspan/layout_right/assert.stride.pass.cpp
+++ b/libcxx/test/std/containers/views/mdspan/layout_right/assert.stride.pass.cpp
@@ -8,8 +8,8 @@
 
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 // <mdspan>
 

diff  --git a/libcxx/test/std/utilities/utility/utility.unreachable/assert.unreachable.pass.cpp b/libcxx/test/std/utilities/utility/utility.unreachable/assert.unreachable.pass.cpp
index f571c1e3e05228..c61684871ece93 100644
--- a/libcxx/test/std/utilities/utility/utility.unreachable/assert.unreachable.pass.cpp
+++ b/libcxx/test/std/utilities/utility/utility.unreachable/assert.unreachable.pass.cpp
@@ -6,11 +6,10 @@
 //
 //===----------------------------------------------------------------------===//
 
-// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
-
 // REQUIRES: has-unix-headers
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 // Make sure that reaching std::unreachable() with assertions enabled triggers an assertion.
 

diff  --git a/libcxx/test/support/test.support/test_check_assertion.pass.cpp b/libcxx/test/support/test.support/test_check_assertion.pass.cpp
index 5612bec28ac988..cb622ada344b9a 100644
--- a/libcxx/test/support/test.support/test_check_assertion.pass.cpp
+++ b/libcxx/test/support/test.support/test_check_assertion.pass.cpp
@@ -8,8 +8,8 @@
 
 // REQUIRES: has-unix-headers
 // UNSUPPORTED: c++03
+// UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode
 // XFAIL: availability-verbose_abort-missing
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
 
 #include <cassert>
 #include <cstdio>

diff  --git a/libcxx/utils/ci/buildkite-pipeline.yml b/libcxx/utils/ci/buildkite-pipeline.yml
index 86e55d0e3df8a9..a0e84450535ffc 100644
--- a/libcxx/utils/ci/buildkite-pipeline.yml
+++ b/libcxx/utils/ci/buildkite-pipeline.yml
@@ -468,24 +468,6 @@ steps:
           limit: 2
     timeout_in_minutes: 120
 
-  - label: "Assertions enabled"
-    command: "libcxx/utils/ci/run-buildbot generic-assertions"
-    artifact_paths:
-      - "**/test-results.xml"
-      - "**/*.abilist"
-    env:
-        CC: "clang-${LLVM_HEAD_VERSION}"
-        CXX: "clang++-${LLVM_HEAD_VERSION}"
-        ENABLE_CLANG_TIDY: "On"
-    agents:
-      queue: "libcxx-builders"
-      os: "linux"
-    retry:
-      automatic:
-        - exit_status: -1  # Agent was lost
-          limit: 2
-    timeout_in_minutes: 120
-
   - label: "Hardened mode"
     command: "libcxx/utils/ci/run-buildbot generic-hardened-mode"
     artifact_paths:
@@ -929,8 +911,8 @@ steps:
             limit: 2
       timeout_in_minutes: 120
 
-    - label: "Apple back-deployment with assertions enabled"
-      command: "libcxx/utils/ci/run-buildbot apple-system-backdeployment-assertions-11.0"
+    - label: "Apple back-deployment with hardening enabled"
+      command: "libcxx/utils/ci/run-buildbot apple-system-backdeployment-hardened-11.0"
       artifact_paths:
         - "**/test-results.xml"
         - "**/*.abilist"

diff  --git a/libcxx/utils/ci/run-buildbot b/libcxx/utils/ci/run-buildbot
index 6e20f167e540fd..6934634ad07b4b 100755
--- a/libcxx/utils/ci/run-buildbot
+++ b/libcxx/utils/ci/run-buildbot
@@ -382,12 +382,6 @@ generic-merged)
                    -DLIBUNWIND_TEST_CONFIG="llvm-libunwind-merged.cfg.in"
     check-runtimes
 ;;
-generic-assertions)
-    clean
-    generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-assertions.cmake"
-    check-runtimes
-    check-abi-list
-;;
 generic-hardened-mode)
     clean
     generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-hardened-mode.cmake"
@@ -495,7 +489,7 @@ apple-system)
     # TODO: It would be better to run the tests against the fake-installed version of libc++ instead
     xcrun --sdk macosx ninja -vC "${BUILD_DIR}/${arch}" check-cxx check-cxxabi check-cxx-abilist
 ;;
-apple-system-backdeployment-assertions-*)
+apple-system-backdeployment-hardened-*)
     clean
 
     if [[ "${OSX_ROOTS}" == "" ]]; then
@@ -506,7 +500,7 @@ apple-system-backdeployment-assertions-*)
         curl "${PREVIOUS_DYLIBS_URL}" | tar -xz --strip-components=1 -C "${OSX_ROOTS}"
     fi
 
-    DEPLOYMENT_TARGET="${BUILDER#apple-system-backdeployment-assertions-}"
+    DEPLOYMENT_TARGET="${BUILDER#apple-system-backdeployment-hardened-}"
 
     # TODO: On Apple platforms, we never produce libc++abi.1.dylib or libunwind.1.dylib,
     #       only libc++abi.dylib and libunwind.dylib. Fix that in the build so that the
@@ -521,7 +515,7 @@ apple-system-backdeployment-assertions-*)
     PARAMS+=";cxx_runtime_root=${OSX_ROOTS}/macOS/libc++/${DEPLOYMENT_TARGET}"
     PARAMS+=";abi_runtime_root=${OSX_ROOTS}/macOS/libc++abi/${DEPLOYMENT_TARGET}"
     PARAMS+=";unwind_runtime_root=${OSX_ROOTS}/macOS/libunwind/${DEPLOYMENT_TARGET}"
-    PARAMS+=";enable_assertions=True"
+    PARAMS+=";hardening_mode=hardened"
 
     generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Apple.cmake" \
                    -DLIBCXX_TEST_CONFIG="apple-libc++-backdeployment.cfg.in" \

diff  --git a/libcxx/utils/libcxx/test/params.py b/libcxx/utils/libcxx/test/params.py
index 885e88048ec584..16861ca5e4da26 100644
--- a/libcxx/utils/libcxx/test/params.py
+++ b/libcxx/utils/libcxx/test/params.py
@@ -283,18 +283,6 @@ def getModuleFlag(cfg, enable_modules):
         help="Whether to enable tests that take longer to run. This can be useful when running on a very slow device.",
         actions=lambda enabled: [] if not enabled else [AddFeature("long_tests")],
     ),
-    Parameter(
-        name="enable_assertions",
-        choices=[True, False],
-        type=bool,
-        default=False,
-        help="Whether to enable assertions when compiling the test suite. This is only meaningful when "
-        "running the tests against libc++.",
-        actions=lambda assertions: [] if not assertions else [
-            AddCompileFlag("-D_LIBCPP_ENABLE_ASSERTIONS=1"),
-            AddFeature("libcpp-has-assertions"),
-        ],
-    ),
     Parameter(
         name="hardening_mode",
         choices=["unchecked", "hardened", "debug"],


        


More information about the libcxx-commits mailing list