[libcxx-commits] [PATCH] D110975: [libcxx] Don't autodetect pthreads on MinGW

Martin Storsjö via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri Oct 1 14:35:25 PDT 2021


mstorsjo created this revision.
mstorsjo added reviewers: mati865, EricWF.
mstorsjo requested review of this revision.
Herald added a project: libc++.
Herald added a reviewer: libc++.

e9ee517930f76a972fcda00d9dd0466db80d60f7 added support for using
winpthreads on Windows, enabled if `__WINPTHREADS_VERSION` was
defined (i.e. if winpthreads headers have been included before
including libcxx `__config`). This was fragile (libcxx changed
behaviour depending on what headers had been included externally
before), and was changed in a1bc823a59d5b6f310bdf6c7c7b62ec71b87d1aa
to use pthreads on Windows whenever the pthread.h header was
available.

In practice, in every modern setup for building libcxx for Windows
I've seen, users end up manually configuring it with
`LIBCXX_HAS_WIN32_THREAD_API=ON`, as the users may have winpthreads
installed (for other libraries/projects to use) while wanting to
build libcxx with the default win32 threading.

Don't automatically pick up pthreads on Windows even if the header
is available. Instead require the user to configure the libcxx
build with `LIBCXX_HAS_PTHREAD_API=ON` if that's desired.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D110975

Files:
  libcxx/include/__config


Index: libcxx/include/__config
===================================================================
--- libcxx/include/__config
+++ libcxx/include/__config
@@ -1072,8 +1072,7 @@
       defined(__APPLE__) || \
       defined(__sun__) || \
       defined(__MVS__) || \
-      defined(_AIX) || \
-      (defined(__MINGW32__) && __has_include(<pthread.h>))
+      defined(_AIX)
 #    define _LIBCPP_HAS_THREAD_API_PTHREAD
 #  elif defined(__Fuchsia__)
      // TODO(44575): Switch to C11 thread API when possible.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D110975.376639.patch
Type: text/x-patch
Size: 509 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20211001/d9e08e60/attachment-0001.bin>


More information about the libcxx-commits mailing list