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

Message ID c0200317fe4346fb484114cee276dff71f92b8c1.1747204236.git.janneke@gnu.org
State New
Headers
Series MinGW: Use winpthreads by default. |

Commit Message

Janneke Nieuwenhuizen May 14, 2025, 6:45 a.m. UTC
  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(-)
  

Patch

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 <ludo@gnu.org>
 ;;; Copyright © 2014, 2015, 2018 Mark H Weaver <mhw@netris.org>
-;;; Copyright © 2016, 2019, 2023, 2024 Janneke Nieuwenhuizen <janneke@gnu.org>
+;;; Copyright © 2016, 2019, 2023-2025 Janneke Nieuwenhuizen <janneke@gnu.org>
 ;;; Copyright © 2016 Manolis Fragkiskos Ragkousis <manolis837@gmail.com>
 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
 ;;; Copyright © 2019, 2020, 2021 Marius Bakke <marius@gnu.org>
@@ -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