[llvm] [openmp] [Flang-RT][OpenMP] Use _GLIBCXX_NO_ASSERTIONS (PR #155440)

Michael Kruse via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 26 08:58:19 PDT 2025


https://github.com/Meinersbur created https://github.com/llvm/llvm-project/pull/155440

Since GCC 15.1, libstdc++ enabled assertions/hardening by default in optimized builds. That is, _GLIBCXX_ASSERTIONS is defined in the libstdc++ headers itself so defining/undefining on the compiler command line no longer has an effect. As the commit message[1,2] suggests, define _GLIBCXX_NO_ASSERTIONS instead.

For libstdc++ headers before 15.1, -U_GLIBCXX_ASSERTIONS is kept at the command line as well

[1] https://github.com/gcc-mirror/gcc/commit/361d230fd7800a7e749aba8ed020f54f5c26d504
[2] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112808

>From 7a8027ab5680cbb5711b7a1e2d553a22143e383b Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Tue, 26 Aug 2025 17:40:07 +0200
Subject: [PATCH] Use _GLIBCXX_NO_ASSERTIONS

---
 flang-rt/cmake/modules/AddFlangRT.cmake | 1 +
 openmp/runtime/src/CMakeLists.txt       | 1 +
 2 files changed, 2 insertions(+)

diff --git a/flang-rt/cmake/modules/AddFlangRT.cmake b/flang-rt/cmake/modules/AddFlangRT.cmake
index 58541609829c4..66e54bd2103a3 100644
--- a/flang-rt/cmake/modules/AddFlangRT.cmake
+++ b/flang-rt/cmake/modules/AddFlangRT.cmake
@@ -281,6 +281,7 @@ function (add_flangrt_library name)
 
     # Disable libstdc++/libc++ assertions, even in an LLVM_ENABLE_ASSERTIONS
     # build, to avoid an unwanted dependency on libstdc++/libc++.so.
+    target_compile_definitions(${tgtname} PUBLIC _GLIBCXX_NO_ASSERTIONS)
     if (FLANG_RT_SUPPORTS_UNDEFINE_FLAG)
       target_compile_options(${tgtname} PUBLIC -U_GLIBCXX_ASSERTIONS)
       target_compile_options(${tgtname} PUBLIC -U_LIBCPP_ENABLE_ASSERTIONS)
diff --git a/openmp/runtime/src/CMakeLists.txt b/openmp/runtime/src/CMakeLists.txt
index 08e1753b93636..b22d03d168419 100644
--- a/openmp/runtime/src/CMakeLists.txt
+++ b/openmp/runtime/src/CMakeLists.txt
@@ -167,6 +167,7 @@ endif()
 
 # Disable libstdc++ assertions, even in an LLVM_ENABLE_ASSERTIONS build, to
 # avoid an unwanted dependency on libstdc++.so.
+add_compile_definitions(_GLIBCXX_NO_ASSERTIONS)
 if(NOT WIN32)
   add_definitions(-U_GLIBCXX_ASSERTIONS)
 endif()



More information about the llvm-commits mailing list