distro: Add i686 support.

* distro/packages/base.scm (gcc-4.7): Turn `arguments' into a lambda.
  Use `glibc-dynamic-linker' instead of the hard-coded linker name.
This commit is contained in:
Nikita Karetnikov 2012-10-16 23:24:58 +00:00 committed by Ludovic Courtès
parent 124b17673b
commit a52e429f76
1 changed files with 77 additions and 75 deletions

View File

@ -1,5 +1,6 @@
;;; Guix --- Nix package management from Guile. -*- coding: utf-8 -*- ;;; Guix --- Nix package management from Guile. -*- coding: utf-8 -*-
;;; Copyright (C) 2012 Ludovic Courtès <ludo@gnu.org> ;;; Copyright (C) 2012 Ludovic Courtès <ludo@gnu.org>
;;; Copyright (C) 2012 Nikita Karetnikov <nikita@karetnikov.org>
;;; ;;;
;;; This file is part of Guix. ;;; This file is part of Guix.
;;; ;;;
@ -704,9 +705,9 @@ BFD (Binary File Descriptor) library, `gprof', `nm', `strip', etc.")
(define (glibc-dynamic-linker system) (define (glibc-dynamic-linker system)
"Return the name of Glibc's dynamic linker for SYSTEM." "Return the name of Glibc's dynamic linker for SYSTEM."
(if (string=? system "x86_64-linux") (cond ((string=? system "x86_64-linux") "/lib/ld-linux-x86-64.so.2")
"ld-linux-x86-64.so.2" ((string=? system "i686-linux") "/lib/ld-linux.so.2")
(error "dynamic linker name not known for this system" system))) (else (error "dynamic linker name not known for this system" system))))
(define-public gcc-4.7 (define-public gcc-4.7
(let ((stripped? #t)) ; TODO: make this a parameter (let ((stripped? #t)) ; TODO: make this a parameter
@ -725,83 +726,84 @@ BFD (Binary File Descriptor) library, `gprof', `nm', `strip', etc.")
("mpfr" ,mpfr) ("mpfr" ,mpfr)
("mpc" ,mpc))) ; TODO: libelf, ppl, cloog, zlib, etc. ("mpc" ,mpc))) ; TODO: libelf, ppl, cloog, zlib, etc.
(arguments (arguments
`(#:out-of-source? #t (lambda (system)
#:strip-binaries? ,stripped? `(#:out-of-source? #t
#:configure-flags #:strip-binaries? ,stripped?
`("--enable-plugin" #:configure-flags
"--enable-languages=c,c++" `("--enable-plugin"
"--disable-multilib" "--enable-languages=c,c++"
,(let ((libc (assoc-ref %build-inputs "libc"))) "--disable-multilib"
(if libc ,(let ((libc (assoc-ref %build-inputs "libc")))
(string-append "--with-native-system-header-dir=" libc (if libc
"/include") (string-append "--with-native-system-header-dir=" libc
"--without-headers"))) "/include")
#:make-flags "--without-headers")))
(let ((libc (assoc-ref %build-inputs "libc"))) #:make-flags
`(,@(if libc (let ((libc (assoc-ref %build-inputs "libc")))
(list (string-append "LDFLAGS_FOR_BUILD=" `(,@(if libc
"-L" libc "/lib " (list (string-append "LDFLAGS_FOR_BUILD="
"-Wl,-dynamic-linker " "-L" libc "/lib "
"-Wl," libc "-Wl,-dynamic-linker "
"/lib/ld-linux-x86-64.so.2")) "-Wl," libc
'()) ,(glibc-dynamic-linker system)))
,(string-append "BOOT_CFLAGS=-O2 " '())
,(if stripped? "-g0" "-g")))) ,(string-append "BOOT_CFLAGS=-O2 "
,(if stripped? "-g0" "-g"))))
#:tests? #f #:tests? #f
#:phases #:phases
(alist-cons-before (alist-cons-before
'configure 'pre-configure 'configure 'pre-configure
(lambda* (#:key inputs outputs #:allow-other-keys) (lambda* (#:key inputs outputs #:allow-other-keys)
(let ((out (assoc-ref outputs "out")) (let ((out (assoc-ref outputs "out"))
(libc (assoc-ref inputs "libc"))) (libc (assoc-ref inputs "libc")))
(when libc (when libc
;; The following is not performed for `--without-headers' ;; The following is not performed for `--without-headers'
;; cross-compiler builds. ;; cross-compiler builds.
;; Fix the dynamic linker's file name. ;; Fix the dynamic linker's file name.
(substitute* "gcc/config/i386/linux64.h" (substitute* "gcc/config/i386/linux64.h"
(("#define GLIBC_DYNAMIC_LINKER([^ ]*).*$" _ suffix) (("#define GLIBC_DYNAMIC_LINKER([^ ]*).*$" _ suffix)
(format #f "#define GLIBC_DYNAMIC_LINKER~a \"~a\"~%" (format #f "#define GLIBC_DYNAMIC_LINKER~a \"~a\"~%"
suffix suffix
(string-append libc "/lib/ld-linux-x86-64.so.2")))) (string-append libc ,(glibc-dynamic-linker system)))))
;; Tell where to find libstdc++, libc, and `?crt*.o', except ;; Tell where to find libstdc++, libc, and `?crt*.o', except
;; `crt{begin,end}.o', which come with GCC. ;; `crt{begin,end}.o', which come with GCC.
;; XXX: For crt*.o, use `STANDARD_STARTFILE_PREFIX' instead? See ;; XXX: For crt*.o, use `STANDARD_STARTFILE_PREFIX' instead? See
;; <http://www.linuxfromscratch.org/lfs/view/stable/chapter05/gcc-pass1.html>. ;; <http://www.linuxfromscratch.org/lfs/view/stable/chapter05/gcc-pass1.html>.
(substitute* ("gcc/config/gnu-user.h" (substitute* ("gcc/config/gnu-user.h"
"gcc/config/i386/gnu-user.h" "gcc/config/i386/gnu-user.h"
"gcc/config/i386/gnu-user64.h") "gcc/config/i386/gnu-user64.h")
(("#define LIB_SPEC (.*)$" _ suffix) (("#define LIB_SPEC (.*)$" _ suffix)
(format #f "#define LIB_SPEC \"-L~a/lib -rpath=~a/lib \ (format #f "#define LIB_SPEC \"-L~a/lib -rpath=~a/lib \
-rpath=~a/lib64 -rpath=~a/lib \" ~a~%" -rpath=~a/lib64 -rpath=~a/lib \" ~a~%"
libc libc out out suffix)) libc libc out out suffix))
(("([^ ]*)crt([^\\.])\\.o" _ prefix suffix) (("([^ ]*)crt([^\\.])\\.o" _ prefix suffix)
(string-append libc "/lib/" prefix "crt" suffix ".o")))) (string-append libc "/lib/" prefix "crt" suffix ".o"))))
;; Don't retain a dependency on the build-time sed. ;; Don't retain a dependency on the build-time sed.
(substitute* "fixincludes/fixincl.x" (substitute* "fixincludes/fixincl.x"
(("static char const sed_cmd_z\\[\\] =.*;") (("static char const sed_cmd_z\\[\\] =.*;")
"static char const sed_cmd_z[] = \"sed\";")))) "static char const sed_cmd_z[] = \"sed\";"))))
(alist-cons-after (alist-cons-after
'configure 'post-configure 'configure 'post-configure
(lambda _ (lambda _
;; Don't store configure flags, to avoid retaining references to ;; Don't store configure flags, to avoid retaining references to
;; build-time dependencies---e.g., `--with-ppl=/nix/store/xxx'. ;; build-time dependencies---e.g., `--with-ppl=/nix/store/xxx'.
(substitute* "Makefile" (substitute* "Makefile"
(("^TOPLEVEL_CONFIGURE_ARGUMENTS=(.*)$" _ rest) (("^TOPLEVEL_CONFIGURE_ARGUMENTS=(.*)$" _ rest)
"TOPLEVEL_CONFIGURE_ARGUMENTS=\n"))) "TOPLEVEL_CONFIGURE_ARGUMENTS=\n")))
(alist-replace 'install (alist-replace 'install
(lambda* (#:key outputs #:allow-other-keys) (lambda* (#:key outputs #:allow-other-keys)
(zero? (zero?
(system* "make" (system* "make"
,(if stripped? ,(if stripped?
"install-strip" "install-strip"
"install")))) "install"))))
%standard-phases))))) %standard-phases))))))
(properties `((gcc-libc . ,(assoc-ref inputs "libc")))) (properties `((gcc-libc . ,(assoc-ref inputs "libc"))))
(description "The GNU Compiler Collection") (description "The GNU Compiler Collection")
@ -1557,7 +1559,7 @@ identifier SYSTEM."
(ice-9 regex) (ice-9 regex)
(srfi srfi-1) (srfi srfi-1)
(srfi srfi-26)) (srfi srfi-26))
,@(substitute-keyword-arguments (package-arguments gcc-4.7) ,@(substitute-keyword-arguments ((package-arguments gcc-4.7) system)
((#:configure-flags flags) ((#:configure-flags flags)
`(append (list ,(string-append "--target=" `(append (list ,(string-append "--target="
(boot-triplet system)) (boot-triplet system))
@ -1762,7 +1764,7 @@ exec ~a/bin/~a-gcc -B~a/lib -Wl,-dynamic-linker -Wl,~a/lib/~a \"$@\"~%"
;; doesn't honor $LIBRARY_PATH, which breaks `gnu-build-system'.) ;; doesn't honor $LIBRARY_PATH, which breaks `gnu-build-system'.)
,@(substitute-keyword-arguments ((package-arguments gcc-boot0) system) ,@(substitute-keyword-arguments ((package-arguments gcc-boot0) system)
((#:configure-flags boot-flags) ((#:configure-flags boot-flags)
(let loop ((args (package-arguments gcc-4.7))) (let loop ((args ((package-arguments gcc-4.7) system)))
(match args (match args
((#:configure-flags normal-flags _ ...) ((#:configure-flags normal-flags _ ...)
normal-flags) normal-flags)