From patchwork Fri Oct 18 17:52:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carl Dong X-Patchwork-Id: 15762 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id B3FCC175D3; Fri, 18 Oct 2019 19:07:23 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTP id 65F7017584 for ; Fri, 18 Oct 2019 19:07:23 +0100 (BST) Received: from localhost ([::1]:44640 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iLWeo-0005WB-K6 for patchwork@mira.cbaines.net; Fri, 18 Oct 2019 14:07:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60225) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iLWQx-0007CC-Ad for guix-patches@gnu.org; Fri, 18 Oct 2019 13:53:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iLWQv-0001hc-TJ for guix-patches@gnu.org; Fri, 18 Oct 2019 13:53:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:42697) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iLWQv-0001hP-QN for guix-patches@gnu.org; Fri, 18 Oct 2019 13:53:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iLWQv-00050G-Nh for guix-patches@gnu.org; Fri, 18 Oct 2019 13:53:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#37813] [PATCH] gnu: mingw-w64: Add -winpthreads variants. Resent-From: Carl Dong Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 18 Oct 2019 17:53:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 37813 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 37813@debbugs.gnu.org X-Debbugs-Original-To: "guix-patches@gnu.org" Received: via spool by submit@debbugs.gnu.org id=B.157142113719167 (code B ref -1); Fri, 18 Oct 2019 17:53:01 +0000 Received: (at submit) by debbugs.gnu.org; 18 Oct 2019 17:52:17 +0000 Received: from localhost ([127.0.0.1]:51518 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iLWQC-0004z3-PO for submit@debbugs.gnu.org; Fri, 18 Oct 2019 13:52:17 -0400 Received: from lists.gnu.org ([209.51.188.17]:53387) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iLWQA-0004yu-Mh for submit@debbugs.gnu.org; Fri, 18 Oct 2019 13:52:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60152) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iLWQ8-00062w-IE for guix-patches@gnu.org; Fri, 18 Oct 2019 13:52:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iLWQ6-0001E1-OC for guix-patches@gnu.org; Fri, 18 Oct 2019 13:52:12 -0400 Received: from mail-40132.protonmail.ch ([185.70.40.132]:49036) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iLWQ6-0001DB-Ba for guix-patches@gnu.org; Fri, 18 Oct 2019 13:52:10 -0400 Date: Fri, 18 Oct 2019 17:52:05 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=carldong.me; s=protonmail; t=1571421128; bh=YfgXmxi24lpxtOJHQszzqQsWwJfP0f7N3P5ndMcdS6Y=; h=Date:To:From:Reply-To:Subject:Feedback-ID:From; b=T3+bKhPJLCPpoflvgLTPmq8vZWCfse6lROAEt7ojb/k7Z/E0ffK5WLm+0hKqtGANO h85ZT7VZBYlP+m9ciGlVrUTdABcLAbV7I4UM++1Lwo47eNMauKD/krmYlvtCXL+804 Lwb+oX+jDdkFsV7xhfifS6mG08GKjWqc7R1KGO9Y= From: Carl Dong Message-ID: <9ex2heUi-a_eFy92HaMuh0B33VewNqHzK6r5aayN566rDR-hlo78vAmX0vhMzY2_hzGQRXZvXRYustyKwDqmT2SK-KNEm2azpTeusxKMiv8=@carldong.me> Feedback-ID: a8j8tDUaJ4AYuDVBywMTwsJebN4w8TVXadJLsJb8td3t3dZi9RdXFlPaQvoFKnI9KgXySsPXcRkajVyY0cGTcA==:Ext:ProtonMail MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Carl Dong Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches 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(-) -- 2.23.0 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)