[libcxxabi] define _LIBCPP_VERBOSE_ABORT
authorNick Desaulniers <ndesaulniers@google.com>
Wed, 17 May 2023 16:30:30 +0000 (09:30 -0700)
committerNick Desaulniers <ndesaulniers@google.com>
Wed, 17 May 2023 16:42:35 +0000 (09:42 -0700)
libc++ may be built with or without assertions. This causes definitions
of various methods of std::string_view to contain assertions and calls
to __libcpp_verbose_abort which libcxxabi does not provide. libcxxabi
does provide abort_message with the same interface, so define
_LIBCPP_VERBOSE_ABORT to use that. Otherwise D148566 will trigger
linkage failures for the missing symbol __libcpp_verbose_abort.

Link: https://libcxx.llvm.org/UsingLibcxx.html#enabling-the-safe-libc-mode
Reviewed By: #libc_abi, philnik, ldionne

Differential Revision: https://reviews.llvm.org/D149092

libcxxabi/src/cxa_demangle.cpp
libcxxabi/src/demangle/DemangleConfig.h

index 7baac68..0616031 100644 (file)
@@ -10,6 +10,7 @@
 // file does not yet support:
 //   - C++ modules TS
 
+#include "demangle/DemangleConfig.h"
 #include "demangle/ItaniumDemangle.h"
 #include "__cxxabi_config.h"
 #include <cassert>
index 9d81853..5ae933c 100644 (file)
 #ifndef LIBCXXABI_DEMANGLE_DEMANGLE_CONFIG_H
 #define LIBCXXABI_DEMANGLE_DEMANGLE_CONFIG_H
 
+// Must be defined before pulling in headers from libc++.
+// https://libcxx.llvm.org/UsingLibcxx.html#enabling-the-safe-libc-mode
+#define _LIBCPP_VERBOSE_ABORT(...) abort_message(__VA_ARGS__)
+
+#include "../abort_message.h"
 #include <ciso646>
 
 #ifdef _MSC_VER