[libcxx-commits] [PATCH] D103947: [libcxx] Fix using the vcruntime ABI with _HAS_EXCEPTIONS=0 defined

Martin Storsjö via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Jun 9 01:29:51 PDT 2021


mstorsjo created this revision.
mstorsjo added reviewers: phosek, zero9178.
mstorsjo requested review of this revision.
Herald added a project: libc++.
Herald added a reviewer: libc++.

_HAS_EXCEPTIONS=0 allows disabling the exception parts of the MS STL
and vcruntime, and e.g. compiler-rt/lib/fuzzer sets this define (to
work around issues with MS STL). If using libc++ instead of MS STL,
this define previously broke the libc++ headers.

If _HAS_EXCEPTIONS is set to 0, the vcruntime_exception.h header
doesn't define the ABI base class std::exception. If no exceptions
are going to be thrown, this probably is fine (although it also
breaks using subclasses of it as regular objects that aren't thrown),
but it requires ifdeffing out all subclasses of all exception/error
derived objects (which are sprinkled throughout the headers).

Instead use the libc++ provided std::exception class in this case,
making the class hierarchies complete. Define _LIBCPP_NO_EXCEPTIONS
to avoid throwing exceptions.

In this build configuration, one can still create instances of
exception subclasses, and those objects will be ABI incompatible
with the ones from when _HAS_EXCEPTIONS isn't defined to 0 - but
that's IMO a pathological/self-imposed problem in that case.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D103947

Files:
  libcxx/include/__config
  libcxx/include/exception
  libcxx/include/stdexcept

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D103947.350812.patch
Type: text/x-patch
Size: 4689 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20210609/b84a6cc8/attachment.bin>


More information about the libcxx-commits mailing list