[flang-commits] [PATCH] D158957: [flang][runtime] Avoid dependency on libc++ for `std::__libcpp_verbose_abort`

Markus Mützel via Phabricator via flang-commits flang-commits at lists.llvm.org
Mon Aug 28 04:29:38 PDT 2023


mmuetzel updated this revision to Diff 553890.
mmuetzel added a comment.

It looks like there are some protections in place that prohibit the user to add functions to the `std` namespace that haven't been declared in the standard headers.

I hope that checking whether `_LIBCPP_AVAILABILITY_HAS_NO_VERBOSE_ABORT` is defined is a good condition to prevent that from happening.

I don't know why this general issue isn't happening in other cases.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158957/new/

https://reviews.llvm.org/D158957

Files:
  flang/runtime/io-api.cpp


Index: flang/runtime/io-api.cpp
===================================================================
--- flang/runtime/io-api.cpp
+++ flang/runtime/io-api.cpp
@@ -1515,3 +1515,17 @@
 #endif
 
 } // namespace Fortran::runtime::io
+
+#if !defined(_LIBCPP_AVAILABILITY_HAS_NO_VERBOSE_ABORT)
+// Provide own definition for `std::__libcpp_verbose_abort` to avoid dependency
+// on the version provided by libc++.
+
+void std::__libcpp_verbose_abort(char const* format, ...) {
+  va_list list;
+  va_start(list, format);
+  std::vfprintf(stderr, format, list);
+  va_end(list);
+
+  std::abort();
+}
+#endif


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D158957.553890.patch
Type: text/x-patch
Size: 601 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20230828/92b02ffa/attachment-0001.bin>


More information about the flang-commits mailing list