From e53f7ca2cb7880ca4f6acfaedb020c2523eaf105 Mon Sep 17 00:00:00 2001 From: Manolis Ragkousis Date: Tue, 18 Mar 2014 11:33:41 +0000 Subject: [PATCH] gnu: base: Added glibc/hurd * gnu/packages/base.scm (glibc/hurd): Added glibc/hurd gnu: crossbase: Added cross-toolchain for the hurd * gnu/packages/crossbase.scm (cross-gcc/hurd): Added a new cross-gcc so I can try different config flags * gnu/packages/crossbase.scm (cross-mig): Added cross-mig because it is need to build the headers * gnu/packages/crossbase.scm (cross-libc/hurd): Added cross-libc/hurd --- gnu/packages/base.scm | 111 ++++++++++++++++++++++++ gnu/packages/cross-base.scm | 205 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 316 insertions(+) diff --git a/gnu/packages/base.scm b/gnu/packages/base.scm index e17933b..ea90c27 100644 --- a/gnu/packages/base.scm +++ b/gnu/packages/base.scm @@ -30,6 +30,10 @@ #:use-module (gnu packages guile) #:use-module (gnu packages multiprecision) #:use-module (gnu packages perl) + #:use-module (gnu packages perl) + #:use-module (guix git-download) + #:use-module (gnu packages autotools) + #:use-module (gnu packages hurd) #:use-module (gnu packages linux) #:use-module (guix packages) #:use-module (guix download) @@ -484,6 +488,113 @@ with the Linux kernel.") (license lgpl2.0+) (home-page "http://www.gnu.org/software/libc/"))) +(define-public glibc/hurd + (package (inherit glibc) + (name "glibc-hurd") + (source (origin + (method git-fetch) + (uri (git-reference + (url "git://git.sv.gnu.org/hurd/glibc") + (commit "bdb7a18d78b04ac3ef7a2d905485500f13bb69fb"))) + (sha256 + (base32 + "0v4hy6yimshbvhbhdbbjdir5fm3xr56zj3lnpf01d4nfa0c1h8k1")) + + )) + (propagated-inputs `(("gnumach-headers" ,gnumach-headers) + ("hurd-headers" ,hurd-headers))) + (native-inputs + `( + ("patch/glibc-make" ,(search-patch "glibc-make-4.0.patch")) + ("mig" ,mig) + ("perl" ,perl) + ("autoconf" ,autoconf-wrapper) + ("automake" ,automake) + ("libpthread" ,(origin + (method git-fetch) + (uri (git-reference + (url "git://git.sv.gnu.org/hurd/libpthread") + (commit "fa9eb2c255e1d46beadcd81edd459b9c3d7dcb8c"))) + (sha256 + (base32 + "0bb8m0pk7b53sww4ahjds77bvqy0alz54g3aylzwncfca52gacqp")) + (file-name "libpthread" ))))) + + (arguments + `(#:out-of-source? #t + #:configure-flags + (list "--without-cvs" + "--enable-add-ons=" + ;;"--sysconfdir=/etc" + "--disable-profile" + "--disable-multi-arch" + + (string-append "libc_cv_localedir=" + (assoc-ref %outputs "locales") + "/share/locale") + + ;; Use our Bash instead of /bin/sh. + (string-append "BASH_SHELL=" + (assoc-ref %build-inputs "bash") + "/bin/bash")) + + #:phases (alist-cons-before + 'pre-configure 'autoconf + (lambda _ + (system* "autoreconf" "-vi" "libpthread")) + (alist-cons-before + 'configure 'pre-configure + (lambda* (#:key inputs outputs #:allow-other-keys) + (let* ((out (assoc-ref outputs "out")) + (bin (string-append out "/bin"))) + ;; Use `pwd', not `/bin/pwd'. + (substitute* "configure" + (("/bin/pwd") "pwd")) + + ;; Copy a statically-linked Bash in the output, with + ;; no references to other store paths. + (mkdir-p bin) + (copy-file (string-append (assoc-ref inputs "static-bash") + "/bin/bash") + (string-append bin "/bash")) + (remove-store-references (string-append bin "/bash")) + (chmod (string-append bin "/bash") #o555) + + ;; Keep a symlink, for `patch-shebang' resolution. + (with-directory-excursion bin + (symlink "bash" "sh")) + + ;; Have `system' use that Bash. + (substitute* "sysdeps/posix/system.c" + (("#define[[:blank:]]+SHELL_PATH.*$") + (format #f "#define SHELL_PATH \"~a/bin/bash\"\n" + out))) + + ;; Same for `popen'. + (substitute* "libio/iopopen.c" + (("/bin/sh") + (string-append out "/bin/bash"))))) + (alist-cons-after + 'install 'install-locales + (lambda _ + (zero? (system* "make" "localedata/install-locales"))) + + (alist-cons-after + 'unpack 'apply-patch + (lambda _ + (zero? (system* "patch" "-p1" "-i" (assoc-ref %build-inputs "patch/glibc-make")))) + (alist-replace + 'unpack + ;; FIXME: Remove this when gnu-build-system handles that + ;; case correctly. + (lambda* (#:key inputs source #:allow-other-keys) + (mkdir "source") + (chdir "source") + (copy-recursively source ".") + (copy-recursively (assoc-ref inputs "libpthread") "libpthread") + #t) + %standard-phases))))))) )) + (define-public tzdata (package (name "tzdata") diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm index 41128b7..2dad637 100644 --- a/gnu/packages/cross-base.scm +++ b/gnu/packages/cross-base.scm @@ -21,6 +21,10 @@ #:use-module (gnu packages) #:use-module (gnu packages gcc) #:use-module (gnu packages base) + #:use-module (gnu packages perl);; + #:use-module (guix git-download);; + #:use-module (gnu packages autotools);; + #:use-module (gnu packages hurd) #:use-module (gnu packages linux) #:use-module (guix packages) #:use-module (guix download) @@ -256,6 +260,207 @@ XBINUTILS and the cross tool chain." ("cross-binutils" ,xbinutils) ,@(package-native-inputs glibc))))) +(define* (cross-gcc/hurd target + #:optional (xbinutils (cross-binutils target)) libc) + "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." + (package (inherit gcc-4.8) + (name (string-append "gcc-cross-hurd-" + (if libc "" "sans-libc-") + target)) + (source (origin (inherit (package-source gcc-4.8)) + (patches + (list (search-patch "gcc-cross-environment-variables.patch"))))) + (arguments + `(#:implicit-inputs? #f + #:modules ((guix build gnu-build-system) + (guix build utils) + (ice-9 regex) + (srfi srfi-1) + (srfi srfi-26)) + + ,@(substitute-keyword-arguments (package-arguments gcc-4.8) + ((#:configure-flags flags) + `(append (list ,(string-append "--target=" target) + ,@(gcc-configure-flags-for-triplet target) + ,@(if libc + '() + `( + ;; Disable features not needed at this stage. + "--disable-shared" "--enable-static" + "--without-headers" + + ;; Disable C++ because libstdc++'s + ;; configure script otherwise fails with + ;; "Link tests are not allowed after + ;; GCC_NO_EXECUTABLES." + "--enable-languages=c" + + ;; Disabling things according to other hurd building + ;; scripts I saw, I will explain everything with my final patch + + "--disable-threads" ; libgcc, would need libc + "--disable-libatomic" + "--disable-libmudflap" + "--disable-libgomp" + "--disable-libssp" + "--disable-libquadmath" + "--disable-decimal-float" ; would need libc + "--with-arch=i686" + ))) + + ,(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 "-"))) + (for-each (lambda (file) + (symlink (string-append binutils file) + (string-append libexec "/" + file))) + '("as" "ld" "nm")) + #t)) + ,phases)))phases));;) + ((#:strip-binaries? _) + ;; Disable stripping as this can break binaries, with object files + ;; of libgcc.a showing up as having an unknown architecture. See + ;; + ;; for instance. + #f)))) + + (native-inputs + `(("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 gcc-4.8) + (alist-delete "libc" %final-inputs)))) + (if libc + `(("libc" ,libc) + ,@inputs) + inputs)))) + + (inputs '()) + + ;; Only search target inputs, not host inputs. + (search-paths + (list (search-path-specification + (variable "CROSS_CPATH") + (directories '("include"))) + (search-path-specification + (variable "CROSS_LIBRARY_PATH") + (directories '("lib" "lib64"))))) + (native-search-paths '()))) + +(define* (cross-mig target + #:optional + (xgcc (cross-gcc/hurd target)) + (xbinutils (cross-binutils target))) + + (define xgnumach-headers + (package (inherit gnumach-headers) + (name (string-append (package-name gnumach-headers) + "-cross-" target)) + + (native-inputs `(("cross-gcc-hurd" ,xgcc) + ("cross-binutils" ,xbinutils) + ,@(package-native-inputs gnumach-headers))))) + + (package (inherit mig) + (name (string-append "mig-cross")) + (arguments + (substitute-keyword-arguments (package-arguments mig) + ((#:configure-flags flags) + `(cons ,(string-append "--target=" target) + ,flags)) + )) + (propagated-inputs `(("cross-gnumach-headers" ,xgnumach-headers))) + (native-inputs `(("cross-gcc-hurd" ,xgcc) + ("cross-binutils" ,xbinutils) + ,@(package-native-inputs mig))))) + +(define* (cross-libc/hurd target + #:optional + (xgcc (cross-gcc/hurd target)) + (xbinutils (cross-binutils target)) + (xmig (cross-mig target))) + "Return a libc cross-built for TARGET, a GNU triplet. Use XGCC and +XBINUTILS and the cross tool chain." + + (define xgnumach-headers + (package (inherit gnumach-headers) + (name (string-append (package-name gnumach-headers) + "-cross-" target)) + + (native-inputs `(("cross-gcc-hurd" ,xgcc) + ("cross-binutils" ,xbinutils) + ,@(package-native-inputs gnumach-headers))))) + + (define xhurd-headers + (package (inherit hurd-headers) + (name (string-append (package-name hurd-headers) + "-cross-" target)) + + ;;removing the --host flag because I am getting the error that gcc cannot produce executables + (arguments + (substitute-keyword-arguments + `(#:modules ((guix build gnu-build-system) + (guix build utils) + (ice-9 regex) + (srfi srfi-1) + (srfi srfi-26)) + ,@(package-arguments hurd-headers)) + ((#:configure-flags flags) + `(remove (cut string-match "--host.*" <>) + ,flags)))) + (native-inputs `(("cross-gcc-hurd" ,xgcc) + ("cross-binutils" ,xbinutils) + ("cross-mig" ,xmig) + ,@(alist-delete "mig"(package-native-inputs hurd-headers)))))) + + + (package (inherit glibc/hurd) + (name (string-append "glibc-hurd-cross-" target)) + (arguments + (substitute-keyword-arguments + `(#:strip-binaries? #f ; disable stripping (see above) + ,@(package-arguments glibc/hurd)) + ((#:configure-flags flags) + `(cons ,(string-append "--target=" target) + ,flags)))) + + (propagated-inputs `(("cross-gnumach-headers" ,xgnumach-headers) + ("cross-hurd-headers" ,xhurd-headers))) + + (native-inputs `(("cross-gcc-hurd" ,xgcc) + ("cross-binutils" ,xbinutils) + ("cross-mig" ,xmig) + ,@(alist-delete "mig"(package-native-inputs glibc/hurd)))) + + )) + ;;; ;;; Concrete cross toolchains. -- 1.9.0