Skip to content

Conversation

Meinersbur
Copy link
Member

@Meinersbur Meinersbur commented Aug 26, 2025

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

@Meinersbur Meinersbur changed the title [Flang-RT][OpenMP] Use _GLIBCXX_NO_ASSERTIONS [Flang-RT][OpenMP] Define _GLIBCXX_NO_ASSERTIONS Aug 26, 2025
@Meinersbur Meinersbur requested review from dpalermo and ronlieb August 26, 2025 15:58
@Meinersbur Meinersbur marked this pull request as ready for review August 26, 2025 19:47
@llvmbot llvmbot added the openmp:libomp OpenMP host runtime label Aug 26, 2025
@Meinersbur Meinersbur requested review from mjklemm and LU-JOHN August 26, 2025 19:48
@@ -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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like for flang-rt, I think we also need -U_LIBCPP_ENABLE_ASSERTIONS in libomp

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is unrelated to gcc-mirror/gcc@361d230, should be a separate PR

@Meinersbur Meinersbur merged commit 88f8ab0 into llvm:main Aug 27, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
openmp:libomp OpenMP host runtime
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants