[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 09:22:17 PST 2026


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

>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 1/3] [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>

>From 3004b4d67ea30eaff10e368becbcf97caf491da5 Mon Sep 17 00:00:00 2001
From: Walter Lee <waltl at google.com>
Date: Wed, 28 Jan 2026 12:03:09 -0500
Subject: [PATCH 2/3] Fix else conditional to exclude C++ for non-clang
 compilers

---
 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 30378e5abef8a..4aa1ad406bcf3 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;
 
-#else
+#elif !defined(__cplusplus) || defined(_LIBCPP_COMPILER_CLANG_BASED)
 
 // 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 aeb4442898c09..e7b787560ddc4 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;
 
-#  else
+#  elif !defined(__cplusplus) || defined(_LIBCPP_COMPILER_CLANG_BASED)
 
 // 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>

>From da303c1720fd97f24218c68bedb20adb8a00f615 Mon Sep 17 00:00:00 2001
From: Walter Lee <waltl at google.com>
Date: Wed, 28 Jan 2026 12:21:51 -0500
Subject: [PATCH 3/3] Revert __cxx03 changes

---
 libcxx/include/__cxx03/stdatomic.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libcxx/include/__cxx03/stdatomic.h b/libcxx/include/__cxx03/stdatomic.h
index 4aa1ad406bcf3..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(__cplusplus) || 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