[libc++] Build thread_win32.cpp only if LIBCXX_HAS_PTHREAD_API is not set
authorColin Finck <colin@reactos.org>
Tue, 16 Feb 2021 15:03:04 +0000 (10:03 -0500)
committerLouis Dionne <ldionne.2@gmail.com>
Tue, 16 Feb 2021 15:03:42 +0000 (10:03 -0500)
This allows building libc++ against winpthreads from mingw-w64 to support
operating systems older than Windows 7. The remaining libc++ code already
supports `WIN32` with `LIBCXX_HAS_PTHREAD_API`.

Note that there is also the older "pthreads-win32". However, that support
library implements `pthread_t` as a struct, which violates the libc++
assumption that `pthread_t` is always a scalar and can be compared,
ordered, and set to zero.

Differential Revision: https://reviews.llvm.org/D96339

libcxx/src/CMakeLists.txt

index 76227d3..cfb7eb1 100644 (file)
@@ -77,8 +77,13 @@ if(WIN32)
   list(APPEND LIBCXX_SOURCES
     support/win32/locale_win32.cpp
     support/win32/support.cpp
-    support/win32/thread_win32.cpp
     )
+
+  if (NOT LIBCXX_HAS_PTHREAD_API)
+    list(APPEND LIBCXX_SOURCES
+      support/win32/thread_win32.cpp
+      )
+  endif()
 elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "SunOS")
   list(APPEND LIBCXX_SOURCES
     support/solaris/mbsnrtowcs.inc