unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* mingw guile.exe cross build patch series v8
@ 2016-05-08 20:42 Jan Nieuwenhuizen
  2016-05-08 20:42 ` [PATCH 01/11] gnu: Add mingw-w64 Jan Nieuwenhuizen
                   ` (10 more replies)
  0 siblings, 11 replies; 36+ messages in thread
From: Jan Nieuwenhuizen @ 2016-05-08 20:42 UTC (permalink / raw)
  To: guix-devel

Hi!

You've seen most of this, and thanks so much for merging my basic cross
build patches (and Ludo: for fixing typo/mergo, sorry!).

Major change is that I compile ncurses now with libtool which because of a
non-standard use of libtool needs a cross-built libtool preinstalled.

Greetings,
Jan

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

* [PATCH 01/11] gnu: Add mingw-w64.
  2016-05-08 20:42 mingw guile.exe cross build patch series v8 Jan Nieuwenhuizen
@ 2016-05-08 20:42 ` Jan Nieuwenhuizen
  2016-05-09  7:07   ` Andy Wingo
  2016-05-08 20:42 ` [PATCH 02/11] gnu: cross-build: i686-w64-mingw32: new cross target Jan Nieuwenhuizen
                   ` (9 subsequent siblings)
  10 siblings, 1 reply; 36+ messages in thread
From: Jan Nieuwenhuizen @ 2016-05-08 20:42 UTC (permalink / raw)
  To: guix-devel

* gnu/packages/patches/gcc-4.9.3-mingw-gthr-default.patch,
gnu/packages/patches/mingw-w64-5.0rc2-gcc-4.9.3.patch,
gnu/packages/mingw.scm: New files.
* gnu/local.mk (dist_patch_DATA): Add them.
---
 gnu/local.mk                                       |   3 +
 gnu/packages/mingw.scm                             |  81 ++++++++
 .../patches/gcc-4.9.3-mingw-gthr-default.patch     |  11 ++
 .../patches/mingw-w64-5.0rc2-gcc-4.9.3.patch       | 218 +++++++++++++++++++++
 4 files changed, 313 insertions(+)
 create mode 100644 gnu/packages/mingw.scm
 create mode 100644 gnu/packages/patches/gcc-4.9.3-mingw-gthr-default.patch
 create mode 100644 gnu/packages/patches/mingw-w64-5.0rc2-gcc-4.9.3.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index cea6a73..d0345e9 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -230,6 +230,7 @@ GNU_SYSTEM_MODULES =				\
   gnu/packages/mcrypt.scm			\
   gnu/packages/messaging.scm			\
   gnu/packages/mg.scm				\
+  gnu/packages/mingw.scm			\
   gnu/packages/mit-krb5.scm			\
   gnu/packages/moe.scm				\
   gnu/packages/moreutils.scm			\
@@ -491,6 +492,7 @@ dist_patch_DATA =						\
   gnu/packages/patches/gcc-arm-link-spec-fix.patch		\
   gnu/packages/patches/gcc-cross-environment-variables.patch	\
   gnu/packages/patches/gcc-libvtv-runpath.patch			\
+  gnu/packages/patches/gcc-4.9.3-mingw-gthr-default.patch	\
   gnu/packages/patches/gcc-5.0-libvtv-runpath.patch		\
   gnu/packages/patches/geoclue-config.patch			\
   gnu/packages/patches/ghostscript-CVE-2015-3228.patch		\
@@ -626,6 +628,7 @@ dist_patch_DATA =						\
   gnu/packages/patches/mcron-install.patch			\
   gnu/packages/patches/mdadm-gcc-4.9-fix.patch			\
   gnu/packages/patches/mhash-keygen-test-segfault.patch		\
+  gnu/packages/patches/mingw-w64-5.0rc2-gcc-4.9.3.patch		\
   gnu/packages/patches/mit-krb5-CVE-2015-8629.patch		\
   gnu/packages/patches/mit-krb5-CVE-2015-8630.patch		\
   gnu/packages/patches/mit-krb5-CVE-2015-8631.patch		\
diff --git a/gnu/packages/mingw.scm b/gnu/packages/mingw.scm
new file mode 100644
index 0000000..aa9f53a
--- /dev/null
+++ b/gnu/packages/mingw.scm
@@ -0,0 +1,81 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu packages mingw)
+  #:use-module ((guix licenses) #:prefix license:)
+  #:use-module (gnu packages)
+  #:use-module (gnu packages base)
+  #:use-module (gnu packages cross-base)
+  #:use-module (gnu packages gcc)
+  #:use-module (gnu packages compression)
+  #:use-module (gnu packages multiprecision)
+  #:use-module (guix build-system gnu)
+  #:use-module (guix packages)
+  #:use-module (guix download)
+  #:use-module (guix utils)
+  #:use-module (ice-9 match))
+
+(define-public mingw-w64
+  (package
+    (name "mingw-w64")
+    (version "5.0-rc2")
+    (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 "0imdary8j07if8ih73pfgxiclpf2ax8h3mz8mxln07i8sbbd30c9"))
+              (patches (search-patches "mingw-w64-5.0rc2-gcc-4.9.3.patch"))))
+    (native-inputs `(("xgcc-core" ,xgcc-sans-libc-i686-w64-mingw32)
+                     ("xbinutils" ,xbinutils-i686-w64-mingw32)))
+    (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 _
+             (let ((xgcc-core (assoc-ref %build-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 "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 does not depend on any 3rd-party C-Runtime dlls.")
+    (license license:fdl1.3+)))
diff --git a/gnu/packages/patches/gcc-4.9.3-mingw-gthr-default.patch b/gnu/packages/patches/gcc-4.9.3-mingw-gthr-default.patch
new file mode 100644
index 0000000..0ea008a
--- /dev/null
+++ b/gnu/packages/patches/gcc-4.9.3-mingw-gthr-default.patch
@@ -0,0 +1,11 @@
+--- a/libgcc/config/i386/gthr-win32.h	2016-03-30 07:45:33.388684463 +0200
++++ b/libgcc/config/i386/gthr-win32.h	2016-03-30 15:51:24.123896436 +0200
+@@ -30,7 +30,7 @@
+
+ /* Make sure CONST_CAST2 (origin in system.h) is declared.  */
+ #ifndef CONST_CAST2
+-#define CONST_CAST2(TOTYPE,FROMTYPE,X) ((__extension__(union {FROMTYPE _q; TOTYPE _nq;})(X))._nq)
++#define CONST_CAST2(TOTYPE,FROMTYPE,X) ((TOTYPE)X)
+ #endif
+
+ /* Windows32 threads specific definitions. The windows32 threading model
diff --git a/gnu/packages/patches/mingw-w64-5.0rc2-gcc-4.9.3.patch b/gnu/packages/patches/mingw-w64-5.0rc2-gcc-4.9.3.patch
new file mode 100644
index 0000000..e8f841c
--- /dev/null
+++ b/gnu/packages/patches/mingw-w64-5.0rc2-gcc-4.9.3.patch
@@ -0,0 +1,218 @@
+This patch includes
+
+   * mingw-w64-headers/include/winnt.h: compile fixes for1 gcc-4.9.3
+   * mingw-w64-headers/crt/math.h: Likewise
+   * mingw-w64-headers/crt/float.h (FLT_EPSILON,DBL_EPSILON,LDBL_EPSILON): Add
+   symbols.
+   * mingw-w64-headers/crt/stat.h (S_ISLNK,S_ISSOCK,S_ISUID,S_ISGID,S_ISLINK):
+   Add symbols.
+   (lstat): Add function.
+   * mingw-w64-headers/crt/_mingw_stat64.h: Likewise
+   * mingw-w64-headers/crt/stdlib.h (realpath): Add function.
+
+Needed for building with gcc-4.9.3 and using with cross-libtool-2.4.6.
+
+Upstream status: not yet presented upstream.
+
+index 9c5cf87..74a8541 100644
+--- a/mingw-w64-crt/misc/dirname.c
++++ b/mingw-w64-crt/misc/dirname.c
+@@ -29,6 +29,12 @@
+ #define __cdecl  /* this may not be defined.                   */
+ #endif
+ 
++char *__cdecl
++realpath(const char *name, char *resolved)
++{
++  return resolved ? strcpy (resolved, name) : strdup (name);
++}
++
+ char * __cdecl
+ dirname(char *path)
+ {
+diff --git a/mingw-w64-headers/crt/_mingw_stat64.h b/mingw-w64-headers/crt/_mingw_stat64.h
+index 17e754c..7d2339b 100644
+--- a/mingw-w64-headers/crt/_mingw_stat64.h
++++ b/mingw-w64-headers/crt/_mingw_stat64.h
+@@ -2,13 +2,17 @@
+ 
+ #ifdef _USE_32BIT_TIME_T
+ #define _fstat32 _fstat
++#define _lstat32 _lstat
+ #define _stat32 _stat
+ #define _wstat32 _wstat
+ #define _fstat32i64 _fstati64
++#define _lstat32i64 _lstati64
+ #define _stat32i64 _stati64
+ #define _wstat32i64 _wstati64
+ #else
+ #define _fstat _fstat64i32
++#define _lstat _lstat64i32
++#define _lstati64 _lstat64
+ #define _fstati64 _fstat64
+ #define _stat _stat64i32
+ #define _stati64 _stat64
+diff --git a/mingw-w64-headers/crt/float.h b/mingw-w64-headers/crt/float.h
+index 5874f4e..bdf4ead 100644
+--- a/mingw-w64-headers/crt/float.h
++++ b/mingw-w64-headers/crt/float.h
+@@ -22,6 +22,15 @@
+ #if (__GNUC__ < 4)
+ #error Corrupt install of gcc-s internal headers, or search order was changed.
+ #else
++
++        /* From gcc-4.9.3 float.h.  */
++        #undef FLT_EPSILON
++        #undef DBL_EPSILON
++        #undef LDBL_EPSILON
++        #define FLT_EPSILON	__FLT_EPSILON__
++        #define DBL_EPSILON	__DBL_EPSILON__
++        #define LDBL_EPSILON	__LDBL_EPSILON__
++
+ 	/* #include_next <float_ginclude.h> */
+ 	
+    	/* Number of decimal digits, q, such that any floating-point number with q
+diff --git a/mingw-w64-headers/crt/math.h b/mingw-w64-headers/crt/math.h
+index 1e970f4..99a332f 100644
+--- a/mingw-w64-headers/crt/math.h
++++ b/mingw-w64-headers/crt/math.h
+@@ -216,6 +216,7 @@ extern "C" {
+ #endif
+   }
+ 
++#if 0
+   __CRT_INLINE long double __cdecl fabsl (long double x)
+   {
+ #ifdef __arm__
+@@ -226,6 +227,7 @@ extern "C" {
+     return res;
+ #endif
+   }
++#endif
+ 
+   __CRT_INLINE double __cdecl fabs (double x)
+   {
+@@ -905,7 +907,7 @@ __mingw_choose_expr (                                         \
+ /* 7.12.7.3  */
+   extern double __cdecl hypot (double, double) __MINGW_ATTRIB_DEPRECATED_MSVC2005; /* in libmoldname.a */
+   extern float __cdecl hypotf (float x, float y);
+-#ifndef __CRT__NO_INLINE
++#if 0 //ndef __CRT__NO_INLINE
+   __CRT_INLINE float __cdecl hypotf (float x, float y) { return (float) hypot ((double)x, (double)y);}
+ #endif
+   extern long double __cdecl hypotl (long double, long double);
+diff --git a/mingw-w64-headers/crt/stdlib.h b/mingw-w64-headers/crt/stdlib.h
+index dfc5ae4..6f0fee3 100644
+--- a/mingw-w64-headers/crt/stdlib.h
++++ b/mingw-w64-headers/crt/stdlib.h
+@@ -8,6 +8,7 @@
+ 
+ #include <crtdefs.h>
+ #include <limits.h>
++#include <string.h>
+ 
+ #if defined (__USE_MINGW_ANSI_STDIO) && ((__USE_MINGW_ANSI_STDIO + 0) != 0) && !defined (__USE_MINGW_STRTOX)
+ #define __USE_MINGW_STRTOX 1
+@@ -676,6 +677,8 @@ unsigned long __cdecl _lrotr(unsigned long,int);
+ 
+ #endif /* !__NO_ISOCEXT */
+ 
++char *__cdecl realpath (const char *name, char *resolved);
++
+ #ifdef __cplusplus
+ }
+ #endif
+diff --git a/mingw-w64-headers/crt/sys/stat.h b/mingw-w64-headers/crt/sys/stat.h
+index ed60219..d88b4f1 100644
+--- a/mingw-w64-headers/crt/sys/stat.h
++++ b/mingw-w64-headers/crt/sys/stat.h
+@@ -58,16 +58,21 @@ extern "C" {
+ #include <_mingw_stat64.h>
+ 
+ #define _S_IFMT 0xF000
++#define _S_IFLNK 0xA000
++#define _S_IFSOCK 0xC000
+ #define _S_IFDIR 0x4000
+ #define _S_IFCHR 0x2000
+ #define _S_IFIFO 0x1000
+ #define _S_IFREG 0x8000
++#define _S_ISUID 0x0400
++#define _S_ISGID 0x0200
+ #define _S_IREAD 0x0100
+ #define _S_IWRITE 0x0080
+ #define _S_IEXEC 0x0040
+ 
+   _CRTIMP int __cdecl _fstat32(int _FileDes,struct _stat32 *_Stat);
+   _CRTIMP int __cdecl _stat32(const char *_Name,struct _stat32 *_Stat);
++  static inline int __cdecl _lstat32(const char *_Name,struct _stat32 *_Stat) {return _stat32(_Name, _Stat);}
+   _CRTIMP int __cdecl _fstat64(int _FileDes,struct _stat64 *_Stat);
+   _CRTIMP int __cdecl _fstat32i64(int _FileDes,struct _stat32i64 *_Stat);
+   int __cdecl _fstat64i32(int _FileDes,struct _stat64i32 *_Stat);
+@@ -97,6 +102,9 @@ extern "C" {
+   _CRTIMP int __cdecl _stat64(const char *_Name,struct _stat64 *_Stat);
+   _CRTIMP int __cdecl _stat32i64(const char *_Name,struct _stat32i64 *_Stat);
+   int __cdecl _stat64i32(const char *_Name,struct _stat64i32 *_Stat);
++  static inline int __cdecl _lstat64(const char *_Name,struct _stat64 *_Stat) {return _stat64(_Name, _Stat);}
++  static inline int __cdecl _lstat32i64(const char *_Name,struct _stat32i64 *_Stat) {return _stat32i64(_Name, _Stat);}
++  static inline int __cdecl _lstat64i32(const char *_Name,struct _stat64i32 *_Stat) {return _stat64i32(_Name, _Stat);}
+ #ifndef __CRT__NO_INLINE
+   __CRT_INLINE int __cdecl _stat64i32(const char *_Name,struct _stat64i32 *_Stat)
+   {
+@@ -132,6 +140,8 @@ extern "C" {
+ #ifndef	NO_OLDNAMES
+ #define	_S_IFBLK	0x3000	/* Block: Is this ever set under w32? */
+ 
++#define S_IFLNK _S_IFLNK
++#define S_IFSOCK _S_IFSOCK
+ #define S_IFMT _S_IFMT
+ #define S_IFDIR _S_IFDIR
+ #define S_IFCHR _S_IFCHR
+@@ -162,6 +172,11 @@ extern "C" {
+ #define S_IXOTH    (S_IXGRP >> 3)
+ #define S_IRWXO    (S_IRWXG >> 3)
+ 
++#define S_ISUID _S_ISUID
++#define S_ISGID _S_ISGID
++
++#define S_ISLNK(m)	(((m) & S_IFMT) == S_IFLNK)
++#define S_ISSOCK(m)	(((m) & S_IFMT) == S_IFSOCK)
+ #define	S_ISDIR(m)	(((m) & S_IFMT) == S_IFDIR)
+ #define	S_ISFIFO(m)	(((m) & S_IFMT) == S_IFIFO)
+ #define	S_ISCHR(m)	(((m) & S_IFMT) == S_IFCHR)
+@@ -174,6 +189,7 @@ extern "C" {
+ int __cdecl stat(const char *_Filename,struct stat *_Stat);
+ int __cdecl fstat(int _Desc,struct stat *_Stat);
+ int __cdecl wstat(const wchar_t *_Filename,struct stat *_Stat);
++static inline int __cdecl lstat(const char *_Filename,struct stat *_Stat){return stat(_Filename, _Stat);}
+ 
+ #ifndef __CRT__NO_INLINE
+ #ifdef _USE_32BIT_TIME_T
+@@ -262,9 +278,11 @@ __CRT_INLINE int __cdecl
+ 
+ #if defined(_FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS == 64)
+ #ifdef _USE_32BIT_TIME_T
++#define lstat _lstat32i64
+ #define stat _stat32i64
+ #define fstat _fstat32i64
+ #else
++#define lstat _lstat64
+ #define stat _stat64
+ #define fstat _fstat64
+ #endif
+diff --git a/mingw-w64-headers/include/winnt.h b/mingw-w64-headers/include/winnt.h
+index 52af29b..8626396 100644
+--- a/mingw-w64-headers/include/winnt.h
++++ b/mingw-w64-headers/include/winnt.h
+@@ -6895,7 +6895,12 @@ __buildmemorybarrier()
+ 	  DWORD Reg : 3;
+ 	  DWORD R : 1;
+ 	  DWORD L : 1;
++/* C is used as a const specifier */
++#define save_C C
++#undef C
+ 	  DWORD C : 1;
++#define C save_C
++#undef save_C
+ 	  DWORD StackAdjust : 10;
+ 	} DUMMYSTRUCTNAME;
+       } DUMMYUNIONNAME;
-- 
2.7.3

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

* [PATCH 02/11] gnu: cross-build: i686-w64-mingw32: new cross target.
  2016-05-08 20:42 mingw guile.exe cross build patch series v8 Jan Nieuwenhuizen
  2016-05-08 20:42 ` [PATCH 01/11] gnu: Add mingw-w64 Jan Nieuwenhuizen
@ 2016-05-08 20:42 ` Jan Nieuwenhuizen
  2016-05-09  7:15   ` Andy Wingo
  2016-05-08 20:42 ` [PATCH 03/11] gnu: Add function libiconv-if-needed Jan Nieuwenhuizen
                   ` (8 subsequent siblings)
  10 siblings, 1 reply; 36+ messages in thread
From: Jan Nieuwenhuizen @ 2016-05-08 20:42 UTC (permalink / raw)
  To: guix-devel

* guix/utils.scm (mingw-target?): New function.
* gnu/packages/cross-base.scm (cross-gcc-snippet): New function for mingw.
(cross-gcc): Use it.
(cross-gcc-arguments, cross-gcc-patches, cross-gcc): Support mingw.
(native-libc, cross-newlib?): New functions.
(cross-libc): Use cross-newlib? to support mingw.
(xbinutils-i686-w64-mingw32, xgcc-sans-libc-i686-w64-mingw32,
xgcc-i686-w64-mingw32): New variables.
---
 gnu/packages/cross-base.scm | 271 +++++++++++++++++++++++++++++++-------------
 guix/utils.scm              |   5 +
 2 files changed, 200 insertions(+), 76 deletions(-)

diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm
index 73ac76a..a7227d0 100644
--- a/gnu/packages/cross-base.scm
+++ b/gnu/packages/cross-base.scm
@@ -19,12 +19,17 @@
 ;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
 
 (define-module (gnu packages cross-base)
-  #:use-module (guix licenses)
+  #:use-module ((guix licenses) #:prefix license:)
   #:use-module (gnu packages)
-  #:use-module (gnu packages gcc)
   #:use-module (gnu packages base)
+  #:use-module (gnu packages bash)
+  #:use-module (gnu packages gawk)
+  #:use-module (gnu packages gcc)
   #:use-module (gnu packages commencement)
+  #:use-module (gnu packages compression)
   #:use-module (gnu packages linux)
+  #:use-module (gnu packages mingw)
+  #:use-module (gnu packages multiprecision)
   #:use-module (guix packages)
   #:use-module (guix download)
   #:use-module (guix utils)
@@ -35,7 +40,8 @@
   #:use-module (ice-9 match)
   #:export (cross-binutils
             cross-libc
-            cross-gcc))
+            cross-gcc
+            cross-newlib?))
 
 (define %xgcc
   ;; GCC package used as the basis for cross-compilation.  It doesn't have to
@@ -121,7 +127,12 @@ may be either a libc package or #f.)"
                                "--disable-libquadmath"
                                "--disable-decimal-float" ;would need libc
                                "--disable-libcilkrts"
-                               )))
+                                ))
+
+                       ;; For a newlib (non-glibc) target
+                       ,@(if (cross-newlib? target)
+                             '("--with-newlib")
+                             '()))
 
                  ,(if libc
                       flags
@@ -163,7 +174,67 @@ may be either a libc package or #f.)"
                     ;; for cross-compilers.
                     (zero? (system* "make" "install-strip")))
                   ,phases))))
-          (if libc
+           (cond
+            ((mingw-target? target)
+             `(modify-phases ,phases
+                (add-before
+                 'configure 'set-cross-path
+                 (lambda* (#:key inputs #: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"))
+                         (gcc (assoc-ref inputs "gcc")))
+                     (define (cross? x)
+                       (and libc (string-prefix? libc x)))
+                     (if libc
+                         (let ((cpath (string-append
+                                       libc "/include"
+                                       ":" libc "/i686-w64-mingw32/include")))
+                           (for-each (cut setenv <> cpath)
+                                     '("CROSS_C_INCLUDE_PATH"
+                                       "CROSS_CPLUS_INCLUDE_PATH"
+                                       "CROSS_OBJC_INCLUDE_PATH"
+                                       "CROSS_OBJCPLUS_INCLUDE_PATH")))
+                         (let ((mingw-source (assoc-ref inputs "mingw-source"))
+                               (mingw-headers
+                                (string-append (getcwd) "/mingw-w64-v5.0-rc2/mingw-w64-headers")))
+                           (system* "tar" "xf" mingw-source)
+                           (copy-file (string-append mingw-headers "/crt/_mingw.h.in")
+                                      (string-append mingw-headers "/crt/_mingw.h"))
+                           (substitute* (string-append mingw-headers "/crt/_mingw.h")
+                             (("@MINGW_HAS_SECURE_API@") "#define MINGW_HAS_SECURE_API 1"))
+                           (let ((cpath (string-append
+                                         mingw-headers "/include"
+                                         ":" mingw-headers "/crt"
+                                         ":" mingw-headers "/defaults/include")))
+                             (for-each (cut setenv <> cpath)
+                                       '("CROSS_C_INCLUDE_PATH"
+                                         "CROSS_CPLUS_INCLUDE_PATH"
+                                         "CROSS_OBJC_INCLUDE_PATH"
+                                         "CROSS_OBJCPLUS_INCLUDE_PATH"
+                                         "CROSS_LIBRARY_PATH")))))
+                     (when libc
+                       (setenv "CROSS_LIBRARY_PATH"
+                               (string-append
+                                libc "/lib"
+                                ":" libc "/i686-w64-mingw32/lib")))
+                     (setenv "CPP" (string-append gcc "/bin/cpp"))
+                     (for-each
+                      (lambda (var)
+                        (and=> (getenv var)
+                               (lambda (value)
+                                 (let* ((path (search-path-as-string->list
+                                               value))
+                                        (native-path (list->search-path-as-string
+                                                      (remove cross? path) ":")))
+                                   (setenv var native-path)))))
+                      '("C_INCLUDE_PATH"
+                        "CPLUS_INCLUDE_PATH"
+                        "OBJC_INCLUDE_PATH"
+                        "OBJCPLUS_INCLUDE_PATH"
+                        "LIBRARY_PATH"))
+                     #t)))))
+            (libc
               `(alist-cons-before
                 'configure 'set-cross-path
                 (lambda* (#:key inputs #:allow-other-keys)
@@ -199,18 +270,27 @@ may be either a libc package or #f.)"
                                 "OBJCPLUS_INCLUDE_PATH"
                                 "LIBRARY_PATH"))
                     #t))
-                ,phases)
-              phases)))))))
+                ,phases))
+          (else phases))))))))
 
 (define (cross-gcc-patches target)
   "Return GCC patches needed for TARGET."
   (cond ((string-prefix? "xtensa-" target)
          ;; Patch by Qualcomm needed to build the ath9k-htc firmware.
          (search-patches "ath9k-htc-firmware-gcc.patch"))
+        ((mingw-target? target)
+         (search-patches "gcc-4.9.3-mingw-gthr-default.patch"))
+        (else '())))
+
+(define (cross-gcc-snippet target)
+  "Return GCC snippet needed for TARGET."
+  (cond ((mingw-target? target)
+         '(copy-recursively "libstdc++-v3/config/os/mingw32-w64"
+                            "libstdc++-v3/config/os/newlib"))
         (else '())))
 
 (define* (cross-gcc target
-                    #:optional (xbinutils (cross-binutils target)) libc)
+                    #:optional (xbinutils (cross-binutils target)) (libc #f))
   "Return a cross-compiler for TARGET, where TARGET is a GNU triplet.  Use
 XBINUTILS as the associated cross-Binutils.  If LIBC is false, then build a
 GCC that does not target a libc; otherwise, target that libc."
@@ -223,7 +303,10 @@ GCC that does not target a libc; otherwise, target that libc."
                (append
                 (origin-patches (package-source %xgcc))
                 (cons (search-patch "gcc-cross-environment-variables.patch")
-                      (cross-gcc-patches target))))))
+                      (cross-gcc-patches target))))
+              (modules '((guix build utils)))
+              (snippet
+               (cross-gcc-snippet target))))
 
     ;; For simplicity, use a single output.  Otherwise libgcc_s & co. are not
     ;; found by default, etc.
@@ -245,6 +328,7 @@ GCC that does not target a libc; otherwise, target that libc."
                              #:target target
                              #:binutils xbinutils))
        ("binutils-cross" ,xbinutils)
+       ("gcc" ,gcc)
 
        ;; Call it differently so that the builder can check whether the "libc"
        ;; input is #f.
@@ -253,13 +337,20 @@ GCC that does not target a libc; otherwise, target that libc."
        ;; Remaining inputs.
        ,@(let ((inputs (append (package-inputs %xgcc)
                                (alist-delete "libc" %final-inputs))))
-           (if libc
+           (cond
+            ((mingw-target? target)
+             (if libc
+                 `(("libc" ,mingw-w64)
+                   ,@inputs)
+                 `(("mingw-source" ,(package-source mingw-w64))
+                   ,@inputs)))
+            (libc
                `(("libc" ,libc)
                  ("xlinux-headers"                ;the target headers
                   ,@(assoc-ref (package-propagated-inputs libc)
                                "linux-headers"))
-                 ,@inputs)
-               inputs))))
+               ,@inputs))
+            (else inputs)))))
 
     (inputs '())
 
@@ -289,70 +380,83 @@ 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"))
-                   (cpath (string-append linux "/include")))
-              (for-each (cut setenv <> cpath)
-                        '("CROSS_C_INCLUDE_PATH"
-                          "CROSS_CPLUS_INCLUDE_PATH"
-                          "CROSS_OBJC_INCLUDE_PATH"
-                          "CROSS_OBJCPLUS_INCLUDE_PATH"))
-              #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
+   ((cross-newlib? target)
+    (cross-newlib? target))
+   (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"))
+                       (cpath (string-append linux "/include")))
+                  (for-each (cut setenv <> cpath)
+                            '("CROSS_C_INCLUDE_PATH"
+                              "CROSS_CPLUS_INCLUDE_PATH"
+                              "CROSS_OBJC_INCLUDE_PATH"
+                              "CROSS_OBJCPLUS_INCLUDE_PATH"))
+                  #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))))))))
+
+(define (native-libc target)
+  (if (mingw-target? target)
+      mingw-w64
+      glibc))
+
+(define (cross-newlib? target)
+  (and (not (eq? (native-libc target) glibc))
+       (native-libc target)))
 
 \f
 ;;;
@@ -394,3 +498,18 @@ XBINUTILS and the cross tool chain."
 ;;     (cross-gcc triplet
 ;;                (cross-binutils triplet)
 ;;                (cross-libc triplet))))
+
+(define-public xgcc-sans-libc-i686-w64-mingw32
+  (let ((triplet "i686-w64-mingw32"))
+    (cross-gcc triplet
+               (cross-binutils triplet))))
+
+(define-public xbinutils-i686-w64-mingw32
+  (let ((triplet "i686-w64-mingw32"))
+    (cross-binutils triplet)))
+
+(define-public xgcc-i686-w64-mingw32
+  (let ((triplet "i686-w64-mingw32"))
+    (cross-gcc triplet
+               (cross-binutils triplet)
+               (cross-newlib? triplet))))
diff --git a/guix/utils.scm b/guix/utils.scm
index d924e43..2109035 100644
--- a/guix/utils.scm
+++ b/guix/utils.scm
@@ -65,6 +65,7 @@
             gnu-triplet->nix-system
             %current-system
             %current-target-system
+            mingw-target?
             package-name->name+version
             version-compare
             version>?
@@ -483,6 +484,10 @@ returned by `config.guess'."
   ;; cross-building to.
   (make-parameter #f))
 
+(define* (mingw-target? #:optional (target (%current-target-system)))
+  (and target
+       (string-suffix? "-mingw32" target)))
+
 (define (package-name->name+version spec)
   "Given SPEC, a package name like \"foo@0.9.1b\", return two values: \"foo\"
 and \"0.9.1b\".  When the version part is unavailable, SPEC and #f are
-- 
2.7.3

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

* [PATCH 03/11] gnu: Add function libiconv-if-needed.
  2016-05-08 20:42 mingw guile.exe cross build patch series v8 Jan Nieuwenhuizen
  2016-05-08 20:42 ` [PATCH 01/11] gnu: Add mingw-w64 Jan Nieuwenhuizen
  2016-05-08 20:42 ` [PATCH 02/11] gnu: cross-build: i686-w64-mingw32: new cross target Jan Nieuwenhuizen
@ 2016-05-08 20:42 ` Jan Nieuwenhuizen
  2016-05-09  7:16   ` Andy Wingo
  2016-05-08 20:42 ` [PATCH 04/11] gnu: libunistring: support mingw: propagate libiconv if needed Jan Nieuwenhuizen
                   ` (7 subsequent siblings)
  10 siblings, 1 reply; 36+ messages in thread
From: Jan Nieuwenhuizen @ 2016-05-08 20:42 UTC (permalink / raw)
  To: guix-devel

* gnu/packages/base.scm (libiconv-if-needed): New function.
---
 gnu/packages/base.scm | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/base.scm b/gnu/packages/base.scm
index beb689e..51d70b1 100644
--- a/gnu/packages/base.scm
+++ b/gnu/packages/base.scm
@@ -44,7 +44,8 @@
   #:use-module (guix download)
   #:use-module (guix git-download)
   #:use-module (guix build-system gnu)
-  #:use-module (guix build-system trivial))
+  #:use-module (guix build-system trivial)
+  :export (libiconv-if-needed))
 
 ;;; Commentary:
 ;;;
@@ -964,6 +965,11 @@ program.  It supports a wide variety of different encodings.")
     (home-page "http://www.gnu.org/software/libiconv/")
     (license lgpl3+)))
 
+(define* (libiconv-if-needed #:optional (target (%current-target-system)))
+  (if (mingw-target? target)
+      `(("libiconv" ,libiconv))
+      '()))
+
 (define-public (canonical-package package)
   ;; Avoid circular dependency by lazily resolving 'commencement'.
   (let* ((iface (resolve-interface '(gnu packages commencement)))
-- 
2.7.3

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

* [PATCH 04/11] gnu: libunistring: support mingw: propagate libiconv if needed.
  2016-05-08 20:42 mingw guile.exe cross build patch series v8 Jan Nieuwenhuizen
                   ` (2 preceding siblings ...)
  2016-05-08 20:42 ` [PATCH 03/11] gnu: Add function libiconv-if-needed Jan Nieuwenhuizen
@ 2016-05-08 20:42 ` Jan Nieuwenhuizen
  2016-05-09  7:17   ` Andy Wingo
  2016-05-08 20:42 ` [PATCH 05/11] gnu: gmp: build shared library for mingw Jan Nieuwenhuizen
                   ` (6 subsequent siblings)
  10 siblings, 1 reply; 36+ messages in thread
From: Jan Nieuwenhuizen @ 2016-05-08 20:42 UTC (permalink / raw)
  To: guix-devel

* gnu/packages/libunistring (libunistring): propagated-inputs: add
libiconv-if-needed.  Fixes unicode translation in mingw.
---
 gnu/packages/libunistring.scm | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/libunistring.scm b/gnu/packages/libunistring.scm
index f29b742..d2feac2 100644
--- a/gnu/packages/libunistring.scm
+++ b/gnu/packages/libunistring.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2012, 2013, 2014 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
+;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -21,7 +22,8 @@
   #:use-module (guix licenses)
   #:use-module (guix packages)
   #:use-module (guix download)
-  #:use-module (guix build-system gnu))
+  #:use-module (guix build-system gnu)
+  #:use-module (gnu packages base))
 
 (define-public libunistring
   (package
@@ -35,7 +37,7 @@
             (sha256
              (base32
               "0ixxmgpgh2v8ifm6hbwsjxl023myk3dfnj7wnvmqjivza31fw9cn"))))
-   (propagated-inputs '())                  ; FIXME: add libiconv when !glibc
+   (propagated-inputs `(,@(libiconv-if-needed)))
    (build-system gnu-build-system)
    (arguments
     ;; Work around parallel build issue whereby C files may be compiled before
-- 
2.7.3

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

* [PATCH 05/11] gnu: gmp: build shared library for mingw.
  2016-05-08 20:42 mingw guile.exe cross build patch series v8 Jan Nieuwenhuizen
                   ` (3 preceding siblings ...)
  2016-05-08 20:42 ` [PATCH 04/11] gnu: libunistring: support mingw: propagate libiconv if needed Jan Nieuwenhuizen
@ 2016-05-08 20:42 ` Jan Nieuwenhuizen
  2016-05-09  7:20   ` Andy Wingo
  2016-05-08 20:42 ` [PATCH 06/11] gnu: ncurses: support mingw Jan Nieuwenhuizen
                   ` (5 subsequent siblings)
  10 siblings, 1 reply; 36+ messages in thread
From: Jan Nieuwenhuizen @ 2016-05-08 20:42 UTC (permalink / raw)
  To: guix-devel

* gnu/packages/multiprecision.scm (gmp)[MINGW]: Use --enable-shared.
---
 gnu/packages/multiprecision.scm | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/multiprecision.scm b/gnu/packages/multiprecision.scm
index 9924323..8c1a9b7 100644
--- a/gnu/packages/multiprecision.scm
+++ b/gnu/packages/multiprecision.scm
@@ -3,6 +3,7 @@
 ;;; Copyright © 2014 Mark H Weaver <mhw@netris.org>
 ;;; Copyright © 2015 Andreas Enge <andreas@enge.fr>
 ;;; Copyright © 2016 Nicolas Goaziou <mail@nicolasgoaziou.fr>
+;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -49,7 +50,13 @@
                 '(;; Build a "fat binary", with routines for several
                   ;; sub-architectures.
                   "--enable-fat"
-                  "--enable-cxx")))
+                  "--enable-cxx"
+                  ,@(cond ((mingw-target?)
+                           ;; Static and shared cannot be built in one go:
+                           ;; they produce different headers.  We need shared.
+                           `("--disable-static"
+                             "--enable-shared"))
+                          (else '())))))
    (synopsis "Multiple-precision arithmetic library")
    (description
     "GMP is a library for arbitrary precision arithmetic, operating on
-- 
2.7.3

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

* [PATCH 06/11] gnu: ncurses: support mingw.
  2016-05-08 20:42 mingw guile.exe cross build patch series v8 Jan Nieuwenhuizen
                   ` (4 preceding siblings ...)
  2016-05-08 20:42 ` [PATCH 05/11] gnu: gmp: build shared library for mingw Jan Nieuwenhuizen
@ 2016-05-08 20:42 ` Jan Nieuwenhuizen
  2016-05-09  7:23   ` Andy Wingo
  2016-05-08 20:42 ` [PATCH 07/11] gnu: cross-base: Add cross-libtool Jan Nieuwenhuizen
                   ` (4 subsequent siblings)
  10 siblings, 1 reply; 36+ messages in thread
From: Jan Nieuwenhuizen @ 2016-05-08 20:42 UTC (permalink / raw)
  To: guix-devel

* gnu/packages/patches/ncurses-mingw.patch: New file.
* gnu-system.am (dist_patch_DATA): Add it.
* gnu/packages/ncurses.scm (ncurses): Support mingw.
---
 gnu/local.mk                             |  1 +
 gnu/packages/ncurses.scm                 | 88 +++++++++++++++++++++++---------
 gnu/packages/patches/ncurses-mingw.patch | 24 +++++++++
 3 files changed, 89 insertions(+), 24 deletions(-)
 create mode 100644 gnu/packages/patches/ncurses-mingw.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index d0345e9..a32fe88 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -639,6 +639,7 @@ dist_patch_DATA =						\
   gnu/packages/patches/mumps-build-parallelism.patch		\
   gnu/packages/patches/mupen64plus-ui-console-notice.patch	\
   gnu/packages/patches/mutt-store-references.patch		\
+  gnu/packages/patches/ncurses-mingw.patch			\
   gnu/packages/patches/net-tools-bitrot.patch			\
   gnu/packages/patches/ngircd-handle-zombies.patch		\
   gnu/packages/patches/ngircd-no-dns-in-tests.patch		\
diff --git a/gnu/packages/ncurses.scm b/gnu/packages/ncurses.scm
index 147033a..840dcf2 100644
--- a/gnu/packages/ncurses.scm
+++ b/gnu/packages/ncurses.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2012, 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2014 Mark H Weaver <mhw@netris.org>
 ;;; Copyright © 2015 Leo Famulari <leo@famulari.name>
+;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -19,9 +20,11 @@
 ;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
 
 (define-module (gnu packages ncurses)
+  #:use-module (gnu packages)
   #:use-module (guix licenses)
   #:use-module (guix packages)
   #:use-module (guix download)
+  #:use-module (guix utils)
   #:use-module (guix build-system gnu))
 
 (define-public ncurses
@@ -36,6 +39,7 @@
                     #:allow-other-keys)
             (let ((out (assoc-ref outputs "out"))
                   (doc (assoc-ref outputs "doc")))
+              (format #t "configure flags: ~s~%" configure-flags)
               (zero? (apply system* "./configure"
                             (string-append "SHELL=" (which "sh"))
                             (string-append "--build=" build)
@@ -60,33 +64,66 @@
                "mandir=share/man"))
             #t))
         (post-install-phase
-         '(lambda* (#:key outputs #:allow-other-keys)
-            (let ((out (assoc-ref outputs "out")))
+         `(lambda* (#:key outputs target #:allow-other-keys)
+            (let ((out (assoc-ref outputs "out"))
+                  (mingw-target? (lambda* (#:optional (target target))
+                                   (and target
+                                        (string-suffix? "-mingw32" target))))
+                  (libraries '("curses" "ncurses" "form" "panel" "menu")))
               ;; When building a wide-character (Unicode) build, create backward
               ;; compatibility links from the the "normal" libraries to the
               ;; wide-character libraries (e.g. libncurses.so to libncursesw.so).
-              (with-directory-excursion (string-append out "/lib")
-                (for-each (lambda (lib)
-                            (define libw.a
-                              (string-append "lib" lib "w.a"))
-                            (define lib.a
-                              (string-append "lib" lib ".a"))
-                            (define libw.so.x
-                              (string-append "lib" lib "w.so.6"))
-                            (define lib.so.x
-                              (string-append "lib" lib ".so.6"))
-                            (define lib.so
-                              (string-append "lib" lib ".so"))
+              (cond
+               ((mingw-target? target)
+                (with-directory-excursion (string-append out "/bin")
+                  (for-each
+                   (lambda (lib)
+                     (define lib.dll
+                       (string-append "lib" lib ".dll"))
+                     (define libw6.dll
+                       (string-append "lib" lib "w6.dll"))
+
+                     (when (file-exists? libw6.dll)
+                       (format #t "creating symlinks for `lib~a'~%" lib)
+                       (symlink libw6.dll lib.dll)))
+                   libraries))
+                ;; TODO: create .la files to link to the .dll?
+                (with-directory-excursion (string-append out "/lib")
+                  (for-each
+                   (lambda (lib)
+                     (define libw.a
+                       (string-append "lib" lib "w.a"))
+                     (define lib.a
+                       (string-append "lib" lib ".a"))
+
+                     (when (file-exists? libw.a)
+                       (format #t "creating symlinks for `lib~a'~%" lib)
+                       (symlink libw.a lib.a)))
+                   libraries)))
+               (else
+                (with-directory-excursion (string-append out "/lib")
+                  (for-each
+                   (lambda (lib)
+                     (define libw.a
+                       (string-append "lib" lib "w.a"))
+                     (define lib.a
+                       (string-append "lib" lib ".a"))
+                     (define libw.so.x
+                       (string-append "lib" lib "w.so.6"))
+                     (define lib.so.x
+                       (string-append "lib" lib ".so.6"))
+                     (define lib.so
+                       (string-append "lib" lib ".so"))
 
-                            (when (file-exists? libw.a)
-                              (format #t "creating symlinks for `lib~a'~%" lib)
-                              (symlink libw.a lib.a)
-                              (symlink libw.so.x lib.so.x)
-                              (false-if-exception (delete-file lib.so))
-                              (call-with-output-file lib.so
-                                (lambda (p)
-                                  (format p "INPUT (-l~aw)~%" lib)))))
-                          '("curses" "ncurses" "form" "panel" "menu")))))))
+                     (when (file-exists? libw.a)
+                       (format #t "creating symlinks for `lib~a'~%" lib)
+                       (symlink libw.a lib.a)
+                       (symlink libw.so.x lib.so.x)
+                       (false-if-exception (delete-file lib.so))
+                       (call-with-output-file lib.so
+                         (lambda (p)
+                           (format p "INPUT (-l~aw)~%" lib)))))
+                   libraries))))))))
     (package
      (name "ncurses")
      (version "6.0")
@@ -94,6 +131,7 @@
               (method url-fetch)
               (uri (string-append "mirror://gnu/ncurses/ncurses-"
                                   version ".tar.gz"))
+              (patches (search-patches "ncurses-mingw.patch"))
               (sha256
                (base32
                 "0q3jck7lna77z5r42f13c4xglc7azd19pxfrjrpgp2yf615w4lgm"))))
@@ -113,7 +151,9 @@
           ;; Make sure programs like 'tic', 'reset', and 'clear' have a
           ;; correct RUNPATH.
           ,(string-append "LDFLAGS=-Wl,-rpath=" (assoc-ref %outputs "out")
-                          "/lib"))
+                          "/lib")
+          ;; MinGW: Provide termcap api, created for the MinGW port.
+          ,@(if ,(mingw-target?) '("--enable-term-driver") '()))
         #:tests? #f                               ; no "check" target
         #:phases (modify-phases %standard-phases
                    (replace 'configure ,configure-phase)
diff --git a/gnu/packages/patches/ncurses-mingw.patch b/gnu/packages/patches/ncurses-mingw.patch
new file mode 100644
index 0000000..0f6a313
--- /dev/null
+++ b/gnu/packages/patches/ncurses-mingw.patch
@@ -0,0 +1,24 @@
+Taken from Eli Zaretskii's gdb bug report
+
+    https://sourceware.org/ml/gdb-patches/2012-04/msg01052.html
+
+Upstream status: Not presented to upstream.
+
+--- ncurses-6.0.orig/include/curses.h.in	2014-08-09 22:39:44.000000000 +0200
++++ ncurses-6.0/include/curses.h.in	2016-04-09 20:47:14.266679000 +0200
+@@ -1420,3 +1420,15 @@
+ #define KEY_BREAK	0401		/* Break key (unreliable) */
+ #define KEY_SRESET	0530		/* Soft (partial) reset (unreliable) */
+ #define KEY_RESET	0531		/* Reset or hard reset (unreliable) */
++
++#ifdef __MINGW32__
++/* Windows API headers, included e.g. by serial.h, define MOUSE_MOVED,
++   and so does PDCurses's curses.h, but for an entirely different
++   purpose.  Since we don't use the Windows semantics of MOUSE_MOVED
++   anywhere, avoid compiler warnings by undefining MOUSE_MOVED before
++   including curses.h.  */
++#undef MOUSE_MOVED
++/* Likewise, KEY_EVENT is defined by ncurses.h, but also by Windows
++   API headers.  */
++#undef KEY_EVENT
++#endif
-- 
2.7.3

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

* [PATCH 07/11] gnu: cross-base: Add cross-libtool.
  2016-05-08 20:42 mingw guile.exe cross build patch series v8 Jan Nieuwenhuizen
                   ` (5 preceding siblings ...)
  2016-05-08 20:42 ` [PATCH 06/11] gnu: ncurses: support mingw Jan Nieuwenhuizen
@ 2016-05-08 20:42 ` Jan Nieuwenhuizen
  2016-05-09  7:29   ` Andy Wingo
  2016-05-08 20:42 ` [PATCH 08/11] gnu: libtool: support cross-libtool mingw Jan Nieuwenhuizen
                   ` (3 subsequent siblings)
  10 siblings, 1 reply; 36+ messages in thread
From: Jan Nieuwenhuizen @ 2016-05-08 20:42 UTC (permalink / raw)
  To: guix-devel

* gnu/packages/cross-base.scm (cross-libtool): New function.
---
 gnu/packages/cross-base.scm | 46 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)

diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm
index a7227d0..011f58d 100644
--- a/gnu/packages/cross-base.scm
+++ b/gnu/packages/cross-base.scm
@@ -22,6 +22,7 @@
   #:use-module ((guix licenses) #:prefix license:)
   #:use-module (gnu packages)
   #:use-module (gnu packages base)
+  #:use-module (gnu packages autotools)
   #:use-module (gnu packages bash)
   #:use-module (gnu packages gawk)
   #:use-module (gnu packages gcc)
@@ -40,6 +41,7 @@
   #:use-module (ice-9 match)
   #:export (cross-binutils
             cross-libc
+            cross-libtool
             cross-gcc
             cross-newlib?))
 
@@ -449,6 +451,50 @@ XBINUTILS and the cross tool chain."
                          ,@(package-inputs glibc)     ;FIXME: static-bash
                          ,@(package-native-inputs glibc))))))))
 
+(define* (cross-libtool target
+                        #:optional
+                        (xgcc (cross-gcc target
+                                         (cross-binutils target)
+                                         (cross-libc target)))
+                        (xbinutils (cross-binutils target))
+                        (xlibc (cross-libc target)))
+  (package
+    (inherit libtool)
+    (name (string-append "cross-libtool-" target))
+    (inputs `(("xlibc" ,xlibc)))
+    (native-inputs `(,@`(("xgcc" ,xgcc)
+                         ("xbinutils" ,xbinutils)
+                         ("xlibc" ,xlibc))
+                     ,@(package-native-inputs libtool)))
+    (arguments
+     `(;; Libltdl is provided as a separate package, so don't install it here.
+       #:configure-flags
+       `("--disable-ltdl-install"
+         ,(string-append "--host=" ,target)
+         ,(string-append "--target=" ,target)
+         ,(string-append "--program-prefix=" ,target "-")
+         ,(string-append "CC=" ,target "-gcc"))
+       #:tests? #f
+       #:phases (modify-phases %standard-phases
+                  (add-before 'configure 'setenv
+                    (lambda* (#:key inputs native-inputs #:allow-other-keys)
+                      (let ((xgcc (assoc-ref inputs "xgcc")))
+                        (setenv "CPP" (string-append xgcc "/bin/"
+                                                     ,target "-cpp")))
+                      (for-each (lambda (var)
+                                  (and=> (getenv var)
+                                         (lambda (value)
+                                           (let ((cross
+                                                  (string-append "CROSS_" var)))
+                                             (setenv cross value))
+                                           (unsetenv var))))
+                                '("C_INCLUDE_PATH"
+                                  "CPLUS_INCLUDE_PATH"
+                                  "OBJC_INCLUDE_PATH"
+                                  "OBJCPLUS_INCLUDE_PATH"
+                                  "LIBRARY_PATH"))
+                      #t)))))))
+
 (define (native-libc target)
   (if (mingw-target? target)
       mingw-w64
-- 
2.7.3

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

* [PATCH 08/11] gnu: libtool: support cross-libtool mingw.
  2016-05-08 20:42 mingw guile.exe cross build patch series v8 Jan Nieuwenhuizen
                   ` (6 preceding siblings ...)
  2016-05-08 20:42 ` [PATCH 07/11] gnu: cross-base: Add cross-libtool Jan Nieuwenhuizen
@ 2016-05-08 20:42 ` Jan Nieuwenhuizen
  2016-05-09  7:39   ` Andy Wingo
  2016-05-08 20:42 ` [PATCH 09/11] gnu: ncurses: build mingw with libtool Jan Nieuwenhuizen
                   ` (2 subsequent siblings)
  10 siblings, 1 reply; 36+ messages in thread
From: Jan Nieuwenhuizen @ 2016-05-08 20:42 UTC (permalink / raw)
  To: guix-devel

* gnu/packages/patches/libtool-mingw.patch: New file.
* gnu/local.mk (dist_patch_DATA): Add it.
* gnu/packages/autotools.scm (libtool): Support cross-libtool for mingw.
---
 gnu/packages/autotools.scm               |  3 ++-
 gnu/packages/patches/libtool-mingw.patch | 40 ++++++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+), 1 deletion(-)
 create mode 100644 gnu/packages/patches/libtool-mingw.patch

diff --git a/gnu/packages/autotools.scm b/gnu/packages/autotools.scm
index ddc628d..30c0482 100644
--- a/gnu/packages/autotools.scm
+++ b/gnu/packages/autotools.scm
@@ -272,7 +272,8 @@ Makefile, simplifying the entire process for the developer.")
               (sha256
                (base32
                 "0vxj52zm709125gwv9qqlw02silj8bnjnh4y07arrz60r31ai1vw"))
-              (patches (search-patches "libtool-skip-tests2.patch"))))
+              (patches (search-patches "libtool-skip-tests2.patch"
+                                       "libtool-mingw.patch"))))
     (build-system gnu-build-system)
     (propagated-inputs `(("m4" ,m4)))
     (native-inputs `(("m4" ,m4)
diff --git a/gnu/packages/patches/libtool-mingw.patch b/gnu/packages/patches/libtool-mingw.patch
new file mode 100644
index 0000000..1246bd7
--- /dev/null
+++ b/gnu/packages/patches/libtool-mingw.patch
@@ -0,0 +1,40 @@
+I do not know why stat (and other functions here) get #define'd to their
+underscore variants; I find no apparent need or rationale for that.  However,
+redefining stat also impacts struct stat, breaking lstat's signature.  That is
+fixed be #define'ing lstat along.
+
+Jan Nieuwenhuizen
+
+Upstream status: not yet presented upstream.
+
+--- libtool-2.4.6/build-aux/ltmain.in~	2015-02-06 13:57:56.000000000 +0100
++++ libtool-2.4.6/build-aux/ltmain.in	2016-05-06 07:46:29.425142546 +0200
+@@ -3658,12 +3658,10 @@
+ #if defined _MSC_VER
+ # define setmode _setmode
+-# define stat    _stat
+ # define chmod   _chmod
+ # define getcwd  _getcwd
+ # define putenv  _putenv
+ # define S_IXUSR _S_IEXEC
+ #elif defined __MINGW32__
+ # define setmode _setmode
+-# define stat    _stat
+ # define chmod   _chmod
+ # define getcwd  _getcwd
+--- libtool-2.4.6/build-aux/ltmain.sh~	2015-02-15 17:15:12.000000000 +0100
++++ libtool-2.4.6/build-aux/ltmain.sh	2016-05-06 08:31:53.854857844 +0200
+@@ -5569,6 +5569,5 @@
+ /* portability defines, excluding path handling macros */
+ #if defined _MSC_VER
+ # define setmode _setmode
+-# define stat    _stat
+ # define chmod   _chmod
+ # define getcwd  _getcwd
+@@ -5576,6 +5577,5 @@
+ # define S_IXUSR _S_IEXEC
+ #elif defined __MINGW32__
+ # define setmode _setmode
+-# define stat    _stat
+ # define chmod   _chmod
+ # define getcwd  _getcwd
-- 
2.7.3

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

* [PATCH 09/11] gnu: ncurses: build mingw with libtool.
  2016-05-08 20:42 mingw guile.exe cross build patch series v8 Jan Nieuwenhuizen
                   ` (7 preceding siblings ...)
  2016-05-08 20:42 ` [PATCH 08/11] gnu: libtool: support cross-libtool mingw Jan Nieuwenhuizen
@ 2016-05-08 20:42 ` Jan Nieuwenhuizen
  2016-05-09  7:44   ` Andy Wingo
  2016-05-08 20:42 ` [PATCH 10/11] gnu: readline: support mingw Jan Nieuwenhuizen
  2016-05-08 20:42 ` [PATCH 11/11] gnu: guile-2.0: " Jan Nieuwenhuizen
  10 siblings, 1 reply; 36+ messages in thread
From: Jan Nieuwenhuizen @ 2016-05-08 20:42 UTC (permalink / raw)
  To: guix-devel

* gnu/packages/ncurses.scm (ncurses)[MINGW]: Build with libtool, as
recommended; enables dlopen'ing.
---
 gnu/packages/ncurses.scm | 32 ++++++++++++++++++++++++--------
 1 file changed, 24 insertions(+), 8 deletions(-)

diff --git a/gnu/packages/ncurses.scm b/gnu/packages/ncurses.scm
index 840dcf2..4c255c9 100644
--- a/gnu/packages/ncurses.scm
+++ b/gnu/packages/ncurses.scm
@@ -27,6 +27,11 @@
   #:use-module (guix utils)
   #:use-module (guix build-system gnu))
 
+(define* (cross-libtool #:optional (target (%current-target-system)))
+  (let* ((libtool (resolve-interface '(gnu packages cross-base)))
+         (cross-libtool (module-ref libtool 'cross-libtool)))
+    `(("xlibtool" ,(cross-libtool target)))))
+
 (define-public ncurses
   (let ((patch-makefile-phase
          '(lambda _
@@ -80,14 +85,13 @@
                    (lambda (lib)
                      (define lib.dll
                        (string-append "lib" lib ".dll"))
-                     (define libw6.dll
-                       (string-append "lib" lib "w6.dll"))
+                     (define libw-6.dll
+                       (string-append "lib" lib "w-6.dll"))
 
-                     (when (file-exists? libw6.dll)
+                     (when (file-exists? libw-6.dll)
                        (format #t "creating symlinks for `lib~a'~%" lib)
-                       (symlink libw6.dll lib.dll)))
+                       (symlink libw-6.dll lib.dll)))
                    libraries))
-                ;; TODO: create .la files to link to the .dll?
                 (with-directory-excursion (string-append out "/lib")
                   (for-each
                    (lambda (lib)
@@ -95,10 +99,17 @@
                        (string-append "lib" lib "w.a"))
                      (define lib.a
                        (string-append "lib" lib ".a"))
+                     (define libw.la
+                       (string-append "lib" lib "w.la"))
+                     (define lib.la
+                       (string-append "lib" lib ".la"))
 
                      (when (file-exists? libw.a)
                        (format #t "creating symlinks for `lib~a'~%" lib)
-                       (symlink libw.a lib.a)))
+                       (symlink libw.a lib.a))
+                     (when (file-exists? libw.la)
+                       (format #t "creating symlinks for `lib~a'~%" lib)
+                       (symlink libw.la lib.la)))
                    libraries)))
                (else
                 (with-directory-excursion (string-append out "/lib")
@@ -135,6 +146,10 @@
               (sha256
                (base32
                 "0q3jck7lna77z5r42f13c4xglc7azd19pxfrjrpgp2yf615w4lgm"))))
+     ;; add to gnu:standard-cross-packages?
+     (native-inputs `(,@(if (mingw-target?)
+                            `(,@(cross-libtool))
+                            '())))
      (build-system gnu-build-system)
      (outputs '("out"
                 "doc"))                          ;1 MiB of man pages
@@ -152,8 +167,9 @@
           ;; correct RUNPATH.
           ,(string-append "LDFLAGS=-Wl,-rpath=" (assoc-ref %outputs "out")
                           "/lib")
-          ;; MinGW: Provide termcap api, created for the MinGW port.
-          ,@(if ,(mingw-target?) '("--enable-term-driver") '()))
+          ;; MinGW: Provide termcap api, created for the MinGW port,
+          ;; use litbool to build .la files to dlopen.
+          ,@(if ,(mingw-target?) `("--enable-term-driver" "--with-libtool") '()))
         #:tests? #f                               ; no "check" target
         #:phases (modify-phases %standard-phases
                    (replace 'configure ,configure-phase)
-- 
2.7.3

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

* [PATCH 10/11] gnu: readline: support mingw.
  2016-05-08 20:42 mingw guile.exe cross build patch series v8 Jan Nieuwenhuizen
                   ` (8 preceding siblings ...)
  2016-05-08 20:42 ` [PATCH 09/11] gnu: ncurses: build mingw with libtool Jan Nieuwenhuizen
@ 2016-05-08 20:42 ` Jan Nieuwenhuizen
  2016-05-09  7:44   ` Andy Wingo
  2016-05-08 20:42 ` [PATCH 11/11] gnu: guile-2.0: " Jan Nieuwenhuizen
  10 siblings, 1 reply; 36+ messages in thread
From: Jan Nieuwenhuizen @ 2016-05-08 20:42 UTC (permalink / raw)
  To: guix-devel

* gnu/packages/patches/readline-6.3-mingw.patch: New file.
* gnu-system.am (dist_patch_DATA): Add it.
* gnu/packages/readline.scm (readline): Support mingw.
---
 gnu/packages/readline.scm | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/readline.scm b/gnu/packages/readline.scm
index db469db..aae20c4 100644
--- a/gnu/packages/readline.scm
+++ b/gnu/packages/readline.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2012, 2013, 2014 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -22,7 +23,8 @@
   #:use-module (gnu packages ncurses)
   #:use-module (guix packages)
   #:use-module (guix download)
-  #:use-module (guix build-system gnu))
+  #:use-module (guix build-system gnu)
+  #:use-module (guix utils))
 
 (define-public readline
   (let ((post-install-phase
@@ -59,8 +61,18 @@
                          ;; cross-compiling, so provide the correct answer.
                          ,@(if (%current-target-system)
                                '("bash_cv_wcwidth_broken=no")
+                               '())
+                         ;; MinGW: ncurses provides the termcap api.
+                         ,@(if (mingw-target?)
+                               '("bash_cv_termcap_lib=ncurses")
                                '()))
 
+                   #:make-flags (list ,@(if (mingw-target?)
+                                            ;; MinGW: termcap in ncurses
+                                            ;; some SIG_* #defined in _POSIX
+                                            '("TERMCAP_LIB=-lncurses"
+                                              "CPPFLAGS=-D_POSIX")
+                                            '()))
                    #:phases (alist-cons-after
                              'install 'post-install
                              ,post-install-phase
-- 
2.7.3

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

* [PATCH 11/11] gnu: guile-2.0: support mingw.
  2016-05-08 20:42 mingw guile.exe cross build patch series v8 Jan Nieuwenhuizen
                   ` (9 preceding siblings ...)
  2016-05-08 20:42 ` [PATCH 10/11] gnu: readline: support mingw Jan Nieuwenhuizen
@ 2016-05-08 20:42 ` Jan Nieuwenhuizen
  2016-05-09  7:48   ` Andy Wingo
  10 siblings, 1 reply; 36+ messages in thread
From: Jan Nieuwenhuizen @ 2016-05-08 20:42 UTC (permalink / raw)
  To: guix-devel

* gnu/packages/guile.scm (guile-2.0): Support mingw.
---
 gnu/packages/guile.scm | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/gnu/packages/guile.scm b/gnu/packages/guile.scm
index 53ea3e5..3fd9ded 100644
--- a/gnu/packages/guile.scm
+++ b/gnu/packages/guile.scm
@@ -135,11 +135,12 @@ without requiring the source code to be rewritten.")
               "1qh3j7308qvsjgwf7h94yqgckpbgz2k3yqdkzsyhqcafvfka9l5f"))
             (patches (search-patches "guile-arm-fixes.patch"))))
    (build-system gnu-build-system)
-   (native-inputs `(("pkgconfig" ,pkg-config)))
+   (native-inputs `(("pkgconfig" ,pkg-config)
+                    ,@(if (mingw-target?) `(("bash" ,bash)) '())))
    (inputs `(("libffi" ,libffi)
              ("readline" ,readline)
-             ("bash" ,bash)))
-
+             ,@(libiconv-if-needed)
+             ,@(if (mingw-target?) '() `(("bash" ,bash)))))
    (propagated-inputs
     `( ;; These ones aren't normally needed here, but since `libguile-2.0.la'
        ;; reads `-lltdl -lunistring', adding them here will add the needed
@@ -168,7 +169,9 @@ without requiring the source code to be rewritten.")
                   (let ((bash (assoc-ref inputs "bash")))
                     (substitute* "module/ice-9/popen.scm"
                       (("/bin/sh")
-                       (string-append bash "/bin/bash")))))
+                       (if bash
+                           (string-append bash "/bin/bash")
+                           "bash")))))
                 %standard-phases)))
 
    (native-search-paths
-- 
2.7.3

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

* Re: [PATCH 01/11] gnu: Add mingw-w64.
  2016-05-08 20:42 ` [PATCH 01/11] gnu: Add mingw-w64 Jan Nieuwenhuizen
@ 2016-05-09  7:07   ` Andy Wingo
  0 siblings, 0 replies; 36+ messages in thread
From: Andy Wingo @ 2016-05-09  7:07 UTC (permalink / raw)
  To: Jan Nieuwenhuizen; +Cc: guix-devel

On Sun 08 May 2016 22:42, Jan Nieuwenhuizen <janneke@gnu.org> writes:

> * gnu/packages/patches/gcc-4.9.3-mingw-gthr-default.patch,
> gnu/packages/patches/mingw-w64-5.0rc2-gcc-4.9.3.patch,
> gnu/packages/mingw.scm: New files.
> * gnu/local.mk (dist_patch_DATA): Add them.

lgtm

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

* Re: [PATCH 02/11] gnu: cross-build: i686-w64-mingw32: new cross target.
  2016-05-08 20:42 ` [PATCH 02/11] gnu: cross-build: i686-w64-mingw32: new cross target Jan Nieuwenhuizen
@ 2016-05-09  7:15   ` Andy Wingo
  2016-05-14 20:27     ` Jan Nieuwenhuizen
  0 siblings, 1 reply; 36+ messages in thread
From: Andy Wingo @ 2016-05-09  7:15 UTC (permalink / raw)
  To: Jan Nieuwenhuizen; +Cc: guix-devel

On Sun 08 May 2016 22:42, Jan Nieuwenhuizen <janneke@gnu.org> writes:

> * guix/utils.scm (mingw-target?): New function.
> * gnu/packages/cross-base.scm (cross-gcc-snippet): New function for mingw.
> (cross-gcc): Use it.
> (cross-gcc-arguments, cross-gcc-patches, cross-gcc): Support mingw.
> (native-libc, cross-newlib?): New functions.
> (cross-libc): Use cross-newlib? to support mingw.
> (xbinutils-i686-w64-mingw32, xgcc-sans-libc-i686-w64-mingw32,
> xgcc-i686-w64-mingw32): New variables.
> ---
>  gnu/packages/cross-base.scm | 271 +++++++++++++++++++++++++++++++-------------
>  guix/utils.scm              |   5 +
>  2 files changed, 200 insertions(+), 76 deletions(-)
>
> diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm
> @@ -163,7 +174,67 @@ may be either a libc package or #f.)"
>                      ;; for cross-compilers.
>                      (zero? (system* "make" "install-strip")))
>                    ,phases))))
> -          (if libc
> +           (cond
> +            ((mingw-target? target)
> +             `(modify-phases ,phases
> +                (add-before
> +                 'configure 'set-cross-path
> +                 (lambda* (#:key inputs #: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"))
> +                         (gcc (assoc-ref inputs "gcc")))
> +                     (define (cross? x)
> +                       (and libc (string-prefix? libc x)))
> +                     (if libc
> +                         (let ((cpath (string-append
> +                                       libc "/include"
> +                                       ":" libc "/i686-w64-mingw32/include")))
> +                           (for-each (cut setenv <> cpath)
> +                                     '("CROSS_C_INCLUDE_PATH"
> +                                       "CROSS_CPLUS_INCLUDE_PATH"
> +                                       "CROSS_OBJC_INCLUDE_PATH"
> +                                       "CROSS_OBJCPLUS_INCLUDE_PATH")))
> +                         (let ((mingw-source (assoc-ref inputs "mingw-source"))
> +                               (mingw-headers
> +                                (string-append (getcwd) "/mingw-w64-v5.0-rc2/mingw-w64-headers")))
> +                           (system* "tar" "xf" mingw-source)
> +                           (copy-file (string-append mingw-headers "/crt/_mingw.h.in")
> +                                      (string-append mingw-headers "/crt/_mingw.h"))
> +                           (substitute* (string-append mingw-headers "/crt/_mingw.h")
> +                             (("@MINGW_HAS_SECURE_API@") "#define MINGW_HAS_SECURE_API 1"))

What's this last bit about? You would think that GCC's configure was
meant to handle this.  It could be the right thing but a comment is
necessary.

>  (define* (cross-gcc target
> -                    #:optional (xbinutils (cross-binutils target)) libc)
> +                    #:optional (xbinutils (cross-binutils target)) (libc #f))

FWIW this change doesn't change anything -- if a default isn't given to
an optional or keyword argument, the default is #f.  It is equally good
both ways, so no feedback to you other than to make sure you know this
is the case :)

>    "Return a cross-compiler for TARGET, where TARGET is a GNU triplet.  Use
>  XBINUTILS as the associated cross-Binutils.  If LIBC is false, then build a
>  GCC that does not target a libc; otherwise, target that libc."
> @@ -223,7 +303,10 @@ GCC that does not target a libc; otherwise, target that libc."
>                 (append
>                  (origin-patches (package-source %xgcc))
>                  (cons (search-patch "gcc-cross-environment-variables.patch")
> -                      (cross-gcc-patches target))))))
> +                      (cross-gcc-patches target))))
> +              (modules '((guix build utils)))
> +              (snippet
> +               (cross-gcc-snippet target))))
>  
>      ;; For simplicity, use a single output.  Otherwise libgcc_s & co. are not
>      ;; found by default, etc.
> @@ -245,6 +328,7 @@ GCC that does not target a libc; otherwise, target that libc."
>                               #:target target
>                               #:binutils xbinutils))
>         ("binutils-cross" ,xbinutils)
> +       ("gcc" ,gcc)
>  
>         ;; Call it differently so that the builder can check whether the "libc"
>         ;; input is #f.
> @@ -253,13 +337,20 @@ GCC that does not target a libc; otherwise, target that libc."
>         ;; Remaining inputs.
>         ,@(let ((inputs (append (package-inputs %xgcc)
>                                 (alist-delete "libc" %final-inputs))))
> -           (if libc
> +           (cond
> +            ((mingw-target? target)
> +             (if libc
> +                 `(("libc" ,mingw-w64)
> +                   ,@inputs)
> +                 `(("mingw-source" ,(package-source mingw-w64))
> +                   ,@inputs)))
> +            (libc
>                 `(("libc" ,libc)

Please fix indentation here.

> @@ -289,70 +380,83 @@ 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"))
> -                   (cpath (string-append linux "/include")))
> -              (for-each (cut setenv <> cpath)
> -                        '("CROSS_C_INCLUDE_PATH"
> -                          "CROSS_CPLUS_INCLUDE_PATH"
> -                          "CROSS_OBJC_INCLUDE_PATH"
> -                          "CROSS_OBJCPLUS_INCLUDE_PATH"))
> -              #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
> +   ((cross-newlib? target)
> +    (cross-newlib? target))

Also (cond (x x)) is the same as (cond (x)).  But what's this about?  I
thought this procedure should return a package, not a boolean.


> +   (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"))
> +                       (cpath (string-append linux "/include")))
> +                  (for-each (cut setenv <> cpath)
> +                            '("CROSS_C_INCLUDE_PATH"
> +                              "CROSS_CPLUS_INCLUDE_PATH"
> +                              "CROSS_OBJC_INCLUDE_PATH"
> +                              "CROSS_OBJCPLUS_INCLUDE_PATH"))
> +                  #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))))))))
> +
> +(define (native-libc target)
> +  (if (mingw-target? target)
> +      mingw-w64
> +      glibc))
> +
> +(define (cross-newlib? target)
> +  (and (not (eq? (native-libc target) glibc))
> +       (native-libc target)))

Aaaah I was confused because cross-newlib? was written as if it returned
a boolean.  Please rename the function to, for example,
`maybe-cross-newlib' or something.  Other names welcome but please,
nothing ending in '?' :)

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

* Re: [PATCH 03/11] gnu: Add function libiconv-if-needed.
  2016-05-08 20:42 ` [PATCH 03/11] gnu: Add function libiconv-if-needed Jan Nieuwenhuizen
@ 2016-05-09  7:16   ` Andy Wingo
  2016-05-14 20:27     ` Jan Nieuwenhuizen
  0 siblings, 1 reply; 36+ messages in thread
From: Andy Wingo @ 2016-05-09  7:16 UTC (permalink / raw)
  To: Jan Nieuwenhuizen; +Cc: guix-devel

On Sun 08 May 2016 22:42, Jan Nieuwenhuizen <janneke@gnu.org> writes:

> * gnu/packages/base.scm (libiconv-if-needed): New function.
> ---
>  gnu/packages/base.scm | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/gnu/packages/base.scm b/gnu/packages/base.scm
> index beb689e..51d70b1 100644
> --- a/gnu/packages/base.scm
> +++ b/gnu/packages/base.scm
> @@ -44,7 +44,8 @@
>    #:use-module (guix download)
>    #:use-module (guix git-download)
>    #:use-module (guix build-system gnu)
> -  #:use-module (guix build-system trivial))
> +  #:use-module (guix build-system trivial)
> +  :export (libiconv-if-needed))
>  
>  ;;; Commentary:
>  ;;;
> @@ -964,6 +965,11 @@ program.  It supports a wide variety of different encodings.")
>      (home-page "http://www.gnu.org/software/libiconv/")
>      (license lgpl3+)))
>  
> +(define* (libiconv-if-needed #:optional (target (%current-target-system)))
> +  (if (mingw-target? target)
> +      `(("libiconv" ,libiconv))
> +      '()))
> +

Needs a docstring, please.  Thanks :)

>  (define-public (canonical-package package)
>    ;; Avoid circular dependency by lazily resolving 'commencement'.
>    (let* ((iface (resolve-interface '(gnu packages commencement)))

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

* Re: [PATCH 04/11] gnu: libunistring: support mingw: propagate libiconv if needed.
  2016-05-08 20:42 ` [PATCH 04/11] gnu: libunistring: support mingw: propagate libiconv if needed Jan Nieuwenhuizen
@ 2016-05-09  7:17   ` Andy Wingo
  0 siblings, 0 replies; 36+ messages in thread
From: Andy Wingo @ 2016-05-09  7:17 UTC (permalink / raw)
  To: Jan Nieuwenhuizen; +Cc: guix-devel

On Sun 08 May 2016 22:42, Jan Nieuwenhuizen <janneke@gnu.org> writes:

> * gnu/packages/libunistring (libunistring): propagated-inputs: add
> libiconv-if-needed.  Fixes unicode translation in mingw.

lgtm

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

* Re: [PATCH 05/11] gnu: gmp: build shared library for mingw.
  2016-05-08 20:42 ` [PATCH 05/11] gnu: gmp: build shared library for mingw Jan Nieuwenhuizen
@ 2016-05-09  7:20   ` Andy Wingo
  2016-05-14 20:27     ` Jan Nieuwenhuizen
  0 siblings, 1 reply; 36+ messages in thread
From: Andy Wingo @ 2016-05-09  7:20 UTC (permalink / raw)
  To: Jan Nieuwenhuizen; +Cc: guix-devel

On Sun 08 May 2016 22:42, Jan Nieuwenhuizen <janneke@gnu.org> writes:

> * gnu/packages/multiprecision.scm (gmp)[MINGW]: Use --enable-shared.
> ---
>  gnu/packages/multiprecision.scm | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/gnu/packages/multiprecision.scm b/gnu/packages/multiprecision.scm
> index 9924323..8c1a9b7 100644
> --- a/gnu/packages/multiprecision.scm
> +++ b/gnu/packages/multiprecision.scm
> @@ -3,6 +3,7 @@
>  ;;; Copyright © 2014 Mark H Weaver <mhw@netris.org>
>  ;;; Copyright © 2015 Andreas Enge <andreas@enge.fr>
>  ;;; Copyright © 2016 Nicolas Goaziou <mail@nicolasgoaziou.fr>
> +;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
>  ;;;
>  ;;; This file is part of GNU Guix.
>  ;;;
> @@ -49,7 +50,13 @@
>                  '(;; Build a "fat binary", with routines for several
>                    ;; sub-architectures.
>                    "--enable-fat"
> -                  "--enable-cxx")))
> +                  "--enable-cxx"
> +                  ,@(cond ((mingw-target?)
> +                           ;; Static and shared cannot be built in one go:
> +                           ;; they produce different headers.  We need shared.
> +                           `("--disable-static"
> +                             "--enable-shared"))
> +                          (else '())))))
>     (synopsis "Multiple-precision arithmetic library")
>     (description
>      "GMP is a library for arbitrary precision arithmetic, operating on

LGTM.  A bit of a shame that mingw is an abnormal architecture in this
way -- i.e. other targets will have both static and shared libraries,
but not this one.  Oh well, this does look to be the right thing for
now.

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

* Re: [PATCH 06/11] gnu: ncurses: support mingw.
  2016-05-08 20:42 ` [PATCH 06/11] gnu: ncurses: support mingw Jan Nieuwenhuizen
@ 2016-05-09  7:23   ` Andy Wingo
  0 siblings, 0 replies; 36+ messages in thread
From: Andy Wingo @ 2016-05-09  7:23 UTC (permalink / raw)
  To: Jan Nieuwenhuizen; +Cc: guix-devel

On Sun 08 May 2016 22:42, Jan Nieuwenhuizen <janneke@gnu.org> writes:

> * gnu/packages/patches/ncurses-mingw.patch: New file.
> * gnu-system.am (dist_patch_DATA): Add it.
> * gnu/packages/ncurses.scm (ncurses): Support mingw.

lgtm

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

* Re: [PATCH 07/11] gnu: cross-base: Add cross-libtool.
  2016-05-08 20:42 ` [PATCH 07/11] gnu: cross-base: Add cross-libtool Jan Nieuwenhuizen
@ 2016-05-09  7:29   ` Andy Wingo
  2016-05-14 20:26     ` Jan Nieuwenhuizen
  0 siblings, 1 reply; 36+ messages in thread
From: Andy Wingo @ 2016-05-09  7:29 UTC (permalink / raw)
  To: Jan Nieuwenhuizen; +Cc: guix-devel

On Sun 08 May 2016 22:42, Jan Nieuwenhuizen <janneke@gnu.org> writes:

> * gnu/packages/cross-base.scm (cross-libtool): New function.
> ---
>  gnu/packages/cross-base.scm | 46 +++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 46 insertions(+)
>
> diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm
> index a7227d0..011f58d 100644
> --- a/gnu/packages/cross-base.scm
> +++ b/gnu/packages/cross-base.scm
> @@ -22,6 +22,7 @@
>    #:use-module ((guix licenses) #:prefix license:)
>    #:use-module (gnu packages)
>    #:use-module (gnu packages base)
> +  #:use-module (gnu packages autotools)
>    #:use-module (gnu packages bash)
>    #:use-module (gnu packages gawk)
>    #:use-module (gnu packages gcc)
> @@ -40,6 +41,7 @@
>    #:use-module (ice-9 match)
>    #:export (cross-binutils
>              cross-libc
> +            cross-libtool
>              cross-gcc
>              cross-newlib?))
>  
> @@ -449,6 +451,50 @@ XBINUTILS and the cross tool chain."
>                           ,@(package-inputs glibc)     ;FIXME: static-bash
>                           ,@(package-native-inputs glibc))))))))
>  
> +(define* (cross-libtool target
> +                        #:optional
> +                        (xgcc (cross-gcc target
> +                                         (cross-binutils target)
> +                                         (cross-libc target)))
> +                        (xbinutils (cross-binutils target))
> +                        (xlibc (cross-libc target)))
> +  (package
> +    (inherit libtool)
> +    (name (string-append "cross-libtool-" target))
> +    (inputs `(("xlibc" ,xlibc)))
> +    (native-inputs `(,@`(("xgcc" ,xgcc)
> +                         ("xbinutils" ,xbinutils)
> +                         ("xlibc" ,xlibc))
> +                     ,@(package-native-inputs libtool)))
> +    (arguments
> +     `(;; Libltdl is provided as a separate package, so don't install it here.
> +       #:configure-flags
> +       `("--disable-ltdl-install"
> +         ,(string-append "--host=" ,target)
> +         ,(string-append "--target=" ,target)
> +         ,(string-append "--program-prefix=" ,target "-")
> +         ,(string-append "CC=" ,target "-gcc"))

Is this the right --host setting?

> +       #:tests? #f
> +       #:phases (modify-phases %standard-phases
> +                  (add-before 'configure 'setenv
> +                    (lambda* (#:key inputs native-inputs #:allow-other-keys)
> +                      (let ((xgcc (assoc-ref inputs "xgcc")))
> +                        (setenv "CPP" (string-append xgcc "/bin/"
> +                                                     ,target "-cpp")))
> +                      (for-each (lambda (var)
> +                                  (and=> (getenv var)
> +                                         (lambda (value)
> +                                           (let ((cross
> +                                                  (string-append "CROSS_" var)))
> +                                             (setenv cross value))
> +                                           (unsetenv var))))
> +                                '("C_INCLUDE_PATH"
> +                                  "CPLUS_INCLUDE_PATH"
> +                                  "OBJC_INCLUDE_PATH"
> +                                  "OBJCPLUS_INCLUDE_PATH"
> +                                  "LIBRARY_PATH"))
> +                      #t)))))))

Ignorant question: Why do we have to do this here?  Is libtool a special
case?  We should certainly limit the number of places in Guix's code
where we have to do (for-each ... '("C_INCLUDE_PATH" ...)).

Andy

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

* Re: [PATCH 08/11] gnu: libtool: support cross-libtool mingw.
  2016-05-08 20:42 ` [PATCH 08/11] gnu: libtool: support cross-libtool mingw Jan Nieuwenhuizen
@ 2016-05-09  7:39   ` Andy Wingo
  2016-05-14 20:27     ` Jan Nieuwenhuizen
  0 siblings, 1 reply; 36+ messages in thread
From: Andy Wingo @ 2016-05-09  7:39 UTC (permalink / raw)
  To: Jan Nieuwenhuizen; +Cc: guix-devel

On Sun 08 May 2016 22:42, Jan Nieuwenhuizen <janneke@gnu.org> writes:

> diff --git a/gnu/packages/patches/libtool-mingw.patch b/gnu/packages/patches/libtool-mingw.patch
> new file mode 100644
> index 0000000..1246bd7
> --- /dev/null
> +++ b/gnu/packages/patches/libtool-mingw.patch
> @@ -0,0 +1,40 @@
> +I do not know why stat (and other functions here) get #define'd to their
> +underscore variants; I find no apparent need or rationale for that.  However,
> +redefining stat also impacts struct stat, breaking lstat's signature.  That is
> +fixed be #define'ing lstat along.
> +
> +Jan Nieuwenhuizen
> +
> +Upstream status: not yet presented upstream.
> +
> +--- libtool-2.4.6/build-aux/ltmain.in~	2015-02-06 13:57:56.000000000 +0100
> ++++ libtool-2.4.6/build-aux/ltmain.in	2016-05-06 07:46:29.425142546 +0200
> +@@ -3658,12 +3658,10 @@
> + #if defined _MSC_VER
> + # define setmode _setmode
> +-# define stat    _stat
> + # define chmod   _chmod
> + # define getcwd  _getcwd
> + # define putenv  _putenv
> + # define S_IXUSR _S_IEXEC
> + #elif defined __MINGW32__
> + # define setmode _setmode
> +-# define stat    _stat
> + # define chmod   _chmod
> + # define getcwd  _getcwd

This doesn't look right to me.  Stat was actually the first of this set
to be added to the weird define list, via:

    commit 781fc82e1b2bceaa5c55388d6ab1d1744663f992
    Author: Peter Rosin <peda@lysator.liu.se>
    Date:   Sun Jul 22 17:57:10 2007 +0000

        * libltdl/config/ltmain.m4sh (func_emit_cwrapperexe_src): Add
        support for Microsoft Visual C. Also, older MinGW versions
        seem to need stdint.h to find intptr_t.

And there does appear to exist "struct _stat" in the API
(https://msdn.microsoft.com/en-us/library/14h5k7ff.aspx).  Does it mean
that "lstat" is coming from somewhere else (i.e. not the system libc),
expecting to have a "struct stat" as an argument?  I don't know very
much about this stuff but this change looks fishy to me.

Andy

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

* Re: [PATCH 09/11] gnu: ncurses: build mingw with libtool.
  2016-05-08 20:42 ` [PATCH 09/11] gnu: ncurses: build mingw with libtool Jan Nieuwenhuizen
@ 2016-05-09  7:44   ` Andy Wingo
  0 siblings, 0 replies; 36+ messages in thread
From: Andy Wingo @ 2016-05-09  7:44 UTC (permalink / raw)
  To: Jan Nieuwenhuizen; +Cc: guix-devel

On Sun 08 May 2016 22:42, Jan Nieuwenhuizen <janneke@gnu.org> writes:

> * gnu/packages/ncurses.scm (ncurses)[MINGW]: Build with libtool, as
> recommended; enables dlopen'ing.

I think Ludovic should review this short one, as he has more of the
bigger picture in his head and the question about
`standard-cross-packages' is a good one.

Andy

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

* Re: [PATCH 10/11] gnu: readline: support mingw.
  2016-05-08 20:42 ` [PATCH 10/11] gnu: readline: support mingw Jan Nieuwenhuizen
@ 2016-05-09  7:44   ` Andy Wingo
  0 siblings, 0 replies; 36+ messages in thread
From: Andy Wingo @ 2016-05-09  7:44 UTC (permalink / raw)
  To: Jan Nieuwenhuizen; +Cc: guix-devel

On Sun 08 May 2016 22:42, Jan Nieuwenhuizen <janneke@gnu.org> writes:

> * gnu/packages/patches/readline-6.3-mingw.patch: New file.
> * gnu-system.am (dist_patch_DATA): Add it.
> * gnu/packages/readline.scm (readline): Support mingw.

LGTM

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

* Re: [PATCH 11/11] gnu: guile-2.0: support mingw.
  2016-05-08 20:42 ` [PATCH 11/11] gnu: guile-2.0: " Jan Nieuwenhuizen
@ 2016-05-09  7:48   ` Andy Wingo
  2016-05-14 20:31     ` Jan Nieuwenhuizen
  0 siblings, 1 reply; 36+ messages in thread
From: Andy Wingo @ 2016-05-09  7:48 UTC (permalink / raw)
  To: Jan Nieuwenhuizen; +Cc: guix-devel

On Sun 08 May 2016 22:42, Jan Nieuwenhuizen <janneke@gnu.org> writes:

> * gnu/packages/guile.scm (guile-2.0): Support mingw.
> ---
>  gnu/packages/guile.scm | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/gnu/packages/guile.scm b/gnu/packages/guile.scm
> index 53ea3e5..3fd9ded 100644
> --- a/gnu/packages/guile.scm
> +++ b/gnu/packages/guile.scm
> @@ -135,11 +135,12 @@ without requiring the source code to be rewritten.")
>                "1qh3j7308qvsjgwf7h94yqgckpbgz2k3yqdkzsyhqcafvfka9l5f"))
>              (patches (search-patches "guile-arm-fixes.patch"))))
>     (build-system gnu-build-system)
> -   (native-inputs `(("pkgconfig" ,pkg-config)))
> +   (native-inputs `(("pkgconfig" ,pkg-config)
> +                    ,@(if (mingw-target?) `(("bash" ,bash)) '())))

AFAIU we can remove the "bash" thing here, as we decided to punt on
(ice-9 popen); sound right to you?

> @@ -168,7 +169,9 @@ without requiring the source code to be rewritten.")
>                    (let ((bash (assoc-ref inputs "bash")))
>                      (substitute* "module/ice-9/popen.scm"
>                        (("/bin/sh")
> -                       (string-append bash "/bin/bash")))))
> +                       (if bash
> +                           (string-append bash "/bin/bash")
> +                           "bash")))))

Needs a comment here explaining that although we should always have bash
as an input, it isn't packaged yet on mingw so we are falling back to
finding it in the run-time path if needed.

FWIW although Windows doesn't support `fork', `open-process' should work
in Windows, and we should therefore be able to get (ice-9 popen) working
in Windows eventually.

Andy

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

* Re: [PATCH 07/11] gnu: cross-base: Add cross-libtool.
  2016-05-09  7:29   ` Andy Wingo
@ 2016-05-14 20:26     ` Jan Nieuwenhuizen
  2016-05-17  7:21       ` Andy Wingo
  0 siblings, 1 reply; 36+ messages in thread
From: Jan Nieuwenhuizen @ 2016-05-14 20:26 UTC (permalink / raw)
  To: Andy Wingo; +Cc: guix-devel

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

Andy Wingo writes:

>> +    (arguments
>> +     `(;; Libltdl is provided as a separate package, so don't install it here.
>> +       #:configure-flags
>> +       `("--disable-ltdl-install"
>> +         ,(string-append "--host=" ,target)
>> +         ,(string-append "--target=" ,target)
>> +         ,(string-append "--program-prefix=" ,target "-")
>> +         ,(string-append "CC=" ,target "-gcc"))
>
> Is this the right --host setting?

I think so.  The libtool script uses $host rather than $target in tests
like these

	if test X-lc = "X$arg" || test X-lm = "X$arg"; then
	  case $host in
	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
	    # These systems don't actually have a C or math library (as such)
	    continue
	    ;;

I have added this comment

         ;; The libtool script uses `host' rather than `target' to decide
         ;; whether to use -lc, for example.
         ,(string-append "--host=" ,target)

>> +                      (for-each (lambda (var)
>> +                                  (and=> (getenv var)
>> +                                         (lambda (value)
>> +                                           (let ((cross
>> + (string-append "CROSS_" var)))
>> +                                             (setenv cross value))
>> +                                           (unsetenv var))))
>> +                                '("C_INCLUDE_PATH"
>> +                                  "CPLUS_INCLUDE_PATH"
>> +                                  "OBJC_INCLUDE_PATH"
>> +                                  "OBJCPLUS_INCLUDE_PATH"
>> +                                  "LIBRARY_PATH"))
>> +                      #t)))))))
>
> Ignorant question: Why do we have to do this here?  Is libtool a special
> case?  We should certainly limit the number of places in Guix's code
> where we have to do (for-each ... '("C_INCLUDE_PATH" ...)).

libtool is `special' when it is built as a cross package, like we do
here in cross-libtool.

I have added this comment

                  ;; As we are setup as a cross package, PATHs get setup
                  ;; without the CROSS_ prefix.  Change that here.
                  (add-before 'configure 'setenv

Thanks!
Greetings,
Jan


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0007-gnu-cross-base-Add-cross-libtool.patch --]
[-- Type: text/x-diff, Size: 3892 bytes --]

From 78efd3acd57df52ec635de5d306a5d3865b473b6 Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen <janneke@gnu.org>
Date: Wed, 27 Apr 2016 10:33:52 +0200
Subject: [PATCH 07/11] gnu: cross-base: Add cross-libtool.

* gnu/packages/cross-base.scm (cross-libtool): New function.
---
 gnu/packages/cross-base.scm | 52 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)

diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm
index 6efd748..18329df 100644
--- a/gnu/packages/cross-base.scm
+++ b/gnu/packages/cross-base.scm
@@ -22,6 +22,7 @@
   #:use-module ((guix licenses) #:prefix license:)
   #:use-module (gnu packages)
   #:use-module (gnu packages base)
+  #:use-module (gnu packages autotools)
   #:use-module (gnu packages bash)
   #:use-module (gnu packages gawk)
   #:use-module (gnu packages gcc)
@@ -40,6 +41,7 @@
   #:use-module (ice-9 match)
   #:export (cross-binutils
             cross-libc
+            cross-libtool
             cross-gcc
             cross-newlib?))
 
@@ -460,6 +462,56 @@ XBINUTILS and the cross tool chain."
                          ,@(package-inputs glibc)     ;FIXME: static-bash
                          ,@(package-native-inputs glibc))))))))
 
+(define* (cross-libtool target
+                        #:optional
+                        (xgcc (cross-gcc target
+                                         (cross-binutils target)
+                                         (cross-libc target)))
+                        (xbinutils (cross-binutils target))
+                        (xlibc (cross-libc target)))
+  (package
+    (inherit libtool)
+    (name (string-append "cross-libtool-" target))
+    (inputs `(("xlibc" ,xlibc)))
+    (native-inputs `(,@`(("xgcc" ,xgcc)
+                         ("xbinutils" ,xbinutils)
+                         ("xlibc" ,xlibc))
+                     ,@(package-native-inputs libtool)))
+    (arguments
+     `(;; Libltdl is provided as a separate package, so don't install it here.
+       #:configure-flags
+       `("--disable-ltdl-install"
+         ;; The libtool script uses `host' rather than `target' to decide
+         ;; whether to use -lc, for example.
+         ,(string-append "--host=" ,target)
+         ,(string-append "--target=" ,target)
+         ,(string-append "--program-prefix=" ,target "-")
+         ,(string-append "CC=" ,target "-gcc"))
+       #:tests? #f
+       #:phases (modify-phases %standard-phases
+                  ;; As we are setup as a cross package, PATHs get setup
+                  ;; without the CROSS_ prefix.  Change that here.
+                  (add-before 'configure 'setenv
+                    (lambda* (#:key inputs native-inputs #:allow-other-keys)
+                      (let ((xgcc (assoc-ref inputs "xgcc")))
+                        (setenv "CPP" (string-append xgcc "/bin/"
+                                                     ,target "-cpp"))
+                        (setenv "CXXCPP" (string-append xgcc "/bin/"
+                                                        ,target "-cpp")))
+                      (for-each (lambda (var)
+                                  (and=> (getenv var)
+                                         (lambda (value)
+                                           (let ((cross
+                                                  (string-append "CROSS_" var)))
+                                             (setenv cross value))
+                                           (unsetenv var))))
+                                '("C_INCLUDE_PATH"
+                                  "CPLUS_INCLUDE_PATH"
+                                  "OBJC_INCLUDE_PATH"
+                                  "OBJCPLUS_INCLUDE_PATH"
+                                  "LIBRARY_PATH"))
+                      #t)))))))
+
 (define (native-libc target)
   (if (mingw-target? target)
       mingw-w64
-- 
2.7.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] 36+ messages in thread

* Re: [PATCH 08/11] gnu: libtool: support cross-libtool mingw.
  2016-05-09  7:39   ` Andy Wingo
@ 2016-05-14 20:27     ` Jan Nieuwenhuizen
  0 siblings, 0 replies; 36+ messages in thread
From: Jan Nieuwenhuizen @ 2016-05-14 20:27 UTC (permalink / raw)
  To: Andy Wingo; +Cc: guix-devel

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

Andy Wingo writes:

>> +Upstream status: not yet presented upstream.
>> +
>> +--- libtool-2.4.6/build-aux/ltmain.in~ 2015-02-06
>> 13:57:56.000000000 +0100
>> ++++ libtool-2.4.6/build-aux/ltmain.in 2016-05-06 07:46:29.425142546
>> +0200
>> +@@ -3658,12 +3658,10 @@
>> + #if defined _MSC_VER
>> + # define setmode _setmode
>> +-# define stat    _stat
>> + # define chmod   _chmod
>> + # define getcwd  _getcwd
>> + # define putenv  _putenv
>> + # define S_IXUSR _S_IEXEC
>> + #elif defined __MINGW32__
>> + # define setmode _setmode
>> +-# define stat    _stat
>> + # define chmod   _chmod
>> + # define getcwd  _getcwd
>
> This doesn't look right to me.  Stat was actually the first of this set
> to be added to the weird define list, via:

Ah, two problems here.  I did not want to patch the _MSC_VER bit and
wanted to /add/ lstat rather than remove stat.  (I have tested quite
some variants until before everything worked; the comment actually
advertises this

    redefining stat also impacts struct stat, breaking lstat's signature.  That is
    fixed be #define'ing lstat along.)

I now have

    @@ -3658,6 +3658,7 @@
     # define S_IXUSR _S_IEXEC
     #elif defined __MINGW32__
     # define setmode _setmode
    +# define lstat   _lstat
     # define stat    _stat
     # define chmod   _chmod
     # define getcwd  _getcwd

(changed both instances of this)

>     commit 781fc82e1b2bceaa5c55388d6ab1d1744663f992
>     Author: Peter Rosin <peda@lysator.liu.se>
>     Date:   Sun Jul 22 17:57:10 2007 +0000
>
>         * libltdl/config/ltmain.m4sh (func_emit_cwrapperexe_src): Add
>         support for Microsoft Visual C. Also, older MinGW versions
>         seem to need stdint.h to find intptr_t.

Wow, you looked it up for me.  Hmm.

> And there does appear to exist "struct _stat" in the API
> (https://msdn.microsoft.com/en-us/library/14h5k7ff.aspx).

Yes, there is _stat, and that's the problem because functions _stat
_lstat use struct _stat, while all other functions use struct stat.

> Does it mean that "lstat" is coming from somewhere else (i.e. not the
> system libc), expecting to have a "struct stat" as an argument?  I
> don't know very much about this stuff but this change looks fishy to
> me.

I have added lstat as a patch to mingw-w64.

We were discussing the readline patch I used that just #ifdef'd-out
apparently missing symbols such as SIGHUP..SIGALRM, S_ISGUID...and
S_SFLNK.  I started looking into porting Bash and found it uses such
symbols that are missing in MinGW without #ifdef guards in many places.

I decided it would make sense to try adding these symbols mingw's
signal.h and sys/stat.h, instead of patching all patches that use them.
On strange thing here is that I found some signals are include in MinGW
but only behind an #ifdef _POSIX flag.  That puzzles me, aren't we
creating (limited) POSIX compatibility here, why limit it further using
a flag...?

Anyway, adding these symbols and using -D_POSIX works nicely for
readline, no patch needed anymore and it helps a lot with bash.

Then, I tried to build ncurses with the cross-libtool.  I found that
when libtool finds S_ISLNK is defined, it decides to use lstat.  So
instead of patching libtool, I went back to mingw-w64 and added lstat
variants alongside stat

    +#define _lstat32 _lstat
     #define _stat32 _stat

    +#define _lstat _lstat64i32
     #define _stat _stat64i32

     int __cdecl stat(const char *_Filename,struct stat *_Stat);
    +static inline int __cdecl lstat(const char *_Filename,struct stat *_Stat){return stat(_Filename, _Stat);}

       _CRTIMP int __cdecl _stat32(const char *_Name,struct _stat32 *_Stat);
    +  static inline int __cdecl _lstat32(const char *_Name,struct _stat32 *_Stat) {return _stat32(_Name, _Stat);}

That also helps with other packages that use lstat without testing (eg,
flex) and seems to be the right thing?

However, now libtool's redefinition of stat without redefining lstat

    # define stat    _stat

breaks lstat here

    +static inline int __cdecl lstat(const char *_Filename,struct stat *_Stat){return stat(_Filename, _Stat);}

Does that make sense?

Greetings,
Jan


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0008-gnu-libtool-support-cross-libtool-mingw.patch --]
[-- Type: text/x-diff, Size: 2515 bytes --]

From 7955f98d8c7608c5b46935577594bcc62c72afa0 Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen <janneke@gnu.org>
Date: Wed, 4 May 2016 20:35:34 +0200
Subject: [PATCH 08/11] gnu: libtool: support cross-libtool mingw.

* gnu/packages/patches/libtool-mingw.patch: New file.
* gnu/local.mk (dist_patch_DATA): Add it.
* gnu/packages/autotools.scm (libtool): Support cross-libtool for mingw.
---
 gnu/packages/autotools.scm               |  3 ++-
 gnu/packages/patches/libtool-mingw.patch | 28 ++++++++++++++++++++++++++++
 2 files changed, 30 insertions(+), 1 deletion(-)
 create mode 100644 gnu/packages/patches/libtool-mingw.patch

diff --git a/gnu/packages/autotools.scm b/gnu/packages/autotools.scm
index ddc628d..30c0482 100644
--- a/gnu/packages/autotools.scm
+++ b/gnu/packages/autotools.scm
@@ -272,7 +272,8 @@ Makefile, simplifying the entire process for the developer.")
               (sha256
                (base32
                 "0vxj52zm709125gwv9qqlw02silj8bnjnh4y07arrz60r31ai1vw"))
-              (patches (search-patches "libtool-skip-tests2.patch"))))
+              (patches (search-patches "libtool-skip-tests2.patch"
+                                       "libtool-mingw.patch"))))
     (build-system gnu-build-system)
     (propagated-inputs `(("m4" ,m4)))
     (native-inputs `(("m4" ,m4)
diff --git a/gnu/packages/patches/libtool-mingw.patch b/gnu/packages/patches/libtool-mingw.patch
new file mode 100644
index 0000000..d406f63
--- /dev/null
+++ b/gnu/packages/patches/libtool-mingw.patch
@@ -0,0 +1,28 @@
+With lstat and _lstat are added to MinGW we need to #define lstat along with
+stat because #define'ing stat impacts struct stat, which would otherwise break
+lstat's signature.
+
+Jan Nieuwenhuizen
+
+Upstream status: not yet presented upstream.
+
+--- libtool-2.4.6/build-aux/ltmain.in~	2015-02-06 13:57:56.000000000 +0100
++++ libtool-2.4.6/build-aux/ltmain.in	2016-05-06 07:46:29.425142546 +0200
+@@ -3658,6 +3658,7 @@
+ # define S_IXUSR _S_IEXEC
+ #elif defined __MINGW32__
+ # define setmode _setmode
++# define lstat   _lstat
+ # define stat    _stat
+ # define chmod   _chmod
+ # define getcwd  _getcwd
+--- libtool-2.4.6/build-aux/ltmain.sh~	2015-02-15 17:15:12.000000000 +0100
++++ libtool-2.4.6/build-aux/ltmain.sh	2016-05-06 08:31:53.854857844 +0200
+@@ -5576,6 +5577,7 @@
+ # define S_IXUSR _S_IEXEC
+ #elif defined __MINGW32__
+ # define setmode _setmode
++# define lstat   _lstat
+ # define stat    _stat
+ # define chmod   _chmod
+ # define getcwd  _getcwd
-- 
2.7.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] 36+ messages in thread

* Re: [PATCH 02/11] gnu: cross-build: i686-w64-mingw32: new cross target.
  2016-05-09  7:15   ` Andy Wingo
@ 2016-05-14 20:27     ` Jan Nieuwenhuizen
  2016-05-17  7:43       ` Andy Wingo
  0 siblings, 1 reply; 36+ messages in thread
From: Jan Nieuwenhuizen @ 2016-05-14 20:27 UTC (permalink / raw)
  To: Andy Wingo; +Cc: guix-devel

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

Andy Wingo writes:

>> +                           (system* "tar" "xf" mingw-source)
>> +                           (copy-file (string-append mingw-headers "/crt/_mingw.h.in")
>> +                                      (string-append mingw-headers "/crt/_mingw.h"))
>> +                           (substitute* (string-append mingw-headers "/crt/_mingw.h")
>> +                             (("@MINGW_HAS_SECURE_API@") "#define MINGW_HAS_SECURE_API 1"))
>
> What's this last bit about? You would think that GCC's configure was
> meant to handle this.  It could be the right thing but a comment is
> necessary.

I have added these comments

         ;; libc is false, so we are building xgcc-sans-libc
         ;; Add essential headers from mingw-w64.
         (let ((mingw-source (assoc-ref inputs "mingw-source"))
               (mingw-headers
                (string-append (getcwd) "/mingw-w64-v5.0-rc2/mingw-w64-headers")))
           (system* "tar" "xf" mingw-source)
           ;; We need _mingw.h which will gets built from
           ;; _mingw.h.in by mingw-w64's configure.  We cannot
           ;; configure mingw-w64 until we have
           ;; xgcc-sans-libc; substitute to the rescue.
           (copy-file (string-append mingw-headers "/crt/_mingw.h.in")
                      (string-append mingw-headers "/crt/_mingw.h"))
           (substitute* (string-append mingw-headers "/crt/_mingw.h")
             (("@MINGW_HAS_SECURE_API@") "#define MINGW_HAS_SECURE_API 1"))


>>  (define* (cross-gcc target
>> -                    #:optional (xbinutils (cross-binutils target)) libc)
>> +                    #:optional (xbinutils (cross-binutils target)) (libc #f))
>
> FWIW this change doesn't change anything -- if a default isn't given to
> an optional or keyword argument, the default is #f.  It is equally good
> both ways, so no feedback to you other than to make sure you know this
> is the case :)

Thanks!  Removed, masking hide my previous ignorance about this :)

>> -           (if libc
>> +           (cond
>> +            ((mingw-target? target)
>> +             (if libc
>> +                 `(("libc" ,mingw-w64)
>> +                   ,@inputs)
>> +                 `(("mingw-source" ,(package-source mingw-w64))
>> +                   ,@inputs)))
>> +            (libc
>>                 `(("libc" ,libc)
>
> Please fix indentation here.

Ok.  In my own code base I always just do indent-region on the whole
file, but that makes for lots of changes in Guix...

>> +  (cond
>> +   ((cross-newlib? target)
>> +    (cross-newlib? target))
>
> Also (cond (x x)) is the same as (cond (x)).

Ah, nice.  Changed now to (as a response to your remarks below)

    (cond
     ((cross-newlib? target)
      (native-libc target))

> But what's this about?  I thought this procedure should return a
> package, not a boolean.

...
>> +(define (native-libc target)
>> +  (if (mingw-target? target)
>> +      mingw-w64
>> +      glibc))
>> +
>> +(define (cross-newlib? target)
>> +  (and (not (eq? (native-libc target) glibc))
>> +       (native-libc target)))
>
> Aaaah I was confused because cross-newlib? was written as if it returned
> a boolean.  Please rename the function to, for example,
> `maybe-cross-newlib' or something.  Other names welcome but please,
> nothing ending in '?' :)

...Ah, okay... Changed to

    (define (native-libc target)
      (if (mingw-target? target)
          mingw-w64
          glibc))

    (define (cross-newlib? target)
      (not (eq? (native-libc target) glibc)))

I have adopted the meme in my own code to have any function? always
return the thing itself; that's also always true (as long as you don't
do things like (eq? (function?) #t).  That allows code like

   (or (foo?) bar)

Something I wanted to ask and I guess now why don't we let functions
like pair?, null?, string-prefix? not return the thing itself?

I guess doing that for new code is frowned up because it breaks the
principle of least surprise.

Thanks!
Greetings, Jan


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

From c587c6d9c635380cc8053e5293de091ada787607 Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen <janneke@gnu.org>
Date: Tue, 3 May 2016 20:08:40 +0200
Subject: [PATCH 02/11] gnu: cross-build: i686-w64-mingw32: new cross target.

* guix/utils.scm (mingw-target?): New function.
* gnu/packages/cross-base.scm (cross-gcc-snippet): New function for mingw.
(cross-gcc): Use it.
(cross-gcc-arguments, cross-gcc-patches, cross-gcc): Support mingw.
(native-libc, cross-newlib?): New functions.
(cross-libc): Use cross-newlib? to support mingw.
(xbinutils-i686-w64-mingw32, xgcc-sans-libc-i686-w64-mingw32,
xgcc-i686-w64-mingw32): New variables.
---
 gnu/packages/cross-base.scm | 292 +++++++++++++++++++++++++++++++-------------
 guix/utils.scm              |   5 +
 2 files changed, 213 insertions(+), 84 deletions(-)

diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm
index 7ed4ae4..6efd748 100644
--- a/gnu/packages/cross-base.scm
+++ b/gnu/packages/cross-base.scm
@@ -19,12 +19,17 @@
 ;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
 
 (define-module (gnu packages cross-base)
-  #:use-module (guix licenses)
+  #:use-module ((guix licenses) #:prefix license:)
   #:use-module (gnu packages)
-  #:use-module (gnu packages gcc)
   #:use-module (gnu packages base)
+  #:use-module (gnu packages bash)
+  #:use-module (gnu packages gawk)
+  #:use-module (gnu packages gcc)
   #:use-module (gnu packages commencement)
+  #:use-module (gnu packages compression)
   #:use-module (gnu packages linux)
+  #:use-module (gnu packages mingw)
+  #:use-module (gnu packages multiprecision)
   #:use-module (guix packages)
   #:use-module (guix download)
   #:use-module (guix utils)
@@ -35,7 +40,8 @@
   #:use-module (ice-9 match)
   #:export (cross-binutils
             cross-libc
-            cross-gcc))
+            cross-gcc
+            cross-newlib?))
 
 (define %xgcc
   ;; GCC package used as the basis for cross-compilation.  It doesn't have to
@@ -121,7 +127,12 @@ may be either a libc package or #f.)"
                                "--disable-libquadmath"
                                "--disable-decimal-float" ;would need libc
                                "--disable-libcilkrts"
-                               )))
+                                ))
+
+                       ;; For a newlib (non-glibc) target
+                       ,@(if (cross-newlib? target)
+                             '("--with-newlib")
+                             '()))
 
                  ,(if libc
                       flags
@@ -163,7 +174,73 @@ may be either a libc package or #f.)"
                     ;; for cross-compilers.
                     (zero? (system* "make" "install-strip")))
                   ,phases))))
-          (if libc
+           (cond
+            ((mingw-target? target)
+             `(modify-phases ,phases
+                (add-before
+                 'configure 'set-cross-path
+                 (lambda* (#:key inputs #: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"))
+                         (gcc (assoc-ref inputs "gcc")))
+                     (define (cross? x)
+                       (and libc (string-prefix? libc x)))
+                     (if libc
+                         (let ((cpath (string-append
+                                       libc "/include"
+                                       ":" libc "/i686-w64-mingw32/include")))
+                           (for-each (cut setenv <> cpath)
+                                     '("CROSS_C_INCLUDE_PATH"
+                                       "CROSS_CPLUS_INCLUDE_PATH"
+                                       "CROSS_OBJC_INCLUDE_PATH"
+                                       "CROSS_OBJCPLUS_INCLUDE_PATH")))
+                         ;; libc is false, so we are building xgcc-sans-libc
+                         ;; Add essential headers from mingw-w64.
+                         (let ((mingw-source (assoc-ref inputs "mingw-source"))
+                               (mingw-headers
+                                (string-append (getcwd) "/mingw-w64-v5.0-rc2/mingw-w64-headers")))
+                           (system* "tar" "xf" mingw-source)
+                           ;; We need _mingw.h which will gets built from
+                           ;; _mingw.h.in by mingw-w64's configure.  We cannot
+                           ;; configure mingw-w64 until we have
+                           ;; xgcc-sans-libc; substitute to the rescue.
+                           (copy-file (string-append mingw-headers "/crt/_mingw.h.in")
+                                      (string-append mingw-headers "/crt/_mingw.h"))
+                           (substitute* (string-append mingw-headers "/crt/_mingw.h")
+                             (("@MINGW_HAS_SECURE_API@") "#define MINGW_HAS_SECURE_API 1"))
+                           (let ((cpath (string-append
+                                         mingw-headers "/include"
+                                         ":" mingw-headers "/crt"
+                                         ":" mingw-headers "/defaults/include")))
+                             (for-each (cut setenv <> cpath)
+                                       '("CROSS_C_INCLUDE_PATH"
+                                         "CROSS_CPLUS_INCLUDE_PATH"
+                                         "CROSS_OBJC_INCLUDE_PATH"
+                                         "CROSS_OBJCPLUS_INCLUDE_PATH"
+                                         "CROSS_LIBRARY_PATH")))))
+                     (when libc
+                       (setenv "CROSS_LIBRARY_PATH"
+                               (string-append
+                                libc "/lib"
+                                ":" libc "/i686-w64-mingw32/lib")))
+                     (setenv "CPP" (string-append gcc "/bin/cpp"))
+                     (for-each
+                      (lambda (var)
+                        (and=> (getenv var)
+                               (lambda (value)
+                                 (let* ((path (search-path-as-string->list
+                                               value))
+                                        (native-path (list->search-path-as-string
+                                                      (remove cross? path) ":")))
+                                   (setenv var native-path)))))
+                      '("C_INCLUDE_PATH"
+                        "CPLUS_INCLUDE_PATH"
+                        "OBJC_INCLUDE_PATH"
+                        "OBJCPLUS_INCLUDE_PATH"
+                        "LIBRARY_PATH"))
+                     #t)))))
+            (libc
               `(alist-cons-before
                 'configure 'set-cross-path
                 (lambda* (#:key inputs #:allow-other-keys)
@@ -199,16 +276,25 @@ may be either a libc package or #f.)"
                                 "OBJCPLUS_INCLUDE_PATH"
                                 "LIBRARY_PATH"))
                     #t))
-                ,phases)
-              phases)))))))
+                ,phases))
+          (else phases))))))))
 
 (define (cross-gcc-patches target)
   "Return GCC patches needed for TARGET."
   (cond ((string-prefix? "xtensa-" target)
          ;; Patch by Qualcomm needed to build the ath9k-htc firmware.
          (search-patches "ath9k-htc-firmware-gcc.patch"))
+        ((mingw-target? target)
+         (search-patches "gcc-4.9.3-mingw-gthr-default.patch"))
         (else '())))
 
+(define (cross-gcc-snippet target)
+  "Return GCC snippet needed for TARGET."
+  (cond ((mingw-target? target)
+         '(copy-recursively "libstdc++-v3/config/os/mingw32-w64"
+                            "libstdc++-v3/config/os/newlib"))
+        (else #f)))
+
 (define* (cross-gcc target
                     #:optional (xbinutils (cross-binutils target)) libc)
   "Return a cross-compiler for TARGET, where TARGET is a GNU triplet.  Use
@@ -223,7 +309,10 @@ GCC that does not target a libc; otherwise, target that libc."
                (append
                 (origin-patches (package-source %xgcc))
                 (cons (search-patch "gcc-cross-environment-variables.patch")
-                      (cross-gcc-patches target))))))
+                      (cross-gcc-patches target))))
+              (modules '((guix build utils)))
+              (snippet
+               (cross-gcc-snippet target))))
 
     ;; For simplicity, use a single output.  Otherwise libgcc_s & co. are not
     ;; found by default, etc.
@@ -245,6 +334,7 @@ GCC that does not target a libc; otherwise, target that libc."
                              #:target target
                              #:binutils xbinutils))
        ("binutils-cross" ,xbinutils)
+       ("gcc" ,gcc)
 
        ;; Call it differently so that the builder can check whether the "libc"
        ;; input is #f.
@@ -253,13 +343,20 @@ GCC that does not target a libc; otherwise, target that 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))))
+           (cond
+            ((mingw-target? target)
+             (if libc
+                 `(("libc" ,mingw-w64)
+                   ,@inputs)
+                 `(("mingw-source" ,(package-source mingw-w64))
+                   ,@inputs)))
+            (libc
+             `(("libc" ,libc)
+               ("xlinux-headers"                ;the target headers
+                ,@(assoc-ref (package-propagated-inputs libc)
+                             "linux-headers"))
+               ,@inputs))
+            (else inputs)))))
 
     (inputs '())
 
@@ -289,75 +386,87 @@ 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
-
-           ;; We need cut from srfi-26
-           #:modules ((guix build gnu-build-system)
-                      (guix build utils)
-                      (srfi srfi-26))
-
-           ,@(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"))
-                   (cpath (string-append linux "/include")))
-              (for-each (cut setenv <> cpath)
-                        '("CROSS_C_INCLUDE_PATH"
-                          "CROSS_CPLUS_INCLUDE_PATH"
-                          "CROSS_OBJC_INCLUDE_PATH"
-                          "CROSS_OBJCPLUS_INCLUDE_PATH"))
-              #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
+   ((cross-newlib? target)
+    (native-libc target))
+   (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
+
+               ;; We need cut from srfi-26
+               #:modules ((guix build gnu-build-system)
+                          (guix build utils)
+                          (srfi srfi-26))
+
+               ,@(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"))
+                       (cpath (string-append linux "/include")))
+                  (for-each (cut setenv <> cpath)
+                            '("CROSS_C_INCLUDE_PATH"
+                              "CROSS_CPLUS_INCLUDE_PATH"
+                              "CROSS_OBJC_INCLUDE_PATH"
+                              "CROSS_OBJCPLUS_INCLUDE_PATH"))
+                  #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))))))))
+
+(define (native-libc target)
+  (if (mingw-target? target)
+      mingw-w64
+      glibc))
+
+(define (cross-newlib? target)
+  (not (eq? (native-libc target) glibc)))
 
 \f
 ;;;
@@ -399,3 +508,18 @@ XBINUTILS and the cross tool chain."
 ;;     (cross-gcc triplet
 ;;                (cross-binutils triplet)
 ;;                (cross-libc triplet))))
+
+(define-public xgcc-sans-libc-i686-w64-mingw32
+  (let ((triplet "i686-w64-mingw32"))
+    (cross-gcc triplet
+               (cross-binutils triplet))))
+
+(define-public xbinutils-i686-w64-mingw32
+  (let ((triplet "i686-w64-mingw32"))
+    (cross-binutils triplet)))
+
+(define-public xgcc-i686-w64-mingw32
+  (let ((triplet "i686-w64-mingw32"))
+    (cross-gcc triplet
+               (cross-binutils triplet)
+               (cross-newlib? triplet))))
diff --git a/guix/utils.scm b/guix/utils.scm
index d924e43..2109035 100644
--- a/guix/utils.scm
+++ b/guix/utils.scm
@@ -65,6 +65,7 @@
             gnu-triplet->nix-system
             %current-system
             %current-target-system
+            mingw-target?
             package-name->name+version
             version-compare
             version>?
@@ -483,6 +484,10 @@ returned by `config.guess'."
   ;; cross-building to.
   (make-parameter #f))
 
+(define* (mingw-target? #:optional (target (%current-target-system)))
+  (and target
+       (string-suffix? "-mingw32" target)))
+
 (define (package-name->name+version spec)
   "Given SPEC, a package name like \"foo@0.9.1b\", return two values: \"foo\"
 and \"0.9.1b\".  When the version part is unavailable, SPEC and #f are
-- 
2.7.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] 36+ messages in thread

* Re: [PATCH 03/11] gnu: Add function libiconv-if-needed.
  2016-05-09  7:16   ` Andy Wingo
@ 2016-05-14 20:27     ` Jan Nieuwenhuizen
  2016-05-17  7:44       ` Andy Wingo
  0 siblings, 1 reply; 36+ messages in thread
From: Jan Nieuwenhuizen @ 2016-05-14 20:27 UTC (permalink / raw)
  To: Andy Wingo; +Cc: guix-devel

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

Andy Wingo writes:

>> +(define* (libiconv-if-needed #:optional (target (%current-target-system)))
>> +  (if (mingw-target? target)
>> +      `(("libiconv" ,libiconv))
>> +      '()))
>> +
>
> Needs a docstring, please.  Thanks :)

How is this?

    (define* (libiconv-if-needed #:optional (target (%current-target-system)))
      "Return either a libiconv package specification to include in a dependency
    list for platforms that have an incomplete libc, or the empty list.  If a
    package needs iconv ,@(libiconv-if-needed) should be added."
      ;; POSIX C libraries provide iconv.  Platforms with an incomplete libc
      ;; without iconv, such as MinGW, must return the then clause.
      (if (mingw-target? target)
          `(("libiconv" ,libiconv))
          '()))

Greetings, Jan


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0003-gnu-Add-function-libiconv-if-needed.patch --]
[-- Type: text/x-diff, Size: 1650 bytes --]

From a1ee6d5a33a9bd32828d9c8534b50f709c27b11a Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen <janneke@gnu.org>
Date: Tue, 3 May 2016 18:49:33 +0200
Subject: [PATCH 03/11] gnu: Add function libiconv-if-needed.

* gnu/packages/base.scm (libiconv-if-needed): New function.
---
 gnu/packages/base.scm | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/base.scm b/gnu/packages/base.scm
index beb689e..35e37e0 100644
--- a/gnu/packages/base.scm
+++ b/gnu/packages/base.scm
@@ -44,7 +44,8 @@
   #:use-module (guix download)
   #:use-module (guix git-download)
   #:use-module (guix build-system gnu)
-  #:use-module (guix build-system trivial))
+  #:use-module (guix build-system trivial)
+  :export (libiconv-if-needed))
 
 ;;; Commentary:
 ;;;
@@ -964,6 +965,16 @@ program.  It supports a wide variety of different encodings.")
     (home-page "http://www.gnu.org/software/libiconv/")
     (license lgpl3+)))
 
+(define* (libiconv-if-needed #:optional (target (%current-target-system)))
+  "Return either a libiconv package specification to include in a dependency
+list for platforms that have an incomplete libc, or the empty list.  If a
+package needs iconv ,@(libiconv-if-needed) should be added."
+  ;; POSIX C libraries provide iconv.  Platforms with an incomplete libc
+  ;; without iconv, such as MinGW, must return the then clause.
+  (if (mingw-target? target)
+      `(("libiconv" ,libiconv))
+      '()))
+
 (define-public (canonical-package package)
   ;; Avoid circular dependency by lazily resolving 'commencement'.
   (let* ((iface (resolve-interface '(gnu packages commencement)))
-- 
2.7.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] 36+ messages in thread

* Re: [PATCH 05/11] gnu: gmp: build shared library for mingw.
  2016-05-09  7:20   ` Andy Wingo
@ 2016-05-14 20:27     ` Jan Nieuwenhuizen
  0 siblings, 0 replies; 36+ messages in thread
From: Jan Nieuwenhuizen @ 2016-05-14 20:27 UTC (permalink / raw)
  To: Andy Wingo; +Cc: guix-devel

Andy Wingo writes:

>> +                  ,@(cond ((mingw-target?)
>> +                           ;; Static and shared cannot be built in one go:
>> +                           ;; they produce different headers.  We need shared.
>> +                           `("--disable-static"
>> +                             "--enable-shared"))
>> +                          (else '())))))
>>     (synopsis "Multiple-precision arithmetic library")
>>     (description
>>      "GMP is a library for arbitrary precision arithmetic, operating on
>
> LGTM.  A bit of a shame that mingw is an abnormal architecture in this
> way -- i.e. other targets will have both static and shared libraries,
> but not this one.  Oh well, this does look to be the right thing for
> now.

Okay, thanks.  Yes, I can imagine that when we find that this change is
needed for more packages/libraries we may want to make a function for
it.

Greetings, Jan

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

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

* Re: [PATCH 11/11] gnu: guile-2.0: support mingw.
  2016-05-09  7:48   ` Andy Wingo
@ 2016-05-14 20:31     ` Jan Nieuwenhuizen
  2016-05-17  7:46       ` Andy Wingo
  0 siblings, 1 reply; 36+ messages in thread
From: Jan Nieuwenhuizen @ 2016-05-14 20:31 UTC (permalink / raw)
  To: Andy Wingo; +Cc: guix-devel

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

Andy Wingo writes:

Hi Andy,

What I meant to say in my first mail, I'll do in the last.  Thanks so
much again for this round of reviews!  It took me quite some rebuilds
to get sane answers to your remarks and there were some bugs that I
needed to get straightened out first, that's why I could not answer
sooner.

>> -   (native-inputs `(("pkgconfig" ,pkg-config)))
>> +   (native-inputs `(("pkgconfig" ,pkg-config)
>> +                    ,@(if (mingw-target?) `(("bash" ,bash)) '())))
>
> AFAIU we can remove the "bash" thing here, as we decided to punt on
> (ice-9 popen); sound right to you?

Indeed.  Tested without this addition and removed.  (This is about the
native, build-hosts' bash anyway.  I think including the build host bash
explicitly may have been necessary when I was creating the cross-build.)

>> +                       (if bash
>> +                           (string-append bash "/bin/bash")
>> +                           "bash")))))
>
> Needs a comment here explaining that although we should always have bash
> as an input, it isn't packaged yet on mingw so we are falling back to
> finding it in the run-time path if needed.

Added this comment

          ;; If bash is #f allow fallback for user to provide
          ;; "bash" in PATH.  This happens when cross-building to
          ;; MinGW for which we do not have Bash yet.
          (("/bin/sh")
           (if bash
               (string-append bash "/bin/bash")
               "bash")))))

> FWIW although Windows doesn't support `fork', `open-process' should work
> in Windows, and we should therefore be able to get (ice-9 popen) working
> in Windows eventually.

Yes, I agree.
Greetings, Jan


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0011-gnu-guile-2.0-support-mingw.patch --]
[-- Type: text/x-diff, Size: 1787 bytes --]

From dfd0f3dbee2c0062b02c9f35c598d937c85ea614 Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen <janneke@gnu.org>
Date: Sun, 24 Apr 2016 14:06:56 +0200
Subject: [PATCH 11/11] gnu: guile-2.0: support mingw.

* gnu/packages/guile.scm (guile-2.0): Support mingw.
---
 gnu/packages/guile.scm | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/gnu/packages/guile.scm b/gnu/packages/guile.scm
index 53ea3e5..b4ffe86 100644
--- a/gnu/packages/guile.scm
+++ b/gnu/packages/guile.scm
@@ -138,8 +138,8 @@ without requiring the source code to be rewritten.")
    (native-inputs `(("pkgconfig" ,pkg-config)))
    (inputs `(("libffi" ,libffi)
              ("readline" ,readline)
-             ("bash" ,bash)))
-
+             ,@(libiconv-if-needed)
+             ,@(if (mingw-target?) '() `(("bash" ,bash)))))
    (propagated-inputs
     `( ;; These ones aren't normally needed here, but since `libguile-2.0.la'
        ;; reads `-lltdl -lunistring', adding them here will add the needed
@@ -167,8 +167,13 @@ without requiring the source code to be rewritten.")
                   ;; Tell (ice-9 popen) the file name of Bash.
                   (let ((bash (assoc-ref inputs "bash")))
                     (substitute* "module/ice-9/popen.scm"
+                      ;; If bash is #f allow fallback for user to provide
+                      ;; "bash" in PATH.  This happens when cross-building to
+                      ;; MinGW for which we do not have Bash yet.
                       (("/bin/sh")
-                       (string-append bash "/bin/bash")))))
+                       (if bash
+                           (string-append bash "/bin/bash")
+                           "bash")))))
                 %standard-phases)))
 
    (native-search-paths
-- 
2.7.3


[-- Attachment #3: Type: text/plain, Size: 156 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] 36+ messages in thread

* Re: [PATCH 07/11] gnu: cross-base: Add cross-libtool.
  2016-05-14 20:26     ` Jan Nieuwenhuizen
@ 2016-05-17  7:21       ` Andy Wingo
  0 siblings, 0 replies; 36+ messages in thread
From: Andy Wingo @ 2016-05-17  7:21 UTC (permalink / raw)
  To: Jan Nieuwenhuizen; +Cc: guix-devel

On Sat 14 May 2016 22:26, Jan Nieuwenhuizen <janneke@gnu.org> writes:

> From 78efd3acd57df52ec635de5d306a5d3865b473b6 Mon Sep 17 00:00:00 2001
> From: Jan Nieuwenhuizen <janneke@gnu.org>
> Date: Wed, 27 Apr 2016 10:33:52 +0200
> Subject: [PATCH 07/11] gnu: cross-base: Add cross-libtool.

Thanks for the comments; LGTM for me :)

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

* Re: [PATCH 02/11] gnu: cross-build: i686-w64-mingw32: new cross target.
  2016-05-14 20:27     ` Jan Nieuwenhuizen
@ 2016-05-17  7:43       ` Andy Wingo
  2016-05-17 22:30         ` Jan Nieuwenhuizen
  0 siblings, 1 reply; 36+ messages in thread
From: Andy Wingo @ 2016-05-17  7:43 UTC (permalink / raw)
  To: Jan Nieuwenhuizen; +Cc: guix-devel

On Sat 14 May 2016 22:27, Jan Nieuwenhuizen <janneke@gnu.org> writes:

> Andy Wingo writes:
>
> Something I wanted to ask and I guess now why don't we let functions
> like pair?, null?, string-prefix? not return the thing itself?

So many possible answers, none of them great ;) For example, why have #t
as a value at all -- I don't know :)

But more directly: pair? only returns a boolean because the standard
convention is that a function with a ? on the end returns a boolean.  A
counter example is `assoc': it returns a pair or #f, and has no trailing
`?'.

As to why have predicates -- well the idea is that a predicate doesn't
do lookup and doesnt' retrieve a value, it just partitions its domain.
You don't need to return the value because you already have the value --
you passed it as the argument.  Also consider boolean? -- what should
(boolean? #f) return?  Anyway that's how predicates are understood by
most other Scheme programmers.

> diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm
>  (define* (cross-gcc target
>                      #:optional (xbinutils (cross-binutils target)) libc)
>    "Return a cross-compiler for TARGET, where TARGET is a GNU triplet.  Use
> @@ -223,7 +309,10 @@ GCC that does not target a libc; otherwise, target that libc."
>                 (append
>                  (origin-patches (package-source %xgcc))
>                  (cons (search-patch "gcc-cross-environment-variables.patch")
> -                      (cross-gcc-patches target))))))
> +                      (cross-gcc-patches target))))
> +              (modules '((guix build utils)))
> +              (snippet
> +               (cross-gcc-snippet target))))
>  
>      ;; For simplicity, use a single output.  Otherwise libgcc_s & co. are not
>      ;; found by default, etc.
> @@ -245,6 +334,7 @@ GCC that does not target a libc; otherwise, target that libc."
>                               #:target target
>                               #:binutils xbinutils))
>         ("binutils-cross" ,xbinutils)
> +       ("gcc" ,gcc)
>  
>         ;; Call it differently so that the builder can check whether the "libc"
>         ;; input is #f.

Why did you add GCC here?  Why was it not needed before?

Other than this nit, LGTM.

Andy

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

* Re: [PATCH 03/11] gnu: Add function libiconv-if-needed.
  2016-05-14 20:27     ` Jan Nieuwenhuizen
@ 2016-05-17  7:44       ` Andy Wingo
  0 siblings, 0 replies; 36+ messages in thread
From: Andy Wingo @ 2016-05-17  7:44 UTC (permalink / raw)
  To: Jan Nieuwenhuizen; +Cc: guix-devel

On Sat 14 May 2016 22:27, Jan Nieuwenhuizen <janneke@gnu.org> writes:

> From a1ee6d5a33a9bd32828d9c8534b50f709c27b11a Mon Sep 17 00:00:00 2001
> From: Jan Nieuwenhuizen <janneke@gnu.org>
> Date: Tue, 3 May 2016 18:49:33 +0200
> Subject: [PATCH 03/11] gnu: Add function libiconv-if-needed.

LGTM, thank you!

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

* Re: [PATCH 11/11] gnu: guile-2.0: support mingw.
  2016-05-14 20:31     ` Jan Nieuwenhuizen
@ 2016-05-17  7:46       ` Andy Wingo
  0 siblings, 0 replies; 36+ messages in thread
From: Andy Wingo @ 2016-05-17  7:46 UTC (permalink / raw)
  To: Jan Nieuwenhuizen; +Cc: guix-devel

On Sat 14 May 2016 22:31, Jan Nieuwenhuizen <janneke@gnu.org> writes:

> From dfd0f3dbee2c0062b02c9f35c598d937c85ea614 Mon Sep 17 00:00:00 2001
> From: Jan Nieuwenhuizen <janneke@gnu.org>
> Date: Sun, 24 Apr 2016 14:06:56 +0200
> Subject: [PATCH 11/11] gnu: guile-2.0: support mingw.

LGTM.  Thank you!

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

* Re: [PATCH 02/11] gnu: cross-build: i686-w64-mingw32: new cross target.
  2016-05-17  7:43       ` Andy Wingo
@ 2016-05-17 22:30         ` Jan Nieuwenhuizen
  2016-05-18  7:27           ` Andy Wingo
  0 siblings, 1 reply; 36+ messages in thread
From: Jan Nieuwenhuizen @ 2016-05-17 22:30 UTC (permalink / raw)
  To: Andy Wingo; +Cc: guix-devel

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

Andy Wingo writes:

> So many possible answers, none of them great ;) For example, why have #t
> as a value at all -- I don't know :)

Thanks :-)

> But more directly: pair? only returns a boolean because the standard
> convention is that a function with a ? on the end returns a boolean.  A
> counter example is `assoc': it returns a pair or #f, and has no trailing
> `?'.

Okay.

> As to why have predicates -- well the idea is that a predicate doesn't
> do lookup and doesnt' retrieve a value, it just partitions its domain.
> You don't need to return the value because you already have the value --
> you passed it as the argument.  Also consider boolean? -- what should
> (boolean? #f) return?  Anyway that's how predicates are understood by
> most other Scheme programmers.

Yes, that makes sense.  I like the boolean? question.

>>         ("binutils-cross" ,xbinutils)
>> +       ("gcc" ,gcc)
>
> Why did you add GCC here?  Why was it not needed before?

If it was ever necessary, it is not anymore.  Removed.

> Other than this nit, LGTM.

Yay...looks like we're almost there!

Greetings,
Jan


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

From e0eb42bbc849e68fcd79a50c2fc5dffceed4e5c5 Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen <janneke@gnu.org>
Date: Tue, 3 May 2016 20:08:40 +0200
Subject: [PATCH 02/11] gnu: cross-build: i686-w64-mingw32: new cross target.

* guix/utils.scm (mingw-target?): New function.
* gnu/packages/cross-base.scm (cross-gcc-snippet): New function for mingw.
(cross-gcc): Use it.
(cross-gcc-arguments, cross-gcc-patches, cross-gcc): Support mingw.
(native-libc, cross-newlib?): New functions.
(cross-libc): Use cross-newlib? to support mingw.
(xbinutils-i686-w64-mingw32, xgcc-sans-libc-i686-w64-mingw32,
xgcc-i686-w64-mingw32): New variables.
---
 gnu/packages/cross-base.scm | 291 +++++++++++++++++++++++++++++++-------------
 guix/utils.scm              |   5 +
 2 files changed, 212 insertions(+), 84 deletions(-)

diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm
index 7ed4ae4..805d9ad 100644
--- a/gnu/packages/cross-base.scm
+++ b/gnu/packages/cross-base.scm
@@ -19,12 +19,17 @@
 ;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
 
 (define-module (gnu packages cross-base)
-  #:use-module (guix licenses)
+  #:use-module ((guix licenses) #:prefix license:)
   #:use-module (gnu packages)
-  #:use-module (gnu packages gcc)
   #:use-module (gnu packages base)
+  #:use-module (gnu packages bash)
+  #:use-module (gnu packages gawk)
+  #:use-module (gnu packages gcc)
   #:use-module (gnu packages commencement)
+  #:use-module (gnu packages compression)
   #:use-module (gnu packages linux)
+  #:use-module (gnu packages mingw)
+  #:use-module (gnu packages multiprecision)
   #:use-module (guix packages)
   #:use-module (guix download)
   #:use-module (guix utils)
@@ -35,7 +40,8 @@
   #:use-module (ice-9 match)
   #:export (cross-binutils
             cross-libc
-            cross-gcc))
+            cross-gcc
+            cross-newlib?))
 
 (define %xgcc
   ;; GCC package used as the basis for cross-compilation.  It doesn't have to
@@ -121,7 +127,12 @@ may be either a libc package or #f.)"
                                "--disable-libquadmath"
                                "--disable-decimal-float" ;would need libc
                                "--disable-libcilkrts"
-                               )))
+                                ))
+
+                       ;; For a newlib (non-glibc) target
+                       ,@(if (cross-newlib? target)
+                             '("--with-newlib")
+                             '()))
 
                  ,(if libc
                       flags
@@ -163,7 +174,73 @@ may be either a libc package or #f.)"
                     ;; for cross-compilers.
                     (zero? (system* "make" "install-strip")))
                   ,phases))))
-          (if libc
+           (cond
+            ((mingw-target? target)
+             `(modify-phases ,phases
+                (add-before
+                 'configure 'set-cross-path
+                 (lambda* (#:key inputs #: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"))
+                         (gcc (assoc-ref inputs "gcc")))
+                     (define (cross? x)
+                       (and libc (string-prefix? libc x)))
+                     (if libc
+                         (let ((cpath (string-append
+                                       libc "/include"
+                                       ":" libc "/i686-w64-mingw32/include")))
+                           (for-each (cut setenv <> cpath)
+                                     '("CROSS_C_INCLUDE_PATH"
+                                       "CROSS_CPLUS_INCLUDE_PATH"
+                                       "CROSS_OBJC_INCLUDE_PATH"
+                                       "CROSS_OBJCPLUS_INCLUDE_PATH")))
+                         ;; libc is false, so we are building xgcc-sans-libc
+                         ;; Add essential headers from mingw-w64.
+                         (let ((mingw-source (assoc-ref inputs "mingw-source"))
+                               (mingw-headers
+                                (string-append (getcwd) "/mingw-w64-v5.0-rc2/mingw-w64-headers")))
+                           (system* "tar" "xf" mingw-source)
+                           ;; We need _mingw.h which will gets built from
+                           ;; _mingw.h.in by mingw-w64's configure.  We cannot
+                           ;; configure mingw-w64 until we have
+                           ;; xgcc-sans-libc; substitute to the rescue.
+                           (copy-file (string-append mingw-headers "/crt/_mingw.h.in")
+                                      (string-append mingw-headers "/crt/_mingw.h"))
+                           (substitute* (string-append mingw-headers "/crt/_mingw.h")
+                             (("@MINGW_HAS_SECURE_API@") "#define MINGW_HAS_SECURE_API 1"))
+                           (let ((cpath (string-append
+                                         mingw-headers "/include"
+                                         ":" mingw-headers "/crt"
+                                         ":" mingw-headers "/defaults/include")))
+                             (for-each (cut setenv <> cpath)
+                                       '("CROSS_C_INCLUDE_PATH"
+                                         "CROSS_CPLUS_INCLUDE_PATH"
+                                         "CROSS_OBJC_INCLUDE_PATH"
+                                         "CROSS_OBJCPLUS_INCLUDE_PATH"
+                                         "CROSS_LIBRARY_PATH")))))
+                     (when libc
+                       (setenv "CROSS_LIBRARY_PATH"
+                               (string-append
+                                libc "/lib"
+                                ":" libc "/i686-w64-mingw32/lib")))
+                     (setenv "CPP" (string-append gcc "/bin/cpp"))
+                     (for-each
+                      (lambda (var)
+                        (and=> (getenv var)
+                               (lambda (value)
+                                 (let* ((path (search-path-as-string->list
+                                               value))
+                                        (native-path (list->search-path-as-string
+                                                      (remove cross? path) ":")))
+                                   (setenv var native-path)))))
+                      '("C_INCLUDE_PATH"
+                        "CPLUS_INCLUDE_PATH"
+                        "OBJC_INCLUDE_PATH"
+                        "OBJCPLUS_INCLUDE_PATH"
+                        "LIBRARY_PATH"))
+                     #t)))))
+            (libc
               `(alist-cons-before
                 'configure 'set-cross-path
                 (lambda* (#:key inputs #:allow-other-keys)
@@ -199,16 +276,25 @@ may be either a libc package or #f.)"
                                 "OBJCPLUS_INCLUDE_PATH"
                                 "LIBRARY_PATH"))
                     #t))
-                ,phases)
-              phases)))))))
+                ,phases))
+          (else phases))))))))
 
 (define (cross-gcc-patches target)
   "Return GCC patches needed for TARGET."
   (cond ((string-prefix? "xtensa-" target)
          ;; Patch by Qualcomm needed to build the ath9k-htc firmware.
          (search-patches "ath9k-htc-firmware-gcc.patch"))
+        ((mingw-target? target)
+         (search-patches "gcc-4.9.3-mingw-gthr-default.patch"))
         (else '())))
 
+(define (cross-gcc-snippet target)
+  "Return GCC snippet needed for TARGET."
+  (cond ((mingw-target? target)
+         '(copy-recursively "libstdc++-v3/config/os/mingw32-w64"
+                            "libstdc++-v3/config/os/newlib"))
+        (else #f)))
+
 (define* (cross-gcc target
                     #:optional (xbinutils (cross-binutils target)) libc)
   "Return a cross-compiler for TARGET, where TARGET is a GNU triplet.  Use
@@ -223,7 +309,10 @@ GCC that does not target a libc; otherwise, target that libc."
                (append
                 (origin-patches (package-source %xgcc))
                 (cons (search-patch "gcc-cross-environment-variables.patch")
-                      (cross-gcc-patches target))))))
+                      (cross-gcc-patches target))))
+              (modules '((guix build utils)))
+              (snippet
+               (cross-gcc-snippet target))))
 
     ;; For simplicity, use a single output.  Otherwise libgcc_s & co. are not
     ;; found by default, etc.
@@ -253,13 +342,20 @@ GCC that does not target a libc; otherwise, target that 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))))
+           (cond
+            ((mingw-target? target)
+             (if libc
+                 `(("libc" ,mingw-w64)
+                   ,@inputs)
+                 `(("mingw-source" ,(package-source mingw-w64))
+                   ,@inputs)))
+            (libc
+             `(("libc" ,libc)
+               ("xlinux-headers"                ;the target headers
+                ,@(assoc-ref (package-propagated-inputs libc)
+                             "linux-headers"))
+               ,@inputs))
+            (else inputs)))))
 
     (inputs '())
 
@@ -289,75 +385,87 @@ 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
-
-           ;; We need cut from srfi-26
-           #:modules ((guix build gnu-build-system)
-                      (guix build utils)
-                      (srfi srfi-26))
-
-           ,@(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"))
-                   (cpath (string-append linux "/include")))
-              (for-each (cut setenv <> cpath)
-                        '("CROSS_C_INCLUDE_PATH"
-                          "CROSS_CPLUS_INCLUDE_PATH"
-                          "CROSS_OBJC_INCLUDE_PATH"
-                          "CROSS_OBJCPLUS_INCLUDE_PATH"))
-              #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
+   ((cross-newlib? target)
+    (native-libc target))
+   (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
+
+               ;; We need cut from srfi-26
+               #:modules ((guix build gnu-build-system)
+                          (guix build utils)
+                          (srfi srfi-26))
+
+               ,@(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"))
+                       (cpath (string-append linux "/include")))
+                  (for-each (cut setenv <> cpath)
+                            '("CROSS_C_INCLUDE_PATH"
+                              "CROSS_CPLUS_INCLUDE_PATH"
+                              "CROSS_OBJC_INCLUDE_PATH"
+                              "CROSS_OBJCPLUS_INCLUDE_PATH"))
+                  #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))))))))
+
+(define (native-libc target)
+  (if (mingw-target? target)
+      mingw-w64
+      glibc))
+
+(define (cross-newlib? target)
+  (not (eq? (native-libc target) glibc)))
 
 \f
 ;;;
@@ -399,3 +507,18 @@ XBINUTILS and the cross tool chain."
 ;;     (cross-gcc triplet
 ;;                (cross-binutils triplet)
 ;;                (cross-libc triplet))))
+
+(define-public xgcc-sans-libc-i686-w64-mingw32
+  (let ((triplet "i686-w64-mingw32"))
+    (cross-gcc triplet
+               (cross-binutils triplet))))
+
+(define-public xbinutils-i686-w64-mingw32
+  (let ((triplet "i686-w64-mingw32"))
+    (cross-binutils triplet)))
+
+(define-public xgcc-i686-w64-mingw32
+  (let ((triplet "i686-w64-mingw32"))
+    (cross-gcc triplet
+               (cross-binutils triplet)
+               (cross-newlib? triplet))))
diff --git a/guix/utils.scm b/guix/utils.scm
index d924e43..2109035 100644
--- a/guix/utils.scm
+++ b/guix/utils.scm
@@ -65,6 +65,7 @@
             gnu-triplet->nix-system
             %current-system
             %current-target-system
+            mingw-target?
             package-name->name+version
             version-compare
             version>?
@@ -483,6 +484,10 @@ returned by `config.guess'."
   ;; cross-building to.
   (make-parameter #f))
 
+(define* (mingw-target? #:optional (target (%current-target-system)))
+  (and target
+       (string-suffix? "-mingw32" target)))
+
 (define (package-name->name+version spec)
   "Given SPEC, a package name like \"foo@0.9.1b\", return two values: \"foo\"
 and \"0.9.1b\".  When the version part is unavailable, SPEC and #f are
-- 
2.7.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] 36+ messages in thread

* Re: [PATCH 02/11] gnu: cross-build: i686-w64-mingw32: new cross target.
  2016-05-17 22:30         ` Jan Nieuwenhuizen
@ 2016-05-18  7:27           ` Andy Wingo
  2016-05-19 22:16             ` Jan Nieuwenhuizen
  0 siblings, 1 reply; 36+ messages in thread
From: Andy Wingo @ 2016-05-18  7:27 UTC (permalink / raw)
  To: Jan Nieuwenhuizen; +Cc: guix-devel

On Wed 18 May 2016 00:30, Jan Nieuwenhuizen <janneke@gnu.org> writes:

> Yay...looks like we're almost there!

Yeah almost!  Just two (?) more nits -- I seem to keep finding these.
Sorry about that.

> @@ -19,12 +19,17 @@
>  ;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
>  
>  (define-module (gnu packages cross-base)
> -  #:use-module (guix licenses)
> +  #:use-module ((guix licenses) #:prefix license:)
>    #:use-module (gnu packages)
> -  #:use-module (gnu packages gcc)
>    #:use-module (gnu packages base)
> +  #:use-module (gnu packages bash)
> +  #:use-module (gnu packages gawk)
> +  #:use-module (gnu packages gcc)
>    #:use-module (gnu packages commencement)
> +  #:use-module (gnu packages compression)
>    #:use-module (gnu packages linux)
> +  #:use-module (gnu packages mingw)
> +  #:use-module (gnu packages multiprecision)
>    #:use-module (guix packages)
>    #:use-module (guix download)
>    #:use-module (guix utils)

It seems that of these additions, only mingw is necessary.  Can you check?

> +                         ;; libc is false, so we are building xgcc-sans-libc
> +                         ;; Add essential headers from mingw-w64.
> +                         (let ((mingw-source (assoc-ref inputs "mingw-source"))
> +                               (mingw-headers
> +                                (string-append (getcwd) "/mingw-w64-v5.0-rc2/mingw-w64-headers")))
> +                           (system* "tar" "xf" mingw-source)
> +                           ;; We need _mingw.h which will gets built from
> +                           ;; _mingw.h.in by mingw-w64's configure.  We cannot
> +                           ;; configure mingw-w64 until we have
> +                           ;; xgcc-sans-libc; substitute to the rescue.
> +                           (copy-file (string-append mingw-headers "/crt/_mingw.h.in")
> +                                      (string-append mingw-headers "/crt/_mingw.h"))
> +                           (substitute* (string-append mingw-headers "/crt/_mingw.h")
> +                             (("@MINGW_HAS_SECURE_API@") "#define MINGW_HAS_SECURE_API 1"))

Humm, this v5.0-rc2 version is definitely going to break in the future.
OK, we're depending on the internal structure of a tarball, we know it's
going to be a bit fragile, but uf...  If you have the bandwidth, a fix
would be nice.  Maybe:

  (define (unpacked-mingw-dir)
    (match (scandir "." (lambda (name) (string-contains name "mingw-w64")))
      ((mingw-dir)
       (string-append (getcwd) "/" mingw-dir "/mingw-w64-headers"))))

You'll need to add (ice-9 match) and (ice-9 ftw) to #:modules, and you'd
have to invoke this function after unpacking the tarball.

Andy

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

* Re: [PATCH 02/11] gnu: cross-build: i686-w64-mingw32: new cross target.
  2016-05-18  7:27           ` Andy Wingo
@ 2016-05-19 22:16             ` Jan Nieuwenhuizen
  0 siblings, 0 replies; 36+ messages in thread
From: Jan Nieuwenhuizen @ 2016-05-19 22:16 UTC (permalink / raw)
  To: Andy Wingo; +Cc: guix-devel

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

Andy Wingo writes:

> Yeah almost!  Just two (?) more nits -- I seem to keep finding these.
> Sorry about that.

:-)

>>  (define-module (gnu packages cross-base)
>> -  #:use-module (guix licenses)
>> +  #:use-module ((guix licenses) #:prefix license:)
>>    #:use-module (gnu packages)
>> -  #:use-module (gnu packages gcc)
>>    #:use-module (gnu packages base)
>> +  #:use-module (gnu packages bash)
>> +  #:use-module (gnu packages gawk)
>> +  #:use-module (gnu packages gcc)
>>    #:use-module (gnu packages commencement)
>> +  #:use-module (gnu packages compression)
>>    #:use-module (gnu packages linux)
>> +  #:use-module (gnu packages mingw)
>> +  #:use-module (gnu packages multiprecision)
>>    #:use-module (guix packages)
>>    #:use-module (guix download)
>>    #:use-module (guix utils)
>
> It seems that of these additions, only mingw is necessary.  Can you check?

Indeed...another remnant of my earlier cross-gcc-core hack.  Removed
additions, still removing unused guix licenses.

>> + (string-append (getcwd) "/mingw-w64-v5.0-rc2/mingw-w64-headers")))
...
>> + (substitute* (string-append mingw-headers "/crt/_mingw.h")
>> + (("@MINGW_HAS_SECURE_API@") "#define MINGW_HAS_SECURE_API 1"))
>
> Humm, this v5.0-rc2 version is definitely going to break in the future.

Yes.

> OK, we're depending on the internal structure of a tarball, we know it's
> going to be a bit fragile, but uf...  If you have the bandwidth, a fix
> would be nice.  Maybe:
>
>   (define (unpacked-mingw-dir)
>     (match (scandir "." (lambda (name) (string-contains name "mingw-w64")))
>       ((mingw-dir)
>        (string-append (getcwd) "/" mingw-dir "/mingw-w64-headers"))))

That works quite nicely.  Changed to use it.

> You'll need to add (ice-9 match) and (ice-9 ftw) to #:modules, and you'd
> have to invoke this function after unpacking the tarball.

With these, of course.  Thanks!

Greetings,
Jan


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

From 241643afa6c9a13edd0fd6afca29d50cffec5abf Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen <janneke@gnu.org>
Date: Tue, 3 May 2016 20:08:40 +0200
Subject: [PATCH 02/11] gnu: cross-build: i686-w64-mingw32: new cross target.

* guix/utils.scm (mingw-target?): New function.
* gnu/packages/cross-base.scm (cross-gcc-snippet): New function for mingw.
(cross-gcc): Use it.
(cross-gcc-arguments, cross-gcc-patches, cross-gcc): Support mingw.
(native-libc, cross-newlib?): New functions.
(cross-libc): Use cross-newlib? to support mingw.
(xbinutils-i686-w64-mingw32, xgcc-sans-libc-i686-w64-mingw32,
xgcc-i686-w64-mingw32): New variables.
---
 gnu/packages/cross-base.scm | 300 +++++++++++++++++++++++++++++++-------------
 guix/utils.scm              |   5 +
 2 files changed, 221 insertions(+), 84 deletions(-)

diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm
index 7ed4ae4..6888b2d 100644
--- a/gnu/packages/cross-base.scm
+++ b/gnu/packages/cross-base.scm
@@ -19,12 +19,12 @@
 ;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
 
 (define-module (gnu packages cross-base)
-  #:use-module (guix licenses)
   #:use-module (gnu packages)
-  #:use-module (gnu packages gcc)
   #:use-module (gnu packages base)
+  #:use-module (gnu packages gcc)
   #:use-module (gnu packages commencement)
   #:use-module (gnu packages linux)
+  #:use-module (gnu packages mingw)
   #:use-module (guix packages)
   #:use-module (guix download)
   #:use-module (guix utils)
@@ -35,7 +35,8 @@
   #:use-module (ice-9 match)
   #:export (cross-binutils
             cross-libc
-            cross-gcc))
+            cross-gcc
+            cross-newlib?))
 
 (define %xgcc
   ;; GCC package used as the basis for cross-compilation.  It doesn't have to
@@ -121,7 +122,12 @@ may be either a libc package or #f.)"
                                "--disable-libquadmath"
                                "--disable-decimal-float" ;would need libc
                                "--disable-libcilkrts"
-                               )))
+                                ))
+
+                       ;; For a newlib (non-glibc) target
+                       ,@(if (cross-newlib? target)
+                             '("--with-newlib")
+                             '()))
 
                  ,(if libc
                       flags
@@ -163,7 +169,85 @@ may be either a libc package or #f.)"
                     ;; for cross-compilers.
                     (zero? (system* "make" "install-strip")))
                   ,phases))))
-          (if libc
+           (cond
+            ((mingw-target? target)
+             `(modify-phases ,phases
+                (add-before
+                 'configure 'set-cross-path
+                 (lambda* (#:key inputs #: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"))
+                         (gcc (assoc-ref inputs "gcc")))
+                     (define (cross? x)
+                       (and libc (string-prefix? libc x)))
+                     (define (unpacked-mingw-dir)
+                       (match
+                           (scandir
+                            "."
+                            (lambda (name) (string-contains name "mingw-w64")))
+                         ((mingw-dir)
+                          (string-append
+                           (getcwd) "/" mingw-dir "/mingw-w64-headers"))))
+                     (if libc
+                         (let ((cpath (string-append
+                                       libc "/include"
+                                       ":" libc "/i686-w64-mingw32/include")))
+                           (for-each (cut setenv <> cpath)
+                                     '("CROSS_C_INCLUDE_PATH"
+                                       "CROSS_CPLUS_INCLUDE_PATH"
+                                       "CROSS_OBJC_INCLUDE_PATH"
+                                       "CROSS_OBJCPLUS_INCLUDE_PATH")))
+                         ;; libc is false, so we are building xgcc-sans-libc
+                         ;; Add essential headers from mingw-w64.
+                         (let ((mingw-source (assoc-ref inputs "mingw-source")))
+                           (system* "tar" "xf" mingw-source)
+                           (let ((mingw-headers (unpacked-mingw-dir)))
+                             ;; We need _mingw.h which will gets built from
+                             ;; _mingw.h.in by mingw-w64's configure.  We cannot
+                             ;; configure mingw-w64 until we have
+                             ;; xgcc-sans-libc; substitute to the rescue.
+                             (copy-file (string-append mingw-headers
+                                                       "/crt/_mingw.h.in")
+                                        (string-append mingw-headers
+                                                       "/crt/_mingw.h"))
+                             (substitute* (string-append mingw-headers
+                                                         "/crt/_mingw.h")
+                               (("@MINGW_HAS_SECURE_API@")
+                                "#define MINGW_HAS_SECURE_API 1"))
+                             (let ((cpath
+                                    (string-append
+                                     mingw-headers "/include"
+                                     ":" mingw-headers "/crt"
+                                     ":" mingw-headers "/defaults/include")))
+                               (for-each (cut setenv <> cpath)
+                                         '("CROSS_C_INCLUDE_PATH"
+                                           "CROSS_CPLUS_INCLUDE_PATH"
+                                           "CROSS_OBJC_INCLUDE_PATH"
+                                           "CROSS_OBJCPLUS_INCLUDE_PATH"
+                                           "CROSS_LIBRARY_PATH"))))
+                             (when libc
+                               (setenv "CROSS_LIBRARY_PATH"
+                                       (string-append
+                                        libc "/lib"
+                                        ":" libc "/i686-w64-mingw32/lib")))))
+                     (setenv "CPP" (string-append gcc "/bin/cpp"))
+                     (for-each
+                      (lambda (var)
+                        (and=> (getenv var)
+                               (lambda (value)
+                                 (let* ((path (search-path-as-string->list
+                                               value))
+                                        (native-path (list->search-path-as-string
+                                                      (remove cross? path) ":")))
+                                   (setenv var native-path)))))
+                      '("C_INCLUDE_PATH"
+                        "CPLUS_INCLUDE_PATH"
+                        "OBJC_INCLUDE_PATH"
+                        "OBJCPLUS_INCLUDE_PATH"
+                        "LIBRARY_PATH"))
+                     #t)))))
+            (libc
               `(alist-cons-before
                 'configure 'set-cross-path
                 (lambda* (#:key inputs #:allow-other-keys)
@@ -199,16 +283,25 @@ may be either a libc package or #f.)"
                                 "OBJCPLUS_INCLUDE_PATH"
                                 "LIBRARY_PATH"))
                     #t))
-                ,phases)
-              phases)))))))
+                ,phases))
+          (else phases))))))))
 
 (define (cross-gcc-patches target)
   "Return GCC patches needed for TARGET."
   (cond ((string-prefix? "xtensa-" target)
          ;; Patch by Qualcomm needed to build the ath9k-htc firmware.
          (search-patches "ath9k-htc-firmware-gcc.patch"))
+        ((mingw-target? target)
+         (search-patches "gcc-4.9.3-mingw-gthr-default.patch"))
         (else '())))
 
+(define (cross-gcc-snippet target)
+  "Return GCC snippet needed for TARGET."
+  (cond ((mingw-target? target)
+         '(copy-recursively "libstdc++-v3/config/os/mingw32-w64"
+                            "libstdc++-v3/config/os/newlib"))
+        (else #f)))
+
 (define* (cross-gcc target
                     #:optional (xbinutils (cross-binutils target)) libc)
   "Return a cross-compiler for TARGET, where TARGET is a GNU triplet.  Use
@@ -223,7 +316,10 @@ GCC that does not target a libc; otherwise, target that libc."
                (append
                 (origin-patches (package-source %xgcc))
                 (cons (search-patch "gcc-cross-environment-variables.patch")
-                      (cross-gcc-patches target))))))
+                      (cross-gcc-patches target))))
+              (modules '((guix build utils)))
+              (snippet
+               (cross-gcc-snippet target))))
 
     ;; For simplicity, use a single output.  Otherwise libgcc_s & co. are not
     ;; found by default, etc.
@@ -233,6 +329,8 @@ GCC that does not target a libc; otherwise, target that libc."
      `(#:implicit-inputs? #f
        #:modules ((guix build gnu-build-system)
                   (guix build utils)
+                  (ice-9 ftw)
+                  (ice-9 match)
                   (ice-9 regex)
                   (srfi srfi-1)
                   (srfi srfi-26))
@@ -253,13 +351,20 @@ GCC that does not target a libc; otherwise, target that 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))))
+           (cond
+            ((mingw-target? target)
+             (if libc
+                 `(("libc" ,mingw-w64)
+                   ,@inputs)
+                 `(("mingw-source" ,(package-source mingw-w64))
+                   ,@inputs)))
+            (libc
+             `(("libc" ,libc)
+               ("xlinux-headers"                ;the target headers
+                ,@(assoc-ref (package-propagated-inputs libc)
+                             "linux-headers"))
+               ,@inputs))
+            (else inputs)))))
 
     (inputs '())
 
@@ -289,75 +394,87 @@ 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
-
-           ;; We need cut from srfi-26
-           #:modules ((guix build gnu-build-system)
-                      (guix build utils)
-                      (srfi srfi-26))
-
-           ,@(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"))
-                   (cpath (string-append linux "/include")))
-              (for-each (cut setenv <> cpath)
-                        '("CROSS_C_INCLUDE_PATH"
-                          "CROSS_CPLUS_INCLUDE_PATH"
-                          "CROSS_OBJC_INCLUDE_PATH"
-                          "CROSS_OBJCPLUS_INCLUDE_PATH"))
-              #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
+   ((cross-newlib? target)
+    (native-libc target))
+   (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
+
+               ;; We need cut from srfi-26
+               #:modules ((guix build gnu-build-system)
+                          (guix build utils)
+                          (srfi srfi-26))
+
+               ,@(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"))
+                       (cpath (string-append linux "/include")))
+                  (for-each (cut setenv <> cpath)
+                            '("CROSS_C_INCLUDE_PATH"
+                              "CROSS_CPLUS_INCLUDE_PATH"
+                              "CROSS_OBJC_INCLUDE_PATH"
+                              "CROSS_OBJCPLUS_INCLUDE_PATH"))
+                  #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))))))))
+
+(define (native-libc target)
+  (if (mingw-target? target)
+      mingw-w64
+      glibc))
+
+(define (cross-newlib? target)
+  (not (eq? (native-libc target) glibc)))
 
 \f
 ;;;
@@ -399,3 +516,18 @@ XBINUTILS and the cross tool chain."
 ;;     (cross-gcc triplet
 ;;                (cross-binutils triplet)
 ;;                (cross-libc triplet))))
+
+(define-public xgcc-sans-libc-i686-w64-mingw32
+  (let ((triplet "i686-w64-mingw32"))
+    (cross-gcc triplet
+               (cross-binutils triplet))))
+
+(define-public xbinutils-i686-w64-mingw32
+  (let ((triplet "i686-w64-mingw32"))
+    (cross-binutils triplet)))
+
+(define-public xgcc-i686-w64-mingw32
+  (let ((triplet "i686-w64-mingw32"))
+    (cross-gcc triplet
+               (cross-binutils triplet)
+               (cross-newlib? triplet))))
diff --git a/guix/utils.scm b/guix/utils.scm
index d924e43..2109035 100644
--- a/guix/utils.scm
+++ b/guix/utils.scm
@@ -65,6 +65,7 @@
             gnu-triplet->nix-system
             %current-system
             %current-target-system
+            mingw-target?
             package-name->name+version
             version-compare
             version>?
@@ -483,6 +484,10 @@ returned by `config.guess'."
   ;; cross-building to.
   (make-parameter #f))
 
+(define* (mingw-target? #:optional (target (%current-target-system)))
+  (and target
+       (string-suffix? "-mingw32" target)))
+
 (define (package-name->name+version spec)
   "Given SPEC, a package name like \"foo@0.9.1b\", return two values: \"foo\"
 and \"0.9.1b\".  When the version part is unavailable, SPEC and #f are
-- 
2.7.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] 36+ messages in thread

end of thread, other threads:[~2016-05-19 22:17 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-08 20:42 mingw guile.exe cross build patch series v8 Jan Nieuwenhuizen
2016-05-08 20:42 ` [PATCH 01/11] gnu: Add mingw-w64 Jan Nieuwenhuizen
2016-05-09  7:07   ` Andy Wingo
2016-05-08 20:42 ` [PATCH 02/11] gnu: cross-build: i686-w64-mingw32: new cross target Jan Nieuwenhuizen
2016-05-09  7:15   ` Andy Wingo
2016-05-14 20:27     ` Jan Nieuwenhuizen
2016-05-17  7:43       ` Andy Wingo
2016-05-17 22:30         ` Jan Nieuwenhuizen
2016-05-18  7:27           ` Andy Wingo
2016-05-19 22:16             ` Jan Nieuwenhuizen
2016-05-08 20:42 ` [PATCH 03/11] gnu: Add function libiconv-if-needed Jan Nieuwenhuizen
2016-05-09  7:16   ` Andy Wingo
2016-05-14 20:27     ` Jan Nieuwenhuizen
2016-05-17  7:44       ` Andy Wingo
2016-05-08 20:42 ` [PATCH 04/11] gnu: libunistring: support mingw: propagate libiconv if needed Jan Nieuwenhuizen
2016-05-09  7:17   ` Andy Wingo
2016-05-08 20:42 ` [PATCH 05/11] gnu: gmp: build shared library for mingw Jan Nieuwenhuizen
2016-05-09  7:20   ` Andy Wingo
2016-05-14 20:27     ` Jan Nieuwenhuizen
2016-05-08 20:42 ` [PATCH 06/11] gnu: ncurses: support mingw Jan Nieuwenhuizen
2016-05-09  7:23   ` Andy Wingo
2016-05-08 20:42 ` [PATCH 07/11] gnu: cross-base: Add cross-libtool Jan Nieuwenhuizen
2016-05-09  7:29   ` Andy Wingo
2016-05-14 20:26     ` Jan Nieuwenhuizen
2016-05-17  7:21       ` Andy Wingo
2016-05-08 20:42 ` [PATCH 08/11] gnu: libtool: support cross-libtool mingw Jan Nieuwenhuizen
2016-05-09  7:39   ` Andy Wingo
2016-05-14 20:27     ` Jan Nieuwenhuizen
2016-05-08 20:42 ` [PATCH 09/11] gnu: ncurses: build mingw with libtool Jan Nieuwenhuizen
2016-05-09  7:44   ` Andy Wingo
2016-05-08 20:42 ` [PATCH 10/11] gnu: readline: support mingw Jan Nieuwenhuizen
2016-05-09  7:44   ` Andy Wingo
2016-05-08 20:42 ` [PATCH 11/11] gnu: guile-2.0: " Jan Nieuwenhuizen
2016-05-09  7:48   ` Andy Wingo
2016-05-14 20:31     ` Jan Nieuwenhuizen
2016-05-17  7:46       ` 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).