diff options
author | Louis Dionne <ldionne.2@gmail.com> | 2022-04-01 16:38:30 -0400 |
---|---|---|
committer | Louis Dionne <ldionne.2@gmail.com> | 2022-06-07 16:33:53 -0400 |
commit | f3966eaf869b7bdd9113ab9d5b78469eb0f5f028 (patch) | |
tree | bcf158f004cdc3420525a87579837d445536e3b0 /libcxx/CMakeLists.txt | |
parent | 89c4b29e8d35ec352019d828e546bea3850403df (diff) | |
download | llvm-f3966eaf869b7bdd9113ab9d5b78469eb0f5f028.tar.gz |
[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
Diffstat (limited to 'libcxx/CMakeLists.txt')
-rw-r--r-- | libcxx/CMakeLists.txt | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt index c36b8e61b30d..829e414103e8 100644 --- a/libcxx/CMakeLists.txt +++ b/libcxx/CMakeLists.txt @@ -68,11 +68,11 @@ option(LIBCXX_ENABLE_FILESYSTEM "Build filesystem as part of the main libc++ lib ${ENABLE_FILESYSTEM_DEFAULT}) option(LIBCXX_INCLUDE_TESTS "Build the libc++ tests." ${LLVM_INCLUDE_TESTS}) option(LIBCXX_ENABLE_PARALLEL_ALGORITHMS "Enable the parallel algorithms library. This requires the PSTL to be available." OFF) -option(LIBCXX_ENABLE_DEBUG_MODE_SUPPORT - "Whether to include support for libc++'s debugging mode in the library. - By default, this is turned on. If you turn it off and try to enable the - debug mode when compiling a program against libc++, it will fail to link - since the required support isn't provided in the library." ON) +option(LIBCXX_ENABLE_DEBUG_MODE + "Whether to build libc++ with the debug mode enabled. + By default, this is turned off. Turning it on results in a different ABI (additional + symbols but also potentially different layouts of types), and one should not mix code + built against a dylib that has debug mode and code built against a regular dylib." OFF) option(LIBCXX_ENABLE_RANDOM_DEVICE "Whether to include support for std::random_device in the library. Disabling this can be useful when building the library for platforms that don't have @@ -210,6 +210,13 @@ set(LIBCXX_ABI_DEFINES "" CACHE STRING "A semicolon separated list of ABI macros option(LIBCXX_EXTRA_SITE_DEFINES "Extra defines to add into __config_site") option(LIBCXX_USE_COMPILER_RT "Use compiler-rt instead of libgcc" OFF) +cmake_dependent_option(LIBCXX_ENABLE_BACKWARDS_COMPATIBILITY_DEBUG_MODE_SYMBOLS + "Whether to include the old Debug mode symbols in the compiled library. This + is provided for backwards compatibility since the compiled library used to + always contain those symbols, regardless of whether the library was built + with the debug mode enabled." ON + "LIBCXX_ABI_VERSION EQUAL 1" OFF) # Always OFF in ABI version != 1 + # ABI Library options --------------------------------------------------------- if (LIBCXX_TARGETING_MSVC) set(LIBCXX_DEFAULT_ABI_LIBRARY "vcruntime") @@ -854,6 +861,7 @@ 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) +config_define_if(LIBCXX_ENABLE_DEBUG_MODE _LIBCPP_ENABLE_DEBUG_MODE) if (LIBCXX_ENABLE_ASSERTIONS) config_define(1 _LIBCPP_ENABLE_ASSERTIONS_DEFAULT) else() |