From: Carl Dong <contact@carldong.me>
To: 37813@debbugs.gnu.org
Subject: [bug#37813] [PATCH] gnu: mingw-w64: Add -winpthreads variants.
Date: Fri, 18 Oct 2019 17:52:05 +0000 [thread overview]
Message-ID: <9ex2heUi-a_eFy92HaMuh0B33VewNqHzK6r5aayN566rDR-hlo78vAmX0vhMzY2_hzGQRXZvXRYustyKwDqmT2SK-KNEm2azpTeusxKMiv8=@carldong.me> (raw)
This recursive package definition really demonstrates how magical Guix
can be :-)
* gnu/packages/mingw.scm (make-mingw-w64): Add XGCC, XBINUTILS optional
arguments to specify using a non-default cross-compiler/binutils. Add
WITH-WINPTHREADS? optional argument to allow building with winpthreads
support. Adjust accordingly for the new arguments.
(mingw-w64-i686-winpthreads, mingw-w64-x86_64-winpthreads): Add
variables.
* gnu/packages/cross-base.scm (native-libc): Add XGCC, XBINUTILS
key arugments and pass to MAKE-MINGW-W64.
(cross-libc): Pass XGCC and XBINUTILS to NATIVE-LIBC.
---
gnu/packages/cross-base.scm | 13 +++++++---
gnu/packages/mingw.scm | 48 ++++++++++++++++++++++++++++++-------
2 files changed, 50 insertions(+), 11 deletions(-)
diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm
index 76d15f4c59..c051c77ad0 100644
--- a/gnu/packages/cross-base.scm
+++ b/gnu/packages/cross-base.scm
@@ -454,7 +454,9 @@ target that libc."
"Return LIBC cross-built for TARGET, a GNU triplet. Use XGCC and XBINUTILS
and the cross tool chain."
(if (cross-newlib? target libc)
- (native-libc target libc)
+ (native-libc target libc
+ #:xgcc xgcc
+ #:xbinutils xbinutils)
(let ((libc libc))
(package (inherit libc)
(name (string-append "glibc-cross-" target))
@@ -511,10 +513,15 @@ and the cross tool chain."
(define* (native-libc target
#:optional
- (libc glibc))
+ (libc glibc)
+ #:key
+ (xgcc #f)
+ (xbinutils #f))
(if (target-mingw? target)
(let ((machine (substring target 0 (string-index target #\-))))
- (make-mingw-w64 machine))
+ (make-mingw-w64 machine
+ #:xgcc xgcc
+ #:xbinutils xbinutils))
libc))
(define* (cross-newlib? target
diff --git a/gnu/packages/mingw.scm b/gnu/packages/mingw.scm
index fe51780fa3..bbfdc0c134 100644
--- a/gnu/packages/mingw.scm
+++ b/gnu/packages/mingw.scm
@@ -30,12 +30,21 @@
#:use-module (guix packages)
#:use-module (guix download)
#:use-module (guix utils)
- #:use-module (ice-9 match))
+ #:use-module (ice-9 match)
+ #:export (make-mingw-w64))
-(define-public (make-mingw-w64 machine)
- (let ((triplet (string-append machine "-" "w64-mingw32")))
+(define* (make-mingw-w64 machine
+ #:key
+ (xgcc #f)
+ (xbinutils #f)
+ (with-winpthreads? #f))
+ "Return a mingw-w64 for targeting MACHINE. If XGCC or XBINUTILS is specified,
+use that gcc or binutils when cross-compiling. If WITH-WINPTHREADS? is
+specified, recurse and return a mingw-w64 with support for winpthreads."
+ (let* ((triplet (string-append machine "-" "w64-mingw32")))
(package
- (name (string-append "mingw-w64" "-" machine))
+ (name (string-append "mingw-w64" "-" machine
+ (if with-winpthreads? "-winpthreads" "")))
(version "6.0.0")
(source (origin
(method url-fetch)
@@ -45,8 +54,14 @@
(sha256
(base32 "1w28mynv500y03h92nh87rgw3fnp82qwnjbxrrzqkmr63q812pl0"))
(patches (search-patches "mingw-w64-6.0.0-gcc.patch"))))
- (native-inputs `(("xgcc-core" ,(cross-gcc triplet))
- ("xbinutils" ,(cross-binutils triplet))))
+ (native-inputs `(("xgcc-core" ,(if xgcc xgcc (cross-gcc triplet)))
+ ("xbinutils" ,(if xbinutils xbinutils (cross-binutils triplet)))
+ ,@(if with-winpthreads?
+ `(("xlibc" ,(make-mingw-w64 machine
+ #:xgcc xgcc
+ #:xbinutils xbinutils
+ #:with-winpthreads? #f)))
+ '())))
(build-system gnu-build-system)
(search-paths
(list (search-path-specification
@@ -59,7 +74,10 @@
,(string-append triplet "/lib")
,(string-append triplet "/lib64"))))))
(arguments
- `(#:configure-flags '(,(string-append "--host=" triplet))
+ `(#:configure-flags '(,(string-append "--host=" triplet)
+ ,@(if with-winpthreads?
+ '("--with-libraries=winpthreads")
+ '()))
#:phases
(modify-phases %standard-phases
(add-before 'configure 'setenv
@@ -74,7 +92,13 @@
":" mingw-headers "/include"
":" mingw-headers "/crt"
":" mingw-headers "/defaults/include"
- ":" mingw-headers "/direct-x/include"))))))
+ ":" mingw-headers "/direct-x/include"))
+ (when ,with-winpthreads?
+ (let ((mingw-itself (assoc-ref inputs "xlibc")))
+ (setenv "CROSS_LIBRARY_PATH"
+ (string-append
+ mingw-itself "/lib" ":"
+ mingw-itself "/" ,triplet "/lib"))))))))
#:make-flags (list "DEFS=-DHAVE_CONFIG_H -D__MINGW_HAS_DXSDK=1")
#:tests? #f ; compiles and includes glibc headers
#:strip-binaries? #f))
@@ -98,4 +122,12 @@ several new APIs such as DirectX and DDK, and 64-bit support.")
(define-public mingw-w64-x86_64
(make-mingw-w64 "x86_64"))
+(define-public mingw-w64-i686-winpthreads
+ (make-mingw-w64 "i686"
+ #:with-winpthreads? #t))
+
+(define-public mingw-w64-x86_64-winpthreads
+ (make-mingw-w64 "x86_64"
+ #:with-winpthreads? #t))
+
(define-public mingw-w64 mingw-w64-i686)
--
2.23.0
next reply other threads:[~2019-10-18 17:53 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-18 17:52 Carl Dong [this message]
2019-10-19 7:35 ` [bug#37813] [PATCH] gnu: mingw-w64: Add -winpthreads variants Jan (janneke) Nieuwenhuizen
2019-10-21 17:49 ` Carl Dong
2019-10-21 18:35 ` Jan Nieuwenhuizen
2019-10-21 20:53 ` Ludovic Courtès
2019-10-21 21:37 ` Carl Dong
2019-10-23 13:49 ` bug#37813: " Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='9ex2heUi-a_eFy92HaMuh0B33VewNqHzK6r5aayN566rDR-hlo78vAmX0vhMzY2_hzGQRXZvXRYustyKwDqmT2SK-KNEm2azpTeusxKMiv8=@carldong.me' \
--to=contact@carldong.me \
--cc=37813@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.