* rfc/rfh: i686-w64-mingw32 cross target @ 2016-03-26 17:38 Jan Nieuwenhuizen 2016-03-27 14:20 ` [RFCv2] build: i686-w64-mingw32: new " Jan Nieuwenhuizen 2016-03-31 20:16 ` rfc/rfh: i686-w64-mingw32 " Ricardo Wurmus 0 siblings, 2 replies; 18+ messages in thread From: Jan Nieuwenhuizen @ 2016-03-26 17:38 UTC (permalink / raw) To: guix-devel [-- Attachment #1: Type: text/plain, Size: 1752 bytes --] Hi, I'm working on a cross target in an effort to get rid of GUB 1) in favour of Guix and could do with some help. I have just succeeded in cross-building hello and running it, doing 18:18:36 janneke@drakenvlieg:~/src/mingw-guix $ ./pre-inst-env guix build --keep-failed --target=i686-w64-mingw32 hello /gnu/store/6556syz1732jnffnp0njikr5g6diqvch-hello-2.10 18:18:36 janneke@drakenvlieg:~/src/mingw-guix $ /gnu/store/5y252qkblhpj639g3bnrc671mz8x920w-profile/bin/wine /gnu/store/6556syz1732jnffnp0njikr5g6diqvch-hello-2.10/bin/hello.exe Hello, world! 18:18:39 janneke@drakenvlieg:~/src/mingw-guix See https://github.com/janneke/guix/tree/wip-mingw32 or attached patch. This platform does not have glibc, it uses --with-newlib and I'm not sure how to fit that in. In a couple of places I have changed (if libc A B) into (cond ((equal? target "i686-w64-mingw32") .. specific code) (libc A) (else B)) and I'm wondering whether to create a `newlib' category, or try to fit newlib into libc somehow, or...any ideas welcome. I was hoping to have (cross-libc <target>) evaluate to i686-w64-mingw32-runtime, but am puzzled by the effect of this code in gnu.scm (standard-cross-packages): `(("cross-gcc" ,(gcc target (binutils target) (if (equal? target "i686-w64-mingw32") #f ;;(module-ref cross 'i686-w64-mingw32-runtime) (libc target)))) unless I use #f here, guix wants to build a cross gcc WITH glibc, instead of using the sans-libc variant. Anaway, I am using a precompiled binary mingw runtime, as a next step I'll be looking into building that from source. Greetings, Jan 1) GUB -- http://lilypond.org/gub/ [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 0001-i686-w64-mingw32-new-cross-target.-WIP.patch --] [-- Type: text/x-diff, Size: 33200 bytes --] From 65917cb25c496219af0c118a6cd6664646839db4 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen <janneke@gnu.org> Date: Fri, 25 Mar 2016 08:03:54 +0100 Subject: [PATCH] i686-w64-mingw32: new cross target. WIP --- gnu/packages/bootstrap.scm | 1 + gnu/packages/cross-base.scm | 594 ++++++++++++++++++++++++++------------------ guix/build-system/gnu.scm | 4 +- 3 files changed, 352 insertions(+), 247 deletions(-) diff --git a/gnu/packages/bootstrap.scm b/gnu/packages/bootstrap.scm index f5bf069..979ab1d 100644 --- a/gnu/packages/bootstrap.scm +++ b/gnu/packages/bootstrap.scm @@ -171,6 +171,7 @@ successful, or false to signal an error." ;; here just so we can keep going. ((string=? system "xtensa-elf") "no-ld.so") ((string=? system "avr") "no-ld.so") + ((string=? system "i686-mingw") "no-ld.so") (else (error "dynamic linker name not known for this system" system)))) diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm index 8bd599c..e2b1dd1 100644 --- a/gnu/packages/cross-base.scm +++ b/gnu/packages/cross-base.scm @@ -23,6 +23,7 @@ #:use-module (gnu packages gcc) #:use-module (gnu packages base) #:use-module (gnu packages commencement) + #:use-module (gnu packages compression) #:use-module (gnu packages linux) #:use-module (guix packages) #:use-module (guix download) @@ -43,38 +44,38 @@ (define (cross p target) (package (inherit p) - (name (string-append (package-name p) "-cross-" target)) - (arguments - (substitute-keyword-arguments (package-arguments p) - ((#:configure-flags flags) - `(cons ,(string-append "--target=" target) - ,flags)))))) + (name (string-append (package-name p) "-cross-" target)) + (arguments + (substitute-keyword-arguments (package-arguments p) + ((#:configure-flags flags) + `(cons ,(string-append "--target=" target) + ,flags)))))) (define (package-with-patch original patch) "Return package ORIGINAL with PATCH applied." (package (inherit original) - (source (origin (inherit (package-source original)) - (patches (list patch)))))) + (source (origin (inherit (package-source original)) + (patches (list patch)))))) (define (cross-binutils target) "Return a cross-Binutils for TARGET." (let ((binutils (package (inherit binutils) - (arguments - (substitute-keyword-arguments (package-arguments - binutils) - ((#:configure-flags flags) - ;; Build with `--with-sysroot' so that ld honors - ;; DT_RUNPATH entries when searching for a needed - ;; library. This works because as a side effect - ;; `genscripts.sh' sets `USE_LIBPATH=yes', which tells - ;; elf32.em to use DT_RUNPATH in its search list. - ;; See <http://sourceware.org/ml/binutils/2013-05/msg00312.html>. - ;; - ;; In theory choosing / as the sysroot could lead ld - ;; to pick up native libs instead of target ones. In - ;; practice the RUNPATH of target libs only refers to - ;; target libs, not native libs, so this is safe. - `(cons "--with-sysroot=/" ,flags))))))) + (arguments + (substitute-keyword-arguments (package-arguments + binutils) + ((#:configure-flags flags) + ;; Build with `--with-sysroot' so that ld honors + ;; DT_RUNPATH entries when searching for a needed + ;; library. This works because as a side effect + ;; `genscripts.sh' sets `USE_LIBPATH=yes', which tells + ;; elf32.em to use DT_RUNPATH in its search list. + ;; See <http://sourceware.org/ml/binutils/2013-05/msg00312.html>. + ;; + ;; In theory choosing / as the sysroot could lead ld + ;; to pick up native libs instead of target ones. In + ;; practice the RUNPATH of target libs only refers to + ;; target libs, not native libs, so this is safe. + `(cons "--with-sysroot=/" ,flags))))))) ;; For Xtensa, apply Qualcomm's patch. (cross (if (string-prefix? "xtensa-" target) @@ -95,107 +96,152 @@ may be either a libc package or #f.)" ;; <http://lists.fedoraproject.org/pipermail/arm/2010-August/000663.html> ;; for instance. (let ((args `(#:strip-binaries? #f - ,@(package-arguments %xgcc)))) - (substitute-keyword-arguments args - ((#:configure-flags flags) - `(append (list ,(string-append "--target=" target) - ,@(if libc - `( ;; Disable libcilkrts because it is not - ;; ported to GNU/Hurd. - "--disable-libcilkrts") - `( ;; Disable features not needed at this stage. - "--disable-shared" "--enable-static" - "--enable-languages=c,c++" - - ;; libstdc++ cannot be built at this stage - ;; ("Link tests are not allowed after - ;; GCC_NO_EXECUTABLES."). - "--disable-libstdc++-v3" - - "--disable-threads" ;libgcc, would need libc - "--disable-libatomic" - "--disable-libmudflap" - "--disable-libgomp" - "--disable-libssp" - "--disable-libquadmath" - "--disable-decimal-float" ;would need libc - "--disable-libcilkrts" - ))) - - ,(if libc - flags - `(remove (cut string-match "--enable-languages.*" <>) - ,flags)))) - ((#:make-flags flags) - (if libc - `(let ((libc (assoc-ref %build-inputs "libc"))) - ;; FLAGS_FOR_TARGET are needed for the target libraries to receive - ;; the -Bxxx for the startfiles. - (cons (string-append "FLAGS_FOR_TARGET=-B" libc "/lib") - ,flags)) - flags)) - ((#:phases phases) - (let ((phases - `(alist-cons-after - 'install 'make-cross-binutils-visible - (lambda* (#:key outputs inputs #:allow-other-keys) - (let* ((out (assoc-ref outputs "out")) - (libexec (string-append out "/libexec/gcc/" - ,target)) - (binutils (string-append - (assoc-ref inputs "binutils-cross") - "/bin/" ,target "-")) - (wrapper (string-append - (assoc-ref inputs "ld-wrapper-cross") - "/bin/" ,target "-ld"))) - (for-each (lambda (file) - (symlink (string-append binutils file) - (string-append libexec "/" - file))) - '("as" "nm")) - (symlink wrapper (string-append libexec "/ld")) - #t)) - (alist-replace - 'install - (lambda _ - ;; Unlike our 'strip' phase, this will do the right thing - ;; for cross-compilers. - (zero? (system* "make" "install-strip"))) - ,phases)))) - (if libc - `(alist-cons-before - 'configure 'set-cross-path - (lambda* (#:key inputs #:allow-other-keys) - ;; Add the cross Linux headers to CROSS_CPATH, and remove them - ;; from CPATH. - (let ((libc (assoc-ref inputs "libc")) - (linux (assoc-ref inputs "xlinux-headers"))) - (define (cross? x) - ;; Return #t if X is a cross-libc or cross Linux. - (or (string-prefix? libc x) - (string-prefix? linux x))) - - (setenv "CROSS_CPATH" - (string-append libc "/include:" - linux "/include")) - (setenv "CROSS_LIBRARY_PATH" - (string-append libc "/lib")) - - (let ((cpath (search-path-as-string->list - (getenv "C_INCLUDE_PATH"))) - (libpath (search-path-as-string->list - (getenv "LIBRARY_PATH")))) - (setenv "CPATH" - (list->search-path-as-string - (remove cross? cpath) ":")) - (for-each unsetenv - '("C_INCLUDE_PATH" "CPLUS_INCLUDE_PATH")) - (setenv "LIBRARY_PATH" - (list->search-path-as-string - (remove cross? libpath) ":")) - #t))) - ,phases) - phases))))))) + ,@(package-arguments %xgcc)))) + (substitute-keyword-arguments args + ((#:configure-flags flags) + `(append (list ,(string-append "--target=" target) + ,@(if libc + `( ;; Disable libcilkrts because it is not + ;; ported to GNU/Hurd. + "--disable-libcilkrts") + `( ;; Disable features not needed at this stage. + "--disable-shared" "--enable-static" + "--enable-languages=c,c++" + + ;; libstdc++ cannot be built at this stage + ;; ("Link tests are not allowed after + ;; GCC_NO_EXECUTABLES."). + "--disable-libstdc++-v3" + + "--disable-threads" ;libgcc, would need libc + "--disable-libatomic" + "--disable-libmudflap" + "--disable-libgomp" + "--disable-libssp" + "--disable-libquadmath" + "--disable-decimal-float" ;would need libc + "--disable-libcilkrts" + )) + ,@(if (equal? target "i686-w64-mingw32") + '("--with-newlib" + "--without-headers") + '())) + + ,(if libc + flags + `(remove (cut string-match "--enable-languages.*" <>) + ,flags)))) + ((#:make-flags flags) + (cond + ((equal? target "i686-w64-mingw32") + `(cons (string-append "FLAGS_FOR_TARGET=-B" + (assoc-ref %build-inputs "i686-w64-mingw32-runtime") + "/lib") + ,flags)) + (libc + `(let ((libc (assoc-ref %build-inputs "libc"))) + ;; FLAGS_FOR_TARGET are needed for the target libraries to receive + ;; the -Bxxx for the startfiles. + (cons (string-append "FLAGS_FOR_TARGET=-B" libc "/lib") + ,flags))) + (else flags))) + ((#:phases phases) + (let ((phases + `(alist-cons-after + 'install 'make-cross-binutils-visible + (lambda* (#:key outputs inputs #:allow-other-keys) + (let* ((out (assoc-ref outputs "out")) + (libexec (string-append out "/libexec/gcc/" + ,target)) + (binutils (string-append + (assoc-ref inputs "binutils-cross") + "/bin/" ,target "-")) + (wrapper (string-append + (assoc-ref inputs "ld-wrapper-cross") + "/bin/" ,target "-ld"))) + (for-each (lambda (file) + (symlink (string-append binutils file) + (string-append libexec "/" + file))) + '("as" "nm")) + (symlink wrapper (string-append libexec "/ld")) + #t)) + (alist-replace + 'install + (lambda _ + ;; Unlike our 'strip' phase, this will do the right thing + ;; for cross-compilers. + (zero? (system* "make" "install-strip"))) + ,phases)))) + (cond + ((equal? target "i686-w64-mingw32") + `(modify-phases ,phases + (add-before + 'configure 'set-cross-path + (lambda* (#:key inputs #:allow-other-keys) + ;; Add the cross Linux headers to CROSS_CPATH, and remove them + ;; from CPATH. + (let ((libc (assoc-ref inputs "i686-w64-mingw32-runtime")) + (gcc (assoc-ref inputs "gcc"))) + (define (cross? x) + (string-prefix? libc x)) + + (setenv "CROSS_CPATH" + (string-append libc "/include" + ":" libc "/i686-w64-mingw32/include")) + (setenv "CROSS_LIBRARY_PATH" + (string-append libc "/lib" + ":" libc "/i686-w64-mingw32/lib")) + + (setenv "CPP" (string-append gcc "/bin/cpp")) + + (let ((cpath (search-path-as-string->list + (getenv "C_INCLUDE_PATH"))) + (libpath (search-path-as-string->list + (getenv "LIBRARY_PATH")))) + (setenv "CPATH" + (list->search-path-as-string + (remove cross? cpath) ":")) + (for-each unsetenv + '("C_INCLUDE_PATH" "CPLUS_INCLUDE_PATH")) + (setenv "LIBRARY_PATH" + (list->search-path-as-string + (remove cross? libpath) ":")) + #t)))))) + (libc + `(alist-cons-before + 'configure 'set-cross-path + (lambda* (#:key inputs #:allow-other-keys) + ;; Add the cross Linux headers to CROSS_CPATH, and remove them + ;; from CPATH. + (let ((libc (assoc-ref inputs libc)) + (linux (assoc-ref inputs "xlinux-headers"))) + (define (cross? x) + ;; Return #t if X is a cross-libc or cross Linux. + (or (string-prefix? libc x) + (string-prefix? linux x))) + + (setenv "CROSS_CPATH" + (string-append libc "/include:" + linux "/include")) + (setenv "CROSS_LIBRARY_PATH" + (string-append libc "/lib")) + + (let ((cpath (search-path-as-string->list + (getenv "C_INCLUDE_PATH"))) + (libpath (search-path-as-string->list + (getenv "LIBRARY_PATH")))) + (setenv "CPATH" + (list->search-path-as-string + (remove cross? cpath) ":")) + (for-each unsetenv + '("C_INCLUDE_PATH" "CPLUS_INCLUDE_PATH")) + (setenv "LIBRARY_PATH" + (list->search-path-as-string + (remove cross? libpath) ":")) + #t))) + ,phases)) + (else phases)))))))) (define (cross-gcc-patches target) "Return GCC patches needed for TARGET." @@ -210,63 +256,68 @@ may be either a libc package or #f.)" XBINUTILS as the associated cross-Binutils. If LIBC is false, then build a GCC that does not target a libc; otherwise, target that libc." (package (inherit %xgcc) - (name (string-append "gcc-cross-" - (if libc "" "sans-libc-") - target)) - (source (origin (inherit (package-source %xgcc)) - (patches - (append - (origin-patches (package-source %xgcc)) - (cons (search-patch "gcc-cross-environment-variables.patch") - (cross-gcc-patches target)))))) - - ;; For simplicity, use a single output. Otherwise libgcc_s & co. are not - ;; found by default, etc. - (outputs '("out")) - - (arguments - `(#:implicit-inputs? #f - #:modules ((guix build gnu-build-system) - (guix build utils) - (ice-9 regex) - (srfi srfi-1) - (srfi srfi-26)) - - ,@(cross-gcc-arguments target libc))) - - (native-inputs - `(("ld-wrapper-cross" ,(make-ld-wrapper - (string-append "ld-wrapper-" target) - #:target target - #:binutils xbinutils)) - ("binutils-cross" ,xbinutils) - - ;; Call it differently so that the builder can check whether the "libc" - ;; input is #f. - ("libc-native" ,@(assoc-ref %final-inputs "libc")) - - ;; Remaining inputs. - ,@(let ((inputs (append (package-inputs %xgcc) - (alist-delete "libc" %final-inputs)))) - (if libc - `(("libc" ,libc) - ("xlinux-headers" ;the target headers - ,@(assoc-ref (package-propagated-inputs libc) - "linux-headers")) - ,@inputs) - inputs)))) - - (inputs '()) - - ;; Only search target inputs, not host inputs. - (search-paths - (list (search-path-specification - (variable "CROSS_CPATH") - (files '("include"))) - (search-path-specification - (variable "CROSS_LIBRARY_PATH") - (files '("lib" "lib64"))))) - (native-search-paths '()))) + (name (string-append "gcc-cross-" + (if libc "" "sans-libc-") + target)) + (source (origin (inherit (package-source %xgcc)) + (patches + (append + (origin-patches (package-source %xgcc)) + (cons (search-patch "gcc-cross-environment-variables.patch") + (cross-gcc-patches target)))))) + + ;; For simplicity, use a single output. Otherwise libgcc_s & co. are not + ;; found by default, etc. + (outputs '("out")) + + (arguments + `(#:implicit-inputs? #f + #:modules ((guix build gnu-build-system) + (guix build utils) + (ice-9 regex) + (srfi srfi-1) + (srfi srfi-26)) + + ,@(cross-gcc-arguments target libc))) + + (native-inputs + `(("ld-wrapper-cross" ,(make-ld-wrapper + (string-append "ld-wrapper-" target) + #:target target + #:binutils xbinutils)) + ("binutils-cross" ,xbinutils) + ("gcc" ,gcc) + + ;; Call it differently so that the builder can check whether the "libc" + ;; input is #f. + ("libc-native" ,@(assoc-ref %final-inputs "libc")) + + ;; Remaining inputs. + ,@(let ((inputs (append (package-inputs %xgcc) + (alist-delete "libc" %final-inputs)))) + (cond + ((equal? target "i686-w64-mingw32") + `(("i686-w64-mingw32-runtime" ,i686-w64-mingw32-runtime) + ,@inputs)) + (libc + `(("libc" ,libc) + ("xlinux-headers" ;the target headers + ,@(assoc-ref (package-propagated-inputs libc) + "linux-headers")) + ,@inputs)) + (else inputs))))) + + (inputs '()) + + ;; Only search target inputs, not host inputs. + (search-paths + (list (search-path-specification + (variable "CROSS_CPATH") + (files '("include"))) + (search-path-specification + (variable "CROSS_LIBRARY_PATH") + (files '("lib" "lib64"))))) + (native-search-paths '()))) (define* (cross-libc target #:optional @@ -274,66 +325,68 @@ GCC that does not target a libc; otherwise, target that libc." (xbinutils (cross-binutils target))) "Return a libc cross-built for TARGET, a GNU triplet. Use XGCC and XBINUTILS and the cross tool chain." - (define xlinux-headers - (package (inherit linux-libre-headers) - (name (string-append (package-name linux-libre-headers) - "-cross-" target)) - (arguments - (substitute-keyword-arguments - `(#:implicit-cross-inputs? #f - ,@(package-arguments linux-libre-headers)) - ((#:phases phases) - `(alist-replace - 'build - (lambda _ - (setenv "ARCH" ,(system->linux-architecture target)) - (format #t "`ARCH' set to `~a' (cross compiling)~%" (getenv "ARCH")) - - (and (zero? (system* "make" "defconfig")) - (zero? (system* "make" "mrproper" "headers_check")))) - ,phases)))) - (native-inputs `(("cross-gcc" ,xgcc) - ("cross-binutils" ,xbinutils) - ,@(package-native-inputs linux-libre-headers))))) - - (package (inherit glibc) - (name (string-append "glibc-cross-" target)) - (arguments - (substitute-keyword-arguments - `(;; Disable stripping (see above.) - #:strip-binaries? #f - - ;; This package is used as a target input, but it should not have - ;; the usual cross-compilation inputs since that would include - ;; itself. - #:implicit-cross-inputs? #f - - ,@(package-arguments glibc)) - ((#:configure-flags flags) - `(cons ,(string-append "--host=" target) - ,flags)) - ((#:phases phases) - `(alist-cons-before - 'configure 'set-cross-linux-headers-path - (lambda* (#:key inputs #:allow-other-keys) - (let ((linux (assoc-ref inputs "linux-headers"))) - (setenv "CROSS_CPATH" - (string-append linux "/include")) - #t)) - ,phases)))) - - ;; Shadow the native "linux-headers" because glibc's recipe expects the - ;; "linux-headers" input to point to the right thing. - (propagated-inputs `(("linux-headers" ,xlinux-headers))) - - ;; FIXME: 'static-bash' should really be an input, not a native input, but - ;; to do that will require building an intermediate cross libc. - (inputs '()) - - (native-inputs `(("cross-gcc" ,xgcc) - ("cross-binutils" ,xbinutils) - ,@(package-inputs glibc) ;FIXME: static-bash - ,@(package-native-inputs glibc))))) + (cond + ((equal? target "i686-w64-mingw32") i686-w64-mingw32-runtime) + (else + (let ((xlinux-headers + (package (inherit linux-libre-headers) + (name (string-append (package-name linux-libre-headers) + "-cross-" target)) + (arguments + (substitute-keyword-arguments + `(#:implicit-cross-inputs? #f + ,@(package-arguments linux-libre-headers)) + ((#:phases phases) + `(alist-replace + 'build + (lambda _ + (setenv "ARCH" ,(system->linux-architecture target)) + (format #t "`ARCH' set to `~a' (cross compiling)~%" (getenv "ARCH")) + + (and (zero? (system* "make" "defconfig")) + (zero? (system* "make" "mrproper" "headers_check")))) + ,phases)))) + (native-inputs `(("cross-gcc" ,xgcc) + ("cross-binutils" ,xbinutils) + ,@(package-native-inputs linux-libre-headers)))))) + (package (inherit glibc) + (name (string-append "glibc-cross-" target)) + (arguments + (substitute-keyword-arguments + `( ;; Disable stripping (see above.) + #:strip-binaries? #f + + ;; This package is used as a target input, but it should not have + ;; the usual cross-compilation inputs since that would include + ;; itself. + #:implicit-cross-inputs? #f + + ,@(package-arguments glibc)) + ((#:configure-flags flags) + `(cons ,(string-append "--host=" target) + ,flags)) + ((#:phases phases) + `(alist-cons-before + 'configure 'set-cross-linux-headers-path + (lambda* (#:key inputs #:allow-other-keys) + (let ((linux (assoc-ref inputs "linux-headers"))) + (setenv "CROSS_CPATH" + (string-append linux "/include")) + #t)) + ,phases)))) + + ;; Shadow the native "linux-headers" because glibc's recipe expects the + ;; "linux-headers" input to point to the right thing. + (propagated-inputs `(("linux-headers" ,xlinux-headers))) + + ;; FIXME: 'static-bash' should really be an input, not a native input, but + ;; to do that will require building an intermediate cross libc. + (inputs '()) + + (native-inputs `(("cross-gcc" ,xgcc) + ("cross-binutils" ,xbinutils) + ,@(package-inputs glibc) ;FIXME: static-bash + ,@(package-native-inputs glibc)))))))) \f ;;; @@ -348,9 +401,9 @@ XBINUTILS and the cross tool chain." ;; Don't attempt to build this cross-compiler on i686; ;; see <http://bugs.gnu.org/19598>. (package (inherit xgcc) - (supported-systems (fold delete - (package-supported-systems xgcc) - '("mips64el-linux" "i686-linux")))))) + (supported-systems (fold delete + (package-supported-systems xgcc) + '("mips64el-linux" "i686-linux")))))) (define-public xgcc-avr ;; AVR cross-compiler, used to build AVR-Libc. @@ -368,10 +421,59 @@ XBINUTILS and the cross tool chain." (cross-binutils triplet) (cross-libc triplet)))) (package (inherit xgcc) - (supported-systems (delete "armhf-linux" %supported-systems))))) + (supported-systems (delete "armhf-linux" %supported-systems))))) ;; (define-public xgcc-armel ;; (let ((triplet "armel-linux-gnueabi")) ;; (cross-gcc triplet ;; (cross-binutils triplet) ;; (cross-libc triplet)))) + +(define-public i686-w64-mingw32-runtime + (package + (name "i686-w64-mingw32-runtime") + (version "4.9.2.v3.rev1.7") + (source (origin + (method url-fetch) + (uri + ;; FIXME: 7z + ;;"https://sourceforge.net/projects/mingw/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/4.9.2/threads-posix/sjlj/i686-4.9.2-release-posix-sjlj-rt_v4-rev4.7z" + "http://lilypond.org/download/gub-sources/mingw-w64-runtime/i686-4.9.2-release-posix-sjlj-rt_v4-rev4.7.tar.gz") + (sha256 + (base32 + "00hkvy2rm5sbvngm0l4ajh2b3b497cgkbz0wc9sbfd8r92bs2lkx")))) + (build-system trivial-build-system) + (native-inputs `(("gzip" ,gzip) + ("source" ,source) + ("tar" ,tar))) + (search-paths + (list (search-path-specification + (variable "CROSS_CPATH") + (files '("include" "i686-w64-mingw32/include"))) + (search-path-specification + (variable "CROSS_LIBRARY_PATH") + (files '("lib" "lib64" "i686-w64-mingw32/lib" "i686-w64-mingw32/lib64"))))) + (arguments + `(#:modules ((guix build utils)) + #:builder (begin + (use-modules (guix build utils)) + (let ((gzip (assoc-ref %build-inputs "gzip")) + (source (assoc-ref %build-inputs "source")) + (tar (assoc-ref %build-inputs "tar"))) + (setenv "PATH" (string-append gzip "/bin" + ":" tar "/bin" + ":" (getenv "PATH"))) + (mkdir-p %output) + (system* "tar" "-C" %output "--strip-components=1" "-xf" source))))) + (home-page "http://mingw.org") + (synopsis "Minimalist GNU for Windows") + (description "MinGW provides a complete Open Source programming tool set +which is suitable for the development of native MS-Windows applications, and +which do not depend on any 3rd-party C-Runtime DLLs.") + (license fdl1.3+))) + +(define-public xgcc-i686-w64-mingw32 + (let ((triplet "i686-w64-mingw32")) + (cross-gcc triplet + (cross-binutils triplet) + (cross-libc triplet)))) diff --git a/guix/build-system/gnu.scm b/guix/build-system/gnu.scm index afd5766..4618182 100644 --- a/guix/build-system/gnu.scm +++ b/guix/build-system/gnu.scm @@ -398,7 +398,9 @@ is one of `host' or `target'." ((host) `(("cross-gcc" ,(gcc target (binutils target) - (libc target))) + (if (equal? target "i686-w64-mingw32") + #f ;;(module-ref cross 'i686-w64-mingw32-runtime) + (libc target)))) ("cross-binutils" ,(binutils target)))) ((target) `(("cross-libc" ,(libc target))))))))) -- 2.6.3 [-- Attachment #3: Type: text/plain, Size: 154 bytes --] -- Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.nl ^ permalink raw reply related [flat|nested] 18+ messages in thread
* [RFCv2] build: i686-w64-mingw32: new cross target. 2016-03-26 17:38 rfc/rfh: i686-w64-mingw32 cross target Jan Nieuwenhuizen @ 2016-03-27 14:20 ` Jan Nieuwenhuizen 2016-03-27 16:17 ` Pjotr Prins 2016-03-31 20:16 ` rfc/rfh: i686-w64-mingw32 " Ricardo Wurmus 1 sibling, 1 reply; 18+ messages in thread From: Jan Nieuwenhuizen @ 2016-03-27 14:20 UTC (permalink / raw) To: guix-devel [-- Attachment #1: Type: text/plain, Size: 921 bytes --] Jan Nieuwenhuizen writes: > I'm working on a cross target in an effort to get rid of GUB 1) in > favour of Guix and could do with some help. It now builds fully from source. See https://github.com/janneke/guix/tree/wip-mingw32 or attached patch. 16:15:25 janneke@drakenvlieg:~/src/mingw-guix $ ./pre-inst-env guix build --keep-failed --target=i686-w64-mingw32 hello /gnu/store/2j8qaqbc9q1w3z6k054nmp7j432yxfq7-hello-2.10 16:15:29 janneke@drakenvlieg:~/src/mingw-guix $ ./pre-inst-env guix environment --ad-hoc wine -- wine /gnu/store/2j8qaqbc9q1w3z6k054nmp7j432yxfq7-hello-2.10/bin/hello.exe Hello, world! 16:15:40 janneke@drakenvlieg:~/src/mingw-guix $ The gcc-cross-core package needs some cleanups and I still need to figure out to remove the i686-w64-mingw32 special casing, i.e, find a way to handle the libc/#f/newlib case. Greetings, Jan 1) GUB -- http://lilypond.org/gub/ [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 0001-build-i686-w64-mingw32-new-cross-target.patch --] [-- Type: text/x-diff, Size: 20198 bytes --] From 7a58b7d85c798e1ca2f11d61e0b344cf2e3bcb10 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen <janneke@gnu.org> Date: Sun, 27 Mar 2016 16:00:36 +0200 Subject: [PATCH] build: i686-w64-mingw32: new cross target. * gnu/packages/cross-base.scm (gcc-cross-core, mingw-w64, xgcc-i686-w64-mingw32): New variables. (cross-gcc): Use them to support i686-w64-mingw32 target. * gnu/packages/bootstrap.scm (glibc-dynamic-linker): Add i686-mingw. * guix/build-system/gnu.scm (standard-cross-packages): Set libc to #f for i686-w64-mingw32. --- gnu/packages/bootstrap.scm | 1 + gnu/packages/cross-base.scm | 276 +++++++++++++++++++++++++++++++++++++++++--- guix/build-system/gnu.scm | 4 +- 3 files changed, 263 insertions(+), 18 deletions(-) diff --git a/gnu/packages/bootstrap.scm b/gnu/packages/bootstrap.scm index f5bf069..979ab1d 100644 --- a/gnu/packages/bootstrap.scm +++ b/gnu/packages/bootstrap.scm @@ -171,6 +171,7 @@ successful, or false to signal an error." ;; here just so we can keep going. ((string=? system "xtensa-elf") "no-ld.so") ((string=? system "avr") "no-ld.so") + ((string=? system "i686-mingw") "no-ld.so") (else (error "dynamic linker name not known for this system" system)))) diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm index 8bd599c..be2f4c0 100644 --- a/gnu/packages/cross-base.scm +++ b/gnu/packages/cross-base.scm @@ -18,12 +18,16 @@ ;;; 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 multiprecision) #:use-module (guix packages) #:use-module (guix download) #:use-module (guix utils) @@ -101,7 +105,7 @@ may be either a libc package or #f.)" `(append (list ,(string-append "--target=" target) ,@(if libc `( ;; Disable libcilkrts because it is not - ;; ported to GNU/Hurd. + ;; ported to GNU/Hurd. "--disable-libcilkrts") `( ;; Disable features not needed at this stage. "--disable-shared" "--enable-static" @@ -120,20 +124,32 @@ may be either a libc package or #f.)" "--disable-libquadmath" "--disable-decimal-float" ;would need libc "--disable-libcilkrts" - ))) + )) + ,@(if (equal? target "i686-w64-mingw32") + '("--with-newlib" + "--without-headers") + '())) ,(if libc flags `(remove (cut string-match "--enable-languages.*" <>) ,flags)))) ((#:make-flags flags) - (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=-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=-B" libc "/lib") - ,flags)) - flags)) + ,flags))) + (else flags))) ((#:phases phases) (let ((phases `(alist-cons-after @@ -162,13 +178,50 @@ may be either a libc package or #f.)" ;; for cross-compilers. (zero? (system* "make" "install-strip"))) ,phases)))) + (cond + ((equal? target "i686-w64-mingw32") + `(modify-phases ,phases + (add-before + 'configure 'set-cross-path + (lambda* (#:key inputs #:allow-other-keys) + ;; Add the cross Linux headers to CROSS_CPATH, and remove them + ;; from CPATH. + (let ((libc (assoc-ref inputs "mingw-w64")) + (gcc (assoc-ref inputs "gcc"))) + (define (cross? 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 "C_INCLUDE_PATH"))) + (libpath (search-path-as-string->list + (getenv "LIBRARY_PATH")))) + (setenv "CPATH" + (list->search-path-as-string + (remove cross? cpath) ":")) + (for-each unsetenv + '("C_INCLUDE_PATH" "CPLUS_INCLUDE_PATH")) + (setenv "LIBRARY_PATH" + (list->search-path-as-string + (remove cross? libpath) ":")) + #t)))))) + (libc `(alist-cons-before 'configure 'set-cross-path (lambda* (#:key inputs #:allow-other-keys) ;; Add the cross Linux headers to CROSS_CPATH, and remove them ;; from CPATH. - (let ((libc (assoc-ref inputs "libc")) + (let ((libc (assoc-ref inputs libc)) (linux (assoc-ref inputs "xlinux-headers"))) (define (cross? x) ;; Return #t if X is a cross-libc or cross Linux. @@ -194,8 +247,8 @@ may be either a libc package or #f.)" (list->search-path-as-string (remove cross? libpath) ":")) #t))) - ,phases) - phases))))))) + ,phases)) + (else phases)))))))) (define (cross-gcc-patches target) "Return GCC patches needed for TARGET." @@ -240,6 +293,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. @@ -248,13 +302,17 @@ 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 + ((equal? target "i686-w64-mingw32") + `(("mingw-w64" ,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 '()) @@ -268,13 +326,105 @@ GCC that does not target a libc; otherwise, target that libc." (files '("lib" "lib64"))))) (native-search-paths '()))) +(define* (cross-gcc-core target + #:optional (xbinutils (cross-binutils target))) + "Return a cross-compiler-core to be used to build the c library for TARGET, +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) + + ("tar" ,tar) + ("xz" ,xz) + + ;;("static-bash" ,static-bash) ;; /bin/sh + ("bash" ,bash) + ("glibc" ,glibc) + + ("coreutils" ,coreutils) + ("sed" ,sed) + + ("gcc" ,gcc) + ("binutils" ,binutils) + ("gawk" ,gawk) + ("grep" ,grep) + + ("make" ,gnu-make) + ("mingw-source" ,(package-source mingw-w64)) + ("bzip2" ,bzip2) ;; unpack mingw .bz2 + ("diffutils" ,diffutils) ;; cmp: are we fdl? + ("gzip" ,gzip))) ;; info docs + (arguments + (let ((args `(,@(package-arguments (cross-gcc target xbinutils))))) + (substitute-keyword-arguments args + ((#:configure-flags flags) + `(append (list + ,(string-append "--target=" target)) + (remove (cut string-match "--enable-languages.*" <>) + ,flags) + '("--with-newlib" + "--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-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")) + (setenv "CROSS_CPATH" + (string-append + mingw-headers "/include" + ":" mingw-headers "/crt" + ":" mingw-headers "/defaults/include")))))))) + (replace 'install + (lambda _ + (zero? (system* "make" "install-gcc" "install-target-libgcc")))) + (delete 'make-cross-binutils-visible) + (delete 'validate-runpath)))))))) + (define* (cross-libc target #:optional (xgcc (cross-gcc target)) (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 + (cond + ((equal? target "i686-w64-mingw32") mingw-w64) + (else + (let ((xlinux-headers (package (inherit linux-libre-headers) (name (string-append (package-name linux-libre-headers) "-cross-" target)) @@ -294,8 +444,7 @@ XBINUTILS and the cross tool chain." ,phases)))) (native-inputs `(("cross-gcc" ,xgcc) ("cross-binutils" ,xbinutils) - ,@(package-native-inputs linux-libre-headers))))) - + ,@(package-native-inputs linux-libre-headers)))))) (package (inherit glibc) (name (string-append "glibc-cross-" target)) (arguments @@ -333,7 +482,91 @@ XBINUTILS and the cross tool chain." (native-inputs `(("cross-gcc" ,xgcc) ("cross-binutils" ,xbinutils) ,@(package-inputs glibc) ;FIXME: static-bash - ,@(package-native-inputs glibc))))) + ,@(package-native-inputs glibc)))))))) + +(define-public mingw-w64 + (package + (name "mingw-w64") + (version "5.0-rc2") + (source (origin + (method url-fetch) + (uri "https://sourceforge.net/projects/mingw-w64/files/mingw-w64/mingw-w64-release/mingw-w64-v5.0-rc2.tar.bz2") + (sha256 + (base32 "0imdary8j07if8ih73pfgxiclpf2ax8h3mz8mxln07i8sbbd30c9")))) + (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/lib64"))))) + (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 (list + "--host=i686-w64-mingw32" + "--target=i686-w64-mingw32" + "--with-as=i686-w64-mingw32-as" + ;;"--with-cpp=i686-w64-mingw32-cpp" + "--with-ld=i686-w64-mingw32-ld" + "--with-nm=i686-w64-mingw32-nm") + ;; FIXME: include _mingw_directx.h ? + #:make-flags (list "DEFS=-DHAVE_CONFIG_H -D__MINGW_HAS_DXSDK=1") + #: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-headers"))) + ;; 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" "/bin" + ":" (getenv "PATH"))) + (setenv "CPP" (string-append xgcc-core "/bin/i686-w64-mingw32-cpp")) + (setenv "C_INCLUDE_PATH" + (string-append + ;;__MINGW_HAS_DXSDK 1 + 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 set +which is suitable for the development of native MS-Windows applications, and +which do not depend on any 3rd-party C-Runtime dlls.") + (license license:fdl1.3+))) + +(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))) \f ;;; @@ -375,3 +608,12 @@ XBINUTILS and the cross tool chain." ;; (cross-gcc triplet ;; (cross-binutils triplet) ;; (cross-libc triplet)))) + +(define-public xgcc-i686-w64-mingw32 + (let ((triplet "i686-w64-mingw32")) + (cross-gcc triplet + (cross-binutils triplet) + #f))) + +(define-public xgcc-i686-w64-mingw32-sans-libc + xgcc-i686-w64-mingw32) diff --git a/guix/build-system/gnu.scm b/guix/build-system/gnu.scm index afd5766..d31a8f8 100644 --- a/guix/build-system/gnu.scm +++ b/guix/build-system/gnu.scm @@ -398,7 +398,9 @@ is one of `host' or `target'." ((host) `(("cross-gcc" ,(gcc target (binutils target) - (libc target))) + (if (equal? target "i686-w64-mingw32") + #f + (libc target)))) ("cross-binutils" ,(binutils target)))) ((target) `(("cross-libc" ,(libc target))))))))) -- 2.6.3 [-- Attachment #3: Type: text/plain, Size: 154 bytes --] -- Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.nl ^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [RFCv2] build: i686-w64-mingw32: new cross target. 2016-03-27 14:20 ` [RFCv2] build: i686-w64-mingw32: new " Jan Nieuwenhuizen @ 2016-03-27 16:17 ` Pjotr Prins 0 siblings, 0 replies; 18+ messages in thread From: Pjotr Prins @ 2016-03-27 16:17 UTC (permalink / raw) To: Jan Nieuwenhuizen; +Cc: guix-devel On Sun, Mar 27, 2016 at 04:20:13PM +0200, Jan Nieuwenhuizen wrote: > Jan Nieuwenhuizen writes: > > > I'm working on a cross target in an effort to get rid of GUB 1) in > > favour of Guix and could do with some help. > > It now builds fully from source. See > https://github.com/janneke/guix/tree/wip-mingw32 or attached patch. > > 16:15:25 janneke@drakenvlieg:~/src/mingw-guix > $ ./pre-inst-env guix build --keep-failed --target=i686-w64-mingw32 hello > /gnu/store/2j8qaqbc9q1w3z6k054nmp7j432yxfq7-hello-2.10 > 16:15:29 janneke@drakenvlieg:~/src/mingw-guix > $ ./pre-inst-env guix environment --ad-hoc wine -- wine /gnu/store/2j8qaqbc9q1w3z6k054nmp7j432yxfq7-hello-2.10/bin/hello.exe > Hello, world! > 16:15:40 janneke@drakenvlieg:~/src/mingw-guix > $ > > The gcc-cross-core package needs some cleanups and I still need to > figure out to remove the i686-w64-mingw32 special casing, i.e, find > a way to handle the libc/#f/newlib case. Awesome work Jan :). Next up are the BSDs. Pj. ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: rfc/rfh: i686-w64-mingw32 cross target 2016-03-26 17:38 rfc/rfh: i686-w64-mingw32 cross target Jan Nieuwenhuizen 2016-03-27 14:20 ` [RFCv2] build: i686-w64-mingw32: new " Jan Nieuwenhuizen @ 2016-03-31 20:16 ` Ricardo Wurmus 2016-03-31 20:26 ` Jan Nieuwenhuizen 1 sibling, 1 reply; 18+ messages in thread From: Ricardo Wurmus @ 2016-03-31 20:16 UTC (permalink / raw) To: Jan Nieuwenhuizen; +Cc: guix-devel Jan Nieuwenhuizen <janneke@gnu.org> writes: > I'm working on a cross target in an effort to get rid of GUB 1) in > favour of Guix and could do with some help. > > I have just succeeded in cross-building hello and running it, > doing > > 18:18:36 janneke@drakenvlieg:~/src/mingw-guix > $ ./pre-inst-env guix build --keep-failed --target=i686-w64-mingw32 hello > /gnu/store/6556syz1732jnffnp0njikr5g6diqvch-hello-2.10 > 18:18:36 janneke@drakenvlieg:~/src/mingw-guix > $ /gnu/store/5y252qkblhpj639g3bnrc671mz8x920w-profile/bin/wine /gnu/store/6556syz1732jnffnp0njikr5g6diqvch-hello-2.10/bin/hello.exe > Hello, world! > 18:18:39 janneke@drakenvlieg:~/src/mingw-guix That’s very cool! > See https://github.com/janneke/guix/tree/wip-mingw32 or attached patch. > This platform does not have glibc, it uses --with-newlib and I'm not > sure how to fit that in. I have also been working on a cross-compiler using newlib: http://lists.gnu.org/archive/html/guix-devel/2016-03/msg00106.html I’m not sure it’s fully working as I only have one board to test it. Maybe there’s something in there you find useful? ~~ Ricardo ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: rfc/rfh: i686-w64-mingw32 cross target 2016-03-31 20:16 ` rfc/rfh: i686-w64-mingw32 " Ricardo Wurmus @ 2016-03-31 20:26 ` Jan Nieuwenhuizen 2016-03-31 20:48 ` Ricardo Wurmus 0 siblings, 1 reply; 18+ messages in thread From: Jan Nieuwenhuizen @ 2016-03-31 20:26 UTC (permalink / raw) To: Ricardo Wurmus; +Cc: guix-devel Ricardo Wurmus writes: >> /gnu/store/6556syz1732jnffnp0njikr5g6diqvch-hello-2.10/bin/hello.exe >> Hello, world! >> 18:18:39 janneke@drakenvlieg:~/src/mingw-guix > > That’s very cool! Thanks! I have just built a full blown gcc compiler (this example only had a plain c-gcc) and am working with phant0mas on cross-build issues. > I have also been working on a cross-compiler using newlib: > > http://lists.gnu.org/archive/html/guix-devel/2016-03/msg00106.html > > I’m not sure it’s fully working as I only have one board to test it. > Maybe there’s something in there you find useful? Thanks, that's great! Are these the only patches you had to make? I find that for mingw, many packages need to be patched and it would be nice to have support for that. 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] 18+ messages in thread
* Re: rfc/rfh: i686-w64-mingw32 cross target 2016-03-31 20:26 ` Jan Nieuwenhuizen @ 2016-03-31 20:48 ` Ricardo Wurmus 2016-04-02 7:30 ` Jan Nieuwenhuizen 0 siblings, 1 reply; 18+ messages in thread From: Ricardo Wurmus @ 2016-03-31 20:48 UTC (permalink / raw) To: Jan Nieuwenhuizen; +Cc: guix-devel Jan Nieuwenhuizen <janneke@gnu.org> writes: > Thanks, that's great! Are these the only patches you had to make? > I find that for mingw, many packages need to be patched and it > would be nice to have support for that. I think these are the only patches I needed. Could you give an example of what things need to be patched for mingw? ~~ Ricardo ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: rfc/rfh: i686-w64-mingw32 cross target 2016-03-31 20:48 ` Ricardo Wurmus @ 2016-04-02 7:30 ` Jan Nieuwenhuizen 2016-04-07 21:12 ` Ludovic Courtès 0 siblings, 1 reply; 18+ messages in thread From: Jan Nieuwenhuizen @ 2016-04-02 7:30 UTC (permalink / raw) To: Ricardo Wurmus; +Cc: guix-devel Ricardo Wurmus writes: > I think these are the only patches I needed. Could you give an example > of what things need to be patched for mingw? The two top commits here are for ncurses and readline https://github.com/janneke/guix/tree/wip-hurd+mingw (work in progress). Typically: configure flags, adding gnulib modules, gnulib updates, dealing with non-posix or mingw-specific libc stuff. Many more examples here https://github.com/janneke/gub/tree/master/patches 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] 18+ messages in thread
* Re: rfc/rfh: i686-w64-mingw32 cross target 2016-04-02 7:30 ` Jan Nieuwenhuizen @ 2016-04-07 21:12 ` Ludovic Courtès 2016-04-14 6:30 ` Jan Nieuwenhuizen 0 siblings, 1 reply; 18+ messages in thread From: Ludovic Courtès @ 2016-04-07 21:12 UTC (permalink / raw) To: Jan Nieuwenhuizen; +Cc: guix-devel Jan Nieuwenhuizen <janneke@gnu.org> skribis: > Ricardo Wurmus writes: > >> I think these are the only patches I needed. Could you give an example >> of what things need to be patched for mingw? > > The two top commits here are for ncurses and readline > > https://github.com/janneke/guix/tree/wip-hurd+mingw Sorry for the delay, but this is awesome work! I’m impressed that you got it working in so little time. I’m not offering a full review yet. I think it’s an additional incentive to finally merge the remaining bits from wip-hurd. ;-) My main concern is the complexity of the cross-base stuff. Why is ‘cross-gcc-core’ needed, for instance? It’s 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. A cosmetic comment: I’d put the MinGW packages in a separate module. > (work in progress). Typically: configure flags, adding gnulib modules, > gnulib updates, dealing with non-posix or mingw-specific libc stuff. > > Many more examples here > > https://github.com/janneke/gub/tree/master/patches 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.) ‘core-updates’ is open, so now is a good time to add patches to the toolchain packages, for instance. :-) Thanks! Ludo’. ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: rfc/rfh: i686-w64-mingw32 cross target 2016-04-07 21:12 ` Ludovic Courtès @ 2016-04-14 6:30 ` Jan Nieuwenhuizen 2016-04-19 14:54 ` Ludovic Courtès 0 siblings, 1 reply; 18+ messages in thread From: Jan Nieuwenhuizen @ 2016-04-14 6:30 UTC (permalink / raw) To: Ludovic Courtès; +Cc: guix-devel [-- Attachment #1: Type: text/plain, Size: 3127 bytes --] Ludovic Courtès writes: > Sorry for the delay, but this is awesome work! I’m impressed that 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__<arch>, 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’m not offering a full review yet. I think it’s an additional > 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 > ‘cross-gcc-core’ 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’s 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=i686-w64-mingw32 hello but guile.exe still segfaults. > A cosmetic comment: I’d put the MinGW packages in a separate module. 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: [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 0001-gnu-gcc-use-CPATH-fixes-cross-builds.patch --] [-- Type: text/x-diff, Size: 1044 bytes --] From 294f158558279bb25ad64b08ffb74281ba9da78d Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen <janneke@gnu.org> 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 [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #3: 0002-gnu-bootstrap-Add-i686-mingw.patch --] [-- Type: text/x-diff, Size: 884 bytes --] From bca595306390b85c01bd226d6167b9336df1b59a Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen <janneke@gnu.org> 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 [-- Attachment #4: 0003-gnu-Add-mingw-w64.patch --] [-- Type: text/x-diff, Size: 9769 bytes --] From 05413c7a4ba8bcef1e3129c93150ebd482c41ec3 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen <janneke@gnu.org> 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 = \ 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 = \ 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..56ea235 --- /dev/null +++ b/gnu/packages/mingw.scm @@ -0,0 +1,109 @@ +;;; 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/" + name "/" name "-release/" name "-v" version ".tar.bz2")) + (sha256 + (base32 "0imdary8j07if8ih73pfgxiclpf2ax8h3mz8mxln07i8sbbd30c9")) + (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/lib64"))))) + (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=i686-w64-mingw32" + "--target=i686-w64-mingw32" + "--with-as=i686-w64-mingw32-as" + "--with-ld=i686-w64-mingw32-ld" + "--with-nm=i686-w64-mingw32-nm") + #:make-flags (list "DEFS=-DHAVE_CONFIG_H -D__MINGW_HAS_DXSDK=1") + #: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-headers"))) + ;; 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" "/bin" + ":" (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 set +which is suitable for the development of native MS-Windows applications, and +which do not depend on any 3rd-party C-Runtime dlls.") + (license 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..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 21: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.871461798 +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) hypot ((double)x, (double)y);} + #endif + extern long double __cdecl hypotl (long double, long double); -- 2.7.3 [-- Attachment #5: 0004-gnu-cross-build-i686-w64-mingw32-new-cross-target.patch --] [-- Type: text/x-diff, Size: 17887 bytes --] From 67fd642293ebc0d88d6f691c2b6bc5ce55eefe36 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen <janneke@gnu.org> 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 © 2013, 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2014, 2015 Mark H Weaver <mhw@netris.org> +;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org> ;;; ;;; This file is part of GNU Guix. ;;; @@ -18,13 +19,18 @@ ;;; 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 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?)) (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=" target) ,@(if libc `( ;; Disable libcilkrts because it is not - ;; ported to GNU/Hurd. + ;; ported to GNU/Hurd. "--disable-libcilkrts") `( ;; Disable features not needed at this stage. "--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=win32 first, and only then + ;; (re)build gcc with --enable-threads=posix. + ;; + ;; i686-w64-mingw32/libstdc++-v3/include/i686-w64-mingw32/bits/gthr-default.h:33:62: + ;; error: types may not be defined in casts + ;; #define CONST_CAST2(TOTYPE,FROMTYPE,X) ((__extension__(union {FROMTYPE _q; TOTYPE _nq;})(X))._nq) + + ,@(if (and libc (equal? target "i686-w64-mingw32")) + ;;'("--with-threads=win32") + '() ;; + '()) + + ,@(if (cross-newlib? target) + '("--with-newlib" + "--without-headers") + '())) ,(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=-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=-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 remove 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 => ~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)))))))) (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 '()))) (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." - + (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")))) - + (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 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. @@ -275,6 +358,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. @@ -283,12 +367,16 @@ 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 + ((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))))) (inputs '()) @@ -302,6 +390,95 @@ GCC that does not target a libc; otherwise, target that libc." (files '("lib" "lib64"))))) (native-search-paths '()))) +(define* (cross-gcc-core target + #:optional (xbinutils (cross-binutils target))) + "Return a cross-compiler-core to be used to build the c library for TARGET, +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=" target)) + (remove (cut string-match "--enable-languages.*" <>) + (remove (cut string-match "--enable-threads=*" <>) + ,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-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")) + (setenv "CROSS_CPATH" + (string-append + mingw-headers "/include" + ":" mingw-headers "/crt" + ":" mingw-headers "/defaults/include")))))))) + (replace 'install + (lambda _ + (zero? (system* "make" "install-gcc" "install-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))))) - (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))))))) +(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))) + \f ;;; ;;; 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)))) -- 2.7.3 [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #6: 0005-gnu-gmp-build-shared-library-for-mingw.patch --] [-- Type: text/x-diff, Size: 1178 bytes --] From aaff9752fd10b7860bdba62fba3107fe8133367f Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen <janneke@gnu.org> 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 [-- Attachment #7: 0006-gnu-Add-libiconv.patch --] [-- Type: text/x-diff, Size: 2815 bytes --] From 6e1d4f58d4a7dca54dbbfeacc45f187bf31451ba Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen <janneke@gnu.org> 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 = \ 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 © 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 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 which +don't have one, or whose implementation cannot convert from/to Unicode.") + (home-page "http://www.gnu.org/software/libiconv/") + (license lgpl3+))) -- 2.7.3 [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #8: 0007-gnu-ncurses-support-mingw.patch --] [-- Type: text/x-diff, Size: 6192 bytes --] From 2e676615104f1605357eabe80fa7d716d80bc486 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen <janneke@gnu.org> 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 <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 @@ -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 [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #9: 0008-gnu-readline-support-mingw.patch --] [-- Type: text/x-diff, Size: 7246 bytes --] From f112c5d09b77b2d89cb5c002516c3e78a715d53f Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen <janneke@gnu.org> 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 <fcntl.h> // S_ISUID + ++#ifndef S_ISDIR ++#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) ++#endif ++ + // strlen() + #if defined (HAVE_STRING_H) + # include <string.h> +@@ -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 [-- Attachment #10: 0009-gnu-guile-2.0-support-mingw.-WIP-builds-links-segfau.patch --] [-- Type: text/x-diff, Size: 6041 bytes --] From 1f513d155890453948c6599e57cc2bb384effbb8 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen <janneke@gnu.org> 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-mingw32") + `(("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-mingw32") + "cmd.exe" + `(if bash + (string-append bash "/bin/bash") + "bash")))))) %standard-phases))) (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) +(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"))))) + + (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/patches/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; } + + # This page is for maintenance of the lists of CPP symbols that are eventually +-# included in error.c (‘errno’ values: E*) and posix.c (signal 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 processed +-# (via pattern rule ‘.syms.c’ below) so that each CPP symbol is transformed to ++# (via pattern rule `.syms.c' below) so that each CPP symbol is transformed 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. + # -- 2.7.3 [-- Attachment #11: Type: text/plain, Size: 38 bytes --] on wip-hurd, replace 0004 with this: [-- Attachment #12: 0004-gnu-cross-build-i686-w64-mingw32-new-cross-target.patch --] [-- Type: text/x-diff, Size: 17887 bytes --] From 67fd642293ebc0d88d6f691c2b6bc5ce55eefe36 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen <janneke@gnu.org> 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 © 2013, 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2014, 2015 Mark H Weaver <mhw@netris.org> +;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org> ;;; ;;; This file is part of GNU Guix. ;;; @@ -18,13 +19,18 @@ ;;; 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 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?)) (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=" target) ,@(if libc `( ;; Disable libcilkrts because it is not - ;; ported to GNU/Hurd. + ;; ported to GNU/Hurd. "--disable-libcilkrts") `( ;; Disable features not needed at this stage. "--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=win32 first, and only then + ;; (re)build gcc with --enable-threads=posix. + ;; + ;; i686-w64-mingw32/libstdc++-v3/include/i686-w64-mingw32/bits/gthr-default.h:33:62: + ;; error: types may not be defined in casts + ;; #define CONST_CAST2(TOTYPE,FROMTYPE,X) ((__extension__(union {FROMTYPE _q; TOTYPE _nq;})(X))._nq) + + ,@(if (and libc (equal? target "i686-w64-mingw32")) + ;;'("--with-threads=win32") + '() ;; + '()) + + ,@(if (cross-newlib? target) + '("--with-newlib" + "--without-headers") + '())) ,(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=-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=-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 remove 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 => ~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)))))))) (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 '()))) (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." - + (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")))) - + (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 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. @@ -275,6 +358,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. @@ -283,12 +367,16 @@ 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 + ((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))))) (inputs '()) @@ -302,6 +390,95 @@ GCC that does not target a libc; otherwise, target that libc." (files '("lib" "lib64"))))) (native-search-paths '()))) +(define* (cross-gcc-core target + #:optional (xbinutils (cross-binutils target))) + "Return a cross-compiler-core to be used to build the c library for TARGET, +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=" target)) + (remove (cut string-match "--enable-languages.*" <>) + (remove (cut string-match "--enable-threads=*" <>) + ,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-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")) + (setenv "CROSS_CPATH" + (string-append + mingw-headers "/include" + ":" mingw-headers "/crt" + ":" mingw-headers "/defaults/include")))))))) + (replace 'install + (lambda _ + (zero? (system* "make" "install-gcc" "install-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))))) - (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))))))) +(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))) + \f ;;; ;;; 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)))) -- 2.7.3 [-- Attachment #13: Type: text/plain, Size: 154 bytes --] -- Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.nl ^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: rfc/rfh: i686-w64-mingw32 cross target 2016-04-14 6:30 ` Jan Nieuwenhuizen @ 2016-04-19 14:54 ` Ludovic Courtès 2016-04-24 21:40 ` [PATCH v4 1/9] gnu: cross: Use CROSS_*_INCLUDE_PATH for system headers Jan Nieuwenhuizen 0 siblings, 1 reply; 18+ messages in thread From: Ludovic Courtès @ 2016-04-19 14:54 UTC (permalink / raw) To: Jan Nieuwenhuizen; +Cc: guix-devel [-- Attachment #1: Type: text/plain, Size: 7085 bytes --] Jan Nieuwenhuizen <janneke@gnu.org> skribis: > 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. I think it’s always possible to create variants of the core packages while testing a new feature, such that you don’t end up rebuilding the world. > 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__<arch>, 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. Here what I would recommend is to temporary switch to your own GCC variant in cross-base.scm, for the purposes for accelerating testing. In some cases, one could use ‘replacement’ fields, which in effect is equivalent, AIUI, to --no-dependencies. >> My main concern is the complexity of the cross-base stuff. Why is >> ‘cross-gcc-core’ 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. I understand, but ‘cross-gcc’ already handles that: it can be called with or without a libc. In the latter case, it produces a “sans-libc” GCC that is then used to build the C library. So I’m under the impression that ‘core-gcc’ duplicates this logic. Or am I missing something? Some comments on the “easy” parts: > From aaff9752fd10b7860bdba62fba3107fe8133367f Mon Sep 17 00:00:00 2001 > From: Jan Nieuwenhuizen <janneke@gnu.org> > 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. [...] > + ,@(cond ((equal? (%current-target-system) "i686-w64-mingw32") I think we should have a procedure like this in (guix utils), below ‘%current-target-system’: (define* (mingw-target? #:optional (target (%current-target-system))) (and target (string-suffix? "-mingw32" target))) and use that in all such cases. > + `("--enable-shared" > + "--disable-static")) In general, I think it’s important to add a comment to justify such changes, because ideally MinGW wouldn’t diverge from other systems, and because we want to be able to maintain such workarounds in the future. > From 6e1d4f58d4a7dca54dbbfeacc45f187bf31451ba Mon Sep 17 00:00:00 2001 > From: Jan Nieuwenhuizen <janneke@gnu.org> > 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. Could you please add it to base.scm? Make sure to run ‘guix lint’, which will suggest a synopsis and description, among other things. > From 2e676615104f1605357eabe80fa7d716d80bc486 Mon Sep 17 00:00:00 2001 > From: Jan Nieuwenhuizen <janneke@gnu.org> > 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. [...] > (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"))))))) Obviously this would need to be made conditional. :-) [...] > - `("--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")) It seems there are no functional changes above. > + (cond ((equal? ,(%current-target-system) "i686-w64-mingw32") > + '("--enable-term-driver" > + "--without-cxx" > + "--without-cxx-binding")) This would need to be justified. > + ,@(cond ((equal? (%current-target-system) "i686-w64-mingw32") > + `((delete 'validate-runpath))) > + (else '())) Use #:validate-runpath? #f instead. If the reason is that RUNPATH does not exist on Windows, then we should instead do something like: [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: Type: text/x-patch, Size: 711 bytes --] diff --git a/guix/build-system/gnu.scm b/guix/build-system/gnu.scm index a7d1952..8a817a5 100644 --- a/guix/build-system/gnu.scm +++ b/guix/build-system/gnu.scm @@ -430,7 +430,7 @@ is one of `host' or `target'." "--enable-deterministic-archives")) (strip-directories ''("lib" "lib64" "libexec" "bin" "sbin")) - (validate-runpath? #t) + (validate-runpath? (not (mingw-target? target))) (phases '%standard-phases) (locale "en_US.utf8") (system (%current-system)) [-- Attachment #3: Type: text/plain, Size: 4084 bytes --] > --- /dev/null > +++ b/gnu/packages/patches/ncurses-mingw.patch Please add a note on the origin and upstream status. > From f112c5d09b77b2d89cb5c002516c3e78a715d53f Mon Sep 17 00:00:00 2001 > From: Jan Nieuwenhuizen <janneke@gnu.org> > 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. [...] > +++ 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. Upstream status? [...] > (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") > + '())) These would need to be justified. > From 1f513d155890453948c6599e57cc2bb384effbb8 Mon Sep 17 00:00:00 2001 > From: Jan Nieuwenhuizen <janneke@gnu.org> > 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. [...] > + ,@(if (equal? (%current-target-system) "i686-w64-mingw32") > + `(("libiconv" ,libiconv)) > + `(("bash" ,bash))))) I think we’d need something like: (define* (libiconv-if-needed #:optional (target (%current-target-system))) (if (mingw-target? target) `(("libiconv" ,libiconv)) '())) > +(define-public cross-guile > + (package > + (inherit guile-2.0) > + (name "cross-guile") > + (version "2.0.11") I don’t think it’s needed, is it? :-) > +++ 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; } > + > + # This page is for maintenance of the lists of CPP symbols that are eventually > +-# included in error.c (‘errno’ values: E*) and posix.c (signal names: SIG*), > ++# included in error.c (`errno' values: E*) and posix.c (signal names: SIG*), Why is this needed? In summary, as a maintainer, I want to minimize maintenance work. :-) So I think we must pay a lot of attention to how we integrate support for alternate platforms. Most likely, cross-compilation support for MinGW will remain seldom used, and thus subject to bitrot. Thus, we must make sure that adjustments made to packages for MinGW support are as little intrusive as possible, and well documented so people know why they are there and what to do about them. WDYT? I guess it’s disappointing because you bring a whole lot of patches and I respond on a lot of minor points to address, but I just want to make sure we don’t overcommit! Thank you, Ludo’. ^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v4 1/9] gnu: cross: Use CROSS_*_INCLUDE_PATH for system headers. 2016-04-19 14:54 ` Ludovic Courtès @ 2016-04-24 21:40 ` Jan Nieuwenhuizen 2016-04-25 10:38 ` Andy Wingo 2016-04-25 22:06 ` Jan Nieuwenhuizen 0 siblings, 2 replies; 18+ messages in thread From: Jan Nieuwenhuizen @ 2016-04-24 21:40 UTC (permalink / raw) To: Ludovic Courtès; +Cc: guix-devel [-- Attachment #1: Type: text/plain, Size: 10268 bytes --] Ludovic Courtès writes: Hi! Find attached v4 of my mingw cross build patches. I'm also working with Manolis and using this patch set rebased on wip-hurd have managed to produce the hurd boostrap binaries. > I think it’s always possible to create variants of the core packages > while testing a new feature, such that you don’t end up rebuilding the > world. Hmm...I have been using cross-* versions. I'll probably have to learn to be more careful when moving changes from say, cross-ncurses to the real ncurses, and more trusting that my mingw cross changes don't affect the native builds. I have been avoiding to create cross-guile to depend on cross-readline, depending on cross-ncurses; possibly that's the way to go though. > Here what I would recommend is to temporary switch to your own GCC > variant in cross-base.scm, for the purposes for accelerating testing. Ah, I think this is what I eventually did with cross-gcc-core and then forgot that choice. > In some cases, one could use ‘replacement’ fields, which in effect is > equivalent, AIUI, to --no-dependencies. That sounds interesting, esp. if I want to attempt another cross build. Do you have an example of this? > I understand, but ‘cross-gcc’ already handles that: it can be called > with or without a libc. In the latter case, it produces a “sans-libc” > GCC that is then used to build the C library. > > So I’m under the impression that ‘core-gcc’ duplicates this logic. Or > am I missing something? You're right; merged it into cross-gcc[-sans-libc]. > I think we should have a procedure like this in (guix utils), below > ‘%current-target-system’: > > (define* (mingw-target? #:optional (target (%current-target-system))) > (and target > (string-suffix? "-mingw32" target))) Thanks, added and > and use that in all such cases. done everywhere...except in the ncurses package. I don't know how to access (guix utils) mingw-target? there, for now I'm using (post-install-phase `(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)))) any help much appreciated. >> + `("--enable-shared" >> + "--disable-static")) > > In general, I think it’s important to add a comment to justify such > changes, because ideally MinGW wouldn’t diverge from other systems, and > because we want to be able to maintain such workarounds in the future. I added ;; Static and shared cannot be built in one go: ;; they produce different headers. We need shared. `("--disable-static" "--enable-shared")) >> * gnu/packages/libiconv.scm: New file. >> gnu-system.am: Add it. > > Could you please add it to base.scm? Make sure to run ‘guix lint’, > which will suggest a synopsis and description, among other things. Thanks, done. >> + (with-directory-excursion (string-append out "/bin") >> + (for-each (lambda (lib) >> + (define lib.dll >> + (string-append "lib" lib ".dll")) > Obviously this would need to be made conditional. :-) Ah, yes! Thanks, this removes the need for disabling validate-runpath. >> - `("--with-shared" "--without-debug" "--enable-widec" >> + (append >> + `("--with-shared" "--without-debug" "--enable-widec" > > It seems there are no functional changes above. Right, only to enable the (append of: >> + (cond ((equal? ,(%current-target-system) "i686-w64-mingw32") >> + '("--enable-term-driver" >> + "--without-cxx" >> + "--without-cxx-binding")) > > This would need to be justified. Removed append, now changed using splicing to ;; MinGW: Use terminal driver, created for the MinGW port. ,@(if ,(mingw-target?) '("--enable-term-driver") '())) the --without-cxx, --without-cxx-binding were probably to help me bootstrapping. >> + ,@(cond ((equal? (%current-target-system) "i686-w64-mingw32") >> + `((delete 'validate-runpath))) >> + (else '())) > > Use #:validate-runpath? #f instead. I have worked on this all morning. It is no longer necessary to disable runpath, it appeared to be collateral damage. > If the reason is that RUNPATH does not exist on Windows, then we should > instead do something like: > > diff --git a/guix/build-system/gnu.scm b/guix/build-system/gnu.scm > index a7d1952..8a817a5 100644 > --- a/guix/build-system/gnu.scm > +++ b/guix/build-system/gnu.scm > @@ -430,7 +430,7 @@ is one of `host' or `target'." > "--enable-deterministic-archives")) > (strip-directories ''("lib" "lib64" "libexec" > "bin" "sbin")) > - (validate-runpath? #t) > + (validate-runpath? (not (mingw-target? target))) > (phases '%standard-phases) > (locale "en_US.utf8") > (system (%current-system)) Not sure. There are no elf files produced on MinGW, so validate-runpath is a no-op anyway. WDYT? >> --- /dev/null >> +++ b/gnu/packages/patches/ncurses-mingw.patch > > Please add a note on the origin and upstream status. Added Taken from Eli Zaretskii's gdb bug report https://sourceware.org/ml/gdb-patches/2012-04/msg01052.html Upstream status: Not presented to upstream. >> +++ 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. > > Upstream status? Added Upstream status: Not presented to upstream. >> ;; 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") >> + '())) > These would need to be justified. This was a bit crude, changed back to ,@(if (%current-target-system) '("bash_cv_wcwidth_broken=no") '()) and added ;; MinGW: ncurses provides the termcap api. ,@(if (mingw-target?) '("bash_cv_termcap_lib=ncurses") '())) #:make-flags (list ,@(if (mingw-target?) ;; MinGW: termcap in ncurses '("TERMCAP_LIB=-lncurses") '())) >> + ,@(if (equal? (%current-target-system) "i686-w64-mingw32") >> + `(("libiconv" ,libiconv)) >> + `(("bash" ,bash))))) > > I think we’d need something like: > > (define* (libiconv-if-needed #:optional (target (%current-target-system))) > (if (mingw-target? target) > `(("libiconv" ,libiconv)) > '())) Thanks! Added to base.scm, changed guile's inputs to (inputs `(("libffi" ,libffi) ("readline" ,readline) ,@(libiconv-if-needed) ,@(if (mingw-target?) '() `(("bash" ,bash))))) >> +(define-public cross-guile >> + (package >> + (inherit guile-2.0) >> + (name "cross-guile") >> + (version "2.0.11") > > I don’t think it’s needed, is it? :-) Well, it can come-in handy ;-) Sorry, removed. >> +++ b/gnu/packages/patches/guile-remove-utf8.patch >> +-# included in error.c (‘errno’ values: E*) and posix.c (signal names: SIG*), >> ++# included in error.c (`errno' values: E*) and posix.c (signal names: SIG*), > > Why is this needed? Removed. This fixed substitute* failing when cross compiling and I figured that using utf8 quotes here was probabl unintentional; I cannot reproduce the problem anymore, possibly an artifact of cross-gcc-core. > In summary, as a maintainer, I want to minimize maintenance work. :-) > So I think we must pay a lot of attention to how we integrate support > for alternate platforms. Sure, I can appreciate that. > Most likely, cross-compilation support for MinGW will remain seldom > used, and thus subject to bitrot. Thus, we must make sure that > adjustments made to packages for MinGW support are as little intrusive > as possible, and well documented so people know why they are there and > what to do about them. > > WDYT? I agree. GUB's approach of target-specialisations has the nice feature of separating out weird ports such as MinGW instead of touching most every package definition, which I'm a stil bit uncomfortable with in Guix. However, that approach is even more susceptible to bitrot. > I guess it’s disappointing because you bring a whole lot of patches and > I respond on a lot of minor points to address, but I just want to make > sure we don’t overcommit! Well, I am aware that adding a new port might take some time to land and your comments are helpful, thanks a lot for taking this time! What's disappointing is having to wait to see result of rebuild world when I move my changes from cross-ncurses to ncurses [too early], my lack of iron to make that fast, my lack of knowledge of Guix to possibly use the repl more :-) Greetings, Jan [-- Attachment #2: 0001-gnu-cross-Use-CROSS_-_INCLUDE_PATH-for-system-header.patch --] [-- Type: text/x-diff, Size: 11444 bytes --] From 360f2e8ed82368857f208d155a1c462570eb7447 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen <janneke@gnu.org> Date: Sun, 17 Apr 2016 18:20:05 +0200 Subject: [PATCH 1/9] gnu: cross: Use CROSS_*_INCLUDE_PATH for system headers. * gnu/packages/patches/gcc-cross-environment-variables.patch: Also use CROSS_ variants: CROSS_C_INCLUDE_PATH, CROSS_CPLUS_INCLUDE_PATH, CROSS_OBJC_INCLUDE_PATH, CROSS_OBJCPLUS_INCLUDE_PATH to be used for system libraries, see https://lists.gnu.org/archive/html/guix-devel/2016-04/msg00620.html. * gnu/packages/cross-base.scm (cross-gcc, cross-gcc-arguments, cross-libc): Use CROSS_*_INCLUDE_PATH (WAS: CPATH). --- gnu/packages/cross-base.scm | 76 ++++++++++++------- .../patches/gcc-cross-environment-variables.patch | 86 +++++++++++++++------- 2 files changed, 110 insertions(+), 52 deletions(-) diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm index 8bd599c..b440750 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 © 2013, 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2014, 2015 Mark H Weaver <mhw@netris.org> +;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org> ;;; ;;; This file is part of GNU Guix. ;;; @@ -31,6 +32,7 @@ #:use-module (guix build-system trivial) #:use-module (srfi srfi-1) #:use-module (srfi srfi-26) + #:use-module (ice-9 and-let-star) #:use-module (ice-9 match) #:export (cross-binutils cross-libc @@ -168,34 +170,44 @@ may be either a libc package or #f.)" (lambda* (#:key inputs #:allow-other-keys) ;; Add the cross Linux headers to CROSS_CPATH, and remove them ;; from CPATH. - (let ((libc (assoc-ref inputs "libc")) + (let ((libc (assoc-ref inputs libc)) (linux (assoc-ref inputs "xlinux-headers"))) (define (cross? x) ;; Return #t if X is a cross-libc or cross Linux. (or (string-prefix? libc x) (string-prefix? linux x))) - - (setenv "CROSS_CPATH" - (string-append libc "/include:" - linux "/include")) + (let ((cpath (string-append + libc "/include" + ":" linux "/include"))) + (for-each (cut setenv <> cpath) + '("CROSS_C_INCLUDE_PATH" + "CROSS_CPLUS_INCLUDE_PATH" + "CROSS_OBJC_INCLUDE_PATH" + "CROSS_OBJCPLUS_INCLUDE_PATH"))) (setenv "CROSS_LIBRARY_PATH" (string-append libc "/lib")) - - (let ((cpath (search-path-as-string->list - (getenv "C_INCLUDE_PATH"))) - (libpath (search-path-as-string->list - (getenv "LIBRARY_PATH")))) - (setenv "CPATH" - (list->search-path-as-string - (remove cross? cpath) ":")) - (for-each unsetenv - '("C_INCLUDE_PATH" "CPLUS_INCLUDE_PATH")) - (setenv "LIBRARY_PATH" - (list->search-path-as-string - (remove cross? libpath) ":")) - #t))) - ,phases) - phases))))))) + (setenv "CPP" (string-append gcc "/bin/cpp")) + (for-each (lambda (var) + (and-let* ((value (getenv var)) + (path (search-path-as-string->list + value)) + (native-path + (list->search-path-as-string + (remove cross? path) ":")))) + (let* ((path (search-path-as-string->list + (getenv var))) + (native-path + (and path + (list->search-path-as-string + (remove cross? path) ":")))) + (if native-path (setenv var native-path)))) + '("C_INCLUDE_PATH" + "CPLUS_INCLUDE_PATH" + "OBJC_INCLUDE_PATH" + "OBJCPLUS_INCLUDE_PATH" + "LIBRARY_PATH")))) + ,phases)) + (else phases)))))))) (define (cross-gcc-patches target) "Return GCC patches needed for TARGET." @@ -228,6 +240,7 @@ 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 and-let-star) (ice-9 regex) (srfi srfi-1) (srfi srfi-26)) @@ -261,7 +274,16 @@ GCC that does not target a libc; otherwise, target that libc." ;; Only search target inputs, not host inputs. (search-paths (list (search-path-specification - (variable "CROSS_CPATH") + (variable "CROSS_C_INCLUDE_PATH") + (files '("include"))) + (search-path-specification + (variable "CROSS_CPLUS_INCLUDE_PATH") + (files '("include"))) + (search-path-specification + (variable "CROSS_OBJC_INCLUDE_PATH") + (files '("include"))) + (search-path-specification + (variable "CROSS_OBJCPLUS_INCLUDE_PATH") (files '("include"))) (search-path-specification (variable "CROSS_LIBRARY_PATH") @@ -316,9 +338,13 @@ XBINUTILS and the cross tool chain." `(alist-cons-before 'configure 'set-cross-linux-headers-path (lambda* (#:key inputs #:allow-other-keys) - (let ((linux (assoc-ref inputs "linux-headers"))) - (setenv "CROSS_CPATH" - (string-append linux "/include")) + (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)))) diff --git a/gnu/packages/patches/gcc-cross-environment-variables.patch b/gnu/packages/patches/gcc-cross-environment-variables.patch index 0bd0be5..a2b94cb 100644 --- a/gnu/packages/patches/gcc-cross-environment-variables.patch +++ b/gnu/packages/patches/gcc-cross-environment-variables.patch @@ -1,9 +1,48 @@ -Search path environment variables for cross-compilers. See the discussion -at <http://gcc.gnu.org/ml/gcc/2013-02/msg00124.html>. +From a1d8c3d926cb43e51a2b4838ad5cca9c2510fbbb Mon Sep 17 00:00:00 2001 +From: Jan Nieuwenhuizen <janneke@gnu.org> +Date: Sat, 16 Apr 2016 10:08:16 +0200 +Subject: [PATCH] Search path environment variables for cross-compilers. See + the discussion at <http://gcc.gnu.org/ml/gcc/2013-02/msg00124.html> ---- gcc-4.7.2/gcc/incpath.c 2012-01-27 00:34:58.000000000 +0100 -+++ gcc-4.7.2/gcc/incpath.c 2013-02-12 10:11:27.000000000 +0100 -@@ -452,7 +452,7 @@ register_include_chains (cpp_reader *pfi +and + +<https://lists.gnu.org/archive/html/guix-devel/2016-04/msg00533.html> +--- + gcc/gcc.c | 2 +- + gcc/incpath.c | 6 +++--- + gcc/system.h | 2 ++ + gcc/tlink.c | 2 +- + 4 files changed, 7 insertions(+), 5 deletions(-) + +diff --git a/gcc/gcc.c b/gcc/gcc.c +index adbf0c4..70448c6 100644 +--- a/gcc/gcc.c ++++ b/gcc/gcc.c +@@ -3853,7 +3853,7 @@ process_command (unsigned int decoded_options_count, + } + + temp = getenv (LIBRARY_PATH_ENV); +- if (temp && *cross_compile == '0') ++ if (temp) + { + const char *startp, *endp; + char *nstore = (char *) alloca (strlen (temp) + 3); +diff --git a/gcc/incpath.c b/gcc/incpath.c +index f495c0a..ba12249 100644 +--- a/gcc/incpath.c ++++ b/gcc/incpath.c +@@ -461,8 +461,8 @@ register_include_chains (cpp_reader *pfile, const char *sysroot, + int stdinc, int cxx_stdinc, int verbose) + { + static const char *const lang_env_vars[] = +- { "C_INCLUDE_PATH", "CPLUS_INCLUDE_PATH", +- "OBJC_INCLUDE_PATH", "OBJCPLUS_INCLUDE_PATH" }; ++ { "CROSS_C_INCLUDE_PATH", "CROSS_CPLUS_INCLUDE_PATH", ++ "CROSS_OBJC_INCLUDE_PATH", "CROSS_OBJCPLUS_INCLUDE_PATH" }; + cpp_options *cpp_opts = cpp_get_options (pfile); + size_t idx = (cpp_opts->objc ? 2: 0); + +@@ -473,7 +473,7 @@ register_include_chains (cpp_reader *pfile, const char *sysroot, /* CPATH and language-dependent environment variables may add to the include chain. */ @@ -12,37 +51,30 @@ at <http://gcc.gnu.org/ml/gcc/2013-02/msg00124.html>. add_env_var_paths (lang_env_vars[idx], SYSTEM); target_c_incpath.extra_pre_includes (sysroot, iprefix, stdinc); - ---- gcc-4.7.2/gcc/system.h 2012-02-17 00:16:28.000000000 +0100 -+++ gcc-4.7.2/gcc/system.h 2013-02-12 10:22:17.000000000 +0100 -@@ -1023,4 +1023,6 @@ helper_const_non_const_cast (const char - #define DEBUG_VARIABLE - #endif +diff --git a/gcc/system.h b/gcc/system.h +index 42bc509..af3b9ad 100644 +--- a/gcc/system.h ++++ b/gcc/system.h +@@ -1063,4 +1063,6 @@ helper_const_non_const_cast (const char *p) + /* Get definitions of HOST_WIDE_INT and HOST_WIDEST_INT. */ + #include "hwint.h" +#define LIBRARY_PATH_ENV "CROSS_LIBRARY_PATH" + #endif /* ! GCC_SYSTEM_H */ - ---- gcc-4.7.2/gcc/tlink.c 2012-02-11 09:50:23.000000000 +0100 -+++ gcc-4.7.2/gcc/tlink.c 2013-05-23 22:06:19.000000000 +0200 -@@ -461,7 +461,7 @@ recompile_files (void) +diff --git a/gcc/tlink.c b/gcc/tlink.c +index bc358b8..ad6242f 100644 +--- a/gcc/tlink.c ++++ b/gcc/tlink.c +@@ -458,7 +458,7 @@ recompile_files (void) file *f; putenv (xstrdup ("COMPILER_PATH=")); - putenv (xstrdup ("LIBRARY_PATH=")); -+ putenv (xstrdup (LIBRARY_PATH_ENV "=")); ++ putenv (xstrdup ("LIBRARY_PATH_ENV=")); while ((f = file_pop ()) != NULL) { +-- +2.1.4 ---- gcc-4.7.3/gcc/gcc.c 2013-03-08 08:25:09.000000000 +0100 -+++ gcc-4.7.3/gcc/gcc.c 2013-05-24 08:58:16.000000000 +0200 -@@ -3726,7 +3726,7 @@ process_command (unsigned int decoded_op - } - - temp = getenv (LIBRARY_PATH_ENV); -- if (temp && *cross_compile == '0') -+ if (temp) - { - const char *startp, *endp; - char *nstore = (char *) alloca (strlen (temp) + 3); -- 2.7.3 [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #3: 0002-gnu-bootstrap-Add-i686-mingw.patch --] [-- Type: text/x-diff, Size: 884 bytes --] From af07226044b6fcf77d863b42e7d25433dd56052d Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen <janneke@gnu.org> Date: Thu, 14 Apr 2016 07:31:35 +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 f5bf069..979ab1d 100644 --- a/gnu/packages/bootstrap.scm +++ b/gnu/packages/bootstrap.scm @@ -171,6 +171,7 @@ successful, or false to signal an error." ;; here just so we can keep going. ((string=? system "xtensa-elf") "no-ld.so") ((string=? system "avr") "no-ld.so") + ((string=? system "i686-mingw") "no-ld.so") (else (error "dynamic linker name not known for this system" system)))) -- 2.7.3 [-- Attachment #4: 0003-gnu-Add-mingw-w64.patch --] [-- Type: text/x-diff, Size: 9792 bytes --] From 80a791a193e921a92fef37429f46ebdce85f7bee Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen <janneke@gnu.org> Date: Thu, 14 Apr 2016 07:35:40 +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 8822d0b..7ab45cd 100644 --- a/gnu-system.am +++ b/gnu-system.am @@ -225,6 +225,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 \ @@ -478,6 +479,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 \ @@ -606,6 +608,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..7d9276a --- /dev/null +++ b/gnu/packages/mingw.scm @@ -0,0 +1,109 @@ +;;; 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/" + name "/" name "-release/" name "-v" version ".tar.bz2")) + (sha256 + (base32 "0imdary8j07if8ih73pfgxiclpf2ax8h3mz8mxln07i8sbbd30c9")) + (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_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"))))) + (native-inputs `(("xgcc-core" ,xgcc-sans-libc-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=i686-w64-mingw32" + "--target=i686-w64-mingw32" + "--with-as=i686-w64-mingw32-as" + "--with-ld=i686-w64-mingw32-ld" + "--with-nm=i686-w64-mingw32-nm") + #:make-flags (list "DEFS=-DHAVE_CONFIG_H -D__MINGW_HAS_DXSDK=1") + #: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-headers"))) + ;; 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" "/bin" + ":" (getenv "PATH"))) + (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")))))))) + (home-page "http://mingw.org") + (synopsis "Minimalist GNU for Windows") + (description "MinGW provides a complete Open Source programming tool set +which is suitable for the development of native MS-Windows applications, and +which do not depend on any 3rd-party C-Runtime dlls.") + (license 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..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 21: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.871461798 +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) hypot ((double)x, (double)y);} + #endif + extern long double __cdecl hypotl (long double, long double); -- 2.7.3 [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #5: 0004-gnu-cross-build-i686-w64-mingw32-new-cross-target.patch --] [-- Type: text/x-diff, Size: 13686 bytes --] From 0f9dd17a6d2223ebe059b566d49130ad8369387f Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen <janneke@gnu.org> Date: Sun, 17 Apr 2016 18:42:43 +0200 Subject: [PATCH 4/9] 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 | 163 +++++++++++++++++++++++++++++++++++++++----- guix/utils.scm | 5 ++ 2 files changed, 151 insertions(+), 17 deletions(-) diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm index b440750..9abfdb9 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) @@ -36,7 +41,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 @@ -122,20 +128,34 @@ may be either a libc package or #f.)" "--disable-libquadmath" "--disable-decimal-float" ;would need libc "--disable-libcilkrts" - ))) + )) + + ,@(if (cross-newlib? target) + '("--with-newlib" + "--without-threads" + "--without-headers") + '())) ,(if libc flags `(remove (cut string-match "--enable-languages.*" <>) ,flags)))) ((#:make-flags flags) - (if libc + (cond + ((mingw-target? target) + `(append (let ((runtime (assoc-ref %build-inputs "mingw-w64"))) + (if runtime + (list + (string-append "FLAGS_FOR_TARGET=-B" runtime "/lib")) + '("all-gcc" "all-target-libgcc"))) + ,flags)) + (libc `(let ((libc (assoc-ref %build-inputs "libc"))) ;; FLAGS_FOR_TARGET are needed for the target libraries to receive ;; the -Bxxx for the startfiles. (cons (string-append "FLAGS_FOR_TARGET=-B" libc "/lib") - ,flags)) - flags)) + ,flags))) + (else flags))) ((#:phases phases) (let ((phases `(alist-cons-after @@ -164,7 +184,70 @@ 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 Linux headers to CROSS_CPATH, and remove 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 => ~a\n" x (and libc (string-prefix? libc 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"))))) + (if 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-let* ((value (getenv var)) + (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"))))) + ,@(if libc '() + '((replace 'install + (lambda _ + (zero? (system* "make" "install-gcc" "install-target-libgcc")))))))) + (libc `(alist-cons-before 'configure 'set-cross-path (lambda* (#:key inputs #:allow-other-keys) @@ -214,10 +297,19 @@ may be either a libc package or #f.)" (cond ((string-prefix? "xtensa-" target) ;; Patch by Qualcomm needed to build the ath9k-htc firmware. (list (search-patch "ath9k-htc-firmware-gcc.patch"))) + ((mingw-target? 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 ((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." @@ -230,7 +322,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,6 +348,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. @@ -261,13 +357,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 + `(("mingw-w64" ,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 '()) @@ -296,7 +399,11 @@ 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 + (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)) @@ -316,8 +423,7 @@ XBINUTILS and the cross tool chain." ,phases)))) (native-inputs `(("cross-gcc" ,xgcc) ("cross-binutils" ,xbinutils) - ,@(package-native-inputs linux-libre-headers))))) - + ,@(package-native-inputs linux-libre-headers)))))) (package (inherit glibc) (name (string-append "glibc-cross-" target)) (arguments @@ -359,7 +465,15 @@ XBINUTILS and the cross tool chain." (native-inputs `(("cross-gcc" ,xgcc) ("cross-binutils" ,xbinutils) ,@(package-inputs glibc) ;FIXME: static-bash - ,@(package-native-inputs glibc))))) + ,@(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 ;;; @@ -401,3 +515,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 de54179..b796bde 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>? @@ -544,6 +545,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 [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #6: 0005-gnu-gmp-build-shared-library-for-mingw.patch --] [-- Type: text/x-diff, Size: 1299 bytes --] From 9631611d35b7cafdc518076fb841420e23fd8d12 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen <janneke@gnu.org> Date: Tue, 12 Apr 2016 15:48:28 +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 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gnu/packages/multiprecision.scm b/gnu/packages/multiprecision.scm index ad50770..7a608f9 100644 --- a/gnu/packages/multiprecision.scm +++ b/gnu/packages/multiprecision.scm @@ -49,7 +49,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 [-- Attachment #7: 0006-gnu-Add-libiconv.patch --] [-- Type: text/x-diff, Size: 2825 bytes --] From 6e87f80249f6383899911e0f4a28a05d0fbb1449 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen <janneke@gnu.org> Date: Tue, 12 Apr 2016 15:46:58 +0200 Subject: [PATCH 6/9] gnu: Add libiconv. * gnu/packages/base.scm (libiconv): New variable. (libiconv-if-needed): New function. --- gnu/packages/base.scm | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/gnu/packages/base.scm b/gnu/packages/base.scm index e662827..aaccf28 100644 --- a/gnu/packages/base.scm +++ b/gnu/packages/base.scm @@ -6,6 +6,7 @@ ;;; Copyright © 2014 Alex Kost <alezost@gmail.com> ;;; Copyright © 2014, 2015 Manolis Fragkiskos Ragkousis <manolis837@gmail.com> ;;; Copyright © 2016 Efraim Flashner <efraim@flashner.co.il> +;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org> ;;; ;;; This file is part of GNU Guix. ;;; @@ -24,7 +25,7 @@ (define-module (gnu packages base) #:use-module ((guix licenses) - #:select (gpl3+ lgpl2.0+ public-domain)) + #:select (gpl3+ lgpl2.0+ lgpl3+ public-domain)) #:use-module (gnu packages) #:use-module (gnu packages acl) #:use-module (gnu packages bash) @@ -43,7 +44,9 @@ #: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 (glibc + libiconv-if-needed)) ;;; Commentary: ;;; @@ -940,6 +943,32 @@ reflect changes made by political bodies to time zone boundaries, UTC offsets, and daylight-saving rules.") (license public-domain))) +(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 + "libiconv provides an implementation of the iconv function for systems +that lack it. iconv is used to convert between character encodings in a +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 [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #8: 0007-gnu-ncurses-support-mingw.patch --] [-- Type: text/x-diff, Size: 8926 bytes --] From 16fb64fafa8843ffde937f144a73b1fadcefed3e Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen <janneke@gnu.org> Date: Tue, 12 Apr 2016 15:47:54 +0200 Subject: [PATCH 7/9] gnu: ncurses: support mingw. * gnu/packages/patches/ncurses-mingw.patch: New file. * gnu/packages/ncurses.scm (ncurses): Support mingw. --- gnu-system.am | 1 + gnu/packages/ncurses.scm | 88 +++++++++++++++++++++++--------- gnu/packages/patches/ncurses-mingw.patch | 24 +++++++++ 3 files changed, 88 insertions(+), 25 deletions(-) create mode 100644 gnu/packages/patches/ncurses-mingw.patch diff --git a/gnu-system.am b/gnu-system.am index 7ab45cd..0105265 100644 --- a/gnu-system.am +++ b/gnu-system.am @@ -619,6 +619,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..74f588c 100644 --- a/gnu/packages/ncurses.scm +++ b/gnu/packages/ncurses.scm @@ -19,9 +19,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 +38,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 +63,65 @@ "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")) - - (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"))))))) + (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))))) + libraries)))))))) (package (name "ncurses") (version "6.0") @@ -94,6 +129,7 @@ (method url-fetch) (uri (string-append "mirror://gnu/ncurses/ncurses-" version ".tar.gz")) + (patches (list (search-patch "ncurses-mingw.patch"))) (sha256 (base32 "0q3jck7lna77z5r42f13c4xglc7azd19pxfrjrpgp2yf615w4lgm")))) @@ -113,7 +149,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 [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #9: 0008-gnu-readline-support-mingw.patch --] [-- Type: text/x-diff, Size: 7703 bytes --] From c5ab72c87c4d46b2356ed50dbb14e115f4013265 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen <janneke@gnu.org> Date: Tue, 12 Apr 2016 15:49:17 +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 | 128 ++++++++++++++++++++++++++ gnu/packages/readline.scm | 18 +++- 3 files changed, 143 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 0105265..f1502c1 100644 --- a/gnu-system.am +++ b/gnu-system.am @@ -705,6 +705,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..28064bb --- /dev/null +++ b/gnu/packages/patches/readline-6.3-mingw.patch @@ -0,0 +1,128 @@ +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. + +Upstream status: Not presented to upstream. + +--- 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 <fcntl.h> // S_ISUID + ++#ifndef S_ISDIR ++#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) ++#endif ++ + // strlen() + #if defined (HAVE_STRING_H) + # include <string.h> +@@ -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..905f710 100644 --- a/gnu/packages/readline.scm +++ b/gnu/packages/readline.scm @@ -22,7 +22,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 @@ -46,21 +47,30 @@ (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 (mingw-target?) "/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") + '()) + ;; MinGW: ncurses provides the termcap api. + ,@(if (mingw-target?) + '("bash_cv_termcap_lib=ncurses") '())) - + #:make-flags (list ,@(if (mingw-target?) + ;; MinGW: termcap in ncurses + '("TERMCAP_LIB=-lncurses") + '())) #:phases (alist-cons-after 'install 'post-install ,post-install-phase -- 2.7.3 [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #10: 0009-gnu-guile-2.0-support-mingw.-WIP-builds-links-segfau.patch --] [-- Type: text/x-diff, Size: 2067 bytes --] From 08215e8579745a5cb1516e26ab9d80b5eb226dbd Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen <janneke@gnu.org> Date: Sun, 24 Apr 2016 14:06:56 +0200 Subject: [PATCH 9/9] gnu: guile-2.0: support mingw. WIP: builds, links, segfaults. * gnu/packages/guile.scm (guile-2.0): Support mingw. --- gnu/packages/guile.scm | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/gnu/packages/guile.scm b/gnu/packages/guile.scm index fe043cb..d0697f6 100644 --- a/gnu/packages/guile.scm +++ b/gnu/packages/guile.scm @@ -134,11 +134,16 @@ without requiring the source code to be rewritten.") "1qh3j7308qvsjgwf7h94yqgckpbgz2k3yqdkzsyhqcafvfka9l5f")) (patches (list (search-patch "guile-arm-fixes.patch"))))) (build-system gnu-build-system) - (native-inputs `(("pkgconfig" ,pkg-config))) + (native-inputs `(("pkgconfig" ,pkg-config) + ,@(if (mingw-target?) + '(("bash" ,bash) + ("guile" ,guile-2.0)) + '()))) (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,7 +172,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 (mingw-target?) + "cmd.exe" + `(if bash + (string-append bash "/bin/bash") + "bash")))))) %standard-phases))) (native-search-paths -- 2.7.3 [-- Attachment #11: Type: text/plain, Size: 154 bytes --] -- Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.nl ^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH v4 1/9] gnu: cross: Use CROSS_*_INCLUDE_PATH for system headers. 2016-04-24 21:40 ` [PATCH v4 1/9] gnu: cross: Use CROSS_*_INCLUDE_PATH for system headers Jan Nieuwenhuizen @ 2016-04-25 10:38 ` Andy Wingo 2016-04-25 11:28 ` Jan Nieuwenhuizen 2016-04-25 22:06 ` Jan Nieuwenhuizen 1 sibling, 1 reply; 18+ messages in thread From: Andy Wingo @ 2016-04-25 10:38 UTC (permalink / raw) To: Jan Nieuwenhuizen; +Cc: guix-devel On Sun 24 Apr 2016 23:40, Jan Nieuwenhuizen <janneke@gnu.org> writes: > + (setenv "CPP" (string-append gcc "/bin/cpp")) > + (for-each (lambda (var) > + (and-let* ((value (getenv var)) > + (path (search-path-as-string->list > + value)) > + (native-path ^^ Bad indentation here; it should be indented like let* > + (list->search-path-as-string > + (remove cross? path) ":")))) > + (let* ((path (search-path-as-string->list > + (getenv var))) However given this, both "value" and "path" should succeed without error... > + (native-path > + (and path > + (list->search-path-as-string > + (remove cross? path) ":")))) And this is a repeat? Perhaps you meant to replace the and-let* block, or to remove this one? I would lean towards not using and-let* fwiw :) > + (if native-path (setenv var native-path)))) For one-armed ifs, please use "when" or "unless". Tx :) Andy ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v4 1/9] gnu: cross: Use CROSS_*_INCLUDE_PATH for system headers. 2016-04-25 10:38 ` Andy Wingo @ 2016-04-25 11:28 ` Jan Nieuwenhuizen 2016-04-26 8:00 ` Andy Wingo 0 siblings, 1 reply; 18+ messages in thread From: Jan Nieuwenhuizen @ 2016-04-25 11:28 UTC (permalink / raw) To: Andy Wingo; +Cc: guix-devel [-- Attachment #1: Type: text/plain, Size: 1670 bytes --] Andy Wingo writes: >> + (setenv "CPP" (string-append gcc "/bin/cpp")) >> + (for-each (lambda (var) >> + (and-let* ((value (getenv var)) >> + (path (search-path-as-string->list >> + value)) >> + (native-path > ^^ > > Bad indentation here; it should be indented like let* Argh, sorry this all wrong, a rebase goof-up; only fixed this on wip-hurd+mingw branch. It was meant as (fixed in attached patch) (and-let* ((value (getenv var)) (path (search-path-as-string->list value)) (native-path (list->search-path-as-string (remove cross? path) ":"))) (setenv var native-path))) What about indentation, I blindly trust Emacs... > However given this, both "value" and "path" should succeed without > error... Yes... >> + (native-path >> + (and path >> + (list->search-path-as-string >> + (remove cross? path) ":")))) > > And this is a repeat? Perhaps you meant to replace the and-let* block, > or to remove this one? I would lean towards not using and-let* fwiw :) Yes... Why do you not prefer the and-let*, how would you write it? > For one-armed ifs, please use "when" or "unless". Tx :) Ok. Thanks! Greetings, Jan [-- Attachment #2: 0001-gnu-cross-Use-CROSS_-_INCLUDE_PATH-for-system-header.patch --] [-- Type: text/x-diff, Size: 11027 bytes --] From f2842ce5e35c0d984fc18912088bb81f9bac38f5 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen <janneke@gnu.org> Date: Sun, 17 Apr 2016 18:20:05 +0200 Subject: [PATCH 1/9] gnu: cross: Use CROSS_*_INCLUDE_PATH for system headers. * gnu/packages/patches/gcc-cross-environment-variables.patch: Also use CROSS_ variants: CROSS_C_INCLUDE_PATH, CROSS_CPLUS_INCLUDE_PATH, CROSS_OBJC_INCLUDE_PATH, CROSS_OBJCPLUS_INCLUDE_PATH to be used for system libraries, see https://lists.gnu.org/archive/html/guix-devel/2016-04/msg00620.html. * gnu/packages/cross-base.scm (cross-gcc, cross-gcc-arguments, cross-libc): Use CROSS_*_INCLUDE_PATH (WAS: CPATH). --- gnu/packages/cross-base.scm | 70 +++++++++++------- .../patches/gcc-cross-environment-variables.patch | 86 +++++++++++++++------- 2 files changed, 104 insertions(+), 52 deletions(-) diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm index 8bd599c..2e1bcf8 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 © 2013, 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2014, 2015 Mark H Weaver <mhw@netris.org> +;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org> ;;; ;;; This file is part of GNU Guix. ;;; @@ -31,6 +32,7 @@ #:use-module (guix build-system trivial) #:use-module (srfi srfi-1) #:use-module (srfi srfi-26) + #:use-module (ice-9 and-let-star) #:use-module (ice-9 match) #:export (cross-binutils cross-libc @@ -168,34 +170,38 @@ may be either a libc package or #f.)" (lambda* (#:key inputs #:allow-other-keys) ;; Add the cross Linux headers to CROSS_CPATH, and remove them ;; from CPATH. - (let ((libc (assoc-ref inputs "libc")) + (let ((libc (assoc-ref inputs libc)) (linux (assoc-ref inputs "xlinux-headers"))) (define (cross? x) ;; Return #t if X is a cross-libc or cross Linux. (or (string-prefix? libc x) (string-prefix? linux x))) - - (setenv "CROSS_CPATH" - (string-append libc "/include:" - linux "/include")) + (let ((cpath (string-append + libc "/include" + ":" linux "/include"))) + (for-each (cut setenv <> cpath) + '("CROSS_C_INCLUDE_PATH" + "CROSS_CPLUS_INCLUDE_PATH" + "CROSS_OBJC_INCLUDE_PATH" + "CROSS_OBJCPLUS_INCLUDE_PATH"))) (setenv "CROSS_LIBRARY_PATH" (string-append libc "/lib")) - - (let ((cpath (search-path-as-string->list - (getenv "C_INCLUDE_PATH"))) - (libpath (search-path-as-string->list - (getenv "LIBRARY_PATH")))) - (setenv "CPATH" - (list->search-path-as-string - (remove cross? cpath) ":")) - (for-each unsetenv - '("C_INCLUDE_PATH" "CPLUS_INCLUDE_PATH")) - (setenv "LIBRARY_PATH" - (list->search-path-as-string - (remove cross? libpath) ":")) - #t))) - ,phases) - phases))))))) + (setenv "CPP" (string-append gcc "/bin/cpp")) + (for-each (lambda (var) + (and-let* ((value (getenv var)) + (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")))) + ,phases)) + (else phases)))))))) (define (cross-gcc-patches target) "Return GCC patches needed for TARGET." @@ -228,6 +234,7 @@ 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 and-let-star) (ice-9 regex) (srfi srfi-1) (srfi srfi-26)) @@ -261,7 +268,16 @@ GCC that does not target a libc; otherwise, target that libc." ;; Only search target inputs, not host inputs. (search-paths (list (search-path-specification - (variable "CROSS_CPATH") + (variable "CROSS_C_INCLUDE_PATH") + (files '("include"))) + (search-path-specification + (variable "CROSS_CPLUS_INCLUDE_PATH") + (files '("include"))) + (search-path-specification + (variable "CROSS_OBJC_INCLUDE_PATH") + (files '("include"))) + (search-path-specification + (variable "CROSS_OBJCPLUS_INCLUDE_PATH") (files '("include"))) (search-path-specification (variable "CROSS_LIBRARY_PATH") @@ -316,9 +332,13 @@ XBINUTILS and the cross tool chain." `(alist-cons-before 'configure 'set-cross-linux-headers-path (lambda* (#:key inputs #:allow-other-keys) - (let ((linux (assoc-ref inputs "linux-headers"))) - (setenv "CROSS_CPATH" - (string-append linux "/include")) + (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)))) diff --git a/gnu/packages/patches/gcc-cross-environment-variables.patch b/gnu/packages/patches/gcc-cross-environment-variables.patch index 0bd0be5..a2b94cb 100644 --- a/gnu/packages/patches/gcc-cross-environment-variables.patch +++ b/gnu/packages/patches/gcc-cross-environment-variables.patch @@ -1,9 +1,48 @@ -Search path environment variables for cross-compilers. See the discussion -at <http://gcc.gnu.org/ml/gcc/2013-02/msg00124.html>. +From a1d8c3d926cb43e51a2b4838ad5cca9c2510fbbb Mon Sep 17 00:00:00 2001 +From: Jan Nieuwenhuizen <janneke@gnu.org> +Date: Sat, 16 Apr 2016 10:08:16 +0200 +Subject: [PATCH] Search path environment variables for cross-compilers. See + the discussion at <http://gcc.gnu.org/ml/gcc/2013-02/msg00124.html> ---- gcc-4.7.2/gcc/incpath.c 2012-01-27 00:34:58.000000000 +0100 -+++ gcc-4.7.2/gcc/incpath.c 2013-02-12 10:11:27.000000000 +0100 -@@ -452,7 +452,7 @@ register_include_chains (cpp_reader *pfi +and + +<https://lists.gnu.org/archive/html/guix-devel/2016-04/msg00533.html> +--- + gcc/gcc.c | 2 +- + gcc/incpath.c | 6 +++--- + gcc/system.h | 2 ++ + gcc/tlink.c | 2 +- + 4 files changed, 7 insertions(+), 5 deletions(-) + +diff --git a/gcc/gcc.c b/gcc/gcc.c +index adbf0c4..70448c6 100644 +--- a/gcc/gcc.c ++++ b/gcc/gcc.c +@@ -3853,7 +3853,7 @@ process_command (unsigned int decoded_options_count, + } + + temp = getenv (LIBRARY_PATH_ENV); +- if (temp && *cross_compile == '0') ++ if (temp) + { + const char *startp, *endp; + char *nstore = (char *) alloca (strlen (temp) + 3); +diff --git a/gcc/incpath.c b/gcc/incpath.c +index f495c0a..ba12249 100644 +--- a/gcc/incpath.c ++++ b/gcc/incpath.c +@@ -461,8 +461,8 @@ register_include_chains (cpp_reader *pfile, const char *sysroot, + int stdinc, int cxx_stdinc, int verbose) + { + static const char *const lang_env_vars[] = +- { "C_INCLUDE_PATH", "CPLUS_INCLUDE_PATH", +- "OBJC_INCLUDE_PATH", "OBJCPLUS_INCLUDE_PATH" }; ++ { "CROSS_C_INCLUDE_PATH", "CROSS_CPLUS_INCLUDE_PATH", ++ "CROSS_OBJC_INCLUDE_PATH", "CROSS_OBJCPLUS_INCLUDE_PATH" }; + cpp_options *cpp_opts = cpp_get_options (pfile); + size_t idx = (cpp_opts->objc ? 2: 0); + +@@ -473,7 +473,7 @@ register_include_chains (cpp_reader *pfile, const char *sysroot, /* CPATH and language-dependent environment variables may add to the include chain. */ @@ -12,37 +51,30 @@ at <http://gcc.gnu.org/ml/gcc/2013-02/msg00124.html>. add_env_var_paths (lang_env_vars[idx], SYSTEM); target_c_incpath.extra_pre_includes (sysroot, iprefix, stdinc); - ---- gcc-4.7.2/gcc/system.h 2012-02-17 00:16:28.000000000 +0100 -+++ gcc-4.7.2/gcc/system.h 2013-02-12 10:22:17.000000000 +0100 -@@ -1023,4 +1023,6 @@ helper_const_non_const_cast (const char - #define DEBUG_VARIABLE - #endif +diff --git a/gcc/system.h b/gcc/system.h +index 42bc509..af3b9ad 100644 +--- a/gcc/system.h ++++ b/gcc/system.h +@@ -1063,4 +1063,6 @@ helper_const_non_const_cast (const char *p) + /* Get definitions of HOST_WIDE_INT and HOST_WIDEST_INT. */ + #include "hwint.h" +#define LIBRARY_PATH_ENV "CROSS_LIBRARY_PATH" + #endif /* ! GCC_SYSTEM_H */ - ---- gcc-4.7.2/gcc/tlink.c 2012-02-11 09:50:23.000000000 +0100 -+++ gcc-4.7.2/gcc/tlink.c 2013-05-23 22:06:19.000000000 +0200 -@@ -461,7 +461,7 @@ recompile_files (void) +diff --git a/gcc/tlink.c b/gcc/tlink.c +index bc358b8..ad6242f 100644 +--- a/gcc/tlink.c ++++ b/gcc/tlink.c +@@ -458,7 +458,7 @@ recompile_files (void) file *f; putenv (xstrdup ("COMPILER_PATH=")); - putenv (xstrdup ("LIBRARY_PATH=")); -+ putenv (xstrdup (LIBRARY_PATH_ENV "=")); ++ putenv (xstrdup ("LIBRARY_PATH_ENV=")); while ((f = file_pop ()) != NULL) { +-- +2.1.4 ---- gcc-4.7.3/gcc/gcc.c 2013-03-08 08:25:09.000000000 +0100 -+++ gcc-4.7.3/gcc/gcc.c 2013-05-24 08:58:16.000000000 +0200 -@@ -3726,7 +3726,7 @@ process_command (unsigned int decoded_op - } - - temp = getenv (LIBRARY_PATH_ENV); -- if (temp && *cross_compile == '0') -+ if (temp) - { - const char *startp, *endp; - char *nstore = (char *) alloca (strlen (temp) + 3); -- 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] 18+ messages in thread
* Re: [PATCH v4 1/9] gnu: cross: Use CROSS_*_INCLUDE_PATH for system headers. 2016-04-25 11:28 ` Jan Nieuwenhuizen @ 2016-04-26 8:00 ` Andy Wingo 2016-04-26 8:37 ` Jan Nieuwenhuizen 0 siblings, 1 reply; 18+ messages in thread From: Andy Wingo @ 2016-04-26 8:00 UTC (permalink / raw) To: Jan Nieuwenhuizen; +Cc: guix-devel Hi! Just one reply to the summary then review of the patches. On Mon 25 Apr 2016 13:28, Jan Nieuwenhuizen <janneke@gnu.org> writes: > Yes... Why do you not prefer the and-let*, how would you write it? Well, you had two versions there, and the second one that just used let* looked fine to me. Dunno. I find that the structure imposed by and-let* tends to contort things in a way I don't want -- sometimes it's only some of the bindings that I want to test for truthiness. I find myself fighting and-let* more than enjoying it. Anyway. It is a very minor point and I don't think it matters here :) > From f2842ce5e35c0d984fc18912088bb81f9bac38f5 Mon Sep 17 00:00:00 2001 > From: Jan Nieuwenhuizen <janneke@gnu.org> > Date: Sun, 17 Apr 2016 18:20:05 +0200 > Subject: [PATCH 1/9] gnu: cross: Use CROSS_*_INCLUDE_PATH for system headers. > > * gnu/packages/patches/gcc-cross-environment-variables.patch: Also use CROSS_ > variants: CROSS_C_INCLUDE_PATH, CROSS_CPLUS_INCLUDE_PATH, > CROSS_OBJC_INCLUDE_PATH, CROSS_OBJCPLUS_INCLUDE_PATH to be used for system > libraries, see > https://lists.gnu.org/archive/html/guix-devel/2016-04/msg00620.html. > * gnu/packages/cross-base.scm (cross-gcc, cross-gcc-arguments, cross-libc): > Use CROSS_*_INCLUDE_PATH (WAS: CPATH). > --- > gnu/packages/cross-base.scm | 70 +++++++++++------- > .../patches/gcc-cross-environment-variables.patch | 86 +++++++++++++++------- > 2 files changed, 104 insertions(+), 52 deletions(-) > > diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm > index 8bd599c..2e1bcf8 100644 > --- a/gnu/packages/cross-base.scm > +++ b/gnu/packages/cross-base.scm > @@ -168,34 +170,38 @@ may be either a libc package or #f.)" > (lambda* (#:key inputs #:allow-other-keys) > ;; Add the cross Linux headers to CROSS_CPATH, and remove them > ;; from CPATH. > - (let ((libc (assoc-ref inputs "libc")) > + (let ((libc (assoc-ref inputs libc)) > (linux (assoc-ref inputs "xlinux-headers"))) FYI while I usually don't vertically line up subexpressions, it would appear to be the guix style ;) So this edit undoes some valid code. I don't think it matters though. > diff --git a/gnu/packages/patches/gcc-cross-environment-variables.patch b/gnu/packages/patches/gcc-cross-environment-variables.patch > index 0bd0be5..a2b94cb 100644 > --- a/gnu/packages/patches/gcc-cross-environment-variables.patch > +++ b/gnu/packages/patches/gcc-cross-environment-variables.patch > @@ -1,9 +1,48 @@ OK so this is literally a patch in a patch and it gets complicated to review :) But cool, I had a question about one piece: > +diff --git a/gcc/gcc.c b/gcc/gcc.c > +index adbf0c4..70448c6 100644 > +--- a/gcc/gcc.c > ++++ b/gcc/gcc.c > +@@ -3853,7 +3853,7 @@ process_command (unsigned int decoded_options_count, > + } > + > + temp = getenv (LIBRARY_PATH_ENV); > +- if (temp && *cross_compile == '0') > ++ if (temp) > + { > + const char *startp, *endp; > + char *nstore = (char *) alloca (strlen (temp) + 3); Why this change? > ---- gcc-4.7.2/gcc/system.h 2012-02-17 00:16:28.000000000 +0100 > -+++ gcc-4.7.2/gcc/system.h 2013-02-12 10:22:17.000000000 +0100 > -@@ -1023,4 +1023,6 @@ helper_const_non_const_cast (const char > - #define DEBUG_VARIABLE > - #endif > +diff --git a/gcc/system.h b/gcc/system.h > +index 42bc509..af3b9ad 100644 > +--- a/gcc/system.h > ++++ b/gcc/system.h > +@@ -1063,4 +1063,6 @@ helper_const_non_const_cast (const char *p) > + /* Get definitions of HOST_WIDE_INT and HOST_WIDEST_INT. */ > + #include "hwint.h" > > +#define LIBRARY_PATH_ENV "CROSS_LIBRARY_PATH" > + > #endif /* ! GCC_SYSTEM_H */ > - I wasn't quite able to understand this bit. > ---- gcc-4.7.2/gcc/tlink.c 2012-02-11 09:50:23.000000000 +0100 > -+++ gcc-4.7.2/gcc/tlink.c 2013-05-23 22:06:19.000000000 +0200 > -@@ -461,7 +461,7 @@ recompile_files (void) > +diff --git a/gcc/tlink.c b/gcc/tlink.c > +index bc358b8..ad6242f 100644 > +--- a/gcc/tlink.c > ++++ b/gcc/tlink.c > +@@ -458,7 +458,7 @@ recompile_files (void) > file *f; > > putenv (xstrdup ("COMPILER_PATH=")); > - putenv (xstrdup ("LIBRARY_PATH=")); > -+ putenv (xstrdup (LIBRARY_PATH_ENV "=")); > ++ putenv (xstrdup ("LIBRARY_PATH_ENV=")); > > while ((f = file_pop ()) != NULL) > { Surely this is incorrect? > ---- gcc-4.7.3/gcc/gcc.c 2013-03-08 08:25:09.000000000 +0100 > -+++ gcc-4.7.3/gcc/gcc.c 2013-05-24 08:58:16.000000000 +0200 > -@@ -3726,7 +3726,7 @@ process_command (unsigned int decoded_op > - } > - > - temp = getenv (LIBRARY_PATH_ENV); > -- if (temp && *cross_compile == '0') > -+ if (temp) > - { > - const char *startp, *endp; > - char *nstore = (char *) alloca (strlen (temp) + 3); > -- > 2.7.3 Similar comment as above. The Scheme parts LGTM; would you mind giving details about the GCC patch? Cheers, Andy ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v4 1/9] gnu: cross: Use CROSS_*_INCLUDE_PATH for system headers. 2016-04-26 8:00 ` Andy Wingo @ 2016-04-26 8:37 ` Jan Nieuwenhuizen 2016-04-26 9:03 ` Jan Nieuwenhuizen 0 siblings, 1 reply; 18+ messages in thread From: Jan Nieuwenhuizen @ 2016-04-26 8:37 UTC (permalink / raw) To: Andy Wingo; +Cc: guix-devel Andy Wingo writes: > Well, you had two versions there, and the second one that just used let* > looked fine to me. Dunno. I find that the structure imposed by > and-let* tends to contort things in a way I don't want -- sometimes it's > only some of the bindings that I want to test for truthiness. I find > myself fighting and-let* more than enjoying it. Anyway. It is a very > minor point and I don't think it matters here :) Okay. >> - (let ((libc (assoc-ref inputs "libc")) >> + (let ((libc (assoc-ref inputs libc)) >> (linux (assoc-ref inputs "xlinux-headers"))) > > FYI while I usually don't vertically line up subexpressions, it would > appear to be the guix style ;) So this edit undoes some valid code. I > don't think it matters though. There's something wrong here that I keep correcting, I'll have a look. I think it should be "libc" ... I have wondered about a patch where I change libc to "libc" -- how did that ever work? Apparently, I broke it here. > OK so this is literally a patch in a patch and it gets complicated to > review :) But cool, I had a question about one piece: What I did was import gcc-4.9.3 into git, applied the original gcc-cross-environment-variables.patch from Guix, made some changes and used git to produce a new gcc-cross-environment-variables.patch. I'm not too happy with this, maybe I should look into making the guix patch-in-patch nicer? Anyway, here inline is the actual diff between the original gcc-cross-environment-variables.patch and the new one: diff --git a/gcc/incpath.c b/gcc/incpath.c index 3a34998..ba12249 100644 --- a/gcc/incpath.c +++ b/gcc/incpath.c @@ -461,8 +461,8 @@ register_include_chains (cpp_reader *pfile, const char *sysroot, int stdinc, int cxx_stdinc, int verbose) { static const char *const lang_env_vars[] = - { "C_INCLUDE_PATH", "CPLUS_INCLUDE_PATH", - "OBJC_INCLUDE_PATH", "OBJCPLUS_INCLUDE_PATH" }; + { "CROSS_C_INCLUDE_PATH", "CROSS_CPLUS_INCLUDE_PATH", + "CROSS_OBJC_INCLUDE_PATH", "CROSS_OBJCPLUS_INCLUDE_PATH" }; cpp_options *cpp_opts = cpp_get_options (pfile); size_t idx = (cpp_opts->objc ? 2: 0); diff --git a/gcc/tlink.c b/gcc/tlink.c index 65d4a84..ad6242f 100644 --- a/gcc/tlink.c +++ b/gcc/tlink.c @@ -458,7 +458,7 @@ recompile_files (void) file *f; putenv (xstrdup ("COMPILER_PATH=")); - putenv (xstrdup (LIBRARY_PATH_ENV "=")); + putenv (xstrdup ("LIBRARY_PATH_ENV=")); while ((f = file_pop ()) != NULL) { > The Scheme parts LGTM; would you mind giving details about the GCC > patch? You spotted the putenv problem, quite visible above; I'm not sure why this still works for me, I'll fix (i.e., revert) this. As to your other two questions about if (temp): those are actually not changes wrt the current gcc-cross-environment-variables.patch. >> +- if (temp && *cross_compile == '0') >> ++ if (temp) >> + { >> + const char *startp, *endp; >> + char *nstore = (char *) alloca (strlen (temp) + 3); > > Why this change? Not a change per se, AIUI our cross patch makes COMPILER_PATH now valid, as we populate it from CROSS_*. >> +#define LIBRARY_PATH_ENV "CROSS_LIBRARY_PATH" >> + >> #endif /* ! GCC_SYSTEM_H */ >> - > > I wasn't quite able to understand this bit. >> - putenv (xstrdup ("LIBRARY_PATH=")); >> -+ putenv (xstrdup (LIBRARY_PATH_ENV "=")); >> ++ putenv (xstrdup ("LIBRARY_PATH_ENV=")); >> >> while ((f = file_pop ()) != NULL) >> { > > Surely this is incorrect? Oops yes, this is wrong. Thanks >> -- if (temp && *cross_compile == '0') >> -+ if (temp) >> - { >> - const char *startp, *endp; >> - char *nstore = (char *) alloca (strlen (temp) + 3); >> -- >> 2.7.3 > > Similar comment as above. Not a change per se, AIUI our cross patch makes LIBRARY_PATH[_ENV] now valid, as we populate it from CROSS_LIBRARY_PATH. Thanks again, greetings, Jan -- Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.nl ^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH v4 1/9] gnu: cross: Use CROSS_*_INCLUDE_PATH for system headers. 2016-04-26 8:37 ` Jan Nieuwenhuizen @ 2016-04-26 9:03 ` Jan Nieuwenhuizen 0 siblings, 0 replies; 18+ messages in thread From: Jan Nieuwenhuizen @ 2016-04-26 9:03 UTC (permalink / raw) To: Andy Wingo; +Cc: guix-devel Jan Nieuwenhuizen writes: Just a quick thing I noticed while preparing new patch >>> +- if (temp && *cross_compile == '0') >>> ++ if (temp) >>> + { >>> + const char *startp, *endp; >>> + char *nstore = (char *) alloca (strlen (temp) + 3); >> >> Why this change? > > Not a change per se, AIUI our cross patch makes COMPILER_PATH now > valid, as we populate it from CROSS_*. This is foo; this change is only for LIBRARY_PATH_ENV and the patch above reverts the one below, making them a no-op >>> -- if (temp && *cross_compile == '0') >>> -+ if (temp) >>> - { >>> - const char *startp, *endp; >>> - char *nstore = (char *) alloca (strlen (temp) + 3); >>> -- >>> 2.7.3 >> >> Similar comment as above. > > Not a change per se, AIUI our cross patch makes LIBRARY_PATH[_ENV] now > valid, as we populate it from CROSS_LIBRARY_PATH. In my new patch this gcc.c patch was the first, and the old guix patch it was the last. I have moved this gcc.c patch it to the bottom now and then it dissappears from the guix patch. :-) 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] 18+ messages in thread
* Re: [PATCH v4 1/9] gnu: cross: Use CROSS_*_INCLUDE_PATH for system headers. 2016-04-24 21:40 ` [PATCH v4 1/9] gnu: cross: Use CROSS_*_INCLUDE_PATH for system headers Jan Nieuwenhuizen 2016-04-25 10:38 ` Andy Wingo @ 2016-04-25 22:06 ` Jan Nieuwenhuizen 2016-04-26 9:02 ` Andy Wingo 1 sibling, 1 reply; 18+ messages in thread From: Jan Nieuwenhuizen @ 2016-04-25 22:06 UTC (permalink / raw) To: Ludovic Courtès; +Cc: guix-devel [-- Attachment #1: Type: text/plain, Size: 204 bytes --] Jan Nieuwenhuizen writes: Yay, with just one small change (find attached), mingw guile.exe now runs. I'll be rebuilding for a while and will send an updated patch set when it finishes. Greetings, Jan [-- Attachment #2: 0009-gnu-libunistring-support-mingw-propagate-libiconv-if.patch --] [-- Type: text/x-diff, Size: 1664 bytes --] From e81d75184f2fec2be9ae3ea769d0799b7141c1c4 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen <janneke@gnu.org> Date: Mon, 25 Apr 2016 23:47:50 +0200 Subject: [PATCH 09/10] gnu: libunistring: support mingw: propagate libiconv if needed. * 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 [-- Attachment #3: Type: text/plain, Size: 154 bytes --] -- Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.nl ^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH v4 1/9] gnu: cross: Use CROSS_*_INCLUDE_PATH for system headers. 2016-04-25 22:06 ` Jan Nieuwenhuizen @ 2016-04-26 9:02 ` Andy Wingo 0 siblings, 0 replies; 18+ messages in thread From: Andy Wingo @ 2016-04-26 9:02 UTC (permalink / raw) To: Jan Nieuwenhuizen; +Cc: guix-devel On Tue 26 Apr 2016 00:06, Jan Nieuwenhuizen <janneke@gnu.org> writes: > Yay, with just one small change (find attached), mingw guile.exe now > runs. Jan you are a hero. A ^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2016-04-26 9:04 UTC | newest] Thread overview: 18+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2016-03-26 17:38 rfc/rfh: i686-w64-mingw32 cross target Jan Nieuwenhuizen 2016-03-27 14:20 ` [RFCv2] build: i686-w64-mingw32: new " Jan Nieuwenhuizen 2016-03-27 16:17 ` Pjotr Prins 2016-03-31 20:16 ` rfc/rfh: i686-w64-mingw32 " Ricardo Wurmus 2016-03-31 20:26 ` Jan Nieuwenhuizen 2016-03-31 20:48 ` Ricardo Wurmus 2016-04-02 7:30 ` Jan Nieuwenhuizen 2016-04-07 21:12 ` Ludovic Courtès 2016-04-14 6:30 ` Jan Nieuwenhuizen 2016-04-19 14:54 ` Ludovic Courtès 2016-04-24 21:40 ` [PATCH v4 1/9] gnu: cross: Use CROSS_*_INCLUDE_PATH for system headers Jan Nieuwenhuizen 2016-04-25 10:38 ` Andy Wingo 2016-04-25 11:28 ` Jan Nieuwenhuizen 2016-04-26 8:00 ` Andy Wingo 2016-04-26 8:37 ` Jan Nieuwenhuizen 2016-04-26 9:03 ` Jan Nieuwenhuizen 2016-04-25 22:06 ` Jan Nieuwenhuizen 2016-04-26 9:02 ` Andy Wingo
Code repositories for project(s) associated with this public inbox https://git.savannah.gnu.org/cgit/guix.git This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).