GNU bug report logs - #37012
[PATCH] gnu: mingw: Add x86_64 support.

Previous Next

Package: guix-patches;

Reported by: Carl Dong <contact <at> carldong.me>

Date: Mon, 12 Aug 2019 20:47:01 UTC

Severity: normal

Tags: patch

Done: Jan Nieuwenhuizen <janneke <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 37012 in the body.
You can then email your comments to 37012 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#37012; Package guix-patches. (Mon, 12 Aug 2019 20:47:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Carl Dong <contact <at> carldong.me>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Mon, 12 Aug 2019 20:47:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Carl Dong <contact <at> carldong.me>
To: "guix-patches <at> gnu.org" <guix-patches <at> gnu.org>
Subject: [PATCH] gnu: mingw: Add x86_64 support.
Date: Mon, 12 Aug 2019 20:46:27 +0000
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?'
helper.
* gnu/ci.scm (%cross-targets): Add "x86_64-w64-mingw32".
---
 gnu/build/cross-toolchain.scm |  11 ++--
 gnu/ci.scm                    |   3 +-
 gnu/packages/bootstrap.scm    |   1 +
 gnu/packages/cross-base.scm   |   5 +-
 gnu/packages/mingw.scm        | 120 ++++++++++++++++++----------------
 5 files changed, 76 insertions(+), 64 deletions(-)

diff --git a/gnu/build/cross-toolchain.scm b/gnu/build/cross-toolchain.scm
index d430b8afc4..77e279f07d 100644
--- a/gnu/build/cross-toolchain.scm
+++ b/gnu/build/cross-toolchain.scm
@@ -22,6 +22,7 @@
 (define-module (gnu build cross-toolchain)
   #:use-module (guix build utils)
   #:use-module (guix build gnu-build-system)
+  #:use-module (guix utils)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-26)
   #:use-module (ice-9 match)
@@ -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,8 @@ C_*INCLUDE_PATH."
 a target triplet."
   (modify-phases phases
     (add-before 'configure 'set-cross-path
-      (if (string-contains target "mingw")
-          set-cross-path/mingw
+      (if (target-mingw? 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..13a7ef5cc5 100644
--- a/gnu/packages/bootstrap.scm
+++ b/gnu/packages/bootstrap.scm
@@ -187,6 +187,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..35cb2ab25f 100644
--- a/gnu/packages/cross-base.scm
+++ b/gnu/packages/cross-base.scm
@@ -249,7 +249,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 +509,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..907f2c3c35 100644
--- a/gnu/packages/mingw.scm
+++ b/gnu/packages/mingw.scm
@@ -31,62 +31,70 @@
   #:use-module (guix utils)
   #:use-module (ice-9 match))

-(define %mingw-triplet
-  "i686-w64-mingw32")
+(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
+de  velopment environment for creating native Microsoft Windows applications.

-(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
-development environment for creating native Microsoft Windows applications.
+It   includes a set of Windows-specific header files and static import libraries
+wh  ich enable the use of the Windows API.  It does not rely on any third-party C
+ru  ntime dynamic-link libraries (@dfn{DLL}s).

-It includes a set of Windows-specific header files and static import libraries
-which enable the use of the Windows API.  It does not rely on any third-party C
-runtime dynamic-link libraries (@dfn{DLL}s).
+Mi  ngw-w64 is an advancement of the original mingw.org project and provides
+se  veral new APIs such as DirectX and DDK, and 64-bit support.")
+      (license license:fdl1.3+))))

-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+)))
+(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)
--
2.22.0





Information forwarded to guix-patches <at> gnu.org:
bug#37012; Package guix-patches. (Tue, 13 Aug 2019 22:28:02 GMT) Full text and rfc822 format available.

Message #8 received at 37012 <at> debbugs.gnu.org (full text, mbox):

From: Jan Nieuwenhuizen <janneke <at> gnu.org>
To: Carl Dong <contact <at> carldong.me>
Cc: 37012 <at> debbugs.gnu.org
Subject: Re: [bug#37012] [PATCH] gnu: mingw: Add x86_64 support.
Date: Wed, 14 Aug 2019 00:27:13 +0200
Carl Dong writes:

Hi Carl!

> This patch parameterizes previously hard-coded instances of
> i686-w64-mingw32, adding support for x86_64-w64-mingw32.

That would be great.  When I try it, I get

--8<---------------cut here---------------start------------->8---
$ ./pre-inst-env guix build --target=i686-w64-mingw32 hello --no-build-hook
building /gnu/store/b3qq8g6lhwgadp09vwwmnyd91bvll3s3-module-import-compiled.drv...
Backtrace:
In ice-9/boot-9.scm:
    841:4 19 (with-throw-handler _ _ _)
In system/base/compile.scm:
    59:11 18 (_)
   155:11 17 (_ #<closed: file 61d8c0>)
   235:18 16 (read-and-compile #<input: /gnu/store/vdspbcgdlfg7xblm?> ?)
   183:32 15 (compile-fold (#<procedure compile-tree-il (x e opts)>) ?)
In ice-9/boot-9.scm:
   2312:4 14 (save-module-excursion _)
In language/scheme/compile-tree-il.scm:
    31:15 13 (_)
In ice-9/psyntax.scm:
  1235:36 12 (expand-top-sequence _ _ _ #f _ _ _)
  1182:24 11 (parse _ (("placeholder" placeholder)) ((top) #(# # ?)) ?)
   285:10 10 (parse _ (("placeholder" placeholder)) (()) _ c&e (# #) #)
In ice-9/eval.scm:
   293:34  9 (_ #<module (#{ g31}#) 62bf00>)
In ice-9/boot-9.scm:
   2874:4  8 (define-module* _ #:filename _ #:pure _ #:version _ # _ ?)
  2071:24  7 (call-with-deferred-observers _)
  2887:24  6 (_)
   222:29  5 (map1 _)
   222:29  4 (map1 (((guix build gnu-build-system)) ((guix utils)) ?))
   222:17  3 (map1 (((guix utils)) ((srfi srfi-1)) ((srfi #)) ((?)) ?))
   2803:6  2 (resolve-interface _ #:select _ #:hide _ #:prefix _ # _ ?)
In unknown file:
           1 (scm-error misc-error #f "~A ~S" ("no code for modu?" ?) ?)
In ice-9/boot-9.scm:
   752:25  0 (dispatch-exception _ _ _)

ice-9/boot-9.scm:752:25: In procedure dispatch-exception:
no code for module (guix utils)
--8<---------------cut here---------------end--------------->8---

Does this it work for you, can you verify?

> diff --git a/gnu/build/cross-toolchain.scm b/gnu/build/cross-toolchain.scm
> index d430b8afc4..77e279f07d 100644
> --- a/gnu/build/cross-toolchain.scm
> +++ b/gnu/build/cross-toolchain.scm
> @@ -22,6 +22,7 @@
>  (define-module (gnu build cross-toolchain)
>    #:use-module (guix build utils)
>    #:use-module (guix build gnu-build-system)
> +  #:use-module (guix utils)

I am suspecting this one here, in which case

> @@ -168,8 +169,8 @@ C_*INCLUDE_PATH."
>  a target triplet."
>    (modify-phases phases
>      (add-before 'configure 'set-cross-path
> -      (if (string-contains target "mingw")
> -          set-cross-path/mingw
> +      (if (target-mingw? 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 <...>))

this would need to change.

> diff --git a/gnu/packages/mingw.scm b/gnu/packages/mingw.scm
> index 3e96f2c475..907f2c3c35 100644
> --- a/gnu/packages/mingw.scm
> +++ b/gnu/packages/mingw.scm
...
> +      (description
> +       "Minimalist GNU for Windows (@dfn{MinGW}) is a complete software
> +de  velopment environment for creating native Microsoft Windows applications.
     ^^
What happened here?

> +It   includes a set of Windows-specific header files and static import libraries
> +wh  ich enable the use of the Windows API.  It does not rely on any third-party C
> +ru  ntime dynamic-link libraries (@dfn{DLL}s).
     ^^

Otherwise, LGTM.

Greetings,
janneke

-- 
Jan Nieuwenhuizen <janneke <at> gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com




Information forwarded to guix-patches <at> gnu.org:
bug#37012; Package guix-patches. (Wed, 14 Aug 2019 06:58:02 GMT) Full text and rfc822 format available.

Message #11 received at 37012 <at> debbugs.gnu.org (full text, mbox):

From: Jan Nieuwenhuizen <janneke <at> gnu.org>
To: Carl Dong <contact <at> carldong.me>
Cc: 37012 <at> debbugs.gnu.org
Subject: Re: [bug#37012] [PATCH] gnu: mingw: Add x86_64 support.
Date: Wed, 14 Aug 2019 08:57:33 +0200
Jan Nieuwenhuizen writes:

Hello again,

>> This patch parameterizes previously hard-coded instances of
>> i686-w64-mingw32, adding support for x86_64-w64-mingw32.
>
> That would be great.

Just before you create a new patch, please also add some copyright
headers.

Thanks!
janneke

-- 
Jan Nieuwenhuizen <janneke <at> gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com




Information forwarded to guix-patches <at> gnu.org:
bug#37012; Package guix-patches. (Wed, 14 Aug 2019 12:10:01 GMT) Full text and rfc822 format available.

Message #14 received at 37012 <at> debbugs.gnu.org (full text, mbox):

From: "Thompson, David" <dthompson2 <at> worcester.edu>
To: Carl Dong <contact <at> carldong.me>
Cc: 37012 <at> debbugs.gnu.org
Subject: Re: [bug#37012] [PATCH] gnu: mingw: Add x86_64 support.
Date: Wed, 14 Aug 2019 08:09:29 -0400
Hi Carl,

On Mon, Aug 12, 2019 at 4:47 PM Carl Dong <contact <at> carldong.me> wrote:
>
> This patch parameterizes previously hard-coded instances of
> i686-w64-mingw32, adding support for x86_64-w64-mingw32.

Thanks for doing this! I've been experimenting with building Guile
projects for Windows and this was on my wishlist.

Which reminds me, I have a patch series that updates to the latest
version of MinGW that I should share.

- Dave




Information forwarded to guix-patches <at> gnu.org:
bug#37012; Package guix-patches. (Wed, 14 Aug 2019 17:56:02 GMT) Full text and rfc822 format available.

Message #17 received at 37012 <at> debbugs.gnu.org (full text, mbox):

From: Carl Dong <contact <at> carldong.me>
To: Jan Nieuwenhuizen <janneke <at> gnu.org>
Cc: "37012 <at> debbugs.gnu.org" <37012 <at> debbugs.gnu.org>
Subject: Re: [bug#37012] [PATCH] gnu: mingw: Add x86_64 support.
Date: Wed, 14 Aug 2019 17:54:59 +0000
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 <contact <at> carldong.me>
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(-)

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 <mhw <at> netris.org>
 ;;; Copyright © 2016 Jan Nieuwenhuizen <janneke <at> gnu.org>
 ;;; Copyright © 2016 Manolis Fragkiskos Ragkousis <manolis837 <at> gmail.com>
+;;; Copyright © 2019 Carl Dong <contact <at> carldong.me>
 ;;;
 ;;; 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 <ludo <at> gnu.org>
 ;;; Copyright © 2014, 2015, 2018 Mark H Weaver <mhw <at> netris.org>
 ;;; Copyright © 2017 Efraim Flashner <efraim <at> flashner.co.il>
+;;; Copyright © 2019 Carl Dong <contact <at> carldong.me>
 ;;;
 ;;; 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 <janneke <at> gnu.org>
 ;;; Copyright © 2016 Manolis Fragkiskos Ragkousis <manolis837 <at> gmail.com>
 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me <at> tobias.gr>
+;;; Copyright © 2019 Carl Dong <contact <at> carldong.me>
 ;;;
 ;;; 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 <janneke <at> gnu.org>
 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me <at> tobias.gr>
+;;; Copyright © 2019 Carl Dong <contact <at> carldong.me>
 ;;;
 ;;; 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)
--
2.22.0

Cheers,
Carl Dong
contact <at> carldong.me
"I fight for the users"




Information forwarded to guix-patches <at> gnu.org:
bug#37012; Package guix-patches. (Wed, 14 Aug 2019 17:57:02 GMT) Full text and rfc822 format available.

Message #20 received at 37012 <at> debbugs.gnu.org (full text, mbox):

From: Carl Dong <contact <at> carldong.me>
To: "Thompson, David" <dthompson2 <at> worcester.edu>
Cc: "37012 <at> debbugs.gnu.org" <37012 <at> debbugs.gnu.org>
Subject: Re: [bug#37012] [PATCH] gnu: mingw: Add x86_64 support.
Date: Wed, 14 Aug 2019 17:56:26 +0000
Dave,

That's fantastic news :-)

I also have a preliminary version of the nsis installer packager, please let me know if you'd have use for it!


Cheers,
Carl Dong
contact <at> carldong.me
"I fight for the users"




Information forwarded to guix-patches <at> gnu.org:
bug#37012; Package guix-patches. (Wed, 14 Aug 2019 18:42:01 GMT) Full text and rfc822 format available.

Message #23 received at 37012 <at> debbugs.gnu.org (full text, mbox):

From: Jan Nieuwenhuizen <janneke <at> gnu.org>
To: Carl Dong <contact <at> carldong.me>
Cc: "37012 <at> debbugs.gnu.org" <37012 <at> debbugs.gnu.org>
Subject: Re: [bug#37012] [PATCH] gnu: mingw: Add x86_64 support.
Date: Wed, 14 Aug 2019 20:40:46 +0200
Carl Dong writes:

Hello Carl,

> Here's the updated patch that I've tested. Let me know if this works for you! :-)

Thanks!

> From e6df2d6f9b47b02abec01a16f2d0b1271dcec1d2 Mon Sep 17 00:00:00 2001
> From: Carl Dong <contact <at> carldong.me>
> Date: Wed, 14 Aug 2019 13:46:53 -0400
> Subject: [PATCH] gnu: mingw: Add x86_64 support.

It looks good and I can compile `hello'; the traditional 32 bit version:

    ./pre-inst-env guix build --target=i686-w64-mingw32 hello

and now also

    ./pre-inst-env guix build --target=x86_64-w64-mingw32 hello

However, while the 32 bit still works for me, the 64 bit version does
not.  How is that for you?  Do you have any idea how to verify if the
x86_64 hello.exe is OK or how to debug that?

--8<---------------cut here---------------start------------->8---
20:33:04 janneke <at> dundal:~/src/guix/wip [env]
$ file /gnu/store/4hayc4wmxz0b0bw555n5gny7xkhg7w6y-hello-2.10/bin/hello.exe
/gnu/store/4hayc4wmxz0b0bw555n5gny7xkhg7w6y-hello-2.10/bin/hello.exe: PE32 executable (console) Intel 80386, for MS Windows
20:34:04 janneke <at> dundal:~/src/guix/wip [env]
$ guix environment --ad-hoc wine -- wine /gnu/store/4hayc4wmxz0b0bw555n5gny7xkhg7w6y-hello-2.10/bin/hello.exe 
Hello, world!
20:34:14 janneke <at> dundal:~/src/guix/wip [env]
$ file /gnu/store/v83ag9ahcg5g5qp06rlvjmvrydyriv7p-hello-2.10/bin/hello.exe 
/gnu/store/v83ag9ahcg5g5qp06rlvjmvrydyriv7p-hello-2.10/bin/hello.exe: PE32+ executable (console) x86-64, for MS Windows
20:34:22 janneke <at> dundal:~/src/guix/wip [env]
$ guix environment --ad-hoc wine -- wine /gnu/store/v83ag9ahcg5g5qp06rlvjmvrydyriv7p-hello-2.10/bin/hello.exe
wine: Bad EXE format for Z:\gnu\store\v83ag9ahcg5g5qp06rlvjmvrydyriv7p-hello-2.10\bin\hello.exe.
[193]
--8<---------------cut here---------------end--------------->8---

Possibly I'm even using wine wrong?

Other than that the patch looks fine.  It would be nice if we knew
wether the 64bit version can produce something useful, though.  Can
you/someone please shed some light on that?

Greetings,
janneke

-- 
Jan Nieuwenhuizen <janneke <at> gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com




Information forwarded to guix-patches <at> gnu.org:
bug#37012; Package guix-patches. (Wed, 14 Aug 2019 18:51:01 GMT) Full text and rfc822 format available.

Message #26 received at 37012 <at> debbugs.gnu.org (full text, mbox):

From: Carl Dong <contact <at> carldong.me>
To: Jan Nieuwenhuizen <janneke <at> gnu.org>
Cc: "37012\\@debbugs.gnu.org" <37012 <at> debbugs.gnu.org>
Subject: Re: [bug#37012] [PATCH] gnu: mingw: Add x86_64 support.
Date: Wed, 14 Aug 2019 18:50:04 +0000
Hey janneke!

It would seem from the synopsis that the version of wine packaged with Guix is 32-bit only. I will test out the 64-bit hello binary when I get home on my Windows machine!

Cheers,
Carl Dong
contact <at> carldong.me
"I fight for the users"

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Wednesday, August 14, 2019 6:40 PM, Jan Nieuwenhuizen <janneke <at> gnu.org> wrote:

> Carl Dong writes:
>
> Hello Carl,
>
> > Here's the updated patch that I've tested. Let me know if this works for you! :-)
>
> Thanks!
>
> > From e6df2d6f9b47b02abec01a16f2d0b1271dcec1d2 Mon Sep 17 00:00:00 2001
> > From: Carl Dong contact <at> carldong.me
> > Date: Wed, 14 Aug 2019 13:46:53 -0400
> > Subject: [PATCH] gnu: mingw: Add x86_64 support.
>
> It looks good and I can compile `hello'; the traditional 32 bit version:
>
> ./pre-inst-env guix build --target=i686-w64-mingw32 hello
>
> and now also
>
> ./pre-inst-env guix build --target=x86_64-w64-mingw32 hello
>
> However, while the 32 bit still works for me, the 64 bit version does
> not. How is that for you? Do you have any idea how to verify if the
> x86_64 hello.exe is OK or how to debug that?
>
> --8<---------------cut here---------------start------------->8---
> 20:33:04 janneke <at> dundal:~/src/guix/wip [env]
> $ file /gnu/store/4hayc4wmxz0b0bw555n5gny7xkhg7w6y-hello-2.10/bin/hello.exe
> /gnu/store/4hayc4wmxz0b0bw555n5gny7xkhg7w6y-hello-2.10/bin/hello.exe: PE32 executable (console) Intel 80386, for MS Windows
> 20:34:04 janneke <at> dundal:~/src/guix/wip [env]
> $ guix environment --ad-hoc wine -- wine /gnu/store/4hayc4wmxz0b0bw555n5gny7xkhg7w6y-hello-2.10/bin/hello.exe
> Hello, world!
> 20:34:14 janneke <at> dundal:~/src/guix/wip [env]
> $ file /gnu/store/v83ag9ahcg5g5qp06rlvjmvrydyriv7p-hello-2.10/bin/hello.exe
> /gnu/store/v83ag9ahcg5g5qp06rlvjmvrydyriv7p-hello-2.10/bin/hello.exe: PE32+ executable (console) x86-64, for MS Windows
> 20:34:22 janneke <at> dundal:~/src/guix/wip [env]
> $ guix environment --ad-hoc wine -- wine /gnu/store/v83ag9ahcg5g5qp06rlvjmvrydyriv7p-hello-2.10/bin/hello.exe
> wine: Bad EXE format for Z:\gnu\store\v83ag9ahcg5g5qp06rlvjmvrydyriv7p-hello-2.10\bin\hello.exe.
> [193]
> --8<---------------cut here---------------end--------------->8---
>
> Possibly I'm even using wine wrong?
>
> Other than that the patch looks fine. It would be nice if we knew
> wether the 64bit version can produce something useful, though. Can
> you/someone please shed some light on that?
>
> Greetings,
> janneke
>
> --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Jan Nieuwenhuizen janneke <at> gnu.org | GNU LilyPond http://lilypond.org
> Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com






Reply sent to Jan Nieuwenhuizen <janneke <at> gnu.org>:
You have taken responsibility. (Wed, 14 Aug 2019 19:35:01 GMT) Full text and rfc822 format available.

Notification sent to Carl Dong <contact <at> carldong.me>:
bug acknowledged by developer. (Wed, 14 Aug 2019 19:35:02 GMT) Full text and rfc822 format available.

Message #31 received at 37012-done <at> debbugs.gnu.org (full text, mbox):

From: Jan Nieuwenhuizen <janneke <at> gnu.org>
To: Carl Dong <contact <at> carldong.me>
Cc: "37012 <at> debbugs.gnu.org" <37012-done <at> debbugs.gnu.org>
Subject: Re: [bug#37012] [PATCH] gnu: mingw: Add x86_64 support.
Date: Wed, 14 Aug 2019 21:33:56 +0200
Carl Dong writes:

Hello Carl,

> It would seem from the synopsis that the version of wine packaged with
> Guix is 32-bit only.

'Doh!

> I will test out the 64-bit hello binary when I get home on my Windows
> machine!

Thanks, but no pressing need for that now, look:

--8<---------------cut here---------------start------------->8---
21:27:49 janneke <at> dundal:~/src/guix/wip [env]
$ guix environment --ad-hoc wine64 -- wine64 /gnu/store/v83ag9ahcg5g5qp06rlvjmvrydyriv7p-hello-2.10/bin/hello.exe
Hello, world!
--8<---------------cut here---------------end--------------->8---

Pushed to master as 67dac6b8920755cb011047157bb7b4fae4760143

Thanks again!
janneke

-- 
Jan Nieuwenhuizen <janneke <at> gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 12 Sep 2019 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 221 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.