Skip to content

Commit 88f8ab0

Browse files
authored
[Flang-RT][OpenMP] Define _GLIBCXX_NO_ASSERTIONS (#155440)
Since GCC 15.1, libstdc++ enabled assertions/hardening by default in non-optimized (-O0) builds [1]. That is, _GLIBCXX_ASSERTIONS is defined in the libstdc++ headers itself so defining/undefining it on the compiler command line no longer has an effect in non-optimized builds. As the commit message[2] suggests, define _GLIBCXX_NO_ASSERTIONS instead. For libstdc++ headers before 15.1, -U_GLIBCXX_ASSERTIONS still has to be on the command line as well. Defining _GLIBCXX_NO_ASSERTIONS was previously proposed in #152223 [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112808 [2] gcc-mirror/gcc@361d230
1 parent 6551f7f commit 88f8ab0

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

flang-rt/cmake/modules/AddFlangRT.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ function (add_flangrt_library name)
281281

282282
# Disable libstdc++/libc++ assertions, even in an LLVM_ENABLE_ASSERTIONS
283283
# build, to avoid an unwanted dependency on libstdc++/libc++.so.
284+
target_compile_definitions(${tgtname} PUBLIC _GLIBCXX_NO_ASSERTIONS)
284285
if (FLANG_RT_SUPPORTS_UNDEFINE_FLAG)
285286
target_compile_options(${tgtname} PUBLIC -U_GLIBCXX_ASSERTIONS)
286287
target_compile_options(${tgtname} PUBLIC -U_LIBCPP_ENABLE_ASSERTIONS)

openmp/runtime/src/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ endif()
167167

168168
# Disable libstdc++ assertions, even in an LLVM_ENABLE_ASSERTIONS build, to
169169
# avoid an unwanted dependency on libstdc++.so.
170+
add_compile_definitions(_GLIBCXX_NO_ASSERTIONS)
170171
if(NOT WIN32)
171172
add_definitions(-U_GLIBCXX_ASSERTIONS)
172173
endif()

0 commit comments

Comments
 (0)