Skip to content

Commit 3ca6376

Browse files
committed
Additional documentation
1 parent d56bb1c commit 3ca6376

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

flang-rt/cmake/modules/AddFlangRT.cmake

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,10 +232,24 @@ function (add_flangrt_library name)
232232
$<$<COMPILE_LANGUAGE:CXX>:-fno-exceptions -fno-rtti -funwind-tables -fno-asynchronous-unwind-tables>
233233
)
234234

235-
# Define our own _GLIBCXX_THROW_OR_ABORT because libstdc++ headers
236-
# reference std::exception in its definition, and we do not want
237-
# to link against std::exception since doing that would link us to
238-
# the C++ runtime.
235+
# We define our own _GLIBCXX_THROW_OR_ABORT here because, as of
236+
# GCC 15.1, libstdc++ uses (void)_EXC in its definition in order
237+
# to silence a warning.
238+
#
239+
# This is a problem for us because some compilers, specifically
240+
# clang, do not always optimize away that (void)_EXC even though
241+
# it is unreachable since it occurs after a call to
242+
# _builtin_abort(). Because _EXC is typically an object derived
243+
# from std::exception, (void)_EXC, when not optimized away,
244+
# causes a link reference to std::exception, and we do not want
245+
# to link against std::exception since doing that would link us
246+
# against the C++ runtime library, and we do not want to link
247+
# the Fortran runtime against the C++ runtime.
248+
#
249+
# Redefining _GLIBCXX_THROW_OR_ABORT in this manner is not
250+
# supported by the maintainers of libstdc++, so future changes
251+
# to libstdc++ may require future changes to this build script
252+
# and/or future changes to the Fortran runtime source code.
239253
target_compile_options(${tgtname} PUBLIC "-D_GLIBCXX_THROW_OR_ABORT(_EXC)=(__builtin_abort())")
240254
elseif (MSVC)
241255
target_compile_options(${tgtname} PRIVATE

0 commit comments

Comments
 (0)