[flang-commits] [flang] [llvm] [openmp] [Flang-RT] Fix GCC 15.1 Fortran Runtime libstdc++ Undefined Symbols (PR #157385)
Michael Kruse via flang-commits
flang-commits at lists.llvm.org
Wed Oct 15 07:23:10 PDT 2025
================
@@ -231,6 +231,26 @@ function (add_flangrt_library name)
target_compile_options(${tgtname} PRIVATE
$<$<COMPILE_LANGUAGE:CXX>:-fno-exceptions -fno-rtti -funwind-tables -fno-asynchronous-unwind-tables>
)
+
+ # We define our own _GLIBCXX_THROW_OR_ABORT here because, as of
+ # GCC 15.1, libstdc++ uses (void)_EXC in its definition in order
+ # to silence a warning.
+ #
+ # This is a problem for us because some compilers, specifically
+ # clang, do not always optimize away that (void)_EXC even though
+ # it is unreachable since it occurs after a call to
+ # _builtin_abort(). Because _EXC is typically an object derived
+ # from std::exception, (void)_EXC, when not optimized away,
+ # causes a link reference to std::exception, and we do not want
+ # to link against std::exception since doing that would link us
+ # against the C++ runtime library, and we do not want to link
+ # the Fortran runtime against the C++ runtime.
----------------
Meinersbur wrote:
Reads like "causes A, and we do not want to do A since doing that would do B, and we do not want to do B" with A = "link to std::exception" and B = "link against C++ standard library". Can shorten and state the reason instead.
```suggestion
# calls std::exception methods in the libstdc++ static or dynamic library. We cannot link libstdc++ because it may conflict with a C++ runtime of a hybrid Fortran/C++ application.
```
https://github.com/llvm/llvm-project/pull/157385
More information about the flang-commits
mailing list