[Openmp-commits] [flang] [llvm] [openmp] [Flang-RT] Fix GCC 15.1 Fortran Runtime libstdc++ Undefined Symbols (PR #157385)
Michael Kruse via Openmp-commits
openmp-commits at lists.llvm.org
Thu Oct 2 04:29:26 PDT 2025
================
@@ -24,6 +24,17 @@ using cuda::std::variant_size_v;
using cuda::std::visit;
} // namespace std
#else // !RT_USE_LIBCUDACXX
+
+// initializer_list is included to load bits/c++config, which can't be included
+// directly and which defines a macro we need to redefine.
+#include <initializer_list>
+
+// Redefine problematic abort macro to avoid defining symbols related to
+// std::exception. std::exception is defined in the C++ runtime library, which
+// we do not want the Fortran runtime library to depend on.
----------------
Meinersbur wrote:
The comment is imprecise. The macro is used to handle `-fno-exceptions`, i.e. does not necessarily abort. Symbols like `std::exception` are always defined, we just need to avoid a use of it. It could mention a lot more details given how unusual doing this is. Suggestion:
```suggestion
// The macro _GLIBCXX_THROW_OR_ABORT is used by libstdc++ to not throw exceptions in -fno-exceptions mode, but immediatly kill the program. Since libstdc++ 15.1 the macro uses (void)(_EXC) after calling abort() to silence compiler warnings of an parameter. In its use in <variant>, _EXC is the construction of `std::bad_variant_access`. In non-optimized builds, some compilers including Clang will emit a call to that constructor. The constructor is implemented in libstdc++.a/.so which Flang-RT must not depend on (to avoid compatibility problems if a Fortran application itself has parts implemented in C++). Note that _GLIBCXX_THROW_OR_ABORT is not on the list of libstdc++'s documented user-configurable macros.
```
https://github.com/llvm/llvm-project/pull/157385
More information about the Openmp-commits
mailing list