Skip to content

Commit ce1365f

Browse files
committed
[libc++] Add a CMake option to control whether the debug mode is supported
Some libc++ builds may want to disable support for the debug mode, for example to reduce code size or because the current implementation of the debug mode requires a global map. This commit adds the LIBCXX_ENABLE_DEBUG_MODE CMake option and ties it into the test suite. It also adds a CI job to test this configuration going forward. Differential Revision: https://reviews.llvm.org/D88923
1 parent 602c193 commit ce1365f

File tree

138 files changed

+182
-296
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

138 files changed

+182
-296
lines changed

libcxx/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ option(LIBCXX_ENABLE_FILESYSTEM "Build filesystem as part of the main libc++ lib
9494
${ENABLE_FILESYSTEM_DEFAULT})
9595
option(LIBCXX_INCLUDE_TESTS "Build the libc++ tests." ${LLVM_INCLUDE_TESTS})
9696
option(LIBCXX_ENABLE_PARALLEL_ALGORITHMS "Enable the parallel algorithms library. This requires the PSTL to be available." OFF)
97+
option(LIBCXX_ENABLE_DEBUG_MODE
98+
"Whether to include support for libc++'s debugging mode in the library.
99+
By default, this is turned on. If you turn it off and try to enable the
100+
debug mode when compiling a program against libc++, it will fail to link
101+
since the required support isn't provided in the library." ON)
97102
option(LIBCXX_TEST_GDB_PRETTY_PRINTERS "Test gdb pretty printers." OFF)
98103
set(LIBCXX_TEST_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}/test/configs/legacy.cfg.in" CACHE STRING
99104
"The Lit testing configuration to use when running the tests.")

libcxx/cmake/caches/Apple.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ set(LIBCXX_TYPEINFO_COMPARISON_IMPLEMENTATION "1" CACHE STRING "")
1111
set(LIBCXX_CXX_ABI libcxxabi CACHE STRING "")
1212
set(LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS OFF CACHE BOOL "")
1313
set(LIBCXX_HIDE_FROM_ABI_PER_TU_BY_DEFAULT ON CACHE BOOL "")
14+
set(LIBCXX_ENABLE_DEBUG_MODE OFF CACHE BOOL "")
1415

1516
set(LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS ON CACHE BOOL "")
1617
set(LIBCXXABI_ENABLE_PIC OFF CACHE BOOL "")
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
set(LIBCXX_ENABLE_DEBUG_MODE OFF CACHE BOOL "")

libcxx/src/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ set(LIBCXX_SOURCES
1111
chrono.cpp
1212
condition_variable.cpp
1313
condition_variable_destructor.cpp
14-
debug.cpp
1514
exception.cpp
1615
functional.cpp
1716
future.cpp
@@ -56,6 +55,10 @@ set(LIBCXX_SOURCES
5655
vector.cpp
5756
)
5857

58+
if (LIBCXX_ENABLE_DEBUG_MODE)
59+
list(APPEND LIBCXX_SOURCES debug.cpp)
60+
endif()
61+
5962
if(WIN32)
6063
list(APPEND LIBCXX_SOURCES
6164
support/win32/locale_win32.cpp

libcxx/test/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ pythonize_bool(LIBCXX_HAS_ATOMIC_LIB)
7070
pythonize_bool(LIBCXX_HAVE_CXX_ATOMICS_WITH_LIB)
7171
pythonize_bool(LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY)
7272
pythonize_bool(LIBCXX_DEBUG_BUILD)
73+
pythonize_bool(LIBCXX_ENABLE_DEBUG_MODE)
7374
pythonize_bool(LIBCXX_ENABLE_PARALLEL_ALGORITHMS)
7475

7576
# By default, for non-standalone builds, libcxx and libcxxabi share a library

libcxx/test/configs/legacy.cfg.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ config.libcxx_src_root = "@LIBCXX_SOURCE_DIR@"
99
config.libcxx_obj_root = "@LIBCXX_BINARY_DIR@"
1010
config.cxx_library_root = "@LIBCXX_LIBRARY_DIR@"
1111
config.enable_exceptions = @LIBCXX_ENABLE_EXCEPTIONS@
12+
config.enable_debug_tests = @LIBCXX_ENABLE_DEBUG_MODE@
1213
config.enable_experimental = @LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY@
1314
config.enable_filesystem = @LIBCXX_ENABLE_FILESYSTEM@
1415
config.enable_rtti = @LIBCXX_ENABLE_RTTI@

libcxx/test/libcxx/containers/sequences/array/array.zero/db_back.pass.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99
// UNSUPPORTED: windows
1010

1111
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
12-
13-
// Can't test the system lib because this test enables debug mode
14-
// UNSUPPORTED: with_system_cxx_lib=macosx
12+
// UNSUPPORTED: libcxx-no-debug-mode
1513

1614
// test array<T, 0>::front() raises a debug error.
1715

libcxx/test/libcxx/containers/sequences/array/array.zero/db_front.pass.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99
// UNSUPPORTED: windows
1010

1111
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
12-
13-
// Can't test the system lib because this test enables debug mode
14-
// UNSUPPORTED: with_system_cxx_lib=macosx
12+
// UNSUPPORTED: libcxx-no-debug-mode
1513

1614
// test array<T, 0>::front() raises a debug error.
1715

libcxx/test/libcxx/containers/sequences/array/array.zero/db_indexing.pass.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99
// UNSUPPORTED: windows
1010

1111
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
12-
13-
// Can't test the system lib because this test enables debug mode
14-
// UNSUPPORTED: with_system_cxx_lib=macosx
12+
// UNSUPPORTED: libcxx-no-debug-mode
1513

1614
// test array<T, 0>::operator[] raises a debug error.
1715

libcxx/test/libcxx/containers/sequences/list/list.cons/db_copy.pass.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
//===----------------------------------------------------------------------===//
88

99
// <list>
10-
// Can't test the system lib because this test enables debug mode
11-
// UNSUPPORTED: with_system_cxx_lib=macosx
1210

1311
// list(list&& c);
1412

13+
// UNSUPPORTED: libcxx-no-debug-mode
14+
1515
#define _LIBCPP_DEBUG 1
1616
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
1717

libcxx/test/libcxx/containers/sequences/list/list.cons/db_move.pass.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,13 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
// UNSUPPORTED: c++03
10-
11-
// Can't test the system lib because this test enables debug mode
12-
// UNSUPPORTED: with_system_cxx_lib=macosx
13-
149
// <list>
1510

1611
// list(list&& c);
1712

13+
// UNSUPPORTED: c++03
14+
// UNSUPPORTED: libcxx-no-debug-mode
15+
1816
#define _LIBCPP_DEBUG 1
1917
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(1))
2018

libcxx/test/libcxx/containers/sequences/list/list.modifiers/emplace_db1.pass.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,13 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
// UNSUPPORTED: c++03
10-
11-
// Can't test the system lib because this test enables debug mode
12-
// UNSUPPORTED: with_system_cxx_lib=macosx
13-
149
// <list>
1510

1611
// template <class... Args> void emplace(const_iterator p, Args&&... args);
1712

13+
// UNSUPPORTED: c++03
14+
// UNSUPPORTED: libcxx-no-debug-mode
15+
1816
#define _LIBCPP_DEBUG 1
1917
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
2018

libcxx/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_db1.pass.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
// Can't test the system lib because this test enables debug mode
10-
// UNSUPPORTED: with_system_cxx_lib=macosx
11-
129
// <list>
1310

1411
// Call erase(const_iterator position) with end()
1512

13+
// UNSUPPORTED: libcxx-no-debug-mode
14+
1615
#define _LIBCPP_DEBUG 1
1716
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
1817

libcxx/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_db2.pass.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
// Can't test the system lib because this test enables debug mode
10-
// UNSUPPORTED: with_system_cxx_lib=macosx
11-
129
// <list>
1310

1411
// Call erase(const_iterator position) with iterator from another container
1512

13+
// UNSUPPORTED: libcxx-no-debug-mode
14+
1615
#define _LIBCPP_DEBUG 1
1716
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
1817

libcxx/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_iter_db1.pass.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
// Can't test the system lib because this test enables debug mode
10-
// UNSUPPORTED: with_system_cxx_lib=macosx
11-
129
// <list>
1310

1411
// Call erase(const_iterator first, const_iterator last); with first iterator from another container
1512

13+
// UNSUPPORTED: libcxx-no-debug-mode
14+
1615
#define _LIBCPP_DEBUG 1
1716
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
1817

libcxx/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_iter_db2.pass.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
// Can't test the system lib because this test enables debug mode
10-
// UNSUPPORTED: with_system_cxx_lib=macosx
11-
129
// <list>
1310

1411
// Call erase(const_iterator first, const_iterator last); with second iterator from another container
1512

13+
// UNSUPPORTED: libcxx-no-debug-mode
14+
1615
#define _LIBCPP_DEBUG 1
1716
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
1817

libcxx/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_iter_db3.pass.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
// Can't test the system lib because this test enables debug mode
10-
// UNSUPPORTED: with_system_cxx_lib=macosx
11-
129
// <list>
1310

1411
// Call erase(const_iterator first, const_iterator last); with both iterators from another container
1512

13+
// UNSUPPORTED: libcxx-no-debug-mode
14+
1615
#define _LIBCPP_DEBUG 1
1716
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
1817

libcxx/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_iter_db4.pass.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
// Can't test the system lib because this test enables debug mode
10-
// UNSUPPORTED: with_system_cxx_lib=macosx
11-
129
// <list>
1310

1411
// Call erase(const_iterator first, const_iterator last); with a bad range
1512

13+
// UNSUPPORTED: libcxx-no-debug-mode
14+
1615
#define _LIBCPP_DEBUG 1
1716
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
1817

libcxx/test/libcxx/containers/sequences/list/list.modifiers/insert_iter_iter_iter_db1.pass.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
// Can't test the system lib because this test enables debug mode
10-
// UNSUPPORTED: with_system_cxx_lib=macosx
11-
129
// <list>
1310

1411
// template <InputIterator Iter>
1512
// iterator insert(const_iterator position, Iter first, Iter last);
1613

14+
// UNSUPPORTED: libcxx-no-debug-mode
1715

1816
#define _LIBCPP_DEBUG 1
1917
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))

libcxx/test/libcxx/containers/sequences/list/list.modifiers/insert_iter_rvalue_db1.pass.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
// Can't test the system lib because this test enables debug mode
10-
// UNSUPPORTED: with_system_cxx_lib=macosx
11-
129
// <list>
1310

1411
// iterator insert(const_iterator position, value_type&& x);
1512

13+
// UNSUPPORTED: libcxx-no-debug-mode
14+
1615
#define _LIBCPP_DEBUG 1
1716
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
1817

libcxx/test/libcxx/containers/sequences/list/list.modifiers/insert_iter_size_value_db1.pass.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
// Can't test the system lib because this test enables debug mode
10-
// UNSUPPORTED: with_system_cxx_lib=macosx
11-
129
// <list>
1310

1411
// iterator insert(const_iterator position, size_type n, const value_type& x);
1512

13+
// UNSUPPORTED: libcxx-no-debug-mode
14+
1615
#define _LIBCPP_DEBUG 1
1716
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
1817

libcxx/test/libcxx/containers/sequences/list/list.modifiers/insert_iter_value_db1.pass.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
// Can't test the system lib because this test enables debug mode
10-
// UNSUPPORTED: with_system_cxx_lib=macosx
11-
129
// <list>
1310

1411
// iterator insert(const_iterator position, const value_type& x);
1512

13+
// UNSUPPORTED: libcxx-no-debug-mode
14+
1615
#define _LIBCPP_DEBUG 1
1716
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
1817

libcxx/test/libcxx/containers/sequences/list/list.modifiers/pop_back_db1.pass.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
// Can't test the system lib because this test enables debug mode
10-
// UNSUPPORTED: with_system_cxx_lib=macosx
11-
129
// <list>
1310

1411
// void pop_back();
1512

13+
// UNSUPPORTED: libcxx-no-debug-mode
14+
1615
#define _LIBCPP_DEBUG 1
1716
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
1817

libcxx/test/libcxx/containers/sequences/list/list.ops/db_splice_pos_list.pass.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
// Can't test the system lib because this test enables debug mode
10-
// UNSUPPORTED: with_system_cxx_lib=macosx
11-
129
// <list>
1310

1411
// void splice(const_iterator position, list& x);
1512

13+
// UNSUPPORTED: libcxx-no-debug-mode
14+
1615
#define _LIBCPP_DEBUG 1
1716
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
1817

libcxx/test/libcxx/containers/sequences/list/list.ops/db_splice_pos_list_iter.pass.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
// Can't test the system lib because this test enables debug mode
10-
// UNSUPPORTED: with_system_cxx_lib=macosx
11-
129
// <list>
1310

1411
// void splice(const_iterator position, list<T,Allocator>& x, iterator i);
1512

13+
// UNSUPPORTED: libcxx-no-debug-mode
14+
1615
#define _LIBCPP_DEBUG 1
1716
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
1817

libcxx/test/libcxx/containers/sequences/list/list.ops/db_splice_pos_list_iter_iter.pass.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
// Can't test the system lib because this test enables debug mode
10-
// UNSUPPORTED: with_system_cxx_lib=macosx
11-
129
// <list>
1310

1411
// void splice(const_iterator position, list& x, iterator first, iterator last);
1512

13+
// UNSUPPORTED: libcxx-no-debug-mode
14+
1615
#define _LIBCPP_DEBUG 1
1716
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
1817

libcxx/test/libcxx/containers/sequences/vector/db_back.pass.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010

1111
// Call back() on empty container.
1212

13-
// This test requires debug mode, which the library on macOS doesn't have.
14-
// UNSUPPORTED: with_system_cxx_lib=macosx
13+
// UNSUPPORTED: libcxx-no-debug-mode
1514

1615
#define _LIBCPP_DEBUG 1
1716
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))

libcxx/test/libcxx/containers/sequences/vector/db_cback.pass.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010

1111
// Call back() on empty const container.
1212

13-
// This test requires debug mode, which the library on macOS doesn't have.
14-
// UNSUPPORTED: with_system_cxx_lib=macosx
13+
// UNSUPPORTED: libcxx-no-debug-mode
1514

1615
#define _LIBCPP_DEBUG 1
1716
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))

libcxx/test/libcxx/containers/sequences/vector/db_cfront.pass.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010

1111
// Call front() on empty const container.
1212

13-
// This test requires debug mode, which the library on macOS doesn't have.
14-
// UNSUPPORTED: with_system_cxx_lib=macosx
13+
// UNSUPPORTED: libcxx-no-debug-mode
1514

1615
#define _LIBCPP_DEBUG 1
1716
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))

0 commit comments

Comments
 (0)