[libcxx-commits] [PATCH] D122941: [libc++] Make the Debug mode a configuration-time only option

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri Apr 1 14:33:09 PDT 2022


ldionne created this revision.
Herald added subscribers: arphaman, mgrang, arichardson, mgorny.
Herald added a project: All.
ldionne requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.

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 increase the granularity of the debug mode
checks so that we can cherry-pick which checks to enable. Furthermore,
a subset of checks that are currently marked as requiring a matching
dylib may be relaxed to not require that (such as the consistent
comparator tests).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D122941

Files:
  libcxx/CMakeLists.txt
  libcxx/cmake/caches/Apple.cmake
  libcxx/cmake/caches/Generic-debug-iterators.cmake
  libcxx/cmake/caches/Generic-debug-mode.cmake
  libcxx/cmake/caches/Generic-no-debug.cmake
  libcxx/docs/DesignDocs/DebugMode.rst
  libcxx/docs/ReleaseNotes.rst
  libcxx/docs/TestingLibcxx.rst
  libcxx/docs/UsingLibcxx.rst
  libcxx/include/__algorithm/comp_ref_type.h
  libcxx/include/__algorithm/nth_element.h
  libcxx/include/__algorithm/partial_sort.h
  libcxx/include/__algorithm/shuffle.h
  libcxx/include/__algorithm/sort.h
  libcxx/include/__algorithm/unwrap_iter.h
  libcxx/include/__assert
  libcxx/include/__config
  libcxx/include/__config_site.in
  libcxx/include/__debug
  libcxx/include/__format/buffer.h
  libcxx/include/__hash_table
  libcxx/include/__iterator/wrap_iter.h
  libcxx/include/list
  libcxx/include/locale
  libcxx/include/span
  libcxx/include/string
  libcxx/include/unordered_map
  libcxx/include/unordered_set
  libcxx/include/vector
  libcxx/lib/abi/CMakeLists.txt
  libcxx/src/CMakeLists.txt
  libcxx/test/CMakeLists.txt
  libcxx/test/libcxx/algorithms/alg.sorting/alg.heap.operations/make.heap/complexity.pass.cpp
  libcxx/test/libcxx/algorithms/alg.sorting/alg.heap.operations/sort.heap/complexity.pass.cpp
  libcxx/test/libcxx/algorithms/debug_less.inconsistent.pass.cpp
  libcxx/test/libcxx/algorithms/debug_less.pass.cpp
  libcxx/test/libcxx/algorithms/nth_element_stability.pass.cpp
  libcxx/test/libcxx/algorithms/partial_sort_stability.pass.cpp
  libcxx/test/libcxx/algorithms/sort_stability.pass.cpp
  libcxx/test/libcxx/containers/sequences/list/list.cons/debug.copy.pass.cpp
  libcxx/test/libcxx/containers/sequences/list/list.modifiers/debug.emplace.pass.cpp
  libcxx/test/libcxx/containers/sequences/list/list.modifiers/debug.erase.iter.pass.cpp
  libcxx/test/libcxx/containers/sequences/list/list.modifiers/debug.erase.iter_iter.pass.cpp
  libcxx/test/libcxx/containers/sequences/list/list.modifiers/debug.insert.iter_iter_iter.pass.cpp
  libcxx/test/libcxx/containers/sequences/list/list.modifiers/debug.insert.iter_rvalue.pass.cpp
  libcxx/test/libcxx/containers/sequences/list/list.modifiers/debug.insert.iter_size_value.pass.cpp
  libcxx/test/libcxx/containers/sequences/list/list.modifiers/debug.insert.iter_value.pass.cpp
  libcxx/test/libcxx/containers/sequences/list/list.ops/debug.splice.pos_list.pass.cpp
  libcxx/test/libcxx/containers/sequences/list/list.ops/debug.splice.pos_list_iter.pass.cpp
  libcxx/test/libcxx/containers/sequences/list/list.ops/debug.splice.pos_list_iter_iter.pass.cpp
  libcxx/test/libcxx/containers/sequences/vector/debug.iterator.add.pass.cpp
  libcxx/test/libcxx/containers/sequences/vector/debug.iterator.compare.pass.cpp
  libcxx/test/libcxx/containers/sequences/vector/debug.iterator.decrement.pass.cpp
  libcxx/test/libcxx/containers/sequences/vector/debug.iterator.dereference.pass.cpp
  libcxx/test/libcxx/containers/sequences/vector/debug.iterator.increment.pass.cpp
  libcxx/test/libcxx/containers/sequences/vector/debug.iterator.index.pass.cpp
  libcxx/test/libcxx/containers/sequences/vector/debug.iterator.subtract.pass.cpp
  libcxx/test/libcxx/containers/unord/unord.map/debug.insert.hint_const_lvalue.pass.cpp
  libcxx/test/libcxx/containers/unord/unord.map/debug.insert.hint_rvalue.pass.cpp
  libcxx/test/libcxx/containers/unord/unord.map/debug.iterator.dereference.pass.cpp
  libcxx/test/libcxx/containers/unord/unord.map/debug.iterator.increment.pass.cpp
  libcxx/test/libcxx/containers/unord/unord.map/debug.local_iterator.dereference.pass.cpp
  libcxx/test/libcxx/containers/unord/unord.map/debug.local_iterator.increment.pass.cpp
  libcxx/test/libcxx/containers/unord/unord.map/debug.swap.pass.cpp
  libcxx/test/libcxx/containers/unord/unord.map/unord.map.modifiers/debug.erase.iter.pass.cpp
  libcxx/test/libcxx/containers/unord/unord.map/unord.map.modifiers/debug.erase.iter_iter.pass.cpp
  libcxx/test/libcxx/containers/unord/unord.multimap/debug.insert.hint_const_lvalue.pass.cpp
  libcxx/test/libcxx/containers/unord/unord.multimap/debug.insert.hint_rvalue.pass.cpp
  libcxx/test/libcxx/containers/unord/unord.multimap/debug.iterator.dereference.pass.cpp
  libcxx/test/libcxx/containers/unord/unord.multimap/debug.iterator.increment.pass.cpp
  libcxx/test/libcxx/containers/unord/unord.multimap/debug.local_iterator.dereference.pass.cpp
  libcxx/test/libcxx/containers/unord/unord.multimap/debug.local_iterator.increment.pass.cpp
  libcxx/test/libcxx/containers/unord/unord.multimap/debug.swap.pass.cpp
  libcxx/test/libcxx/containers/unord/unord.multimap/unord.multimap.modifiers/debug.erase.iter.pass.cpp
  libcxx/test/libcxx/containers/unord/unord.multimap/unord.multimap.modifiers/debug.erase.iter_iter.pass.cpp
  libcxx/test/libcxx/containers/unord/unord.multiset/debug.erase.iter.pass.cpp
  libcxx/test/libcxx/containers/unord/unord.multiset/debug.erase.iter_iter.pass.cpp
  libcxx/test/libcxx/containers/unord/unord.multiset/debug.insert.hint_const_lvalue.pass.cpp
  libcxx/test/libcxx/containers/unord/unord.multiset/debug.iterator.dereference.pass.cpp
  libcxx/test/libcxx/containers/unord/unord.multiset/debug.iterator.increment.pass.cpp
  libcxx/test/libcxx/containers/unord/unord.multiset/debug.local_iterator.dereference.pass.cpp
  libcxx/test/libcxx/containers/unord/unord.multiset/debug.local_iterator.increment.pass.cpp
  libcxx/test/libcxx/containers/unord/unord.multiset/debug.swap.pass.cpp
  libcxx/test/libcxx/containers/unord/unord.set/debug.erase.iter.pass.cpp
  libcxx/test/libcxx/containers/unord/unord.set/debug.erase.iter_iter.pass.cpp
  libcxx/test/libcxx/containers/unord/unord.set/debug.insert.hint_const_lvalue.pass.cpp
  libcxx/test/libcxx/containers/unord/unord.set/debug.iterator.dereference.pass.cpp
  libcxx/test/libcxx/containers/unord/unord.set/debug.iterator.increment.pass.cpp
  libcxx/test/libcxx/containers/unord/unord.set/debug.local_iterator.dereference.pass.cpp
  libcxx/test/libcxx/containers/unord/unord.set/debug.local_iterator.increment.pass.cpp
  libcxx/test/libcxx/containers/unord/unord.set/debug.swap.pass.cpp
  libcxx/test/libcxx/debug/containers.multithread.pass.cpp
  libcxx/test/libcxx/debug/containers/associative_containers.pass.cpp
  libcxx/test/libcxx/debug/containers/sequence_container_iterators.pass.cpp
  libcxx/test/libcxx/debug/containers/string.pass.cpp
  libcxx/test/libcxx/debug/containers/unord_containers.pass.cpp
  libcxx/test/libcxx/debug/extern-templates.sh.cpp
  libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.add.pass.cpp
  libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.compare.pass.cpp
  libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.decrement.pass.cpp
  libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.dereference.pass.cpp
  libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.increment.pass.cpp
  libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.index.pass.cpp
  libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.subtract.pass.cpp
  libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.erase.iter.pass.cpp
  libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.erase.iter_iter.pass.cpp
  libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.insert.iter_char.pass.cpp
  libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.insert.iter_iter_iter.pass.cpp
  libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.insert.iter_size_char.pass.cpp
  libcxx/test/std/algorithms/alg.sorting/alg.merge/inplace_merge_comp.pass.cpp
  libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.proximate/proximate.pass.cpp
  libcxx/test/std/utilities/format/format.functions/locale-specific_form.pass.cpp
  libcxx/test/support/container_debug_tests.h
  libcxx/utils/ci/buildkite-pipeline.yml
  libcxx/utils/ci/run-buildbot
  libcxx/utils/libcxx/test/features.py
  libcxx/utils/libcxx/test/params.py

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D122941.419864.patch
Type: text/x-patch
Size: 115431 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220401/c25ee4a3/attachment-0001.bin>


More information about the libcxx-commits mailing list