[libcxx-commits] [libcxx] [libc++] "Always" include_next for non C++ path in stdatomic.h (PR #178463)

Walter Lee via libcxx-commits libcxx-commits at lists.llvm.org
Wed Jan 28 08:41:24 PST 2026


https://github.com/googlewalt created https://github.com/llvm/llvm-project/pull/178463

In https://github.com/llvm/llvm-project/pull/176903, `#include <__configuration/compiler.h>` is moved into the 
`#ifdef _cplusplus` clause, so `_LIBCPP_COMPILER_CLANG_BASED` is no longer set for C compiles.  This causes a regression internally, where when C compiles includes stdatomic.h, they no longer get the corresponding C header.

C++ stdlib headers "shouldn't" be on the search patch for C compile, but we do and so do lots of other people, so libc++ tends to support that.  This include_next for a C compile should be unconditional, not conditional upon being Clang.

>From 195b82164d17344c4ce4fbf051feb817eaf5cf65 Mon Sep 17 00:00:00 2001
From: Walter Lee <waltl at google.com>
Date: Wed, 28 Jan 2026 11:33:18 -0500
Subject: [PATCH] [libcpp] Unconditionally include_next in stdatomic.h

"#ifdef _cplusplus", so _LIBCPP_COMPILER_CLANG_BASED is no longer set
for C compiles.  This causes a regression internally, where C compiles
no longer get the C header when it includes stdatomic.h.

C++ stdlib headers "shouldn't" be on the search patch for C compile,
but we do and so do lots of other people, so libc++ tends to support
that.  The include_next for a C compile should be unconditional, not
conditional upon being Clang.
---
 libcxx/include/__cxx03/stdatomic.h | 2 +-
 libcxx/include/stdatomic.h         | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libcxx/include/__cxx03/stdatomic.h b/libcxx/include/__cxx03/stdatomic.h
index 78bb745303c1a..30378e5abef8a 100644
--- a/libcxx/include/__cxx03/stdatomic.h
+++ b/libcxx/include/__cxx03/stdatomic.h
@@ -220,7 +220,7 @@ using std::atomic_store_explicit _LIBCPP_USING_IF_EXISTS;
 using std::atomic_signal_fence _LIBCPP_USING_IF_EXISTS;
 using std::atomic_thread_fence _LIBCPP_USING_IF_EXISTS;
 
-#elif defined(_LIBCPP_COMPILER_CLANG_BASED)
+#else
 
 // Before C++23, we include the next <stdatomic.h> on the path to avoid hijacking
 // the header. We do this because Clang has historically shipped a <stdatomic.h>
diff --git a/libcxx/include/stdatomic.h b/libcxx/include/stdatomic.h
index 2991030eee456..aeb4442898c09 100644
--- a/libcxx/include/stdatomic.h
+++ b/libcxx/include/stdatomic.h
@@ -231,7 +231,7 @@ using std::atomic_store_explicit _LIBCPP_USING_IF_EXISTS;
 using std::atomic_signal_fence _LIBCPP_USING_IF_EXISTS;
 using std::atomic_thread_fence _LIBCPP_USING_IF_EXISTS;
 
-#  elif defined(_LIBCPP_COMPILER_CLANG_BASED)
+#  else
 
 // Before C++23, we include the next <stdatomic.h> on the path to avoid hijacking
 // the header. We do this because Clang has historically shipped a <stdatomic.h>



More information about the libcxx-commits mailing list