From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Nieuwenhuizen Subject: Re: rfc/rfh: i686-w64-mingw32 cross target Date: Thu, 14 Apr 2016 08:30:18 +0200 Message-ID: <87d1pssnwl.fsf@drakenvlieg.flower> References: <87vb492l7s.fsf@drakenvlieg.flower> <877fgio11v.fsf@elephly.net> <87r3eq2y2s.fsf@drakenvlieg.flower> <8760w2nzl4.fsf@elephly.net> <87d1q8lb7j.fsf@drakenvlieg.flower> <87k2k99l7w.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:59893) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aqanm-0000Px-NA for guix-devel@gnu.org; Thu, 14 Apr 2016 02:31:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aqang-0003zt-4L for guix-devel@gnu.org; Thu, 14 Apr 2016 02:30:54 -0400 In-Reply-To: <87k2k99l7w.fsf@gnu.org> ("Ludovic \=\?utf-8\?Q\?Court\=C3\=A8s\=22'\?\= \=\?utf-8\?Q\?s\?\= message of "Thu, 07 Apr 2016 23:12:51 +0200") List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: Ludovic =?utf-8?Q?Court=C3=A8s?= Cc: guix-devel@gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Ludovic Court=C3=A8s writes: > Sorry for the delay, but this is awesome work! I=E2=80=99m impressed tha= t you > got it working in so little time. Thank you! The way Guix (and Nix) handles builds, using clean environments, together with the gcc-cross-environment-variables patch makes it a lot less error-prone. The fact that almost every little change triggers a full world rebuild makes creating a cross build on Guix quite annoying, though. I wonder if we would like to make this friendlier, even if only to bootstrap cross builds. Our old GUB cross build system has two features that vastly reduce the number of toolchain/world rebuilds * every package (class Name) can possbly have a architecture-specific specialisation: class Name__, that the build system looks for and uses if present * there is a `-x,--no-dependencies' option that says: just rebuild this package, even if some of its dependencies are out of date I can speficy e.g. a modified Gcc for mingw only (GUB uses Python, my favourite before I changed to Guile) like so class Gcc (cross.AutoBuild): ... class Gcc_core (Gcc): ...build minimal c-only compiler to build a libc... class Gcc__mingw (Gcc): ...add a patch for the c++ compiler to build... Then the native toolchain won't be rebuilt when experimenting with mingw. To avoid rebuilding the core gcc and the c library when working to get the c++ compiler built, I can use --no-dependencies until it works, then suffer a full rebuild only once at the end. > I=E2=80=99m not offering a full review yet. I think it=E2=80=99s an addi= tional > incentive to finally merge the remaining bits from wip-hurd. ;-) Ok, thanks! :-) > My main concern is the complexity of the cross-base stuff. Why is > =E2=80=98cross-gcc-core=E2=80=99 needed, for instance? It is needed to break a circular bootstrap dependency. To build a new c library, you need a cross compiler. A full flegded gcc can only be built when you have a c library: the circular dependency. This simple, minimal `core-gcc' can be built with only the headers of the new c library; breaking the circle. > It=E2=80=99s probably inevitable for the complexity to be proportional to= the > number of target libcs, but I think we should start thinking about how > to master this complexity by factoring/abstracting things a bit. Okay. It's cross-base is getting better but I/we haven't really addressed this. So no need to review that bit. Meanwhile I'm offering a new set of patches leading up to a mingw guile.exe for others to look at and will look at refactoring cross-base. Note that hello.exe runs in wine ./pre-inst-env guix build --target=3Di686-w64-mingw32 hello but guile.exe still segfaults. > A cosmetic comment: I=E2=80=99d put the MinGW packages in a separate modu= le. Ok. > I think portability patches should be (1) submitted upstream ;-), and > (2) applied unconditionally on all architectures (assuming they do not > make any difference on the other architectures.) Yes, I agree. Greetings, Jan on master: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-gnu-gcc-use-CPATH-fixes-cross-builds.patch >From 294f158558279bb25ad64b08ffb74281ba9da78d Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Sun, 27 Mar 2016 16:00:36 +0200 Subject: [PATCH 1/9] gnu: gcc: use CPATH, fixes cross builds. * gnu/packages/gcc (gcc): Use CPATH instead of C_INCLUDE_PATH. Fixes usage of native glibc headers when cross-compiling. --- gnu/packages/gcc.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gnu/packages/gcc.scm b/gnu/packages/gcc.scm index bdcb275..fc0ef6e 100644 --- a/gnu/packages/gcc.scm +++ b/gnu/packages/gcc.scm @@ -311,7 +311,7 @@ where the OS part is overloaded to denote a specific ABI---into GCC ;; treated as "system headers" (headers exempt from warnings) just like ;; the typical /usr/include headers on an FHS system. (list (search-path-specification - (variable "C_INCLUDE_PATH") + (variable "CPATH") (files '("include"))) (search-path-specification (variable "CPLUS_INCLUDE_PATH") -- 2.7.3 --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0002-gnu-bootstrap-Add-i686-mingw.patch >From bca595306390b85c01bd226d6167b9336df1b59a Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Thu, 14 Apr 2016 07:27:07 +0200 Subject: [PATCH 2/9] gnu: bootstrap: Add i686-mingw. * gnu/packages/bootstrap.scm (glibc-dynamic-linker): Add i686-mingw. --- gnu/packages/bootstrap.scm | 1 + 1 file changed, 1 insertion(+) diff --git a/gnu/packages/bootstrap.scm b/gnu/packages/bootstrap.scm index 561de0d..02ed901 100644 --- a/gnu/packages/bootstrap.scm +++ b/gnu/packages/bootstrap.scm @@ -171,6 +171,7 @@ successful, or false to signal an error." ;; here just so we can keep going. ((string=? system "xtensa-elf") "no-ld.so") ((string=? system "avr") "no-ld.so") + ((string=? system "i686-mingw") "no-ld.so") (else (error "dynamic linker name not known for this system" system)))) -- 2.7.3 --=-=-= Content-Type: text/x-diff; charset=utf-8 Content-Disposition: inline; filename=0003-gnu-Add-mingw-w64.patch Content-Transfer-Encoding: quoted-printable >From 05413c7a4ba8bcef1e3129c93150ebd482c41ec3 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Thu, 14 Apr 2016 07:38:44 +0200 Subject: [PATCH 3/9] gnu: Add mingw-w64. * 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-system.am: Add them. --- gnu-system.am | 3 + gnu/packages/mingw.scm | 109 +++++++++++++++++= ++++ .../patches/gcc-4.9.3-mingw-gthr-default.patch | 11 +++ .../patches/mingw-w64-5.0rc2-gcc-4.9.3.patch | 38 +++++++ 4 files changed, 161 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-system.am b/gnu-system.am index d03ef7f..68f8267 100644 --- a/gnu-system.am +++ b/gnu-system.am @@ -223,6 +223,7 @@ GNU_SYSTEM_MODULES =3D \ 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 \ @@ -480,6 +481,7 @@ dist_patch_DATA =3D \ 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 =3D \ 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..56ea235 --- /dev/null +++ b/gnu/packages/mingw.scm @@ -0,0 +1,109 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright =C2=A9 2016 Jan Nieuwenhuizen +;;; +;;; 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 . + +(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/" + name "/" name "-release/" name "-v" version ".tar.bz2"= )) + (sha256 + (base32 "0imdary8j07if8ih73pfgxiclpf2ax8h3mz8mxln07i8sbbd30= c9")) + (patches (list + (search-patch "mingw-w64-5.0rc2-gcc-4.9.3.patch"))= ))) + (build-system gnu-build-system) + (search-paths + (list (search-path-specification + (variable "CROSS_CPATH") + (files '("include" "i686-w64-mingw32/include"))) + (search-path-specification + (variable "CROSS_LIBRARY_PATH") + (files + '("lib" "lib64" "i686-w64-mingw32/lib" "i686-w64-mingw32/lib6= 4"))))) + (native-inputs `(("xgcc-core" ,xgcc-core-i686-w64-mingw32) + ("xbinutils" ,xbinutils-i686-w64-mingw32) + ;; FIXME: these do not propagate along + ("gmp" ,gmp) + ("mpfr" ,mpfr) + ("mpc" ,mpc) + ("zlib" ,zlib))) + (arguments + `(#:configure-flags + '("--host=3Di686-w64-mingw32" + "--target=3Di686-w64-mingw32" + "--with-as=3Di686-w64-mingw32-as" + "--with-ld=3Di686-w64-mingw32-ld" + "--with-nm=3Di686-w64-mingw32-nm") + #:make-flags (list "DEFS=3D-DHAVE_CONFIG_H -D__MINGW_HAS_DXSDK=3D1") + #:tests? #f ;; FIXME: compiles and includes glibc headers + #:phases + (modify-phases %standard-phases + (add-before + 'configure 'setenv + (lambda _ + (let (;; FIXME: these do not propagate along + (xgcc-core (assoc-ref %build-inputs "xgcc-core")) + (xbinutils (assoc-ref %build-inputs "xbinutils")) + (gmp (assoc-ref %build-inputs "gmp")) + (mpfr (assoc-ref %build-inputs "mpfr")) + (mpc (assoc-ref %build-inputs "mpc")) + (zlib (assoc-ref %build-inputs "zlib")) + (mingw-headers (string-append (getcwd) "/mingw-w64-head= ers"))) + ;; FIXME: LD_LIBRARY_PATH does not propagate along + (setenv "LD_LIBRARY_PATH" + (string-append + gmp "/lib" + ":" mpfr "/lib" + ":" mpc "/lib" + ":" zlib "/lib")) + (format (current-error-port) "LD_LIBRARY_PATH:~a\n" (getenv= "LD_LIBRARY_PATH")) + (setenv "PATH" + (string-append xbinutils "/" "i686-w64-mingw32" "/b= in" + ":" (getenv "PATH"))) + (setenv "CPP" + (string-append xgcc-core "/bin/i686-w64-mingw32-cpp= ")) + (setenv "CROSS_CPATH" + (string-append + mingw-headers + ":" mingw-headers "/include" + ":" mingw-headers "/crt" + ":" mingw-headers "/defaults/include" + ":" mingw-headers "/direct-x/include")))))))) + (home-page "http://mingw.org") + (synopsis "Minimalist GNU for Windows") + (description "MinGW provides a complete Open Source programming tool s= et +which is suitable for the development of native MS-Windows applications, a= nd +which do 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/pa= ckages/patches/mingw-w64-5.0rc2-gcc-4.9.3.patch new file mode 100644 index 0000000..6048fb2 --- /dev/null +++ b/gnu/packages/patches/mingw-w64-5.0rc2-gcc-4.9.3.patch @@ -0,0 +1,38 @@ +--- mingw-w64-v5.0-rc2/mingw-w64-headers/include/winnt.h.orig 2016-03-30 2= 1:32:21.111586941 +0200 ++++ mingw-w64-v5.0-rc2/mingw-w64-headers/include/winnt.h 2016-03-30 21:31:= 53.607559496 +0200 +@@ -6895,7 +6895,7 @@ + DWORD Reg : 3; + DWORD R : 1; + DWORD L : 1; +- DWORD C : 1; ++ DWORD C_ : 1; + DWORD StackAdjust : 10; + } DUMMYSTRUCTNAME; + } DUMMYUNIONNAME; +--- mingw-w64-v5.0-rc2/mingw-w64-headers/crt/math.h.orig 2016-03-30 21:27:= 25.375475927 +0200 ++++ mingw-w64-v5.0-rc2/mingw-w64-headers/crt/math.h 2016-03-30 21:28:57.87= 1461798 +0200 +@@ -216,6 +216,7 @@ + #endif + } + ++#if 0 + __CRT_INLINE long double __cdecl fabsl (long double x) + { + #ifdef __arm__ +@@ -226,6 +227,7 @@ + return res; + #endif + } ++#endif + + __CRT_INLINE double __cdecl fabs (double x) + { +@@ -905,7 +907,7 @@ + /* 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) h= ypot ((double)x, (double)y);} + #endif + extern long double __cdecl hypotl (long double, long double); --=20 2.7.3 --=-=-= Content-Type: text/x-diff; charset=utf-8 Content-Disposition: inline; filename=0004-gnu-cross-build-i686-w64-mingw32-new-cross-target.patch Content-Transfer-Encoding: quoted-printable >From 67fd642293ebc0d88d6f691c2b6bc5ce55eefe36 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Thu, 14 Apr 2016 07:39:37 +0200 Subject: [PATCH 4/9] gnu: cross-build: i686-w64-mingw32: new cross target. * gnu/packages/cross-base.scm (cross-gcc-core): New variable. Minimal core gcc to cross-build a newlib/non-glibc libc, needed to build a full cross-gcc. --- gnu/packages/cross-base.scm | 242 ++++++++++++++++++++++++++++++++++++++++= ---- 1 file changed, 222 insertions(+), 20 deletions(-) diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm index f1ac2ea..bb0aae8 100644 --- a/gnu/packages/cross-base.scm +++ b/gnu/packages/cross-base.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright =C2=A9 2013, 2014, 2015, 2016 Ludovic Court=C3=A8s ;;; Copyright =C2=A9 2014, 2015 Mark H Weaver +;;; Copyright =C2=A9 2016 Jan Nieuwenhuizen ;;; ;;; This file is part of GNU Guix. ;;; @@ -18,13 +19,18 @@ ;;; along with GNU Guix. If not, see . =20 (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 linux) + #:use-module (gnu packages compression) #:use-module (gnu packages hurd) + #: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 +41,9 @@ #:use-module (ice-9 match) #:export (cross-binutils cross-libc - cross-gcc)) + cross-gcc + cross-gcc-core + cross-newlib?)) =20 (define %xgcc ;; GCC package used as the basis for cross-compilation. It doesn't have= to @@ -102,7 +110,7 @@ may be either a libc package or #f.)" `(append (list ,(string-append "--target=3D" target) ,@(if libc `( ;; Disable libcilkrts because it is not - ;; ported to GNU/Hurd.=20 + ;; ported to GNU/Hurd. "--disable-libcilkrts") `( ;; Disable features not needed at this sta= ge. "--disable-shared" "--enable-static" @@ -129,20 +137,46 @@ may be either a libc package or #f.)" "--disable-libitm" "--disable-libvtv" "--disable-libsanitizer" - ))) + )) + + ;; We need to build gcc+winpthreads with + ;; --enable-threads=3Dwin32 first, and only then + ;; (re)build gcc with --enable-threads=3Dposix. + ;; + ;; i686-w64-mingw32/libstdc++-v3/include/i686-w64-m= ingw32/bits/gthr-default.h:33:62: + ;; error: types may not be defined in casts + ;; #define CONST_CAST2(TOTYPE,FROMTYPE,X) ((__exten= sion__(union {FROMTYPE _q; TOTYPE _nq;})(X))._nq) + + ,@(if (and libc (equal? target "i686-w64-mingw32")) + ;;'("--with-threads=3Dwin32") + '() ;; + '()) + + ,@(if (cross-newlib? target) + '("--with-newlib" + "--without-headers") + '())) =20 ,(if libc flags `(remove (cut string-match "--enable-languages.*" <>) ,flags)))) ((#:make-flags flags) - (if libc + (cond + ((equal? target "i686-w64-mingw32") + `(append (let ((runtime (assoc-ref %build-inputs "mingw-w64"))) + (if runtime + (list + (string-append "FLAGS_FOR_TARGET=3D-B" runtime = "/lib")) + '())) + ,flags)) + (libc `(let ((libc (assoc-ref %build-inputs "libc"))) ;; FLAGS_FOR_TARGET are needed for the target libraries to = receive ;; the -Bxxx for the startfiles. (cons (string-append "FLAGS_FOR_TARGET=3D-B" libc "/lib") - ,flags)) - flags)) + ,flags))) + (else flags))) ((#:phases phases) (let ((phases `(alist-cons-after @@ -171,7 +205,44 @@ may be either a libc package or #f.)" ;; for cross-compilers. (zero? (system* "make" "install-strip"))) ,phases)))) - (if libc + (cond + ((equal? target "i686-w64-mingw32") + `(modify-phases ,phases + (add-before + 'configure 'set-cross-path + (lambda* (#:key inputs #:allow-other-keys) + ;; Add the cross Linux headers to CROSS_CPATH, and remo= ve them + ;; from CPATH. + (let ((libc (assoc-ref inputs "mingw-w64")) + (gcc (assoc-ref inputs "gcc"))) + (define (cross? x) + (format (current-error-port) "cross? remove ~a =3D>= ~a\n" x (and libc (string-prefix? libc x))) + (and libc (string-prefix? libc x))) + (if libc + (setenv "CROSS_CPATH" + (string-append + libc "/include" + ":" libc "/i686-w64-mingw32/include"))) + (if libc + (setenv "CROSS_LIBRARY_PATH" + (string-append + libc "/lib" + ":" libc "/i686-w64-mingw32/lib"))) + (setenv "CPP" (string-append gcc "/bin/cpp")) + (let ((cpath (search-path-as-string->list + (getenv "CPATH"))) + (libpath (search-path-as-string->list + (getenv "LIBRARY_PATH")))) + (setenv "CPATH" + (list->search-path-as-string + (remove cross? cpath) ":")) + (for-each unsetenv + '("C_INCLUDE_PATH" "CPLUS_INCLUDE_PATH")) + (setenv "LIBRARY_PATH" + (list->search-path-as-string + (remove cross? libpath) ":")) + #t)))))) + (libc `(alist-cons-before 'configure 'set-cross-path (lambda* (#:key inputs #:allow-other-keys) @@ -220,22 +291,31 @@ may be either a libc package or #f.)" (list->search-path-as-string (remove cross? libpath) ":")) #t))) - ,phases) - phases))))))) + ,phases)) + (else phases)))))))) =20 (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. (list (search-patch "ath9k-htc-firmware-gcc.patch"))) + ((equal? "i686-w64-mingw32" target) + (list (search-patch "gcc-4.9.3-mingw-gthr-default.patch"))) + (else '()))) + +(define (cross-gcc-snippet target) + "Return GCC snippet needed for TARGET." + (cond ((equal? "i686-w64-mingw32" target) + '(copy-recursively "libstdc++-v3/config/os/mingw32-w64" + "libstdc++-v3/config/os/newlib")) (else '()))) =20 (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." -=20=20 + (define (cross-kernel-headers target libc) "Return headers depending on TARGET." (match target @@ -243,7 +323,7 @@ GCC that does not target a libc; otherwise, target that= libc." (assoc-ref (package-propagated-inputs libc) "hurd-kernel-headers")) (_ (assoc-ref (package-propagated-inputs libc) "linux-headers")))) -=20=20 + (package (inherit %xgcc) (name (string-append "gcc-cross-" (if libc "" "sans-libc-") @@ -253,7 +333,10 @@ GCC that does not target a libc; otherwise, target tha= t 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)))) =20 ;; For simplicity, use a single output. Otherwise libgcc_s & co. are = not ;; found by default, etc. @@ -275,6 +358,7 @@ GCC that does not target a libc; otherwise, target that= libc." #:target target #:binutils xbinutils)) ("binutils-cross" ,xbinutils) + ("gcc" ,gcc) =20 ;; Call it differently so that the builder can check whether the "l= ibc" ;; input is #f. @@ -283,12 +367,16 @@ GCC that does not target a libc; otherwise, target th= at libc." ;; Remaining inputs. ,@(let ((inputs (append (package-inputs %xgcc) (alist-delete "libc" %final-inputs)))) - (if libc + (cond + ((equal? target "i686-w64-mingw32") + `(("mingw-w64" ,mingw-w64) + ,@inputs)) + (libc `(("libc" ,libc) ("xkernel-headers" ;the target headers ,@(cross-kernel-headers target libc)) - ,@inputs) - inputs)))) + ,@inputs)) + (else inputs))))) =20 (inputs '()) =20 @@ -302,6 +390,95 @@ GCC that does not target a libc; otherwise, target tha= t libc." (files '("lib" "lib64"))))) (native-search-paths '()))) =20 +(define* (cross-gcc-core target + #:optional (xbinutils (cross-binutils target))) + "Return a cross-compiler-core to be used to build the c library for TARG= ET, +where TARGET is a GNU triplet. Use XBINUTILS as the associated +cross-Binutils." + (package (inherit (cross-gcc target xbinutils)) + (name (string-append "gcc-core-cross-" target)) + (inputs `()) + ;; FIXME: no effect? must add inputs to mingw-source + (propagated-inputs + `(("gmp" ,gmp) + ("mpfr" ,mpfr) + ("mpc" ,mpc) + ("zlib" ,zlib))) + (native-inputs + `(("ld-wrapper-cross" ,(make-ld-wrapper + (string-append "ld-wrapper-" target) + #:target target + #:binutils xbinutils)) + ("cross-binutils" ,xbinutils) + ("make" ,gnu-make) + ("tar" ,tar) + ("xz" ,xz) + ("bash" ,bash) + ("glibc" ,glibc) + ("coreutils" ,coreutils) + ("sed" ,sed) + ("gcc" ,gcc) + ("binutils" ,binutils) + ("gawk" ,gawk) + ("grep" ,grep) + ("make" ,gnu-make) + ("bzip2" ,bzip2) + ("diffutils" ,diffutils) + ("gzip" ,gzip) + ,@(if (equal? target "i686-w64-mingw32") + `(("mingw-source" ,(package-source mingw-w64))) + '()))) + (arguments + (let ((args `(,@(package-arguments (cross-gcc target xbinutils= ))))) + (substitute-keyword-arguments args + ((#:configure-flags flags) + `(append (list + ,(string-append "--target=3D" target)) + (remove (cut string-match "--enable-languages.*"= <>) + (remove (cut string-match "--enable-thre= ads=3D*" <>) + ,flags)) + '("--with-newlib" + "--without-threads" + "--without-headers"))) + ((#:make-flags flags) + `(append '("all-gcc" "all-target-libgcc") + ,flags)) + ((#:phases phases) + `(modify-phases ,phases + (add-before + 'configure 'setenv + (lambda* (#:key outputs inputs #:allow-other-keys) + (let* ((gmp (assoc-ref inputs "gmp")) + (mpfr (assoc-ref inputs "mpfr")) + (mpc (assoc-ref inputs "mpc")) + (zlib (assoc-ref inputs "zlib"))) + (setenv "LD_LIBRARY_PATH" + (string-append + gmp "/lib" + ":" mpfr "/lib" + ":" mpc "/lib" + ":" zlib "/lib")) + (cond + ((equal? ,target "i686-w64-mingw32") + (let ((mingw-source (assoc-ref inputs "mingw-so= urce")) + (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 "/c= rt/_mingw.h") + (("@MINGW_HAS_SECURE_API@") "#define MINGW_= HAS_SECURE_API 1")) + (setenv "CROSS_CPATH" + (string-append + mingw-headers "/include" + ":" mingw-headers "/crt" + ":" mingw-headers "/defaults/include= ")))))))) + (replace 'install + (lambda _ + (zero? (system* "make" "install-gcc" "insta= ll-target-libgcc")))) + (delete 'make-cross-binutils-visible) + (delete 'validate-runpath)))))))) + (define* (cross-libc target #:optional (xgcc (cross-gcc target)) @@ -330,7 +507,7 @@ XBINUTILS and the cross tool chain." ("cross-binutils" ,xbinutils) ,@(package-native-inputs linux-libre-headers))))) =20 - (define xgnumach-headers + (define xgnumach-headers (package (inherit gnumach-headers) (name (string-append (package-name gnumach-headers) "-cross-" target)) @@ -453,6 +630,8 @@ XBINUTILS and the cross tool chain." ("cross-binutils" ,xbinutils) ("cross-mig" ,xmig) ,@(alist-delete "mig"(package-native-inputs glibc/= hurd)))))) + ((? cross-newlib?) + (cross-newlib? target)) (_ (package (inherit glibc) (name (string-append "glibc-cross-" target)) @@ -493,6 +672,14 @@ XBINUTILS and the cross tool chain." ,@(package-inputs glibc) ;FIXME: static-bash ,@(package-native-inputs glibc))))))) =20 +(define (native-libc target) + (if (equal? target "i686-w64-mingw32") mingw-w64 + glibc)) + +(define (cross-newlib? target) + (and (not (eq? (native-libc target) glibc)) + (native-libc target))) + ;;; ;;; Concrete cross toolchains. @@ -533,3 +720,18 @@ XBINUTILS and the cross tool chain." ;; (cross-gcc triplet ;; (cross-binutils triplet) ;; (cross-libc triplet)))) + +(define-public xgcc-core-i686-w64-mingw32 + (let ((triplet "i686-w64-mingw32")) + (cross-gcc-core 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)))) --=20 2.7.3 --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0005-gnu-gmp-build-shared-library-for-mingw.patch >From aaff9752fd10b7860bdba62fba3107fe8133367f Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Tue, 12 Apr 2016 15:22:51 +0200 Subject: [PATCH 5/9] gnu: gmp: build shared library for mingw. * gnu/packages/multiprecision.scm (gmp)[MINGW]: Use --enable-shared. --- gnu/packages/multiprecision.scm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gnu/packages/multiprecision.scm b/gnu/packages/multiprecision.scm index ad50770..6977f80 100644 --- a/gnu/packages/multiprecision.scm +++ b/gnu/packages/multiprecision.scm @@ -49,7 +49,11 @@ '(;; Build a "fat binary", with routines for several ;; sub-architectures. "--enable-fat" - "--enable-cxx"))) + "--enable-cxx" + ,@(cond ((equal? (%current-target-system) "i686-w64-mingw32") + `("--enable-shared" + "--disable-static")) + (else '()))))) (synopsis "Multiple-precision arithmetic library") (description "GMP is a library for arbitrary precision arithmetic, operating on -- 2.7.3 --=-=-= Content-Type: text/x-diff; charset=utf-8 Content-Disposition: inline; filename=0006-gnu-Add-libiconv.patch Content-Transfer-Encoding: quoted-printable >From 6e1d4f58d4a7dca54dbbfeacc45f187bf31451ba Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Tue, 12 Apr 2016 15:15:04 +0200 Subject: [PATCH 6/9] gnu: Add libiconv. * gnu/packages/libiconv.scm: New file. gnu-system.am: Add it. --- gnu-system.am | 1 + gnu/packages/libiconv.scm | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 gnu/packages/libiconv.scm diff --git a/gnu-system.am b/gnu-system.am index 68f8267..6c45fba 100644 --- a/gnu-system.am +++ b/gnu-system.am @@ -190,6 +190,7 @@ GNU_SYSTEM_MODULES =3D \ gnu/packages/libffi.scm \ gnu/packages/libftdi.scm \ gnu/packages/calendar.scm \ + gnu/packages/libiconv.scm \ gnu/packages/libidn.scm \ gnu/packages/libphidget.scm \ gnu/packages/libreoffice.scm \ diff --git a/gnu/packages/libiconv.scm b/gnu/packages/libiconv.scm new file mode 100644 index 0000000..9643747 --- /dev/null +++ b/gnu/packages/libiconv.scm @@ -0,0 +1,43 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright =C2=A9 2016 Jan Nieuwenhuizen +;;; +;;; 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 . + +(define-module (gnu packages libiconv) + #:use-module (guix licenses) + #:use-module (guix packages) + #:use-module (guix download) + #:use-module (guix build-system gnu)) + +(define-public libiconv + (package + (name "libiconv") + (version "1.14") + (source (origin + (method url-fetch) + (uri (string-append + "mirror://gnu/libiconv/libiconv-" + version ".tar.gz")) + (sha256 + (base32 + "04q6lgl3kglmmhw59igq1n7v3rp1rpkypl366cy1k1yn2znlvckj")))) + (build-system gnu-build-system) + (synopsis "character set conversion library") + (description + "GNU libiconv provides an iconv() implementation, for use on systems w= hich +don't have one, or whose implementation cannot convert from/to Unicode.") + (home-page "http://www.gnu.org/software/libiconv/") + (license lgpl3+))) --=20 2.7.3 --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0007-gnu-ncurses-support-mingw.patch >From 2e676615104f1605357eabe80fa7d716d80bc486 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Tue, 12 Apr 2016 15:24:53 +0200 Subject: [PATCH 7/9] gnu: ncurses: support mingw. * gnu/packages/patches/ncurses-mingw.patch: New file. * gnu/packages/ncurses.scm (ncurses)[MINGW]: Support mingw. --- gnu-system.am | 1 + gnu/packages/ncurses.scm | 42 ++++++++++++++++++++++++-------- gnu/packages/patches/ncurses-mingw.patch | 18 ++++++++++++++ 3 files changed, 51 insertions(+), 10 deletions(-) create mode 100644 gnu/packages/patches/ncurses-mingw.patch diff --git a/gnu-system.am b/gnu-system.am index 6c45fba..7b16d68 100644 --- a/gnu-system.am +++ b/gnu-system.am @@ -640,6 +640,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..1281af3 100644 --- a/gnu/packages/ncurses.scm +++ b/gnu/packages/ncurses.scm @@ -19,9 +19,11 @@ ;;; along with GNU Guix. If not, see . (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 @@ -86,6 +88,16 @@ (call-with-output-file lib.so (lambda (p) (format p "INPUT (-l~aw)~%" lib))))) + '("curses" "ncurses" "form" "panel" "menu"))) + (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))) '("curses" "ncurses" "form" "panel" "menu"))))))) (package (name "ncurses") @@ -94,6 +106,7 @@ (method url-fetch) (uri (string-append "mirror://gnu/ncurses/ncurses-" version ".tar.gz")) + (patches (list (search-patch "ncurses-mingw.patch"))) (sha256 (base32 "0q3jck7lna77z5r42f13c4xglc7azd19pxfrjrpgp2yf615w4lgm")))) @@ -102,23 +115,32 @@ "doc")) ;1 MiB of man pages (arguments `(#:configure-flags - `("--with-shared" "--without-debug" "--enable-widec" + (append + `("--with-shared" "--without-debug" "--enable-widec" - ;; By default headers land in an `ncursesw' subdir, which is not - ;; what users expect. - ,(string-append "--includedir=" (assoc-ref %outputs "out") - "/include") - "--enable-overwrite" ;really honor --includedir + ;; By default headers land in an `ncursesw' subdir, which is not + ;; what users expect. + ,(string-append "--includedir=" (assoc-ref %outputs "out") + "/include") + "--enable-overwrite" ;really honor --includedir - ;; Make sure programs like 'tic', 'reset', and 'clear' have a - ;; correct RUNPATH. - ,(string-append "LDFLAGS=-Wl,-rpath=" (assoc-ref %outputs "out") - "/lib")) + ;; Make sure programs like 'tic', 'reset', and 'clear' have a + ;; correct RUNPATH. + ,(string-append "LDFLAGS=-Wl,-rpath=" (assoc-ref %outputs "out") + "/lib")) + (cond ((equal? ,(%current-target-system) "i686-w64-mingw32") + '("--enable-term-driver" + "--without-cxx" + "--without-cxx-binding")) + (else '()))) #:tests? #f ; no "check" target #:phases (modify-phases %standard-phases (replace 'configure ,configure-phase) (add-after 'install 'post-install ,post-install-phase) + ,@(cond ((equal? (%current-target-system) "i686-w64-mingw32") + `((delete 'validate-runpath))) + (else '())) (add-before 'configure 'patch-makefile-SHELL ,patch-makefile-phase) (add-after 'unpack 'remove-unneeded-shebang diff --git a/gnu/packages/patches/ncurses-mingw.patch b/gnu/packages/patches/ncurses-mingw.patch new file mode 100644 index 0000000..9801a81 --- /dev/null +++ b/gnu/packages/patches/ncurses-mingw.patch @@ -0,0 +1,18 @@ +--- 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 --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0008-gnu-readline-support-mingw.patch >From f112c5d09b77b2d89cb5c002516c3e78a715d53f Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Tue, 12 Apr 2016 15:26:10 +0200 Subject: [PATCH 8/9] gnu: readline: support mingw. * gnu/packages/patches/readline-6.3-mingw.patch: New file. * gnu-system.am: Add it. * gnu/packages/readline.scm (readline): Support mingw. --- gnu-system.am | 1 + gnu/packages/patches/readline-6.3-mingw.patch | 126 ++++++++++++++++++++++++++ gnu/packages/readline.scm | 13 ++- 3 files changed, 136 insertions(+), 4 deletions(-) create mode 100644 gnu/packages/patches/readline-6.3-mingw.patch diff --git a/gnu-system.am b/gnu-system.am index 7b16d68..ba76020 100644 --- a/gnu-system.am +++ b/gnu-system.am @@ -725,6 +725,7 @@ dist_patch_DATA = \ gnu/packages/patches/qt4-ldflags.patch \ gnu/packages/patches/ratpoison-shell.patch \ gnu/packages/patches/readline-link-ncurses.patch \ + gnu/packages/patches/readline-6.3-mingw.patch \ gnu/packages/patches/ripperx-missing-file.patch \ gnu/packages/patches/rsem-makefile.patch \ gnu/packages/patches/sed-hurd-path-max.patch \ diff --git a/gnu/packages/patches/readline-6.3-mingw.patch b/gnu/packages/patches/readline-6.3-mingw.patch new file mode 100644 index 0000000..8ad036c --- /dev/null +++ b/gnu/packages/patches/readline-6.3-mingw.patch @@ -0,0 +1,126 @@ +Mingw lacks some SIG*. Taken from + + wget https://raw.githubusercontent.com/Alexpux/MINGW-packages/master/mingw-w64-readline/readline-6.3-mingw.patch + +some updates to make it apply. + +--- colors.c~ 2013-03-20 11:19:08.000000000 -0400 ++++ colors.c 2015-07-20 12:44:31.821014500 -0400 +@@ -37,6 +37,10 @@ + #include "posixstat.h" // stat related macros (S_ISREG, ...) + #include // S_ISUID + ++#ifndef S_ISDIR ++#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) ++#endif ++ + // strlen() + #if defined (HAVE_STRING_H) + # include +@@ -151,12 +155,17 @@ + if (S_ISREG (mode)) + { + colored_filetype = C_FILE; +- ++#ifdef S_ISUID + if ((mode & S_ISUID) != 0 && is_colored (C_SETUID)) + colored_filetype = C_SETUID; +- else if ((mode & S_ISGID) != 0 && is_colored (C_SETGID)) ++ else ++#endif ++#ifdef S_ISGID ++ if ((mode & S_ISGID) != 0 && is_colored (C_SETGID)) + colored_filetype = C_SETGID; +- else if (is_colored (C_CAP) && 0) //f->has_capability) ++ else ++#endif ++ if (is_colored (C_CAP) && 0) //f->has_capability) + colored_filetype = C_CAP; + else if ((mode & S_IXUGO) != 0 && is_colored (C_EXEC)) + colored_filetype = C_EXEC; +@@ -180,15 +189,19 @@ + colored_filetype = C_STICKY; + #endif + } ++ #ifdef S_ISLNK + else if (S_ISLNK (mode)) + colored_filetype = ((linkok == 0 + && (!strncmp (_rl_color_indicator[C_LINK].string, "target", 6) + || _rl_color_indicator[C_ORPHAN].string)) + ? C_ORPHAN : C_LINK); ++ #endif + else if (S_ISFIFO (mode)) + colored_filetype = C_FIFO; ++ #ifdef S_ISSOCK + else if (S_ISSOCK (mode)) + colored_filetype = C_SOCK; ++#endif + else if (S_ISBLK (mode)) + colored_filetype = C_BLK; + else if (S_ISCHR (mode)) +--- signals.c~ 2014-01-10 15:06:48.000000000 -0500 ++++ signals.c 2015-07-20 12:33:07.437472100 -0400 +@@ -216,7 +216,9 @@ + /* FALLTHROUGH */ + + case SIGTERM: ++#if defined (SIGHUP) + case SIGHUP: ++#endif + #if defined (SIGTSTP) + case SIGTSTP: + case SIGTTOU: +@@ -397,7 +399,9 @@ + + sigaddset (&bset, SIGINT); + sigaddset (&bset, SIGTERM); ++#ifdef SIGHUP + sigaddset (&bset, SIGHUP); ++#endif + #if defined (SIGQUIT) + sigaddset (&bset, SIGQUIT); + #endif +@@ -426,7 +430,9 @@ + + rl_maybe_set_sighandler (SIGINT, rl_signal_handler, &old_int); + rl_maybe_set_sighandler (SIGTERM, rl_signal_handler, &old_term); ++#ifdef SIGHUP + rl_maybe_set_sighandler (SIGHUP, rl_signal_handler, &old_hup); ++#endif + #if defined (SIGQUIT) + rl_maybe_set_sighandler (SIGQUIT, rl_signal_handler, &old_quit); + #endif +@@ -491,7 +497,9 @@ + overhead */ + rl_maybe_restore_sighandler (SIGINT, &old_int); + rl_maybe_restore_sighandler (SIGTERM, &old_term); ++#ifdef SIGHUP + rl_maybe_restore_sighandler (SIGHUP, &old_hup); ++#endif + #if defined (SIGQUIT) + rl_maybe_restore_sighandler (SIGQUIT, &old_quit); + #endif +--- input.c~ 1970-01-01 01:00:00.000000000 +0100 ++++ input.c 2016-04-01 20:13:24.293063372 +0200 +@@ -532,11 +532,18 @@ + Otherwise (not EINTR), some error occurred, also signifying EOF. */ + if (errno != EINTR) + return (RL_ISSTATE (RL_STATE_READCMD) ? READERR : EOF); +- else if (_rl_caught_signal == SIGHUP || _rl_caught_signal == SIGTERM) ++ else if ( ++#ifdef SIGHUP ++ _rl_caught_signal == SIGHUP || ++#endif ++ _rl_caught_signal == SIGTERM) + return (RL_ISSTATE (RL_STATE_READCMD) ? READERR : EOF); +- else if (_rl_caught_signal == SIGINT || _rl_caught_signal == SIGQUIT) ++ else if (_rl_caught_signal == SIGINT ++#ifdef SIGQUIT ++ || _rl_caught_signal == SIGQUIT ++#endif ++ ) + RL_CHECK_SIGNALS (); +- + if (rl_signal_event_hook) + (*rl_signal_event_hook) (); + } diff --git a/gnu/packages/readline.scm b/gnu/packages/readline.scm index 13ce916..369b00b 100644 --- a/gnu/packages/readline.scm +++ b/gnu/packages/readline.scm @@ -46,21 +46,26 @@ (sha256 (base32 "0hzxr9jxqqx5sxsv9vmlxdnvlr9vi4ih1avjb869hbs6p5qn1fjn")) - (patches (list (search-patch "readline-link-ncurses.patch"))) + (patches (list (search-patch "readline-link-ncurses.patch") + (search-patch "readline-6.3-mingw.patch"))) (patch-flags '("-p0")))) (build-system gnu-build-system) (propagated-inputs `(("ncurses" ,ncurses))) (arguments `(#:configure-flags (list (string-append "LDFLAGS=-Wl,-rpath -Wl," (assoc-ref %build-inputs "ncurses") - "/lib") + ,(if (equal? (%current-target-system) "i686-w64-mingw32") "/bin" + "/lib")) ;; This test does an 'AC_TRY_RUN', which aborts when ;; cross-compiling, so provide the correct answer. ,@(if (%current-target-system) - '("bash_cv_wcwidth_broken=no") + '("bash_cv_wcwidth_broken=no" + "bash_cv_termcap_lib=ncurses") '())) - + #:make-flags (list ,@(if (%current-target-system) + '("TERMCAP_LIB=-lncurses") + '())) #:phases (alist-cons-after 'install 'post-install ,post-install-phase -- 2.7.3 --=-=-= Content-Type: text/x-diff; charset=utf-8 Content-Disposition: inline; filename=0009-gnu-guile-2.0-support-mingw.-WIP-builds-links-segfau.patch Content-Transfer-Encoding: quoted-printable >From 1f513d155890453948c6599e57cc2bb384effbb8 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Tue, 12 Apr 2016 15:27:33 +0200 Subject: [PATCH 9/9] gnu: guile-2.0: support mingw. WIP, builds, links, segfaults. * gnu/packages/patches/guile-remove-utf8.patch: New file. * gnu-system.am: Add it. * gnu/packages/guile.scm (guile-2.0): Support mingw. --- gnu/packages/guile.scm | 60 ++++++++++++++++++++++++= +--- gnu/packages/patches/guile-remove-utf8.patch | 16 ++++++++ 2 files changed, 71 insertions(+), 5 deletions(-) create mode 100644 gnu/packages/patches/guile-remove-utf8.patch diff --git a/gnu/packages/guile.scm b/gnu/packages/guile.scm index fe043cb..bfde659 100644 --- a/gnu/packages/guile.scm +++ b/gnu/packages/guile.scm @@ -30,6 +30,7 @@ #:use-module (gnu packages libffi) #:use-module (gnu packages autotools) #:use-module (gnu packages flex) + #:use-module (gnu packages libiconv) #:use-module (gnu packages libunistring) #:use-module (gnu packages linux) #:use-module (gnu packages m4) @@ -132,13 +133,19 @@ without requiring the source code to be rewritten.") (sha256 (base32 "1qh3j7308qvsjgwf7h94yqgckpbgz2k3yqdkzsyhqcafvfka9l5f")) - (patches (list (search-patch "guile-arm-fixes.patch"))))) + (patches (list (search-patch "guile-arm-fixes.patch") + (search-patch "guile-remove-utf8.patch"))))) (build-system gnu-build-system) - (native-inputs `(("pkgconfig" ,pkg-config))) + (native-inputs `(("pkgconfig" ,pkg-config) + ,@(if (equal? (%current-target-system) "i686-w64-mingw= 32") + `(("bash" ,bash) + ("guile" ,guile-2.0)) + '()))) (inputs `(("libffi" ,libffi) ("readline" ,readline) - ("bash" ,bash))) - + ,@(if (equal? (%current-target-system) "i686-w64-mingw32") + `(("libiconv" ,libiconv)) + `(("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,7 +174,11 @@ 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 (equal? (%current-target-system) "i686-w64-min= gw32") + "cmd.exe" + `(if bash + (string-append bash "/bin/bash") + "bash")))))) %standard-phases))) =20 (native-search-paths @@ -194,6 +205,45 @@ without requiring the source code to be rewritten.") ;; in the `base' module, and thus changing it entails a full rebuild. guile-2.0) =20 +(define-public cross-guile + (package + (inherit guile-2.0) + (name "cross-guile") + (version "2.0.11") + + (source (origin + (method url-fetch) + (uri (string-append "mirror://gnu/guile/guile-" version + ".tar.xz")) + (sha256 + (base32 + "1qh3j7308qvsjgwf7h94yqgckpbgz2k3yqdkzsyhqcafvfka9l5f")) + (patches (list (search-patch "guile-arm-fixes.patch") + (search-patch "guile-remove-utf8.patch"))))) +=20=20=20 + (self-native-input? #f) + (native-inputs `(("bash" ,bash) + ("guile" ,guile-2.0) + ("pkgconfig" ,pkg-config))) + + (inputs `(("libffi" ,libffi) + ("readline" ,readline) + ,@(if (equal? (%current-target-system) "i686-w64-mingw32") + `(("libiconv" ,libiconv)) + `(("bash" ,bash))))) + (arguments + `(#:phases (modify-phases %standard-phases + (add-before 'configure 'pre-configure + (lambda* (#:key inputs #:allow-other-keys) + (let ((bash (assoc-ref inputs "bash"))) + (substitute* "module/ice-9/popen.scm" + (("/bin/sh") + ,(if (equal? (%current-target-system) "i686-w64= -mingw32") + "cmd.exe" + (if bash + (string-append bash "/bin/bash") + "bash")))))))))))) + (define-public guile-next (package (inherit guile-2.0) (name "guile-next") diff --git a/gnu/packages/patches/guile-remove-utf8.patch b/gnu/packages/pa= tches/guile-remove-utf8.patch new file mode 100644 index 0000000..da195c0 --- /dev/null +++ b/gnu/packages/patches/guile-remove-utf8.patch @@ -0,0 +1,16 @@ +--- guile-2.0.11/libguile/Makefile.in.orig 2016-04-11 07:46:38.792593661 += 0200 ++++ guile-2.0.11/libguile/Makefile.in 2016-04-11 07:55:44.410618808 +0200 +@@ -3735,11 +3735,11 @@ + flex -t $(srcdir)/c-tokenize.lex > $@ || { rm $@; false; } +=20 + # This page is for maintenance of the lists of CPP symbols that are event= ually +-# included in error.c (=E2=80=98errno=E2=80=99 values: E*) and posix.c (s= ignal names: SIG*), ++# included in error.c (`errno' values: E*) and posix.c (signal names: SIG= *), + # in the funcs scm_init_{error,posix}, respectively. + # + # The lists (files cpp-{E,SIG}.syms) are not included verbatim, but proce= ssed +-# (via pattern rule =E2=80=98.syms.c=E2=80=99 below) so that each CPP sym= bol is transformed to ++# (via pattern rule `.syms.c' below) so that each CPP symbol is transform= ed to + # fragment of #ifdef'd C code that defines a Scheme variable of the same = name. + # The resulting files, cpp-{E,SIG}.c, are the ones #include:d. + # --=20 2.7.3 --=-=-= Content-Type: text/plain on wip-hurd, replace 0004 with this: --=-=-= Content-Type: text/x-diff; charset=utf-8 Content-Disposition: inline; filename=0004-gnu-cross-build-i686-w64-mingw32-new-cross-target.patch Content-Transfer-Encoding: quoted-printable >From 67fd642293ebc0d88d6f691c2b6bc5ce55eefe36 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Thu, 14 Apr 2016 07:39:37 +0200 Subject: [PATCH 4/9] gnu: cross-build: i686-w64-mingw32: new cross target. * gnu/packages/cross-base.scm (cross-gcc-core): New variable. Minimal core gcc to cross-build a newlib/non-glibc libc, needed to build a full cross-gcc. --- gnu/packages/cross-base.scm | 242 ++++++++++++++++++++++++++++++++++++++++= ---- 1 file changed, 222 insertions(+), 20 deletions(-) diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm index f1ac2ea..bb0aae8 100644 --- a/gnu/packages/cross-base.scm +++ b/gnu/packages/cross-base.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright =C2=A9 2013, 2014, 2015, 2016 Ludovic Court=C3=A8s ;;; Copyright =C2=A9 2014, 2015 Mark H Weaver +;;; Copyright =C2=A9 2016 Jan Nieuwenhuizen ;;; ;;; This file is part of GNU Guix. ;;; @@ -18,13 +19,18 @@ ;;; along with GNU Guix. If not, see . =20 (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 linux) + #:use-module (gnu packages compression) #:use-module (gnu packages hurd) + #: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 +41,9 @@ #:use-module (ice-9 match) #:export (cross-binutils cross-libc - cross-gcc)) + cross-gcc + cross-gcc-core + cross-newlib?)) =20 (define %xgcc ;; GCC package used as the basis for cross-compilation. It doesn't have= to @@ -102,7 +110,7 @@ may be either a libc package or #f.)" `(append (list ,(string-append "--target=3D" target) ,@(if libc `( ;; Disable libcilkrts because it is not - ;; ported to GNU/Hurd.=20 + ;; ported to GNU/Hurd. "--disable-libcilkrts") `( ;; Disable features not needed at this sta= ge. "--disable-shared" "--enable-static" @@ -129,20 +137,46 @@ may be either a libc package or #f.)" "--disable-libitm" "--disable-libvtv" "--disable-libsanitizer" - ))) + )) + + ;; We need to build gcc+winpthreads with + ;; --enable-threads=3Dwin32 first, and only then + ;; (re)build gcc with --enable-threads=3Dposix. + ;; + ;; i686-w64-mingw32/libstdc++-v3/include/i686-w64-m= ingw32/bits/gthr-default.h:33:62: + ;; error: types may not be defined in casts + ;; #define CONST_CAST2(TOTYPE,FROMTYPE,X) ((__exten= sion__(union {FROMTYPE _q; TOTYPE _nq;})(X))._nq) + + ,@(if (and libc (equal? target "i686-w64-mingw32")) + ;;'("--with-threads=3Dwin32") + '() ;; + '()) + + ,@(if (cross-newlib? target) + '("--with-newlib" + "--without-headers") + '())) =20 ,(if libc flags `(remove (cut string-match "--enable-languages.*" <>) ,flags)))) ((#:make-flags flags) - (if libc + (cond + ((equal? target "i686-w64-mingw32") + `(append (let ((runtime (assoc-ref %build-inputs "mingw-w64"))) + (if runtime + (list + (string-append "FLAGS_FOR_TARGET=3D-B" runtime = "/lib")) + '())) + ,flags)) + (libc `(let ((libc (assoc-ref %build-inputs "libc"))) ;; FLAGS_FOR_TARGET are needed for the target libraries to = receive ;; the -Bxxx for the startfiles. (cons (string-append "FLAGS_FOR_TARGET=3D-B" libc "/lib") - ,flags)) - flags)) + ,flags))) + (else flags))) ((#:phases phases) (let ((phases `(alist-cons-after @@ -171,7 +205,44 @@ may be either a libc package or #f.)" ;; for cross-compilers. (zero? (system* "make" "install-strip"))) ,phases)))) - (if libc + (cond + ((equal? target "i686-w64-mingw32") + `(modify-phases ,phases + (add-before + 'configure 'set-cross-path + (lambda* (#:key inputs #:allow-other-keys) + ;; Add the cross Linux headers to CROSS_CPATH, and remo= ve them + ;; from CPATH. + (let ((libc (assoc-ref inputs "mingw-w64")) + (gcc (assoc-ref inputs "gcc"))) + (define (cross? x) + (format (current-error-port) "cross? remove ~a =3D>= ~a\n" x (and libc (string-prefix? libc x))) + (and libc (string-prefix? libc x))) + (if libc + (setenv "CROSS_CPATH" + (string-append + libc "/include" + ":" libc "/i686-w64-mingw32/include"))) + (if libc + (setenv "CROSS_LIBRARY_PATH" + (string-append + libc "/lib" + ":" libc "/i686-w64-mingw32/lib"))) + (setenv "CPP" (string-append gcc "/bin/cpp")) + (let ((cpath (search-path-as-string->list + (getenv "CPATH"))) + (libpath (search-path-as-string->list + (getenv "LIBRARY_PATH")))) + (setenv "CPATH" + (list->search-path-as-string + (remove cross? cpath) ":")) + (for-each unsetenv + '("C_INCLUDE_PATH" "CPLUS_INCLUDE_PATH")) + (setenv "LIBRARY_PATH" + (list->search-path-as-string + (remove cross? libpath) ":")) + #t)))))) + (libc `(alist-cons-before 'configure 'set-cross-path (lambda* (#:key inputs #:allow-other-keys) @@ -220,22 +291,31 @@ may be either a libc package or #f.)" (list->search-path-as-string (remove cross? libpath) ":")) #t))) - ,phases) - phases))))))) + ,phases)) + (else phases)))))))) =20 (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. (list (search-patch "ath9k-htc-firmware-gcc.patch"))) + ((equal? "i686-w64-mingw32" target) + (list (search-patch "gcc-4.9.3-mingw-gthr-default.patch"))) + (else '()))) + +(define (cross-gcc-snippet target) + "Return GCC snippet needed for TARGET." + (cond ((equal? "i686-w64-mingw32" target) + '(copy-recursively "libstdc++-v3/config/os/mingw32-w64" + "libstdc++-v3/config/os/newlib")) (else '()))) =20 (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." -=20=20 + (define (cross-kernel-headers target libc) "Return headers depending on TARGET." (match target @@ -243,7 +323,7 @@ GCC that does not target a libc; otherwise, target that= libc." (assoc-ref (package-propagated-inputs libc) "hurd-kernel-headers")) (_ (assoc-ref (package-propagated-inputs libc) "linux-headers")))) -=20=20 + (package (inherit %xgcc) (name (string-append "gcc-cross-" (if libc "" "sans-libc-") @@ -253,7 +333,10 @@ GCC that does not target a libc; otherwise, target tha= t 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)))) =20 ;; For simplicity, use a single output. Otherwise libgcc_s & co. are = not ;; found by default, etc. @@ -275,6 +358,7 @@ GCC that does not target a libc; otherwise, target that= libc." #:target target #:binutils xbinutils)) ("binutils-cross" ,xbinutils) + ("gcc" ,gcc) =20 ;; Call it differently so that the builder can check whether the "l= ibc" ;; input is #f. @@ -283,12 +367,16 @@ GCC that does not target a libc; otherwise, target th= at libc." ;; Remaining inputs. ,@(let ((inputs (append (package-inputs %xgcc) (alist-delete "libc" %final-inputs)))) - (if libc + (cond + ((equal? target "i686-w64-mingw32") + `(("mingw-w64" ,mingw-w64) + ,@inputs)) + (libc `(("libc" ,libc) ("xkernel-headers" ;the target headers ,@(cross-kernel-headers target libc)) - ,@inputs) - inputs)))) + ,@inputs)) + (else inputs))))) =20 (inputs '()) =20 @@ -302,6 +390,95 @@ GCC that does not target a libc; otherwise, target tha= t libc." (files '("lib" "lib64"))))) (native-search-paths '()))) =20 +(define* (cross-gcc-core target + #:optional (xbinutils (cross-binutils target))) + "Return a cross-compiler-core to be used to build the c library for TARG= ET, +where TARGET is a GNU triplet. Use XBINUTILS as the associated +cross-Binutils." + (package (inherit (cross-gcc target xbinutils)) + (name (string-append "gcc-core-cross-" target)) + (inputs `()) + ;; FIXME: no effect? must add inputs to mingw-source + (propagated-inputs + `(("gmp" ,gmp) + ("mpfr" ,mpfr) + ("mpc" ,mpc) + ("zlib" ,zlib))) + (native-inputs + `(("ld-wrapper-cross" ,(make-ld-wrapper + (string-append "ld-wrapper-" target) + #:target target + #:binutils xbinutils)) + ("cross-binutils" ,xbinutils) + ("make" ,gnu-make) + ("tar" ,tar) + ("xz" ,xz) + ("bash" ,bash) + ("glibc" ,glibc) + ("coreutils" ,coreutils) + ("sed" ,sed) + ("gcc" ,gcc) + ("binutils" ,binutils) + ("gawk" ,gawk) + ("grep" ,grep) + ("make" ,gnu-make) + ("bzip2" ,bzip2) + ("diffutils" ,diffutils) + ("gzip" ,gzip) + ,@(if (equal? target "i686-w64-mingw32") + `(("mingw-source" ,(package-source mingw-w64))) + '()))) + (arguments + (let ((args `(,@(package-arguments (cross-gcc target xbinutils= ))))) + (substitute-keyword-arguments args + ((#:configure-flags flags) + `(append (list + ,(string-append "--target=3D" target)) + (remove (cut string-match "--enable-languages.*"= <>) + (remove (cut string-match "--enable-thre= ads=3D*" <>) + ,flags)) + '("--with-newlib" + "--without-threads" + "--without-headers"))) + ((#:make-flags flags) + `(append '("all-gcc" "all-target-libgcc") + ,flags)) + ((#:phases phases) + `(modify-phases ,phases + (add-before + 'configure 'setenv + (lambda* (#:key outputs inputs #:allow-other-keys) + (let* ((gmp (assoc-ref inputs "gmp")) + (mpfr (assoc-ref inputs "mpfr")) + (mpc (assoc-ref inputs "mpc")) + (zlib (assoc-ref inputs "zlib"))) + (setenv "LD_LIBRARY_PATH" + (string-append + gmp "/lib" + ":" mpfr "/lib" + ":" mpc "/lib" + ":" zlib "/lib")) + (cond + ((equal? ,target "i686-w64-mingw32") + (let ((mingw-source (assoc-ref inputs "mingw-so= urce")) + (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 "/c= rt/_mingw.h") + (("@MINGW_HAS_SECURE_API@") "#define MINGW_= HAS_SECURE_API 1")) + (setenv "CROSS_CPATH" + (string-append + mingw-headers "/include" + ":" mingw-headers "/crt" + ":" mingw-headers "/defaults/include= ")))))))) + (replace 'install + (lambda _ + (zero? (system* "make" "install-gcc" "insta= ll-target-libgcc")))) + (delete 'make-cross-binutils-visible) + (delete 'validate-runpath)))))))) + (define* (cross-libc target #:optional (xgcc (cross-gcc target)) @@ -330,7 +507,7 @@ XBINUTILS and the cross tool chain." ("cross-binutils" ,xbinutils) ,@(package-native-inputs linux-libre-headers))))) =20 - (define xgnumach-headers + (define xgnumach-headers (package (inherit gnumach-headers) (name (string-append (package-name gnumach-headers) "-cross-" target)) @@ -453,6 +630,8 @@ XBINUTILS and the cross tool chain." ("cross-binutils" ,xbinutils) ("cross-mig" ,xmig) ,@(alist-delete "mig"(package-native-inputs glibc/= hurd)))))) + ((? cross-newlib?) + (cross-newlib? target)) (_ (package (inherit glibc) (name (string-append "glibc-cross-" target)) @@ -493,6 +672,14 @@ XBINUTILS and the cross tool chain." ,@(package-inputs glibc) ;FIXME: static-bash ,@(package-native-inputs glibc))))))) =20 +(define (native-libc target) + (if (equal? target "i686-w64-mingw32") mingw-w64 + glibc)) + +(define (cross-newlib? target) + (and (not (eq? (native-libc target) glibc)) + (native-libc target))) + ;;; ;;; Concrete cross toolchains. @@ -533,3 +720,18 @@ XBINUTILS and the cross tool chain." ;; (cross-gcc triplet ;; (cross-binutils triplet) ;; (cross-libc triplet)))) + +(define-public xgcc-core-i686-w64-mingw32 + (let ((triplet "i686-w64-mingw32")) + (cross-gcc-core 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)))) --=20 2.7.3 --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable --=20 Jan Nieuwenhuizen | GNU LilyPond http://lilypond.org Freelance IT http://JoyofSource.com | Avatar=C2=AE http://AvatarAcademy.nl= =20=20 --=-=-=--