[PATCH] D53631: Fix libcxx build with MinGW winpthreads

Peiyuan Song via Phabricator reviews at reviews.llvm.org
Tue Oct 23 18:33:02 PDT 2018


SquallATF created this revision.
Herald added subscribers: libcxx-commits, jfb, ldionne, christof, mgorny.
Herald added a reviewer: EricWF.

1. winpthreads build broken after https://reviews.llvm.org/D42214, should not build thread_win32.cpp when enable pthread witht MinGW.
2. _LIBCPP_SAFE_STATIC incompatible with winpthreads, because winpthread PTHREAD_*_INITIALIZER use reinterpret_cast are not const.


Repository:
  rCXX libc++

https://reviews.llvm.org/D53631

Files:
  include/__config
  lib/CMakeLists.txt


Index: lib/CMakeLists.txt
===================================================================
--- lib/CMakeLists.txt
+++ lib/CMakeLists.txt
@@ -4,7 +4,13 @@
 # FIXME: Don't use glob here
 file(GLOB LIBCXX_SOURCES ../src/*.cpp)
 if(WIN32)
-  file(GLOB LIBCXX_WIN32_SOURCES ../src/support/win32/*.cpp)
+  set(LIBCXX_WIN32_SOURCES
+    ../src/support/win32/locale_win32.cpp
+    ../src/support/win32/support.cpp
+  )
+  if(LIBCXX_HAS_WIN32_THREAD_API)
+    list(APPEND LIBCXX_WIN32_SOURCES ../src/support/win32/thread_win32.cpp)
+  endif()
   list(APPEND LIBCXX_SOURCES ${LIBCXX_WIN32_SOURCES})
 elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "SunOS")
   file(GLOB LIBCXX_SOLARIS_SOURCES ../src/support/solaris/*.cpp)
Index: include/__config
===================================================================
--- include/__config
+++ include/__config
@@ -1225,7 +1225,8 @@
 #  endif
 #endif
 
-#if __has_attribute(require_constant_initialization)
+#if __has_attribute(require_constant_initialization) &&                        \
+    !(defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && defined(__MINGW32__))
 #  define _LIBCPP_SAFE_STATIC __attribute__((__require_constant_initialization__))
 #else
 #  define _LIBCPP_SAFE_STATIC


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53631.170802.patch
Type: text/x-patch
Size: 1213 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20181024/e2c59041/attachment-0001.bin>


More information about the libcxx-commits mailing list