From patchwork Wed Aug 14 17:54:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Carl Dong X-Patchwork-Id: 14926 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 3FB9A172D7; Wed, 14 Aug 2019 18:56:18 +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, URIBL_BLOCKED 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 9BEF2172D4 for ; Wed, 14 Aug 2019 18:56:17 +0100 (BST) Received: from localhost ([::1]:34726 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hxxVQ-0008Dq-Mf for patchwork@mira.cbaines.net; Wed, 14 Aug 2019 13:56:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38452) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hxxVF-000879-4o for guix-patches@gnu.org; Wed, 14 Aug 2019 13:56:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hxxVC-0005I2-Tx for guix-patches@gnu.org; Wed, 14 Aug 2019 13:56:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:40818) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hxxVC-0005Hs-O5 for guix-patches@gnu.org; Wed, 14 Aug 2019 13:56:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hxxVC-0003EM-JZ for guix-patches@gnu.org; Wed, 14 Aug 2019 13:56:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#37012] [PATCH] gnu: mingw: Add x86_64 support. Resent-From: Carl Dong Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 14 Aug 2019 17:56:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 37012 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Jan Nieuwenhuizen Received: via spool by 37012-submit@debbugs.gnu.org id=B37012.156580531912371 (code B ref 37012); Wed, 14 Aug 2019 17:56:02 +0000 Received: (at 37012) by debbugs.gnu.org; 14 Aug 2019 17:55:19 +0000 Received: from localhost ([127.0.0.1]:49639 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hxxUO-0003DL-Kx for submit@debbugs.gnu.org; Wed, 14 Aug 2019 13:55:19 -0400 Received: from mail1.protonmail.ch ([185.70.40.18]:41933) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hxxUK-0003D0-PM for 37012@debbugs.gnu.org; Wed, 14 Aug 2019 13:55:11 -0400 Date: Wed, 14 Aug 2019 17:54:59 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=carldong.me; s=protonmail; t=1565805300; bh=wOJsX4VuZMCNyhBuAYudZoL5Qe4/moL+qf13QoaC9f4=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References: Feedback-ID:From; b=ao2wwfY2vjlqLL8MVCitQ/+6lPV4ECiW2WMEIuJLev4oey81wJHBLK1v6U6SQdWWF a0pjqmAbvksRn92LKWQ3cJVsQT4TiWqK07XNdzp8qHz+AoKm42D82J58GFF9mD4nJr FrXqDaXYIJD18rZj6mddneJsas4/0f8ZVYezamiw= From: Carl Dong Message-ID: In-Reply-To: <874l2kmdya.fsf@gnu.org> References: <87o90sitvi.fsf@gnu.org> <874l2kmdya.fsf@gnu.org> Feedback-ID: a8j8tDUaJ4AYuDVBywMTwsJebN4w8TVXadJLsJb8td3t3dZi9RdXFlPaQvoFKnI9KgXySsPXcRkajVyY0cGTcA==:Ext:ProtonMail MIME-Version: 1.0 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 Cc: "37012@debbugs.gnu.org" <37012@debbugs.gnu.org> Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches Here's the updated patch that I've tested. Let me know if this works for you! :-) From e6df2d6f9b47b02abec01a16f2d0b1271dcec1d2 Mon Sep 17 00:00:00 2001 From: Carl Dong Date: Wed, 14 Aug 2019 13:46:53 -0400 Subject: [PATCH] gnu: mingw: Add x86_64 support. This patch parameterizes previously hard-coded instances of i686-w64-mingw32, adding support for x86_64-w64-mingw32. * gnu/packages/mingw.scm (make-mingw-w64): New procedure. (mingw-w64-i686, mingw-w64-x86_64): New variables. (%mingw-triplet): Remove. (mingw-w64): Update to point to 'mingw-w64-i686'. * gnu/packages/cross-base.scm (cross-gcc): Use 'libc' keyword argument if specified, instead of treating it as a boolean. (native-libc): Return the correct mingw-w64 depending on machine specified in target. * gnu/packages/bootstrap.scm (glibc-dynamic-linker): Add "x86_64-mingw". * gnu/build/cross-toolchain.scm (set-cross-path/mingw): Replace hardcoded 'i686-w64-mingw32' instances with 'target' keyword argument. (cross-gcc-build-phases): Update accordingly; use 'target-mingw?' implementation of target checking and add commentary. * gnu/ci.scm (%cross-targets): Add "x86_64-w64-mingw32". --- gnu/build/cross-toolchain.scm | 15 +++-- gnu/ci.scm | 3 +- gnu/packages/bootstrap.scm | 2 + gnu/packages/cross-base.scm | 6 +- gnu/packages/mingw.scm | 111 ++++++++++++++++++---------------- 5 files changed, 78 insertions(+), 59 deletions(-) -- 2.22.0 Cheers, Carl Dong contact@carldong.me "I fight for the users" diff --git a/gnu/build/cross-toolchain.scm b/gnu/build/cross-toolchain.scm index d430b8afc4..201b36ff7c 100644 --- a/gnu/build/cross-toolchain.scm +++ b/gnu/build/cross-toolchain.scm @@ -3,6 +3,7 @@ ;;; Copyright © 2014, 2015, 2018 Mark H Weaver ;;; Copyright © 2016 Jan Nieuwenhuizen ;;; Copyright © 2016 Manolis Fragkiskos Ragkousis +;;; Copyright © 2019 Carl Dong ;;; ;;; This file is part of GNU Guix. ;;; @@ -95,7 +96,7 @@ C_INCLUDE_PATH et al." ;; We're building the sans-libc cross-compiler, so nothing to do. #t))) -(define* (set-cross-path/mingw #:key inputs #:allow-other-keys) +(define* (set-cross-path/mingw #:key inputs target #:allow-other-keys) "Add the cross MinGW headers to CROSS_C_*_INCLUDE_PATH, and remove them from C_*INCLUDE_PATH." (let ((libc (assoc-ref inputs "libc")) @@ -112,7 +113,7 @@ C_*INCLUDE_PATH." (if libc (let ((cpath (string-append libc "/include" - ":" libc "/i686-w64-mingw32/include"))) + ":" libc "/" target "/include"))) (for-each (cut setenv <> cpath) %gcc-cross-include-paths)) @@ -142,7 +143,7 @@ C_*INCLUDE_PATH." (when libc (setenv "CROSS_LIBRARY_PATH" (string-append libc "/lib" - ":" libc "/i686-w64-mingw32/lib"))) + ":" libc "/" target "/lib"))) (setenv "CPP" (string-append gcc "/bin/cpp")) (for-each (lambda (var) @@ -168,8 +169,12 @@ C_*INCLUDE_PATH." a target triplet." (modify-phases phases (add-before 'configure 'set-cross-path - (if (string-contains target "mingw") - set-cross-path/mingw + ;; This mingw32 target checking logic should match that of target-mingw? + ;; in (guix utils), but (guix utils) is too large too copy over to the + ;; build side entirely and for now we have no way to select variables to + ;; copy over. See (gnu packages cross-base) for more details. + (if (string-suffix? "-mingw32" target) + (cut set-cross-path/mingw #:target target <...>) set-cross-path)) (add-after 'install 'make-cross-binutils-visible (cut make-cross-binutils-visible #:target target <...>)) diff --git a/gnu/ci.scm b/gnu/ci.scm index 4885870e16..aeebd4f14b 100644 --- a/gnu/ci.scm +++ b/gnu/ci.scm @@ -130,7 +130,8 @@ SYSTEM." "aarch64-linux-gnu" "powerpc-linux-gnu" "i586-pc-gnu" ;aka. GNU/Hurd - "i686-w64-mingw32")) + "i686-w64-mingw32" + "x86_64-w64-mingw32")) (define %guixsd-supported-systems '("x86_64-linux" "i686-linux" "armhf-linux")) diff --git a/gnu/packages/bootstrap.scm b/gnu/packages/bootstrap.scm index 5030b815b9..cd99425379 100644 --- a/gnu/packages/bootstrap.scm +++ b/gnu/packages/bootstrap.scm @@ -2,6 +2,7 @@ ;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès ;;; Copyright © 2014, 2015, 2018 Mark H Weaver ;;; Copyright © 2017 Efraim Flashner +;;; Copyright © 2019 Carl Dong ;;; ;;; This file is part of GNU Guix. ;;; @@ -187,6 +188,7 @@ return value is ignored." ((string=? system "avr") "no-ld.so") ((string=? system "propeller-elf") "no-ld.so") ((string=? system "i686-mingw") "no-ld.so") + ((string=? system "x86_64-mingw") "no-ld.so") ((string=? system "vc4-elf") "no-ld.so") (else (error "dynamic linker name not known for this system" diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm index a0341ebc5d..e277139f25 100644 --- a/gnu/packages/cross-base.scm +++ b/gnu/packages/cross-base.scm @@ -4,6 +4,7 @@ ;;; Copyright © 2016 Jan Nieuwenhuizen ;;; Copyright © 2016 Manolis Fragkiskos Ragkousis ;;; Copyright © 2018 Tobias Geerinckx-Rice +;;; Copyright © 2019 Carl Dong ;;; ;;; This file is part of GNU Guix. ;;; @@ -249,7 +250,7 @@ target that libc." (cond ((target-mingw? target) (if libc - `(("libc" ,mingw-w64) + `(("libc" ,libc) ,@inputs) `(("mingw-source" ,(package-source mingw-w64)) ,@inputs))) @@ -509,7 +510,8 @@ and the cross tool chain." #:optional (libc glibc)) (if (target-mingw? target) - mingw-w64 + (let ((machine (substring target 0 (string-index target #\-)))) + (make-mingw-w64 machine)) libc)) (define* (cross-newlib? target diff --git a/gnu/packages/mingw.scm b/gnu/packages/mingw.scm index 3e96f2c475..017f9453ab 100644 --- a/gnu/packages/mingw.scm +++ b/gnu/packages/mingw.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2016 Jan Nieuwenhuizen ;;; Copyright © 2018 Tobias Geerinckx-Rice +;;; Copyright © 2019 Carl Dong ;;; ;;; This file is part of GNU Guix. ;;; @@ -31,56 +32,56 @@ #:use-module (guix utils) #:use-module (ice-9 match)) -(define %mingw-triplet - "i686-w64-mingw32") - -(define-public mingw-w64 - (package - (name "mingw-w64") - (version "5.0.4") - (source (origin - (method url-fetch) - (uri (string-append - "https://sourceforge.net/projects/mingw-w64/files/mingw-w64/" - "mingw-w64-release/mingw-w64-v" version ".tar.bz2")) - (sha256 - (base32 "00zq3z1hbzd5yzmskskjg79xrzwsqx7ihyprfaxy4hb897vf29sm")) - (patches (search-patches "mingw-w64-5.0rc2-gcc-4.9.3.patch")))) - (native-inputs `(("xgcc-core" ,(cross-gcc %mingw-triplet)) - ("xbinutils" ,(cross-binutils %mingw-triplet)))) - (build-system gnu-build-system) - (search-paths - (list (search-path-specification - (variable "CROSS_C_INCLUDE_PATH") - (files '("include" "i686-w64-mingw32/include"))) - (search-path-specification - (variable "CROSS_LIBRARY_PATH") - (files - '("lib" "lib64" "i686-w64-mingw32/lib" "i686-w64-mingw32/lib64"))))) - (arguments - `(#:configure-flags '("--host=i686-w64-mingw32") - #:phases - (modify-phases %standard-phases - (add-before 'configure 'setenv - (lambda* (#:key inputs #:allow-other-keys) - (let ((xgcc-core (assoc-ref inputs "xgcc-core")) - (mingw-headers (string-append (getcwd) "/mingw-w64-headers"))) - (setenv "CPP" - (string-append xgcc-core "/bin/i686-w64-mingw32-cpp")) - (setenv "CROSS_C_INCLUDE_PATH" - (string-append - mingw-headers - ":" mingw-headers "/include" - ":" mingw-headers "/crt" - ":" mingw-headers "/defaults/include" - ":" mingw-headers "/direct-x/include")))))) - #:make-flags (list "DEFS=-DHAVE_CONFIG_H -D__MINGW_HAS_DXSDK=1") - #:tests? #f ; compiles and includes glibc headers - #:strip-binaries? #f)) - (home-page "https://mingw-w64.org") - (synopsis "Minimalist GNU for Windows") - (description - "Minimalist GNU for Windows (@dfn{MinGW}) is a complete software +(define-public (make-mingw-w64 machine) + (let ((triplet (string-append machine "-" "w64-mingw32"))) + (package + (name (string-append "mingw-w64" "-" machine)) + (version "5.0.4") + (source (origin + (method url-fetch) + (uri (string-append + "https://sourceforge.net/projects/mingw-w64/files/mingw-w64/" + "mingw-w64-release/mingw-w64-v" version ".tar.bz2")) + (sha256 + (base32 "00zq3z1hbzd5yzmskskjg79xrzwsqx7ihyprfaxy4hb897vf29sm")) + (patches (search-patches "mingw-w64-5.0rc2-gcc-4.9.3.patch")))) + (native-inputs `(("xgcc-core" ,(cross-gcc triplet)) + ("xbinutils" ,(cross-binutils triplet)))) + (build-system gnu-build-system) + (search-paths + (list (search-path-specification + (variable "CROSS_C_INCLUDE_PATH") + (files `("include" ,(string-append triplet "/include")))) + (search-path-specification + (variable "CROSS_LIBRARY_PATH") + (files + `("lib" "lib64" + ,(string-append triplet "/lib") + ,(string-append triplet "/lib64")))))) + (arguments + `(#:configure-flags '(,(string-append "--host=" triplet)) + #:phases + (modify-phases %standard-phases + (add-before 'configure 'setenv + (lambda* (#:key inputs #:allow-other-keys) + (let ((xgcc-core (assoc-ref inputs "xgcc-core")) + (mingw-headers (string-append (getcwd) "/mingw-w64-headers"))) + (setenv "CPP" + (string-append xgcc-core ,(string-append "/bin/" triplet "-cpp"))) + (setenv "CROSS_C_INCLUDE_PATH" + (string-append + mingw-headers + ":" mingw-headers "/include" + ":" mingw-headers "/crt" + ":" mingw-headers "/defaults/include" + ":" mingw-headers "/direct-x/include")))))) + #:make-flags (list "DEFS=-DHAVE_CONFIG_H -D__MINGW_HAS_DXSDK=1") + #:tests? #f ; compiles and includes glibc headers + #:strip-binaries? #f)) + (home-page "https://mingw-w64.org") + (synopsis "Minimalist GNU for Windows") + (description + "Minimalist GNU for Windows (@dfn{MinGW}) is a complete software development environment for creating native Microsoft Windows applications. It includes a set of Windows-specific header files and static import libraries @@ -89,4 +90,12 @@ runtime dynamic-link libraries (@dfn{DLL}s). Mingw-w64 is an advancement of the original mingw.org project and provides several new APIs such as DirectX and DDK, and 64-bit support.") - (license license:fdl1.3+))) + (license license:fdl1.3+)))) + +(define-public mingw-w64-i686 + (make-mingw-w64 "i686")) + +(define-public mingw-w64-x86_64 + (make-mingw-w64 "x86_64")) + +(define-public mingw-w64 mingw-w64-i686)