gnu: hidapi: Fix 'license'.
[jackhill/guix/guix.git] / gnu / packages / commencement.scm
index 22da2e0..cce831b 100644 (file)
@@ -1,8 +1,8 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2012, 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2012, 2013, 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2014 Andreas Enge <andreas@enge.fr>
 ;;; Copyright © 2012 Nikita Karetnikov <nikita@karetnikov.org>
-;;; Copyright © 2014 Mark H Weaver <mhw@netris.org>
+;;; Copyright © 2014, 2015 Mark H Weaver <mhw@netris.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -31,6 +31,7 @@
   #:use-module (gnu packages gawk)
   #:use-module (gnu packages bison)
   #:use-module (gnu packages guile)
+  #:use-module (gnu packages gettext)
   #:use-module (gnu packages multiprecision)
   #:use-module (gnu packages compression)
   #:use-module (gnu packages perl)
@@ -64,7 +65,6 @@
   (package-with-bootstrap-guile
    (package (inherit gnu-make)
      (name "make-boot0")
-     (location (source-properties->location (current-source-location)))
      (arguments
       `(#:guile ,%bootstrap-guile
         #:implicit-inputs? #f
                                             ,@%bootstrap-inputs)
                                           #:guile %bootstrap-guile)))
      (package (inherit p)
-       (location (source-properties->location (current-source-location)))
+       (name "diffutils-boot0")
        (arguments `(#:tests? #f         ; the test suite needs diffutils
                     ,@(package-arguments p)))))))
 
 (define findutils-boot0
   (package-with-bootstrap-guile
-   (package-with-explicit-inputs findutils
+   (package-with-explicit-inputs (package
+                                   (inherit findutils)
+                                   (name "findutils-boot0"))
                                  `(("make" ,gnu-make-boot0)
                                    ("diffutils" ,diffutils-boot0) ; for tests
                                    ,@%bootstrap-inputs)
 
 (define file-boot0
   (package-with-bootstrap-guile
-   (package-with-explicit-inputs file
+   (package-with-explicit-inputs (package
+                                   (inherit file)
+                                   (name "file-boot0"))
                                  `(("make" ,gnu-make-boot0)
                                    ,@%bootstrap-inputs)
                                  (current-source-location)
      (arguments
       `(#:guile ,%bootstrap-guile
         #:implicit-inputs? #f
+
+        #:modules ((guix build gnu-build-system)
+                   (guix build utils)
+                   (ice-9 ftw))                    ; for 'scandir'
+        #:phases (alist-cons-after
+                  'install 'add-symlinks
+                  (lambda* (#:key outputs #:allow-other-keys)
+                    ;; The cross-gcc invokes 'as', 'ld', etc, without the
+                    ;; triplet prefix, so add symlinks.
+                    (let ((out (assoc-ref outputs "out"))
+                          (triplet-prefix (string-append ,(boot-triplet) "-")))
+                      (define (has-triplet-prefix? name)
+                        (string-prefix? triplet-prefix name))
+                      (define (remove-triplet-prefix name)
+                        (substring name (string-length triplet-prefix)))
+                      (with-directory-excursion (string-append out "/bin")
+                        (for-each (lambda (name)
+                                    (symlink name (remove-triplet-prefix name)))
+                                  (scandir "." has-triplet-prefix?)))
+                      #t))
+                  %standard-phases)
+
         ,@(substitute-keyword-arguments (package-arguments binutils)
             ((#:configure-flags cf)
              `(cons ,(string-append "--target=" (boot-triplet))
 
 (define gcc-boot0
   (package-with-bootstrap-guile
-   (package (inherit gcc-4.8)
+   (package (inherit gcc)
      (name "gcc-cross-boot0")
      (arguments
       `(#:guile ,%bootstrap-guile
                    (ice-9 regex)
                    (srfi srfi-1)
                    (srfi srfi-26))
-        ,@(substitute-keyword-arguments (package-arguments gcc-4.8)
-            ((#:validate-runpath? _)
-             #t)
+        ,@(substitute-keyword-arguments (package-arguments gcc)
             ((#:configure-flags flags)
              `(append (list ,(string-append "--target=" (boot-triplet))
 
                             "--disable-libsanitizer"
                             "--disable-libitm"
                             "--disable-libgomp"
+                            "--disable-libcilkrts"
+                            "--disable-libvtv"
                             "--disable-libssp"
                             "--disable-libquadmath"
                             "--disable-decimal-float")
-                      (remove (cut string-match "--enable-languages.*" <>)
+                      (remove (cut string-match
+                                "--(with-system-zlib|enable-languages.*)" <>)
                               ,flags)))
             ((#:phases phases)
              `(alist-cons-after
                                         (package-full-name lib)
                                         char-set:letter)
                                       ,(package-name lib)))
-                          (list gmp mpfr mpc))))
+                          (list gmp-6.0 mpfr mpc))))
                (alist-cons-after
                 'install 'symlink-libgcc_eh
                 (lambda* (#:key outputs #:allow-other-keys)
                     (with-directory-excursion
                         (string-append out "/lib/gcc/"
                                        ,(boot-triplet)
-                                       "/" ,(package-version gcc-4.8))
+                                       "/" ,(package-version gcc))
                       (symlink "libgcc.a" "libgcc_eh.a"))))
                 ,phases))))))
 
-     (inputs `(("gmp-source" ,(package-source gmp))
+     (inputs `(("gmp-source" ,(package-source gmp-6.0))
                ("mpfr-source" ,(package-source mpfr))
                ("mpc-source" ,(package-source mpc))
                ("binutils-cross" ,binutils-boot0)
 
      ;; No need for Texinfo at this stage.
      (native-inputs (alist-delete "texinfo"
-                                  (package-native-inputs gcc-4.8))))))
+                                  (package-native-inputs gcc))))))
 
 (define perl-boot0
-  (package-with-bootstrap-guile
-   (package-with-explicit-inputs perl
-                                 %boot0-inputs
-                                 (current-source-location)
-                                 #:guile %bootstrap-guile)))
+  (let ((perl (package
+                (inherit perl)
+                (name "perl-boot0")
+                (replacement #f)
+                (arguments
+                 ;; At the very least, this must not depend on GCC & co.
+                 (let ((args `(#:disallowed-references
+                               ,(list %bootstrap-binutils))))
+                   (substitute-keyword-arguments (package-arguments perl)
+                     ((#:phases phases)
+                      `(modify-phases ,phases
+                         ;; Pthread support is missing in the bootstrap compiler
+                         ;; (broken spec file), so disable it.
+                         (add-before 'configure 'disable-pthreads
+                           (lambda _
+                             (substitute* "Configure"
+                               (("^libswanted=(.*)pthread" _ before)
+                                (string-append "libswanted=" before)))))))))))))
+    (package-with-bootstrap-guile
+     (package-with-explicit-inputs perl
+                                   %boot0-inputs
+                                   (current-source-location)
+                                   #:guile %bootstrap-guile))))
 
 (define (linux-libre-headers-boot0)
   "Return Linux-Libre header files for the bootstrap environment."
   ;; because we don't need the stand-alone Info reader.
   ;; Also, use %BOOT0-INPUTS to avoid building Perl once more.
   (let ((texinfo (package (inherit texinfo)
-                   (inputs (alist-delete "ncurses" (package-inputs texinfo))))))
+                   (native-inputs '())
+                   (inputs `(("perl" ,perl-boot0)))
+
+                   ;; Some of Texinfo 6.1's tests would fail with "Couldn't
+                   ;; set UTF-8 character type in locale" but we don't have a
+                   ;; UTF-8 locale at this stage, so skip them.
+                   (arguments '(#:tests? #f)))))
     (package-with-bootstrap-guile
      (package-with-explicit-inputs texinfo %boot0-inputs
                                    (current-source-location)
   ;; 2nd stage inputs.
   `(("gcc" ,gcc-boot0)
     ("binutils-cross" ,binutils-boot0)
-
-    ;; Keep "binutils" here because the cross-gcc invokes `as', not the
-    ;; cross-`as'.
-    ,@%boot0-inputs))
+    ,@(alist-delete "binutils" %boot0-inputs)))
 
 (define glibc-final-with-bootstrap-bash
   ;; The final libc, "cross-built".  If everything went well, the resulting
                                    "export CPATH\n"
                                    all "\n"))))
                ,phases)))))
-     (propagated-inputs `(("linux-headers" ,(linux-libre-headers-boot0))))
+     (propagated-inputs `(("kernel-headers" ,(linux-libre-headers-boot0))))
      (native-inputs
       `(("texinfo" ,texinfo-boot0)
         ("perl" ,perl-boot0)))
 (define (cross-gcc-wrapper gcc binutils glibc bash)
   "Return a wrapper for the pseudo-cross toolchain GCC/BINUTILS/GLIBC
 that makes it available under the native tool names."
-  (package (inherit gcc-4.8)
+  (package (inherit gcc)
     (name (string-append (package-name gcc) "-wrapped"))
     (source #f)
     (build-system trivial-build-system)
@@ -390,35 +438,78 @@ exec ~a/bin/~a-~a -B~a/lib -Wl,-dynamic-linker -Wl,~a/~a \"$@\"~%"
                                                (current-source-location)
                                                #:guile %bootstrap-guile)))
          (bison (package (inherit bison)
-                  (native-inputs `(("perl" ,perl-boot0)))
                   (propagated-inputs `(("m4" ,m4)))
                   (inputs '())                    ;remove Flex...
-                  (arguments '(#:tests? #f)))))   ;... and thus disable tests
-   (package-with-bootstrap-guile
-    (package-with-explicit-inputs bison %boot0-inputs
-                                  (current-source-location)
-                                  #:guile %bootstrap-guile))))
+                  (arguments
+                   '(#:tests? #f                  ;... and thus disable tests
+
+                     ;; Zero timestamps in liby.a; this must be done
+                     ;; explicitly here because the bootstrap Binutils don't
+                     ;; do that (default is "cru".)
+                     #:make-flags '("ARFLAGS=crD" "RANLIB=ranlib -D"
+                                    "V=1"))))))
+    (package
+      (inherit (package-with-bootstrap-guile
+                (package-with-explicit-inputs bison %boot0-inputs
+                                              (current-source-location)
+                                              #:guile %bootstrap-guile)))
+      (native-inputs `(("perl" ,perl-boot0))))))
 
 (define static-bash-for-glibc
-  ;; A statically-linked Bash to be embedded in GLIBC-FINAL, for use by
-  ;; system(3) & co.
+  ;; A statically-linked Bash to be used by GLIBC-FINAL in system(3) & co.
   (let* ((gcc  (cross-gcc-wrapper gcc-boot0 binutils-boot0
                                   glibc-final-with-bootstrap-bash
                                   (car (assoc-ref %boot1-inputs "bash"))))
-         (bash (package (inherit bash-light)
-                 (native-inputs `(("bison" ,bison-boot1)))
+         (bash (package (inherit static-bash)
                  (arguments
                   `(#:guile ,%bootstrap-guile
-                    ,@(package-arguments bash-light))))))
+                    ,@(package-arguments static-bash)))))
+         (inputs `(("gcc" ,gcc)
+                   ("libc" ,glibc-final-with-bootstrap-bash)
+                   ,@(fold alist-delete %boot1-inputs
+                           '("gcc" "libc")))))
+    (package
+      (inherit (package-with-bootstrap-guile
+                (package-with-explicit-inputs bash inputs
+                                              (current-source-location)
+                                              #:guile %bootstrap-guile)))
+      (native-inputs `(("bison" ,bison-boot1))))))
+
+(define gettext-boot0
+  ;; A minimal gettext used during bootstrap.
+  (let ((gettext-minimal
+         (package (inherit gnu-gettext)
+           (name "gettext-boot0")
+           (inputs '())                           ;zero dependencies
+           (arguments
+            (substitute-keyword-arguments
+                `(#:tests? #f
+                  ,@(package-arguments gnu-gettext))
+              ((#:phases phases)
+               `(modify-phases ,phases
+                  ;; Build only the tools.
+                  (add-after 'unpack 'chdir
+                             (lambda _
+                               (chdir "gettext-tools")))
+
+                  ;; Some test programs require pthreads, which we don't have.
+                  (add-before 'configure 'no-test-programs
+                              (lambda _
+                                (substitute* "tests/Makefile.in"
+                                  (("^PROGRAMS =.*$")
+                                   "PROGRAMS =\n"))
+                                #t))
+
+                  ;; Don't try to link against libexpat.
+                  (delete 'link-expat)
+                  (delete 'patch-tests))))))))
     (package-with-bootstrap-guile
-     (package-with-explicit-inputs (static-package bash)
-                                   `(("gcc" ,gcc)
-                                     ("libc" ,glibc-final-with-bootstrap-bash)
-                                     ,@(fold alist-delete %boot1-inputs
-                                             '("gcc" "libc")))
-                                   (current-source-location)))))
-
-(define-public glibc-final
+     (package-with-explicit-inputs gettext-minimal
+                                   %boot1-inputs
+                                   (current-source-location)
+                                   #:guile %bootstrap-guile))))
+
+(define glibc-final
   ;; The final glibc, which embeds the statically-linked Bash built above.
   (package (inherit glibc-final-with-bootstrap-bash)
     (name "glibc")
@@ -427,12 +518,17 @@ exec ~a/bin/~a-~a -B~a/lib -Wl,-dynamic-linker -Wl,~a/~a \"$@\"~%"
                  "static-bash"
                  (package-inputs glibc-final-with-bootstrap-bash))))
 
+    ;; This time we need 'msgfmt' to install all the libc.mo files.
+    (native-inputs `(,@(package-native-inputs glibc-final-with-bootstrap-bash)
+                     ("gettext" ,gettext-boot0)))
+
     ;; The final libc only refers to itself, but the 'debug' output contains
     ;; references to GCC-BOOT0 and to the Linux headers.  XXX: Would be great
     ;; if 'allowed-references' were per-output.
     (arguments
      `(#:allowed-references
        ,(cons* `(,gcc-boot0 "lib") (linux-libre-headers-boot0)
+               static-bash-for-glibc
                (package-outputs glibc-final-with-bootstrap-bash))
 
        ,@(package-arguments glibc-final-with-bootstrap-bash)))))
@@ -462,13 +558,14 @@ exec ~a/bin/~a-~a -B~a/lib -Wl,-dynamic-linker -Wl,~a/~a \"$@\"~%"
 (define libstdc++
   ;; Intermediate libstdc++ that will allow us to build the final GCC
   ;; (remember that GCC-BOOT0 cannot build libstdc++.)
+  ;; TODO: Write in terms of 'make-libstdc++'.
   (package-with-bootstrap-guile
-   (package (inherit gcc-4.8)
+   (package (inherit gcc)
      (name "libstdc++")
      (arguments
       `(#:guile ,%bootstrap-guile
         #:implicit-inputs? #f
-
+        #:allowed-references ("out")
         #:out-of-source? #t
         #:phases (alist-cons-before
                   'configure 'chdir
@@ -482,7 +579,7 @@ exec ~a/bin/~a-~a -B~a/lib -Wl,-dynamic-linker -Wl,~a/~a \"$@\"~%"
                                             (assoc-ref %outputs "out")
                                             "/include"
                                             ;; "/include/c++/"
-                                            ;; ,(package-version gcc-4.8)
+                                            ;; ,(package-version gcc)
                                             ))))
      (outputs '("out"))
      (inputs %boot2-inputs)
@@ -490,67 +587,89 @@ exec ~a/bin/~a-~a -B~a/lib -Wl,-dynamic-linker -Wl,~a/~a \"$@\"~%"
      (propagated-inputs '())
      (synopsis "GNU C++ standard library (intermediate)"))))
 
-(define-public gcc-final
+(define zlib-final
+  ;; Zlib used by GCC-FINAL.
+  (package-with-bootstrap-guile
+   (package
+     (inherit zlib)
+     (arguments
+      `(#:guile ,%bootstrap-guile
+        #:implicit-inputs? #f
+        #:allowed-references ("out" ,glibc-final)
+        ,@(package-arguments zlib)))
+     (inputs %boot2-inputs))))
+
+(define ld-wrapper-boot3
+  ;; A linker wrapper that uses the bootstrap Guile.
+  (make-ld-wrapper "ld-wrapper-boot3"
+                   #:binutils binutils-final
+                   #:guile %bootstrap-guile
+                   #:bash (car (assoc-ref %boot2-inputs "bash"))))
+
+(define gcc-final
   ;; The final GCC.
   (package (inherit gcc-boot0)
     (name "gcc")
-    (location (source-properties->location (current-source-location)))
+
+    ;; XXX: Currently #:allowed-references applies to all the outputs but the
+    ;; "debug" output contains disallowed references, notably
+    ;; linux-libre-headers.  Disable the debugging output to work around that.
+    (outputs (delete "debug" (package-outputs gcc-boot0)))
+
     (arguments
      `(#:guile ,%bootstrap-guile
        #:implicit-inputs? #f
 
-       #:allowed-references ("out" "lib" ,glibc-final)
+       #:allowed-references ("out" "lib" ,zlib-final
+                             ,glibc-final ,static-bash-for-glibc)
+
+       ;; Things like libasan.so and libstdc++.so NEED ld.so for some
+       ;; reason, but it is not in their RUNPATH.  This is a false
+       ;; positive, so turn it off.
+       #:validate-runpath? #f
 
        ;; Build again GMP & co. within GCC's build process, because it's hard
        ;; to do outside (because GCC-BOOT0 is a cross-compiler, and thus
        ;; doesn't honor $LIBRARY_PATH, which breaks `gnu-build-system'.)
        ,@(substitute-keyword-arguments (package-arguments gcc-boot0)
            ((#:configure-flags boot-flags)
-            (let loop ((args (package-arguments gcc-4.8)))
+            (let loop ((args (package-arguments gcc)))
               (match args
                 ((#:configure-flags normal-flags _ ...)
                  normal-flags)
                 ((_ rest ...)
                  (loop rest)))))
            ((#:make-flags flags)
-            ;; Since $LIBRARY_PATH and $CPATH are not honored, add the
-            ;; relevant flags.
-            `(cons (string-append "CPPFLAGS=-I"
-                                  (assoc-ref %build-inputs "libstdc++")
-                                  "/include")
-                   (map (lambda (flag)
-                          (if (string-prefix? "LDFLAGS=" flag)
-                              (string-append flag " -L"
-                                             (assoc-ref %build-inputs "libstdc++")
-                                             "/lib")
-                              flag))
-                        ,flags)))
-           ((#:validate-runpath? _)
-            ;; Things like libasan.so and libstdc++.so NEED ld.so and/or
-            ;; libgcc_s.so but RUNPATH is empty.  This is a false positive, so
-            ;; turn it off.
-            #f)
+            ;; Since $LIBRARY_PATH is not honored, add the relevant flags.
+            `(let ((zlib (assoc-ref %build-inputs "zlib")))
+               (map (lambda (flag)
+                      (if (string-prefix? "LDFLAGS=" flag)
+                          (string-append flag " -L"
+                                         (assoc-ref %build-inputs "libstdc++")
+                                         "/lib -L" zlib "/lib -Wl,-rpath="
+                                         zlib "/lib")
+                          flag))
+                    ,flags)))
            ((#:phases phases)
             `(alist-delete 'symlink-libgcc_eh ,phases)))))
 
-    ;; This time we want Texinfo, so we get the manual.
+    ;; This time we want Texinfo, so we get the manual.  Add
+    ;; STATIC-BASH-FOR-GLIBC so that it's used in the final shebangs of
+    ;; scripts such as 'mkheaders' and 'fixinc.sh' (XXX: who cares about these
+    ;; scripts?).
     (native-inputs `(("texinfo" ,texinfo-boot0)
+                     ("static-bash" ,static-bash-for-glibc)
                      ,@(package-native-inputs gcc-boot0)))
 
-    (inputs `(("gmp-source" ,(bootstrap-origin (package-source gmp)))
+    (inputs `(("gmp-source" ,(bootstrap-origin (package-source gmp-6.0)))
               ("mpfr-source" ,(package-source mpfr))
               ("mpc-source" ,(package-source mpc))
+              ("ld-wrapper" ,ld-wrapper-boot3)
               ("binutils" ,binutils-final)
               ("libstdc++" ,libstdc++)
+              ("zlib" ,zlib-final)
               ,@%boot2-inputs))))
 
-(define ld-wrapper-boot3
-  ;; A linker wrapper that uses the bootstrap Guile.
-  (make-ld-wrapper "ld-wrapper-boot3"
-                   #:binutils binutils-final
-                   #:guile %bootstrap-guile
-                   #:bash (car (assoc-ref %boot2-inputs "bash"))))
-
 (define %boot3-inputs
   ;; 4th stage inputs.
   `(("gcc" ,gcc-final)
@@ -560,11 +679,13 @@ exec ~a/bin/~a-~a -B~a/lib -Wl,-dynamic-linker -Wl,~a/~a \"$@\"~%"
 (define bash-final
   ;; Link with `-static-libgcc' to make sure we don't retain a reference
   ;; to the bootstrap GCC.
-  (package-with-bootstrap-guile
-   (package-with-explicit-inputs (static-libgcc-package bash)
-                                 %boot3-inputs
-                                 (current-source-location)
-                                 #:guile %bootstrap-guile)))
+  (package
+    (inherit (package-with-bootstrap-guile
+              (package-with-explicit-inputs (static-libgcc-package bash)
+                                            %boot3-inputs
+                                            (current-source-location)
+                                            #:guile %bootstrap-guile)))
+    (native-inputs `(("bison" ,bison-boot1)))))
 
 (define %boot4-inputs
   ;; Now use the final Bash.
@@ -572,13 +693,15 @@ exec ~a/bin/~a-~a -B~a/lib -Wl,-dynamic-linker -Wl,~a/~a \"$@\"~%"
     ,@(alist-delete "bash" %boot3-inputs)))
 
 (define-public guile-final
+  ;; This package must be public because other modules refer to it.  However,
+  ;; mark it as hidden so that 'fold-packages' ignores it.
   (package-with-bootstrap-guile
-   (package-with-explicit-inputs guile-2.0/fixed
+   (package-with-explicit-inputs (hidden-package guile-2.0/fixed)
                                  %boot4-inputs
                                  (current-source-location)
                                  #:guile %bootstrap-guile)))
 
-(define-public glibc-utf8-locales-final
+(define glibc-utf8-locales-final
   ;; Now that we have GUILE-FINAL, build the UTF-8 locales.  They are needed
   ;; by the build processes afterwards so their 'scm_to_locale_string' works
   ;; with the full range of Unicode codepoints (remember
@@ -592,8 +715,19 @@ exec ~a/bin/~a-~a -B~a/lib -Wl,-dynamic-linker -Wl,~a/~a \"$@\"~%"
                                               (current-source-location)
                                               #:guile %bootstrap-guile))))))
 
+(define-public ld-wrapper
+  ;; The final 'ld' wrapper, which uses the final Guile and Binutils.
+  (package (inherit ld-wrapper-boot3)
+    (name "ld-wrapper")
+    (inputs `(("guile" ,guile-final)
+              ("bash"  ,bash-final)
+              ,@(fold alist-delete (package-inputs ld-wrapper-boot3)
+                      '("guile" "bash"))))))
+
 (define %boot5-inputs
-  ;; Now with UTF-8 locale.
+  ;; Now with UTF-8 locales.  Remember that the bootstrap binaries were built
+  ;; with an older libc, which cannot load the new locale format.  See
+  ;; <https://lists.gnu.org/archive/html/guix-devel/2015-08/msg00737.html>.
   `(("locales" ,glibc-utf8-locales-final)
     ,@%boot4-inputs))
 
@@ -605,15 +739,6 @@ exec ~a/bin/~a-~a -B~a/lib -Wl,-dynamic-linker -Wl,~a/~a \"$@\"~%"
                                    ,@%boot5-inputs)
                                  (current-source-location))))
 
-(define-public ld-wrapper
-  ;; The final `ld' wrapper, which uses the final Guile.
-  (package (inherit ld-wrapper-boot3)
-    (name "ld-wrapper")
-    (inputs `(("guile" ,guile-final)
-              ("bash"  ,bash-final)
-              ,@(fold alist-delete (package-inputs ld-wrapper-boot3)
-                      '("guile" "bash"))))))
-
 (define coreutils-final
   ;; The final Coreutils.  Treat them specially because some packages, such as
   ;; Findutils, keep a reference to the Coreutils they were built with.
@@ -632,7 +757,9 @@ exec ~a/bin/~a-~a -B~a/lib -Wl,-dynamic-linker -Wl,~a/~a \"$@\"~%"
   ;; The final grep.  Gzip holds a reference to it (via zgrep), so it must be
   ;; built before gzip.
   (package-with-bootstrap-guile
-   (package-with-explicit-inputs grep
+   (package-with-explicit-inputs (package
+                                   (inherit grep)
+                                   (native-inputs `(("perl" ,perl-boot0))))
                                  %boot5-inputs
                                  (current-source-location)
                                  #:guile guile-final)))
@@ -708,19 +835,6 @@ COREUTILS-FINAL vs. COREUTILS, etc."
 ;;; GCC toolchain.
 ;;;
 
-(define (fixed-ld-wrapper)
-  ;; FIXME: In this cycle, a bug was introduced in ld-wrapper: it would
-  ;; incorrectly flag ~/.guix-profile/lib/libfoo.so as "impure", due to a bug
-  ;; in its symlink resolution code.  To work around that while avoiding a
-  ;; full rebuild, use an ld-wrapper with the bug-fix for 'gcc-toolchain'.
-  (let ((orig (car (assoc-ref %final-inputs "ld-wrapper"))))
-    (package
-      (inherit orig)
-      (location (source-properties->location (current-source-location)))
-      (inputs `(("wrapper" ,(search-path %load-path
-                                         "gnu/packages/ld-wrapper2.in"))
-                ,@(package-inputs orig))))))
-
 (define (gcc-toolchain gcc)
   "Return a complete toolchain for GCC."
   (package
@@ -732,16 +846,18 @@ COREUTILS-FINAL vs. COREUTILS, etc."
      '(#:modules ((guix build union))
        #:builder (begin
                    (use-modules (ice-9 match)
+                                (srfi srfi-26)
                                 (guix build union))
 
-                   (match %build-inputs
-                     (((names . directories) ...)
-                      (union-build (assoc-ref %outputs "out")
-                                   directories)))
+                   (let ((out (assoc-ref %outputs "out")))
+
+                     (match %build-inputs
+                       (((names . directories) ...)
+                        (union-build out directories)))
 
-                   (union-build (assoc-ref %outputs "debug")
-                                (list (assoc-ref %build-inputs
-                                                 "libc-debug"))))))
+                     (union-build (assoc-ref %outputs "debug")
+                                  (list (assoc-ref %build-inputs
+                                                   "libc-debug")))))))
 
     (native-search-paths (package-native-search-paths gcc))
     (search-paths (package-search-paths gcc))
@@ -759,15 +875,21 @@ and binaries, plus debugging symbols in the 'debug' output), and Binutils.")
     ;; install everything that we need, and (2) to make sure ld-wrapper comes
     ;; before Binutils' ld in the user's profile.
     (inputs `(("gcc" ,gcc)
-              ("ld-wrapper" ,(fixed-ld-wrapper))
+              ("ld-wrapper" ,(car (assoc-ref %final-inputs "ld-wrapper")))
               ("binutils" ,binutils-final)
               ("libc" ,glibc-final)
               ("libc-debug" ,glibc-final "debug")))))
 
 (define-public gcc-toolchain-4.8
-  (gcc-toolchain gcc-final))
+  (gcc-toolchain gcc-4.8))
 
 (define-public gcc-toolchain-4.9
-  (gcc-toolchain gcc-4.9))
+  (gcc-toolchain gcc-final))
+
+(define-public gcc-toolchain-5
+  (gcc-toolchain gcc-5))
+
+(define-public gcc-toolchain-6
+  (gcc-toolchain gcc-6))
 
 ;;; commencement.scm ends here