Subject: [bug#78417] [PATCH 2/2] gnu: cross-base: mingw: Use winpthreads by default.

From: Janneke Nieuwenhuizen <[email-masked]>
Date: Wed, 14 May 2025 08:45:22 +0200

Using a version of mingw-64 with winpthreads, packages that support posix
threads, such as Guile, can be (cross-)built for MinGW with thread support.

Also, since gcc-13, a MinGW (cross-)compiler provides g++ with std::mutex when
built with a version of mingw-w64 that has winpthreads enabled.

* gnu/packages/cross-base.scm (cross-gcc-toolchain/implementation):
Add #:with-winpthreads? parameter, defaulting to #t.  Pass it...
(cross-libc*): ...to new #:with-winpthreads? parameter here, defaulting to #t.
Pass it to make-mingw-w64 for winpthread support.

Change-Id: Iaf34d9cc812543762cfd626693ea715880341c13
---
 gnu/packages/cross-base.scm | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm
index 5df06418e3..97afa240e3 100644
--- a/gnu/packages/cross-base.scm
+++ b/gnu/packages/cross-base.scm
@@ -1,7 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2013-2018, 2020, 2023-2024 Ludovic Courtès <[email-masked]>
 ;;; Copyright © 2014, 2015, 2018 Mark H Weaver <[email-masked]>
-;;; Copyright © 2016, 2019, 2023, 2024 Janneke Nieuwenhuizen <[email-masked]>
+;;; Copyright © 2016, 2019, 2023-2025 Janneke Nieuwenhuizen <[email-masked]>
 ;;; Copyright © 2016 Manolis Fragkiskos Ragkousis <[email-masked]>
 ;;; Copyright © 2018 Tobias Geerinckx-Rice <[email-masked]>
 ;;; Copyright © 2019, 2020, 2021 Marius Bakke <[email-masked]>
@@ -673,7 +673,8 @@ (define* (cross-libc* target
                       (libc (libc-for-target target))
                       (xgcc (cross-gcc target))
                       (xbinutils (cross-binutils target))
-                      (xheaders (cross-kernel-headers target)))
+                      (xheaders (cross-kernel-headers target))
+                      (with-winpthreads? #t))
   "Return LIBC cross-built for TARGET, a GNU triplet. Use XGCC and XBINUTILS
 and the cross tool chain.  If TARGET doesn't have a standard C library #f is
 returned."
@@ -682,7 +683,8 @@ (define* (cross-libc* target
     (let ((machine (substring target 0 (string-index target #\-))))
       (make-mingw-w64 machine
                       #:xgcc xgcc
-                      #:xbinutils xbinutils)))
+                      #:xbinutils xbinutils
+                      #:with-winpthreads? #t)))
    ((or (? target-linux?) (? target-hurd?))
     (package
       (inherit libc)
@@ -787,10 +789,12 @@ (define* (cross-gcc-toolchain/implementation target
                                              #:key
                                              (base-gcc %xgcc)
                                              (xbinutils (cross-binutils target))
+                                             (with-winpthreads? #t)
                                              (libc (cross-libc
-                                                     target
-                                                     #:xgcc (cross-gcc target #:xgcc base-gcc)
-                                                     #:xbinutils xbinutils))
+                                                    target
+                                                    #:xgcc (cross-gcc target #:xgcc base-gcc)
+                                                    #:xbinutils xbinutils
+                                                    #:with-winpthreads? with-winpthreads?))
                                              (xgcc (cross-gcc target
                                                               #:xgcc base-gcc
                                                               #:libc libc
-- 
2.49.0