[libcxx-commits] [libcxx] [libc++][pstl] Use libdispatch on Apple platforms by default (PR #223240)
Michael G. Kazakov via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Sep 13 08:24:10 PDT 2026
https://github.com/mikekazakov updated https://github.com/llvm/llvm-project/pull/223240
>From fc426276388244dc39ce45bdb7c5332cad51066e Mon Sep 17 00:00:00 2001
From: Michael Kazakov <mike.kazakov at gmail.com>
Date: Sun, 13 Sep 2026 13:15:54 +0100
Subject: [PATCH 1/3] Use libdispatch on Apple platforms by default
---
libcxx/CMakeLists.txt | 10 +++++++---
libcxx/cmake/caches/Apple.cmake | 1 -
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index 8841f5d07aaf6..d163f0f579c39 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -320,12 +320,16 @@ option(LIBCXX_HAS_EXTERNAL_THREAD_API
This option may only be set to ON when LIBCXX_ENABLE_THREADS=ON." OFF)
option(LIBCXX_HAS_C11_THREAD_API "Ignore auto-detection and force use of C11 thread API" OFF)
-if (LIBCXX_ENABLE_THREADS)
- set(LIBCXX_PSTL_BACKEND "std_thread" CACHE STRING "Which PSTL backend to use")
+if (APPLE)
+ set(LIBCXX_PSTL_BACKEND_DEFAULT_VALUE "libdispatch")
+elseif(LIBCXX_ENABLE_THREADS)
+ set(LIBCXX_PSTL_BACKEND_DEFAULT_VALUE "std_thread")
else()
- set(LIBCXX_PSTL_BACKEND "serial" CACHE STRING "Which PSTL backend to use")
+ set(LIBCXX_PSTL_BACKEND_DEFAULT_VALUE "serial")
endif()
+set(LIBCXX_PSTL_BACKEND "${LIBCXX_PSTL_BACKEND_DEFAULT_VALUE}" CACHE STRING "Which PSTL backend to use")
+
# Misc options ----------------------------------------------------------------
# FIXME: Turn -pedantic back ON. It is currently off because it warns
# about #include_next which is used everywhere.
diff --git a/libcxx/cmake/caches/Apple.cmake b/libcxx/cmake/caches/Apple.cmake
index 7dbe90fb351a9..e4fff36788ea9 100644
--- a/libcxx/cmake/caches/Apple.cmake
+++ b/libcxx/cmake/caches/Apple.cmake
@@ -8,7 +8,6 @@ set(LIBCXX_ENABLE_STATIC ON CACHE BOOL "")
set(LIBCXX_ENABLE_SHARED ON CACHE BOOL "")
set(LIBCXX_CXX_ABI libcxxabi CACHE STRING "")
set(LIBCXX_ENABLE_VENDOR_AVAILABILITY_ANNOTATIONS ON CACHE BOOL "")
-set(LIBCXX_PSTL_BACKEND libdispatch CACHE STRING "")
set(LIBCXX_HERMETIC_STATIC_LIBRARY ON CACHE BOOL "")
set(LIBCXXABI_HERMETIC_STATIC_LIBRARY ON CACHE BOOL "")
>From 46c13590e8d446c009c31402335d759c887950fc Mon Sep 17 00:00:00 2001
From: Michael Kazakov <mike.kazakov at gmail.com>
Date: Sun, 13 Sep 2026 16:21:11 +0100
Subject: [PATCH 2/3] Missing include
---
libcxx/include/__pstl/backends/libdispatch.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/libcxx/include/__pstl/backends/libdispatch.h b/libcxx/include/__pstl/backends/libdispatch.h
index dbd9fa34e1f87..b39691ee5a2bb 100644
--- a/libcxx/include/__pstl/backends/libdispatch.h
+++ b/libcxx/include/__pstl/backends/libdispatch.h
@@ -17,6 +17,7 @@
#include <__algorithm/lower_bound.h>
#include <__algorithm/max.h>
#include <__algorithm/merge.h>
+#include <__algorithm/move.h>
#include <__algorithm/upper_bound.h>
#include <__atomic/atomic.h>
#include <__config>
>From ceecfd65f16115df34ee7c74ff8e834642b94b69 Mon Sep 17 00:00:00 2001
From: Michael Kazakov <mike.kazakov at gmail.com>
Date: Sun, 13 Sep 2026 16:23:56 +0100
Subject: [PATCH 3/3] Don't check libdispatch partitioning in C++ < 17
---
.../algorithms/pstl.libdispatch.chunk_partitions.pass.cpp | 2 ++
1 file changed, 2 insertions(+)
diff --git a/libcxx/test/libcxx/algorithms/pstl.libdispatch.chunk_partitions.pass.cpp b/libcxx/test/libcxx/algorithms/pstl.libdispatch.chunk_partitions.pass.cpp
index b48ac02dd79c5..614eb4fc5c155 100644
--- a/libcxx/test/libcxx/algorithms/pstl.libdispatch.chunk_partitions.pass.cpp
+++ b/libcxx/test/libcxx/algorithms/pstl.libdispatch.chunk_partitions.pass.cpp
@@ -8,7 +8,9 @@
// <algorithm>
+// REQUIRES: std-at-least-c++17
// REQUIRES: libcpp-pstl-backend-libdispatch
+// UNSUPPORTED: libcpp-has-no-incomplete-pstl
// __chunk_partitions __partition_chunks(ptrdiff_t);
More information about the libcxx-commits
mailing list