[libc++] Make the Debug mode a configuration-time only option
The debug mode has been broken pretty much ever since it was shipped
because it was possible to enable the debug mode in user code without
actually enabling it in the dylib, leading to ODR violations that
caused various kinds of failures.
This commit makes the debug mode a knob that is configured when
building the library and which can't be changed afterwards. This is
less flexible for users, however it will actually work as intended
and it will allow us, in the future, to add various kinds of checks
that do not assume the same ABI as the normal library. Furthermore,
this will make the debug mode more robust, which means that vendors
might be more tempted to support it properly, which hasn't been the
case with the current debug mode.
This patch shouldn't break any user code, except folks who are building
against a library that doesn't have the debug mode enabled and who try
to enable the debug mode in their code. Such users will get a compile-time
error explaining that this configuration isn't supported anymore.
In the future, we should further increase the granularity of the debug
mode checks so that we can cherry-pick which checks to enable, like we
do for unspecified behavior randomization.
Differential Revision: https://reviews.llvm.org/D122941
NOKEYCHECK=True
GitOrigin-RevId: f3966eaf869b7bdd9113ab9d5b78469eb0f5f028
diff --git a/docs/ReleaseNotes.rst b/docs/ReleaseNotes.rst
index c21d1f9..cb4691f 100644
--- a/docs/ReleaseNotes.rst
+++ b/docs/ReleaseNotes.rst
@@ -113,6 +113,13 @@
- ``vector<bool>::const_reference``, ``vector<bool>::const_iterator::reference``
and ``bitset::const_reference`` are now aliases for `bool` in the unstable ABI.
+- The ``_LIBCPP_DEBUG`` macro is not supported anymore. It will be honoured until
+ LLVM 16, and then it will be an error to define that macro. To enable basic
+ assertions (previously ``_LIBCPP_DEBUG=0``), please use ``_LIBCPP_ENABLE_ASSERTIONS=1``.
+ To enable the debug mode (previously ``_LIBCPP_DEBUG=1|2``), please ensure that
+ the library has been built with support for the debug mode, and it will be
+ enabled automatically (no need to define ``_LIBCPP_DEBUG``).
+
ABI Changes
-----------
@@ -168,3 +175,7 @@
configuration and isn't supported by one of the configurations in ``libcxx/test/configs``,
``libcxxabi/test/configs`` or ``libunwind/test/configs``, please move to one of those
configurations or define your own.
+
+- The ``LIBCXX_ENABLE_DEBUG_MODE_SUPPORT`` CMake configuration is not supported anymore. If you
+ were disabling support for the debug mode with that flag, please use ``LIBCXX_ENABLE_BACKWARDS_COMPATIBILITY_DEBUG_MODE_SYMBOLS=OFF``
+ instead.