[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 05:22:07 PDT 2026


https://github.com/mikekazakov created https://github.com/llvm/llvm-project/pull/223240

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`.

>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] 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 8841f5d07aaf6c..d163f0f579c395 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 7dbe90fb351a9e..e4fff36788ea95 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 "")



More information about the libcxx-commits mailing list