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".
This commit is contained in:
Carl Dong 2019-08-14 13:46:53 -04:00 committed by Jan Nieuwenhuizen
parent 4afdb79249
commit 67dac6b892
No known key found for this signature in database
GPG Key ID: F3C1A0D9C1D65273
5 changed files with 78 additions and 59 deletions

View File

@ -3,6 +3,7 @@
;;; Copyright © 2014, 2015, 2018 Mark H Weaver <mhw@netris.org>
;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
;;; Copyright © 2016 Manolis Fragkiskos Ragkousis <manolis837@gmail.com>
;;; Copyright © 2019 Carl Dong <contact@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 <...>))

View File

@ -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"))

View File

@ -2,6 +2,7 @@
;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2014, 2015, 2018 Mark H Weaver <mhw@netris.org>
;;; Copyright © 2017 Efraim Flashner <efraim@flashner.co.il>
;;; Copyright © 2019 Carl Dong <contact@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"

View File

@ -4,6 +4,7 @@
;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
;;; Copyright © 2016 Manolis Fragkiskos Ragkousis <manolis837@gmail.com>
;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
;;; Copyright © 2019 Carl Dong <contact@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

View File

@ -1,6 +1,7 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
;;; Copyright © 2019 Carl Dong <contact@carldong.me>
;;;
;;; This file is part of GNU Guix.
;;;
@ -31,12 +32,10 @@
#:use-module (guix utils)
#:use-module (ice-9 match))
(define %mingw-triplet
"i686-w64-mingw32")
(define-public mingw-w64
(define-public (make-mingw-w64 machine)
(let ((triplet (string-append machine "-" "w64-mingw32")))
(package
(name "mingw-w64")
(name (string-append "mingw-w64" "-" machine))
(version "5.0.4")
(source (origin
(method url-fetch)
@ -46,19 +45,21 @@
(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))))
(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" "i686-w64-mingw32/include")))
(files `("include" ,(string-append triplet "/include"))))
(search-path-specification
(variable "CROSS_LIBRARY_PATH")
(files
'("lib" "lib64" "i686-w64-mingw32/lib" "i686-w64-mingw32/lib64")))))
`("lib" "lib64"
,(string-append triplet "/lib")
,(string-append triplet "/lib64"))))))
(arguments
`(#:configure-flags '("--host=i686-w64-mingw32")
`(#:configure-flags '(,(string-append "--host=" triplet))
#:phases
(modify-phases %standard-phases
(add-before 'configure 'setenv
@ -66,7 +67,7 @@
(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"))
(string-append xgcc-core ,(string-append "/bin/" triplet "-cpp")))
(setenv "CROSS_C_INCLUDE_PATH"
(string-append
mingw-headers
@ -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)