[libcxx-commits] [PATCH] D143689: [libc++] Add an option to disable the use of __ulock_wait

Byoungchan Lee via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Feb 9 16:00:02 PST 2023


bc-lee created this revision.
bc-lee added reviewers: libc++, ldionne.
Herald added a project: All.
bc-lee requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added 1 blocking reviewer(s): libc++.

`__ulock_wait` / `__ulock_wake` are considered private APIs and
their use will result in rejection from the App Store.
libc++ comes natively on Apple platforms, but some projects
prefer to static link their own libc++ builds.

So, add a CMake option to disable the use of `__ulock_wait`
on Apple platforms.

Also fix an issue where `__ulock_wait` code-path is actually not used
due to a missing include.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D143689

Files:
  libcxx/CMakeLists.txt
  libcxx/include/__config_site.in
  libcxx/src/atomic.cpp
  libcxx/src/include/apple_availability.h


Index: libcxx/src/include/apple_availability.h
===================================================================
--- libcxx/src/include/apple_availability.h
+++ libcxx/src/include/apple_availability.h
@@ -29,6 +29,7 @@
 #endif
 #endif // __ENVIRONMENT_.*_VERSION_MIN_REQUIRED__
 
+#if !defined(_LIBCXXX_DISABLE_ULOCK_WAIT)
 #if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)
 #if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101500
 #define _LIBCPP_USE_ULOCK
@@ -46,6 +47,7 @@
 #define _LIBCPP_USE_ULOCK
 #endif
 #endif // __ENVIRONMENT_.*_VERSION_MIN_REQUIRED__
+#endif // _LIBCXXX_DISABLE_ULOCK_WAIT
 
 #endif // __APPLE__
 
Index: libcxx/src/atomic.cpp
===================================================================
--- libcxx/src/atomic.cpp
+++ libcxx/src/atomic.cpp
@@ -26,6 +26,9 @@
 # define SYS_futex SYS_futex_time64
 #endif
 
+#elif defined(__APPLE__)
+#include "include/apple_availability.h"
+
 #elif defined(__FreeBSD__)
 
 #include <sys/types.h>
Index: libcxx/include/__config_site.in
===================================================================
--- libcxx/include/__config_site.in
+++ libcxx/include/__config_site.in
@@ -32,6 +32,9 @@
 #cmakedefine _LIBCPP_HAS_NO_WIDE_CHARACTERS
 #cmakedefine01 _LIBCPP_ENABLE_ASSERTIONS_DEFAULT
 #cmakedefine _LIBCPP_ENABLE_DEBUG_MODE
+#ifdef __APPLE__
+#cmakedefine _LIBCXXX_DISABLE_ULOCK_WAIT
+#endif
 
 // __USE_MINGW_ANSI_STDIO gets redefined on MinGW
 #ifdef __clang__
Index: libcxx/CMakeLists.txt
===================================================================
--- libcxx/CMakeLists.txt
+++ libcxx/CMakeLists.txt
@@ -285,6 +285,8 @@
 option(LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY
     "Build libc++ with an externalized threading library.
      This option may only be set to ON when LIBCXX_ENABLE_THREADS=ON" OFF)
+option(LIBCXXX_DISABLE_APPLE_ULOCK_WAIT
+    "Build libc++ without __ulock_wait on Apple platforms" OFF)
 
 # Misc options ----------------------------------------------------------------
 # FIXME: Turn -pedantic back ON. It is currently off because it warns
@@ -857,6 +859,9 @@
 else()
   config_define(0 _LIBCPP_ENABLE_ASSERTIONS_DEFAULT)
 endif()
+if (APPLE)
+  config_define_if(LIBCXXX_DISABLE_APPLE_ULOCK_WAIT _LIBCXXX_DISABLE_ULOCK_WAIT)
+endif()
 
 if (LIBCXX_ABI_DEFINES)
   set(abi_defines)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D143689.496270.patch
Type: text/x-patch
Size: 2299 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20230210/89809696/attachment-0001.bin>


More information about the libcxx-commits mailing list