[libcxx-commits] [PATCH] D119969: [libc++] Unconditionally provide the ability for users to enable assertions

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Feb 16 12:47:22 PST 2022


ldionne created this revision.
Herald added a subscriber: mgorny.
ldionne requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.

Previously, assertions could only be enabled if the library was configured
to include support for the Debug mode. This patch unconditionally adds the
very small amount of code needed to support assertions (and assertions
only, not the whole iterator debugging functionality) to the shared library.

This means that users can turn assertions on in their code regardless of
how the library was configured, which makes it a true user-facing knob.
I think this makes sense, just like we allow users to decide whether
`assert()` is enabled or not.

If they don't enable assertions in their code, nothing changes compared
to before this patch, except the shared library will now be a tiny bit
larger than it used to be. In my opinion, this is insignificant compared
to the benefit of being able to turn assertions on, and it's not even
worth the complexity to provide a knob to turn that part off.

Also note that technically, functions compiled inside the shared library
may or may not have assertions enabled, depending on whether the vendor
configured the library with `LIBCXX_ENABLE_ASSERTIONS` when building.
This can lead to ODR violations, however I think those are all benign.

Finally, since we're adding symbols to the shared library, this means
that this feature won't be available when linking against older dylibs,
hence the accompanying availability markup.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D119969

Files:
  libcxx/docs/ReleaseNotes.rst
  libcxx/include/__assert
  libcxx/include/__availability
  libcxx/lib/abi/x86_64-apple-darwin.libcxxabi.v1.stable.exceptions.nonew.nodebug.noincomplete.abilist
  libcxx/src/CMakeLists.txt

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D119969.409373.patch
Type: text/x-patch
Size: 6686 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220216/056e5584/attachment-0001.bin>


More information about the libcxx-commits mailing list