[libcxx-commits] [libcxx] [libc++][pstl] Use libdispatch on Apple platforms by default (PR #223240)
via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Sep 13 12:05:49 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libcxx
Author: Michael G. Kazakov (mikekazakov)
<details>
<summary>Changes</summary>
Currently the default on Apple platforms is "std_thread", which is now a serial dummy.
To enable automatic benchmarking of PSTL, set the backend to "libdispatch" by default, so it doesn't require specific overrides in `libcxx/utils/ci/lnt/cmake`.
As a drive-by, fixes some of the minor issues with this backend that surfaced once more pipelines started using it.
---
Full diff: https://github.com/llvm/llvm-project/pull/223240.diff
4 Files Affected:
- (modified) libcxx/CMakeLists.txt (+7-3)
- (modified) libcxx/cmake/caches/Apple.cmake (-1)
- (modified) libcxx/include/__pstl/backends/libdispatch.h (+1)
- (modified) libcxx/test/libcxx/algorithms/pstl.libdispatch.chunk_partitions.pass.cpp (+2)
``````````diff
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 "")
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>
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);
``````````
</details>
https://github.com/llvm/llvm-project/pull/223240
More information about the libcxx-commits
mailing list