[flang-commits] [flang] flang: Fix build with latest libc++ (PR #127362)

Tom Stellard via flang-commits flang-commits at lists.llvm.org
Sat Feb 15 17:45:46 PST 2025


https://github.com/tstellar updated https://github.com/llvm/llvm-project/pull/127362

>From e8e1e76b1f40ff17dfedfcb2d32f86c4282b0533 Mon Sep 17 00:00:00 2001
From: Tom Stellard <tstellar at redhat.com>
Date: Sat, 15 Feb 2025 14:46:20 +0000
Subject: [PATCH 1/2] flang: Fix build with latest libc++

I think this first stopped working with
954836634abb446f18719b14120c386a929a42d1.  This patch fixes the
following error:

/home/runner/work/llvm-project/llvm-project/flang/runtime/io-api-minimal.cpp:153:11: error: '__libcpp_verbose_abort' is missing exception specification 'noexcept'
   153 | void std::__libcpp_verbose_abort(char const *format, ...) {
       |           ^
       |                                                           noexcept
/mnt/build/bin/../include/c++/v1/__verbose_abort:30:28: note: previous declaration is here
    30 |     __printf__, 1, 2) void __libcpp_verbose_abort(const char* __format, ...) _LIBCPP_VERBOSE_ABORT_NOEXCEPT;
       |                            ^
1 error generated.
---
 flang/runtime/io-api-minimal.cpp | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/flang/runtime/io-api-minimal.cpp b/flang/runtime/io-api-minimal.cpp
index 68768427be0c2..e53089e02d93d 100644
--- a/flang/runtime/io-api-minimal.cpp
+++ b/flang/runtime/io-api-minimal.cpp
@@ -150,7 +150,12 @@ bool IODEF(OutputLogical)(Cookie cookie, bool truth) {
 // 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, ...) {
+#if !defined(_LIBCPP_VERBOSE_ABORT_NOEXCEPT)
+  #define _LIBCPP_VERBOSE_ABORT_NOEXCEPT
+#endif
+
+
+void std::__libcpp_verbose_abort(char const *format, ...) _LIBCPP_VERBOSE_ABORT_NOEXCEPT {
   va_list list;
   va_start(list, format);
   std::vfprintf(stderr, format, list);

>From 9b0da99ddc105f0f70c5628425e54aaff9e754b6 Mon Sep 17 00:00:00 2001
From: Tom Stellard <tstellar at redhat.com>
Date: Sat, 15 Feb 2025 17:45:02 -0800
Subject: [PATCH 2/2] Fix formatting

---
 flang/runtime/io-api-minimal.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/flang/runtime/io-api-minimal.cpp b/flang/runtime/io-api-minimal.cpp
index e53089e02d93d..a661261535f40 100644
--- a/flang/runtime/io-api-minimal.cpp
+++ b/flang/runtime/io-api-minimal.cpp
@@ -151,11 +151,11 @@ bool IODEF(OutputLogical)(Cookie cookie, bool truth) {
 // on the version provided by libc++.
 
 #if !defined(_LIBCPP_VERBOSE_ABORT_NOEXCEPT)
-  #define _LIBCPP_VERBOSE_ABORT_NOEXCEPT
+#define _LIBCPP_VERBOSE_ABORT_NOEXCEPT
 #endif
 
-
-void std::__libcpp_verbose_abort(char const *format, ...) _LIBCPP_VERBOSE_ABORT_NOEXCEPT {
+void std::__libcpp_verbose_abort(
+    char const *format, ...) _LIBCPP_VERBOSE_ABORT_NOEXCEPT {
   va_list list;
   va_start(list, format);
   std::vfprintf(stderr, format, list);



More information about the flang-commits mailing list