[packages/crossmingw32-gcc] - added pthreads-w32, use POSIX threading model for std::thread/std::mutex support

qboosh qboosh at pld-linux.org
Sat Apr 22 11:38:06 CEST 2023


commit 46fc5303aefb32b43e2d1dd71f1a25045f2ce661
Author: Jakub Bogusz <qboosh at pld-linux.org>
Date:   Sat Apr 22 11:40:49 2023 +0200

    - added pthreads-w32, use POSIX threading model for std::thread/std::mutex support

 crossmingw32-gcc.spec  | 10 ++++++++--
 gcc-pthreads-w32.patch | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 57 insertions(+), 2 deletions(-)
---
diff --git a/crossmingw32-gcc.spec b/crossmingw32-gcc.spec
index 24c88fd..6706a42 100644
--- a/crossmingw32-gcc.spec
+++ b/crossmingw32-gcc.spec
@@ -1,9 +1,13 @@
 #
 # Conditional build:
 %bcond_with	bootstrap	# bootstrap build (using binary w32api/mingwrt, only C/C++, no gomp)
+%bcond_without	pthreads	# POSIX threads support (needed for GOMP and C++ 11 thread/mutex support)
 %bcond_without	gomp		# OpenMP libraries
 #
 %if %{with bootstrap}
+%undefine	with_pthreads
+%endif
+%if %{without pthreads}
 %undefine	with_gomp
 %endif
 Summary:	Cross MinGW32 GNU binary utility development utilities - gcc
@@ -35,12 +39,13 @@ Patch1:		%{name}-buildsystem2.patch
 Patch2:		%{name}-lfs.patch
 Patch3:		gcc-mingw32.patch
 Patch4:		gcc-build-libvtv.patch
+Patch5:		gcc-pthreads-w32.patch
 URL:		http://gcc.gnu.org/
 BuildRequires:	autoconf >= 2.64
 BuildRequires:	automake >= 1:1.11.1
 BuildRequires:	bison
 BuildRequires:	crossmingw32-binutils >= 2.23
-%{?with_gomp:BuildRequires:	crossmingw32-pthreads-w32}
+%{?with_pthreads:BuildRequires:	crossmingw32-pthreads-w32}
 %if %{without bootstrap}
 BuildRequires:	crossmingw32-runtime >= 3.5
 BuildRequires:	crossmingw32-w32api >= 3.1
@@ -477,6 +482,7 @@ Biblioteka DLL GCC do obsługi typu __float128 dla Windows.
 %patch2 -p1
 %patch3 -p1
 %patch4 -p1
+%patch5 -p1
 
 %if %{with bootstrap}
 # note: "winsup" dirs are special, handled by gcc's configure
@@ -550,7 +556,7 @@ CXXFLAGS_FOR_TARGET="-O2 -march=i486" \
 	--enable-shared \
 	--disable-sjlj-exceptions \
 	--disable-symvers \
-	--enable-threads \
+	--enable-threads%{?with_pthreads:=posix} \
 	--disable-werror \
 	--disable-win32-registry \
 	--target=%{target}
diff --git a/gcc-pthreads-w32.patch b/gcc-pthreads-w32.patch
new file mode 100644
index 0000000..6589e6f
--- /dev/null
+++ b/gcc-pthreads-w32.patch
@@ -0,0 +1,49 @@
+--- gcc-9.5.0/libgcc/gthr-posix.h.orig	2022-05-27 09:21:12.915389144 +0200
++++ gcc-9.5.0/libgcc/gthr-posix.h	2023-04-21 21:34:01.235216833 +0200
+@@ -372,7 +372,7 @@ __gthread_objc_thread_detach (void (*fun
+ 
+   if (!(__gthrw_(pthread_create) (&new_thread_handle, &_objc_thread_attribs,
+ 				  (void *) func, arg)))
+-    thread_id = (objc_thread_t) new_thread_handle;
++    thread_id = (objc_thread_t) new_thread_handle.p;
+   else
+     thread_id = NULL;
+ 
+@@ -469,7 +469,7 @@ static inline objc_thread_t
+ __gthread_objc_thread_id (void)
+ {
+   if (__gthread_active_p ())
+-    return (objc_thread_t) __gthrw_(pthread_self) ();
++    return (objc_thread_t) __gthrw_(pthread_self) ().x;
+   else
+     return (objc_thread_t) 1;
+ }
+--- gcc-9.5.0/libstdc++-v3/include/std/thread.orig	2022-05-27 09:21:13.435391692 +0200
++++ gcc-9.5.0/libstdc++-v3/include/std/thread	2023-04-21 22:05:23.125021761 +0200
+@@ -279,7 +279,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
+     // can't safely use __gthread_equal on default-constructed values (nor
+     // the non-zero value returned by this_thread::get_id() for
+     // single-threaded programs using GNU libc). Assume EqualityComparable.
+-    return __x._M_thread == __y._M_thread;
++    return __x._M_thread.p == __y._M_thread.p;
+   }
+ 
+   inline bool
+@@ -291,7 +291,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
+   {
+     // Pthreads doesn't define any way to do this, so we just have to
+     // assume native_handle_type is LessThanComparable.
+-    return __x._M_thread < __y._M_thread;
++    return __x._M_thread.p < __y._M_thread.p;
+   }
+ 
+   inline bool
+@@ -314,7 +314,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
+     {
+       size_t
+       operator()(const thread::id& __id) const noexcept
+-      { return std::_Hash_impl::hash(__id._M_thread); }
++      { return std::_Hash_impl::hash(__id._M_thread.p); }
+     };
+ 
+   template<class _CharT, class _Traits>
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/crossmingw32-gcc.git/commitdiff/46fc5303aefb32b43e2d1dd71f1a25045f2ce661



More information about the pld-cvs-commit mailing list