[libcxx-commits] [libcxx] [libc++] Hoist <compare> outside the threads guard in <thread> (PR #202535)

via libcxx-commits libcxx-commits at lists.llvm.org
Tue Jun 9 01:25:05 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libcxx

Author: Louis Dionne (ldionne)

<details>
<summary>Changes</summary>

The standard mandates [thread.syn] include <compare> as part of <thread>'s synopsis. This is a standards-mandated dependency, not a thread-feature dependency, so it should be visible regardless of _LIBCPP_HAS_THREADS.

This matches how we handle standard-mandated includes elsewhere, see for example #<!-- -->134877.

---
Full diff: https://github.com/llvm/llvm-project/pull/202535.diff


1 Files Affected:

- (modified) libcxx/include/thread (+5-5) 


``````````diff
diff --git a/libcxx/include/thread b/libcxx/include/thread
index f252273ebadcd..a8f7958346554 100644
--- a/libcxx/include/thread
+++ b/libcxx/include/thread
@@ -91,6 +91,11 @@ void sleep_for(const chrono::duration<Rep, Period>& rel_time);
 #else
 #  include <__config>
 
+// standard-mandated includes
+
+// [thread.syn]
+#  include <compare>
+
 #  if _LIBCPP_HAS_THREADS
 
 #    include <__thread/this_thread.h>
@@ -106,11 +111,6 @@ void sleep_for(const chrono::duration<Rep, Period>& rel_time);
 
 #    include <version>
 
-// standard-mandated includes
-
-// [thread.syn]
-#    include <compare>
-
 #    if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #      pragma GCC system_header
 #    endif

``````````

</details>


https://github.com/llvm/llvm-project/pull/202535


More information about the libcxx-commits mailing list