unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* rfc/rfh: i686-w64-mingw32 cross target
@ 2016-03-26 17:38 Jan Nieuwenhuizen
  2016-03-27 14:20 ` [RFCv2] build: i686-w64-mingw32: new " Jan Nieuwenhuizen
  2016-03-31 20:16 ` rfc/rfh: i686-w64-mingw32 " Ricardo Wurmus
  0 siblings, 2 replies; 18+ messages in thread
From: Jan Nieuwenhuizen @ 2016-03-26 17:38 UTC (permalink / raw)
  To: guix-devel

[-- Attachment #1: Type: text/plain, Size: 1752 bytes --]

Hi,

I'm working on a cross target in an effort to get rid of GUB 1) in
favour of Guix and could do with some help.

I have just succeeded in cross-building hello and running it,
doing

   18:18:36 janneke@drakenvlieg:~/src/mingw-guix
   $ ./pre-inst-env guix build --keep-failed --target=i686-w64-mingw32 hello
   /gnu/store/6556syz1732jnffnp0njikr5g6diqvch-hello-2.10
   18:18:36 janneke@drakenvlieg:~/src/mingw-guix
   $ /gnu/store/5y252qkblhpj639g3bnrc671mz8x920w-profile/bin/wine /gnu/store/6556syz1732jnffnp0njikr5g6diqvch-hello-2.10/bin/hello.exe 
   Hello, world!
   18:18:39 janneke@drakenvlieg:~/src/mingw-guix

See https://github.com/janneke/guix/tree/wip-mingw32 or attached patch.
This platform does not have glibc, it uses --with-newlib and I'm not
sure how to fit that in.

In a couple of places I have changed

   (if libc A B)

into

  (cond
   ((equal? target "i686-w64-mingw32") .. specific code)
   (libc A)
   (else B))

and I'm wondering whether to create a `newlib' category, or try
to fit newlib into libc somehow, or...any ideas welcome.

I was hoping to have (cross-libc <target>) evaluate to
i686-w64-mingw32-runtime, but am puzzled by the effect of this
code in

   gnu.scm (standard-cross-packages):

   `(("cross-gcc" ,(gcc target
                    (binutils target)
                     (if (equal? target "i686-w64-mingw32")
                         #f ;;(module-ref cross 'i686-w64-mingw32-runtime)
                      (libc target))))

unless I use #f here, guix wants to build a cross gcc WITH glibc,
instead of using the sans-libc variant.

Anaway, I am using a precompiled binary mingw runtime, as a next step
I'll be looking into building that from source.

Greetings,
Jan

1) GUB -- http://lilypond.org/gub/


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-i686-w64-mingw32-new-cross-target.-WIP.patch --]
[-- Type: text/x-diff, Size: 33200 bytes --]

From 65917cb25c496219af0c118a6cd6664646839db4 Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen <janneke@gnu.org>
Date: Fri, 25 Mar 2016 08:03:54 +0100
Subject: [PATCH] i686-w64-mingw32: new cross target.  WIP

---
 gnu/packages/bootstrap.scm  |   1 +
 gnu/packages/cross-base.scm | 594 ++++++++++++++++++++++++++------------------
 guix/build-system/gnu.scm   |   4 +-
 3 files changed, 352 insertions(+), 247 deletions(-)

diff --git a/gnu/packages/bootstrap.scm b/gnu/packages/bootstrap.scm
index f5bf069..979ab1d 100644
--- a/gnu/packages/bootstrap.scm
+++ b/gnu/packages/bootstrap.scm
@@ -171,6 +171,7 @@ successful, or false to signal an error."
         ;; here just so we can keep going.
         ((string=? system "xtensa-elf") "no-ld.so")
         ((string=? system "avr") "no-ld.so")
+        ((string=? system "i686-mingw") "no-ld.so")
 
         (else (error "dynamic linker name not known for this system"
                      system))))
diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm
index 8bd599c..e2b1dd1 100644
--- a/gnu/packages/cross-base.scm
+++ b/gnu/packages/cross-base.scm
@@ -23,6 +23,7 @@
   #:use-module (gnu packages gcc)
   #:use-module (gnu packages base)
   #:use-module (gnu packages commencement)
+  #:use-module (gnu packages compression)
   #:use-module (gnu packages linux)
   #:use-module (guix packages)
   #:use-module (guix download)
@@ -43,38 +44,38 @@
 
 (define (cross p target)
   (package (inherit p)
-    (name (string-append (package-name p) "-cross-" target))
-    (arguments
-     (substitute-keyword-arguments (package-arguments p)
-       ((#:configure-flags flags)
-        `(cons ,(string-append "--target=" target)
-               ,flags))))))
+           (name (string-append (package-name p) "-cross-" target))
+           (arguments
+            (substitute-keyword-arguments (package-arguments p)
+              ((#:configure-flags flags)
+               `(cons ,(string-append "--target=" target)
+                      ,flags))))))
 
 (define (package-with-patch original patch)
   "Return package ORIGINAL with PATCH applied."
   (package (inherit original)
-    (source (origin (inherit (package-source original))
-              (patches (list patch))))))
+           (source (origin (inherit (package-source original))
+                           (patches (list patch))))))
 
 (define (cross-binutils target)
   "Return a cross-Binutils for TARGET."
   (let ((binutils (package (inherit binutils)
-                    (arguments
-                     (substitute-keyword-arguments (package-arguments
-                                                    binutils)
-                       ((#:configure-flags flags)
-                        ;; Build with `--with-sysroot' so that ld honors
-                        ;; DT_RUNPATH entries when searching for a needed
-                        ;; library.  This works because as a side effect
-                        ;; `genscripts.sh' sets `USE_LIBPATH=yes', which tells
-                        ;; elf32.em to use DT_RUNPATH in its search list.
-                        ;; See <http://sourceware.org/ml/binutils/2013-05/msg00312.html>.
-                        ;;
-                        ;; In theory choosing / as the sysroot could lead ld
-                        ;; to pick up native libs instead of target ones.  In
-                        ;; practice the RUNPATH of target libs only refers to
-                        ;; target libs, not native libs, so this is safe.
-                        `(cons "--with-sysroot=/" ,flags)))))))
+                           (arguments
+                            (substitute-keyword-arguments (package-arguments
+                                                           binutils)
+                              ((#:configure-flags flags)
+                               ;; Build with `--with-sysroot' so that ld honors
+                               ;; DT_RUNPATH entries when searching for a needed
+                               ;; library.  This works because as a side effect
+                               ;; `genscripts.sh' sets `USE_LIBPATH=yes', which tells
+                               ;; elf32.em to use DT_RUNPATH in its search list.
+                               ;; See <http://sourceware.org/ml/binutils/2013-05/msg00312.html>.
+                               ;;
+                               ;; In theory choosing / as the sysroot could lead ld
+                               ;; to pick up native libs instead of target ones.  In
+                               ;; practice the RUNPATH of target libs only refers to
+                               ;; target libs, not native libs, so this is safe.
+                               `(cons "--with-sysroot=/" ,flags)))))))
 
     ;; For Xtensa, apply Qualcomm's patch.
     (cross (if (string-prefix? "xtensa-" target)
@@ -95,107 +96,152 @@ may be either a libc package or #f.)"
     ;; <http://lists.fedoraproject.org/pipermail/arm/2010-August/000663.html>
     ;; for instance.
     (let ((args `(#:strip-binaries? #f
-                  ,@(package-arguments %xgcc))))
-     (substitute-keyword-arguments args
-       ((#:configure-flags flags)
-        `(append (list ,(string-append "--target=" target)
-                       ,@(if libc
-                             `( ;; Disable libcilkrts because it is not
-                                ;; ported to GNU/Hurd. 
-                               "--disable-libcilkrts")
-                             `( ;; Disable features not needed at this stage.
-                               "--disable-shared" "--enable-static"
-                               "--enable-languages=c,c++"
-
-                               ;; libstdc++ cannot be built at this stage
-                               ;; ("Link tests are not allowed after
-                               ;; GCC_NO_EXECUTABLES.").
-                               "--disable-libstdc++-v3"
-
-                               "--disable-threads" ;libgcc, would need libc
-                               "--disable-libatomic"
-                               "--disable-libmudflap"
-                               "--disable-libgomp"
-                               "--disable-libssp"
-                               "--disable-libquadmath"
-                               "--disable-decimal-float" ;would need libc
-                               "--disable-libcilkrts"
-                               )))
-
-                 ,(if libc
-                      flags
-                      `(remove (cut string-match "--enable-languages.*" <>)
-                               ,flags))))
-       ((#:make-flags flags)
-        (if libc
-            `(let ((libc (assoc-ref %build-inputs "libc")))
-               ;; FLAGS_FOR_TARGET are needed for the target libraries to receive
-               ;; the -Bxxx for the startfiles.
-               (cons (string-append "FLAGS_FOR_TARGET=-B" libc "/lib")
-                     ,flags))
-            flags))
-       ((#:phases phases)
-        (let ((phases
-               `(alist-cons-after
-                 'install 'make-cross-binutils-visible
-                 (lambda* (#:key outputs inputs #:allow-other-keys)
-                   (let* ((out      (assoc-ref outputs "out"))
-                          (libexec  (string-append out "/libexec/gcc/"
-                                                   ,target))
-                          (binutils (string-append
-                                     (assoc-ref inputs "binutils-cross")
-                                     "/bin/" ,target "-"))
-                          (wrapper  (string-append
-                                     (assoc-ref inputs "ld-wrapper-cross")
-                                     "/bin/" ,target "-ld")))
-                     (for-each (lambda (file)
-                                 (symlink (string-append binutils file)
-                                          (string-append libexec "/"
-                                                         file)))
-                               '("as" "nm"))
-                     (symlink wrapper (string-append libexec "/ld"))
-                     #t))
-                 (alist-replace
-                  'install
-                  (lambda _
-                    ;; Unlike our 'strip' phase, this will do the right thing
-                    ;; for cross-compilers.
-                    (zero? (system* "make" "install-strip")))
-                  ,phases))))
-          (if libc
-              `(alist-cons-before
-                'configure 'set-cross-path
-                (lambda* (#:key inputs #:allow-other-keys)
-                  ;; Add the cross Linux headers to CROSS_CPATH, and remove them
-                  ;; from CPATH.
-                  (let ((libc  (assoc-ref inputs "libc"))
-                        (linux (assoc-ref inputs "xlinux-headers")))
-                    (define (cross? x)
-                      ;; Return #t if X is a cross-libc or cross Linux.
-                      (or (string-prefix? libc x)
-                          (string-prefix? linux x)))
-
-                    (setenv "CROSS_CPATH"
-                            (string-append libc "/include:"
-                                           linux "/include"))
-                    (setenv "CROSS_LIBRARY_PATH"
-                            (string-append libc "/lib"))
-
-                    (let ((cpath   (search-path-as-string->list
-                                    (getenv "C_INCLUDE_PATH")))
-                          (libpath (search-path-as-string->list
-                                    (getenv "LIBRARY_PATH"))))
-                      (setenv "CPATH"
-                              (list->search-path-as-string
-                               (remove cross? cpath) ":"))
-                      (for-each unsetenv
-                                '("C_INCLUDE_PATH" "CPLUS_INCLUDE_PATH"))
-                      (setenv "LIBRARY_PATH"
-                              (list->search-path-as-string
-                               (remove cross? libpath) ":"))
-                      #t)))
-                ,phases)
-              phases)))))))
+                                    ,@(package-arguments %xgcc))))
+      (substitute-keyword-arguments args
+        ((#:configure-flags flags)
+         `(append (list ,(string-append "--target=" target)
+                        ,@(if libc
+                              `( ;; Disable libcilkrts because it is not
+                                ;; ported to GNU/Hurd.
+                                "--disable-libcilkrts")
+                              `( ;; Disable features not needed at this stage.
+                                "--disable-shared" "--enable-static"
+                                "--enable-languages=c,c++"
+
+                                ;; libstdc++ cannot be built at this stage
+                                ;; ("Link tests are not allowed after
+                                ;; GCC_NO_EXECUTABLES.").
+                                "--disable-libstdc++-v3"
+
+                                "--disable-threads" ;libgcc, would need libc
+                                "--disable-libatomic"
+                                "--disable-libmudflap"
+                                "--disable-libgomp"
+                                "--disable-libssp"
+                                "--disable-libquadmath"
+                                "--disable-decimal-float" ;would need libc
+                                "--disable-libcilkrts"
+                                ))
+                        ,@(if (equal? target "i686-w64-mingw32")
+                              '("--with-newlib"
+                                "--without-headers")
+                              '()))
+
+                  ,(if libc
+                       flags
+                       `(remove (cut string-match "--enable-languages.*" <>)
+                                ,flags))))
+        ((#:make-flags flags)
+         (cond
+          ((equal? target "i686-w64-mingw32")
+           `(cons (string-append "FLAGS_FOR_TARGET=-B"
+                                 (assoc-ref %build-inputs "i686-w64-mingw32-runtime")
+                                 "/lib")
+                  ,flags))
+          (libc
+                `(let ((libc (assoc-ref %build-inputs "libc")))
+                   ;; FLAGS_FOR_TARGET are needed for the target libraries to receive
+                   ;; the -Bxxx for the startfiles.
+                   (cons (string-append "FLAGS_FOR_TARGET=-B" libc "/lib")
+                         ,flags)))
+               (else flags)))
+        ((#:phases phases)
+         (let ((phases
+                `(alist-cons-after
+                  'install 'make-cross-binutils-visible
+                  (lambda* (#:key outputs inputs #:allow-other-keys)
+                    (let* ((out      (assoc-ref outputs "out"))
+                           (libexec  (string-append out "/libexec/gcc/"
+                                                    ,target))
+                           (binutils (string-append
+                                      (assoc-ref inputs "binutils-cross")
+                                      "/bin/" ,target "-"))
+                           (wrapper  (string-append
+                                      (assoc-ref inputs "ld-wrapper-cross")
+                                      "/bin/" ,target "-ld")))
+                      (for-each (lambda (file)
+                                  (symlink (string-append binutils file)
+                                           (string-append libexec "/"
+                                                          file)))
+                                '("as" "nm"))
+                      (symlink wrapper (string-append libexec "/ld"))
+                      #t))
+                  (alist-replace
+                   'install
+                   (lambda _
+                     ;; Unlike our 'strip' phase, this will do the right thing
+                     ;; for cross-compilers.
+                     (zero? (system* "make" "install-strip")))
+                   ,phases))))
+           (cond
+            ((equal? target "i686-w64-mingw32")
+             `(modify-phases ,phases
+                (add-before
+                 'configure 'set-cross-path
+                 (lambda* (#:key inputs #:allow-other-keys)
+                   ;; Add the cross Linux headers to CROSS_CPATH, and remove them
+                   ;; from CPATH.
+                   (let ((libc (assoc-ref inputs "i686-w64-mingw32-runtime"))
+                         (gcc (assoc-ref inputs "gcc")))
+                     (define (cross? x)
+                       (string-prefix? libc x))
+
+                     (setenv "CROSS_CPATH"
+                             (string-append libc "/include"
+                                            ":" libc "/i686-w64-mingw32/include"))
+                     (setenv "CROSS_LIBRARY_PATH"
+                             (string-append libc "/lib"
+                                            ":" libc "/i686-w64-mingw32/lib"))
+
+                     (setenv "CPP" (string-append gcc "/bin/cpp"))
+
+                     (let ((cpath   (search-path-as-string->list
+                                     (getenv "C_INCLUDE_PATH")))
+                           (libpath (search-path-as-string->list
+                                     (getenv "LIBRARY_PATH"))))
+                       (setenv "CPATH"
+                               (list->search-path-as-string
+                                (remove cross? cpath) ":"))
+                       (for-each unsetenv
+                                 '("C_INCLUDE_PATH" "CPLUS_INCLUDE_PATH"))
+                       (setenv "LIBRARY_PATH"
+                               (list->search-path-as-string
+                                (remove cross? libpath) ":"))
+                       #t))))))
+            (libc
+             `(alist-cons-before
+               'configure 'set-cross-path
+               (lambda* (#:key inputs #:allow-other-keys)
+                 ;; Add the cross Linux headers to CROSS_CPATH, and remove them
+                 ;; from CPATH.
+                 (let ((libc (assoc-ref inputs libc))
+                       (linux (assoc-ref inputs "xlinux-headers")))
+                   (define (cross? x)
+                     ;; Return #t if X is a cross-libc or cross Linux.
+                     (or (string-prefix? libc x)
+                         (string-prefix? linux x)))
+
+                   (setenv "CROSS_CPATH"
+                           (string-append libc "/include:"
+                                          linux "/include"))
+                   (setenv "CROSS_LIBRARY_PATH"
+                           (string-append libc "/lib"))
+
+                   (let ((cpath   (search-path-as-string->list
+                                   (getenv "C_INCLUDE_PATH")))
+                         (libpath (search-path-as-string->list
+                                   (getenv "LIBRARY_PATH"))))
+                     (setenv "CPATH"
+                             (list->search-path-as-string
+                              (remove cross? cpath) ":"))
+                     (for-each unsetenv
+                               '("C_INCLUDE_PATH" "CPLUS_INCLUDE_PATH"))
+                     (setenv "LIBRARY_PATH"
+                             (list->search-path-as-string
+                              (remove cross? libpath) ":"))
+                     #t)))
+               ,phases))
+            (else phases))))))))
 
 (define (cross-gcc-patches target)
   "Return GCC patches needed for TARGET."
@@ -210,63 +256,68 @@ may be either a libc package or #f.)"
 XBINUTILS as the associated cross-Binutils.  If LIBC is false, then build a
 GCC that does not target a libc; otherwise, target that libc."
   (package (inherit %xgcc)
-    (name (string-append "gcc-cross-"
-                         (if libc "" "sans-libc-")
-                         target))
-    (source (origin (inherit (package-source %xgcc))
-              (patches
-               (append
-                (origin-patches (package-source %xgcc))
-                (cons (search-patch "gcc-cross-environment-variables.patch")
-                      (cross-gcc-patches target))))))
-
-    ;; For simplicity, use a single output.  Otherwise libgcc_s & co. are not
-    ;; found by default, etc.
-    (outputs '("out"))
-
-    (arguments
-     `(#:implicit-inputs? #f
-       #:modules ((guix build gnu-build-system)
-                  (guix build utils)
-                  (ice-9 regex)
-                  (srfi srfi-1)
-                  (srfi srfi-26))
-
-       ,@(cross-gcc-arguments target libc)))
-
-    (native-inputs
-     `(("ld-wrapper-cross" ,(make-ld-wrapper
-                             (string-append "ld-wrapper-" target)
-                             #:target target
-                             #:binutils xbinutils))
-       ("binutils-cross" ,xbinutils)
-
-       ;; Call it differently so that the builder can check whether the "libc"
-       ;; input is #f.
-       ("libc-native" ,@(assoc-ref %final-inputs "libc"))
-
-       ;; Remaining inputs.
-       ,@(let ((inputs (append (package-inputs %xgcc)
-                               (alist-delete "libc" %final-inputs))))
-           (if libc
-               `(("libc" ,libc)
-                 ("xlinux-headers"                ;the target headers
-                  ,@(assoc-ref (package-propagated-inputs libc)
-                               "linux-headers"))
-                 ,@inputs)
-               inputs))))
-
-    (inputs '())
-
-    ;; Only search target inputs, not host inputs.
-    (search-paths
-     (list (search-path-specification
-            (variable "CROSS_CPATH")
-            (files '("include")))
-           (search-path-specification
-            (variable "CROSS_LIBRARY_PATH")
-            (files '("lib" "lib64")))))
-    (native-search-paths '())))
+           (name (string-append "gcc-cross-"
+                                (if libc "" "sans-libc-")
+                                target))
+           (source (origin (inherit (package-source %xgcc))
+                           (patches
+                            (append
+                             (origin-patches (package-source %xgcc))
+                             (cons (search-patch "gcc-cross-environment-variables.patch")
+                                   (cross-gcc-patches target))))))
+
+           ;; For simplicity, use a single output.  Otherwise libgcc_s & co. are not
+           ;; found by default, etc.
+           (outputs '("out"))
+
+           (arguments
+            `(#:implicit-inputs? #f
+                                 #:modules ((guix build gnu-build-system)
+                                            (guix build utils)
+                                            (ice-9 regex)
+                                            (srfi srfi-1)
+                                            (srfi srfi-26))
+
+                                 ,@(cross-gcc-arguments target libc)))
+
+           (native-inputs
+            `(("ld-wrapper-cross" ,(make-ld-wrapper
+                                    (string-append "ld-wrapper-" target)
+                                    #:target target
+                                    #:binutils xbinutils))
+              ("binutils-cross" ,xbinutils)
+              ("gcc" ,gcc)
+
+              ;; Call it differently so that the builder can check whether the "libc"
+              ;; input is #f.
+              ("libc-native" ,@(assoc-ref %final-inputs "libc"))
+
+              ;; Remaining inputs.
+              ,@(let ((inputs (append (package-inputs %xgcc)
+                                      (alist-delete "libc" %final-inputs))))
+                  (cond
+                   ((equal? target "i686-w64-mingw32")
+                    `(("i686-w64-mingw32-runtime" ,i686-w64-mingw32-runtime)
+                      ,@inputs))
+                   (libc
+                    `(("libc" ,libc)
+                      ("xlinux-headers"                ;the target headers
+                       ,@(assoc-ref (package-propagated-inputs libc)
+                                    "linux-headers"))
+                      ,@inputs))
+                   (else inputs)))))
+
+           (inputs '())
+
+           ;; Only search target inputs, not host inputs.
+           (search-paths
+            (list (search-path-specification
+                   (variable "CROSS_CPATH")
+                   (files '("include")))
+                  (search-path-specification
+                   (variable "CROSS_LIBRARY_PATH")
+                   (files '("lib" "lib64")))))
+           (native-search-paths '())))
 
 (define* (cross-libc target
                      #:optional
@@ -274,66 +325,68 @@ GCC that does not target a libc; otherwise, target that libc."
                      (xbinutils (cross-binutils target)))
   "Return a libc cross-built for TARGET, a GNU triplet.  Use XGCC and
 XBINUTILS and the cross tool chain."
-  (define xlinux-headers
-    (package (inherit linux-libre-headers)
-      (name (string-append (package-name linux-libre-headers)
-                           "-cross-" target))
-      (arguments
-       (substitute-keyword-arguments
-           `(#:implicit-cross-inputs? #f
-             ,@(package-arguments linux-libre-headers))
-         ((#:phases phases)
-          `(alist-replace
-            'build
-            (lambda _
-              (setenv "ARCH" ,(system->linux-architecture target))
-              (format #t "`ARCH' set to `~a' (cross compiling)~%" (getenv "ARCH"))
-
-              (and (zero? (system* "make" "defconfig"))
-                   (zero? (system* "make" "mrproper" "headers_check"))))
-            ,phases))))
-      (native-inputs `(("cross-gcc" ,xgcc)
-                       ("cross-binutils" ,xbinutils)
-                       ,@(package-native-inputs linux-libre-headers)))))
-
-  (package (inherit glibc)
-    (name (string-append "glibc-cross-" target))
-    (arguments
-     (substitute-keyword-arguments
-         `(;; Disable stripping (see above.)
-           #:strip-binaries? #f
-
-           ;; This package is used as a target input, but it should not have
-           ;; the usual cross-compilation inputs since that would include
-           ;; itself.
-           #:implicit-cross-inputs? #f
-
-           ,@(package-arguments glibc))
-       ((#:configure-flags flags)
-        `(cons ,(string-append "--host=" target)
-               ,flags))
-       ((#:phases phases)
-        `(alist-cons-before
-          'configure 'set-cross-linux-headers-path
-          (lambda* (#:key inputs #:allow-other-keys)
-            (let ((linux (assoc-ref inputs "linux-headers")))
-              (setenv "CROSS_CPATH"
-                      (string-append linux "/include"))
-              #t))
-          ,phases))))
-
-    ;; Shadow the native "linux-headers" because glibc's recipe expects the
-    ;; "linux-headers" input to point to the right thing.
-    (propagated-inputs `(("linux-headers" ,xlinux-headers)))
-
-    ;; FIXME: 'static-bash' should really be an input, not a native input, but
-    ;; to do that will require building an intermediate cross libc.
-    (inputs '())
-
-    (native-inputs `(("cross-gcc" ,xgcc)
-                     ("cross-binutils" ,xbinutils)
-                     ,@(package-inputs glibc)     ;FIXME: static-bash
-                     ,@(package-native-inputs glibc)))))
+  (cond
+   ((equal? target "i686-w64-mingw32") i686-w64-mingw32-runtime)
+   (else
+    (let ((xlinux-headers
+           (package (inherit linux-libre-headers)
+                    (name (string-append (package-name linux-libre-headers)
+                                         "-cross-" target))
+                    (arguments
+                     (substitute-keyword-arguments
+                         `(#:implicit-cross-inputs? #f
+                                                    ,@(package-arguments linux-libre-headers))
+                       ((#:phases phases)
+                        `(alist-replace
+                          'build
+                          (lambda _
+                            (setenv "ARCH" ,(system->linux-architecture target))
+                            (format #t "`ARCH' set to `~a' (cross compiling)~%" (getenv "ARCH"))
+
+                            (and (zero? (system* "make" "defconfig"))
+                                 (zero? (system* "make" "mrproper" "headers_check"))))
+                          ,phases))))
+                    (native-inputs `(("cross-gcc" ,xgcc)
+                                     ("cross-binutils" ,xbinutils)
+                                     ,@(package-native-inputs linux-libre-headers))))))
+      (package (inherit glibc)
+               (name (string-append "glibc-cross-" target))
+               (arguments
+                (substitute-keyword-arguments
+                    `( ;; Disable stripping (see above.)
+                      #:strip-binaries? #f
+
+                                        ;; This package is used as a target input, but it should not have
+                                        ;; the usual cross-compilation inputs since that would include
+                                        ;; itself.
+                                        #:implicit-cross-inputs? #f
+
+                                        ,@(package-arguments glibc))
+                  ((#:configure-flags flags)
+                   `(cons ,(string-append "--host=" target)
+                          ,flags))
+                  ((#:phases phases)
+                   `(alist-cons-before
+                     'configure 'set-cross-linux-headers-path
+                     (lambda* (#:key inputs #:allow-other-keys)
+                       (let ((linux (assoc-ref inputs "linux-headers")))
+                         (setenv "CROSS_CPATH"
+                                 (string-append linux "/include"))
+                         #t))
+                     ,phases))))
+
+               ;; Shadow the native "linux-headers" because glibc's recipe expects the
+               ;; "linux-headers" input to point to the right thing.
+               (propagated-inputs `(("linux-headers" ,xlinux-headers)))
+
+               ;; FIXME: 'static-bash' should really be an input, not a native input, but
+               ;; to do that will require building an intermediate cross libc.
+               (inputs '())
+
+               (native-inputs `(("cross-gcc" ,xgcc)
+                                ("cross-binutils" ,xbinutils)
+                                ,@(package-inputs glibc) ;FIXME: static-bash
+                                ,@(package-native-inputs glibc))))))))
 
 \f
 ;;;
@@ -348,9 +401,9 @@ XBINUTILS and the cross tool chain."
     ;; Don't attempt to build this cross-compiler on i686;
     ;; see <http://bugs.gnu.org/19598>.
     (package (inherit xgcc)
-      (supported-systems (fold delete
-                               (package-supported-systems xgcc)
-                               '("mips64el-linux" "i686-linux"))))))
+             (supported-systems (fold delete
+                                      (package-supported-systems xgcc)
+                                      '("mips64el-linux" "i686-linux"))))))
 
 (define-public xgcc-avr
   ;; AVR cross-compiler, used to build AVR-Libc.
@@ -368,10 +421,59 @@ XBINUTILS and the cross tool chain."
                              (cross-binutils triplet)
                              (cross-libc triplet))))
     (package (inherit xgcc)
-      (supported-systems (delete "armhf-linux" %supported-systems)))))
+             (supported-systems (delete "armhf-linux" %supported-systems)))))
 
 ;; (define-public xgcc-armel
 ;;   (let ((triplet "armel-linux-gnueabi"))
 ;;     (cross-gcc triplet
 ;;                (cross-binutils triplet)
 ;;                (cross-libc triplet))))
+
+(define-public i686-w64-mingw32-runtime
+  (package
+    (name "i686-w64-mingw32-runtime")
+    (version "4.9.2.v3.rev1.7")
+    (source (origin
+              (method url-fetch)
+              (uri
+               ;; FIXME: 7z
+               ;;"https://sourceforge.net/projects/mingw/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/4.9.2/threads-posix/sjlj/i686-4.9.2-release-posix-sjlj-rt_v4-rev4.7z"
+               "http://lilypond.org/download/gub-sources/mingw-w64-runtime/i686-4.9.2-release-posix-sjlj-rt_v4-rev4.7.tar.gz")
+              (sha256
+               (base32
+                "00hkvy2rm5sbvngm0l4ajh2b3b497cgkbz0wc9sbfd8r92bs2lkx"))))
+    (build-system trivial-build-system)
+    (native-inputs `(("gzip" ,gzip)
+                     ("source" ,source)
+                     ("tar" ,tar)))
+    (search-paths
+     (list (search-path-specification
+            (variable "CROSS_CPATH")
+            (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
+     `(#:modules ((guix build utils))
+                 #:builder (begin
+                             (use-modules (guix build utils))
+                             (let ((gzip (assoc-ref %build-inputs "gzip"))
+                                   (source (assoc-ref %build-inputs "source"))
+                                   (tar (assoc-ref %build-inputs "tar")))
+                               (setenv "PATH" (string-append gzip "/bin"
+                                                             ":" tar "/bin"
+                                                             ":" (getenv "PATH")))
+                               (mkdir-p %output)
+                               (system* "tar" "-C" %output "--strip-components=1" "-xf" source)))))
+    (home-page "http://mingw.org")
+    (synopsis "Minimalist GNU for Windows")
+    (description "MinGW provides a complete Open Source programming tool set
+which is suitable for the development of native MS-Windows applications, and
+which do not depend on any 3rd-party C-Runtime DLLs.")
+    (license fdl1.3+)))
+
+(define-public xgcc-i686-w64-mingw32
+  (let ((triplet "i686-w64-mingw32"))
+    (cross-gcc triplet
+               (cross-binutils triplet)
+               (cross-libc triplet))))
diff --git a/guix/build-system/gnu.scm b/guix/build-system/gnu.scm
index afd5766..4618182 100644
--- a/guix/build-system/gnu.scm
+++ b/guix/build-system/gnu.scm
@@ -398,7 +398,9 @@ is one of `host' or `target'."
          ((host)
           `(("cross-gcc" ,(gcc target
                                (binutils target)
-                               (libc target)))
+                               (if (equal? target "i686-w64-mingw32")
+                                   #f ;;(module-ref cross 'i686-w64-mingw32-runtime)
+                                   (libc target))))
             ("cross-binutils" ,(binutils target))))
          ((target)
           `(("cross-libc" ,(libc target)))))))))
-- 
2.6.3


[-- Attachment #3: Type: text/plain, Size: 154 bytes --]


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

^ permalink raw reply related	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2016-04-26  9:04 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-26 17:38 rfc/rfh: i686-w64-mingw32 cross target Jan Nieuwenhuizen
2016-03-27 14:20 ` [RFCv2] build: i686-w64-mingw32: new " Jan Nieuwenhuizen
2016-03-27 16:17   ` Pjotr Prins
2016-03-31 20:16 ` rfc/rfh: i686-w64-mingw32 " Ricardo Wurmus
2016-03-31 20:26   ` Jan Nieuwenhuizen
2016-03-31 20:48     ` Ricardo Wurmus
2016-04-02  7:30       ` Jan Nieuwenhuizen
2016-04-07 21:12         ` Ludovic Courtès
2016-04-14  6:30           ` Jan Nieuwenhuizen
2016-04-19 14:54             ` Ludovic Courtès
2016-04-24 21:40               ` [PATCH v4 1/9] gnu: cross: Use CROSS_*_INCLUDE_PATH for system headers Jan Nieuwenhuizen
2016-04-25 10:38                 ` Andy Wingo
2016-04-25 11:28                   ` Jan Nieuwenhuizen
2016-04-26  8:00                     ` Andy Wingo
2016-04-26  8:37                       ` Jan Nieuwenhuizen
2016-04-26  9:03                         ` Jan Nieuwenhuizen
2016-04-25 22:06                 ` Jan Nieuwenhuizen
2016-04-26  9:02                   ` Andy Wingo

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).