gnu: spice: Fix CVE-2017-7506.
[jackhill/guix/guix.git] / gnu / packages / commencement.scm
index 56c4cef..54cf89b 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, 2017 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2014 Andreas Enge <andreas@enge.fr>
 ;;; Copyright © 2012 Nikita Karetnikov <nikita@karetnikov.org>
-;;; Copyright © 2014, 2015 Mark H Weaver <mhw@netris.org>
+;;; Copyright © 2014, 2015, 2017 Mark H Weaver <mhw@netris.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
 (define-module (gnu packages commencement)
   #:use-module ((guix licenses)
                 #:select (gpl3+ lgpl2.0+ public-domain))
+  #:use-module (gnu packages)
   #:use-module (gnu packages bootstrap)
   #:use-module (gnu packages base)
   #:use-module (gnu packages bash)
   #:use-module (gnu packages gcc)
   #:use-module (gnu packages m4)
+  #:use-module (gnu packages indent)
   #:use-module (gnu packages file)
   #:use-module (gnu packages gawk)
   #:use-module (gnu packages bison)
+  #:use-module (gnu packages flex)
   #: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)
   #:use-module (gnu packages linux)
+  #:use-module (gnu packages hurd)
   #:use-module (gnu packages texinfo)
   #:use-module (gnu packages pkg-config)
   #:use-module (guix packages)
@@ -46,7 +50,8 @@
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-26)
   #:use-module (ice-9 vlist)
-  #:use-module (ice-9 match))
+  #:use-module (ice-9 match)
+  #:use-module (ice-9 regex))
 
 ;;; Commentary:
 ;;;
         #:tests? #f                  ; cannot run "make check"
         ,@(substitute-keyword-arguments (package-arguments gnu-make)
             ((#:phases phases)
-             `(alist-replace
-               'build (lambda _
-                        (zero? (system* "./build.sh")))
-               (alist-replace
-                'install (lambda* (#:key outputs #:allow-other-keys)
-                           (let* ((out (assoc-ref outputs "out"))
-                                  (bin (string-append out "/bin")))
-                             (mkdir-p bin)
-                             (copy-file "make"
-                                        (string-append bin "/make"))))
-                ,phases))))))
+             `(modify-phases ,phases
+                (replace 'build
+                  (lambda _
+                    (zero? (system* "./build.sh"))))
+                (replace 'install
+                  (lambda* (#:key outputs #:allow-other-keys)
+                    (let* ((out (assoc-ref outputs "out"))
+                           (bin (string-append out "/bin")))
+                      (install-file "make" bin)))))))))
      (native-inputs '())                          ; no need for 'pkg-config'
      (inputs %bootstrap-inputs))))
 
                                             ,@%bootstrap-inputs)
                                           #:guile %bootstrap-guile)))
      (package (inherit p)
+       (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)
                     ,cf)))))
      (inputs %boot0-inputs))))
 
+(define libstdc++-boot0
+  ;; GCC's libcc1 is always built as a shared library (the top-level
+  ;; 'Makefile.def' forcefully adds --enable-shared) and thus needs to refer
+  ;; to libstdc++.so.  We cannot build libstdc++-5.3 because it relies on
+  ;; C++14 features missing in our bootstrap compiler.
+  (let ((lib (package-with-bootstrap-guile (make-libstdc++ gcc-4.9))))
+    (package
+      (inherit lib)
+      (name "libstdc++-boot0")
+      (arguments
+       `(#:guile ,%bootstrap-guile
+         #:implicit-inputs? #f
+
+         ;; XXX: libstdc++.so NEEDs ld.so for some reason.
+         #:validate-runpath? #f
+
+         ,@(package-arguments lib)))
+      (inputs %boot0-inputs)
+      (native-inputs '()))))
+
 (define gcc-boot0
   (package-with-bootstrap-guile
    (package (inherit gcc)
                             "--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)
                       (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)
 
+               ;; The libstdc++ that libcc1 links against.
+               ("libstdc++" ,libstdc++-boot0)
+
                ;; Call it differently so that the builder can check whether
                ;; the "libc" input is #f.
                ("libc-native" ,@(assoc-ref %boot0-inputs "libc"))
                                   (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")
+                (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)))))))
+                     ;; Do not configure with '-Dusethreads' since pthread
+                     ;; support is missing.
+                     ((#:configure-flags configure-flags)
+                      `(delete "-Dusethreads" ,configure-flags))))))))
+    (package-with-bootstrap-guile
+     (package-with-explicit-inputs perl
+                                   %boot0-inputs
+                                   (current-source-location)
+                                   #:guile %bootstrap-guile))))
+
+(define bison-boot0
+  ;; This Bison is needed to build MiG so we need it early in the process.
+  ;; It is also needed to rebuild Bash's parser, which is modified by
+  ;; its CVE patches.  Remove it when it's no longer needed.
+  (let* ((m4    (package-with-bootstrap-guile
+                 (package-with-explicit-inputs m4 %boot0-inputs
+                                               (current-source-location)
+                                               #:guile %bootstrap-guile)))
+         (bison (package (inherit bison)
+                  (propagated-inputs `(("m4" ,m4)))
+                  (inputs '())                    ;remove Flex...
+                  (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 flex-boot0
+  ;; This Flex is needed to build MiG.
+  (let* ((flex (package (inherit flex)
+                 (native-inputs `(("bison" ,bison-boot0)))
+                 (propagated-inputs `(("m4" ,m4)))
+                 (inputs `(("indent" ,indent)))
+                 (arguments '(#:tests? #f)))))
+    (package-with-bootstrap-guile
+     (package-with-explicit-inputs flex %boot0-inputs
+                                   (current-source-location)
+                                   #:guile %bootstrap-guile))))
 
 (define (linux-libre-headers-boot0)
   "Return Linux-Libre header files for the bootstrap environment."
       `(("perl" ,perl-boot0)
         ,@%boot0-inputs)))))
 
+(define gnumach-headers-boot0
+  (package-with-bootstrap-guile
+   (package-with-explicit-inputs gnumach-headers
+                                 %boot0-inputs
+                                 (current-source-location)
+                                 #:guile %bootstrap-guile)))
+
+(define mig-boot0
+  (let* ((mig (package (inherit mig)
+                 (native-inputs `(("bison" ,bison-boot0)
+                                  ("flex" ,flex-boot0)))
+                 (inputs `(("flex" ,flex-boot0)))
+                 (arguments
+                  `(#:configure-flags
+                    `(,(string-append "LDFLAGS=-Wl,-rpath="
+                                      (assoc-ref %build-inputs "flex") "/lib/")))))))
+    (package-with-bootstrap-guile
+     (package-with-explicit-inputs mig %boot0-inputs
+                                   (current-source-location)
+                                   #:guile %bootstrap-guile))))
+
+(define hurd-headers-boot0
+  (let ((hurd-headers (package (inherit hurd-headers)
+                        (native-inputs `(("mig" ,mig-boot0)))
+                        (inputs '()))))
+    (package-with-bootstrap-guile
+     (package-with-explicit-inputs hurd-headers %boot0-inputs
+                                   (current-source-location)
+                                   #:guile %bootstrap-guile))))
+
+(define hurd-minimal-boot0
+  (let ((hurd-minimal (package (inherit hurd-minimal)
+                        (native-inputs `(("mig" ,mig-boot0)))
+                        (inputs '()))))
+    (package-with-bootstrap-guile
+     (package-with-explicit-inputs hurd-minimal %boot0-inputs
+                                   (current-source-location)
+                                   #:guile %bootstrap-guile))))
+
+(define (hurd-core-headers-boot0)
+  "Return the Hurd and Mach headers as well as initial Hurd libraries for
+the bootstrap environment."
+  (package-with-bootstrap-guile
+   (package (inherit hurd-core-headers)
+            (arguments `(#:guile ,%bootstrap-guile
+                                 ,@(package-arguments hurd-core-headers)))
+            (inputs
+             `(("gnumach-headers" ,gnumach-headers-boot0)
+               ("hurd-headers" ,hurd-headers-boot0)
+               ("hurd-minimal" ,hurd-minimal-boot0)
+               ,@%boot0-inputs)))))
+
+(define* (kernel-headers-boot0 #:optional (system (%current-system)))
+  (match system
+    ("i586-gnu" (hurd-core-headers-boot0))
+    (_ (linux-libre-headers-boot0))))
+
 (define texinfo-boot0
   ;; Texinfo used to build libc's manual.
   ;; We build without ncurses because it fails to build at this stage, and
   ;; Also, use %BOOT0-INPUTS to avoid building Perl once more.
   (let ((texinfo (package (inherit texinfo)
                    (native-inputs '())
-                   (inputs (alist-delete "ncurses" (package-inputs texinfo))))))
+                   (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)
                                    #:guile %bootstrap-guile))))
 
+(define ld-wrapper-boot0
+  ;; We need this so binaries on Hurd will have libmachuser and libhurduser
+  ;; in their RUNPATH, otherwise validate-runpath will fail.
+  (make-ld-wrapper "ld-wrapper-boot0"
+                   #:target boot-triplet
+                   #:binutils binutils-boot0
+                   #:guile %bootstrap-guile
+                   #:bash (car (assoc-ref %boot0-inputs "bash"))))
+
 (define %boot1-inputs
   ;; 2nd stage inputs.
   `(("gcc" ,gcc-boot0)
+    ("ld-wrapper-cross" ,ld-wrapper-boot0)
     ("binutils-cross" ,binutils-boot0)
     ,@(alist-delete "binutils" %boot0-inputs)))
 
   ;; built just below; the only difference is that this one uses the
   ;; bootstrap Bash.
   (package-with-bootstrap-guile
-   (package (inherit glibc)
+   (package/inherit glibc
      (name "glibc-intermediate")
      (arguments
       `(#:guile ,%bootstrap-guile
                  (setenv "NATIVE_CPATH" (getenv "CPATH"))
                  (unsetenv "CPATH")
 
+                 ;; Tell 'libpthread' where to find 'libihash' on Hurd systems.
+                 ,@(if (hurd-triplet? (%current-system))
+                       `((substitute* "libpthread/Makefile"
+                           (("LDLIBS-pthread.so =.*")
+                            (string-append "LDLIBS-pthread.so = "
+                                           (assoc-ref %build-inputs "kernel-headers")
+                                           "/lib/libihash.a\n"))))
+                       '())
+
                  ;; 'rpcgen' needs native libc headers to be built.
                  (substitute* "sunrpc/Makefile"
                    (("sunrpc-CPPFLAGS =.*" all)
                                    "export CPATH\n"
                                    all "\n"))))
                ,phases)))))
-     (propagated-inputs `(("linux-headers" ,(linux-libre-headers-boot0))))
+     (propagated-inputs `(("kernel-headers" ,(kernel-headers-boot0))))
      (native-inputs
       `(("texinfo" ,texinfo-boot0)
-        ("perl" ,perl-boot0)))
+        ("perl" ,perl-boot0)
+        ;; Apply this patch only on i686 to avoid a full rebuild.
+        ;; TODO: Remove in the next update cycle.
+        ,@(if (string-prefix? "i686" (or (%current-target-system)
+                                         (%current-system)))
+              `(("glibc-memchr-overflow-i686.patch"
+                 ,(search-patch "glibc-memchr-overflow-i686.patch")))
+              '())))
      (inputs
       `(;; The boot inputs.  That includes the bootstrap libc.  We don't want
         ;; it in $CPATH, hence the 'pre-configure' phase above.
         ,@%boot1-inputs
 
+        ;; A native MiG is needed to build Glibc on Hurd.
+        ,@(if (hurd-triplet? (%current-system))
+              `(("mig" ,mig-boot0))
+              '())
+
         ;; A native GCC is needed to build `cross-rpcgen'.
         ("native-gcc" ,@(assoc-ref %boot0-inputs "gcc"))
 
@@ -401,51 +585,34 @@ exec ~a/bin/~a-~a -B~a/lib -Wl,-dynamic-linker -Wl,~a/~a \"$@\"~%"
        ("bash" ,bash)))
     (inputs '())))
 
-(define bison-boot1
-  ;; XXX: This Bison is needed to rebuild Bash's parser, which is modified by
-  ;; its CVE patches.  Remove it when it's no longer needed.
-  (let* ((m4    (package-with-bootstrap-guile
-                 (package-with-explicit-inputs m4 %boot0-inputs
-                                               (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))))
-
 (define static-bash-for-glibc
   ;; 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 static-bash)
-                 (native-inputs `(("bison" ,bison-boot1)))
                  (arguments
                   `(#:guile ,%bootstrap-guile
-                    ,@(package-arguments static-bash))))))
+                    ,@(package-arguments static-bash)))))
+         (inputs `(("gcc" ,gcc)
+                   ("libc" ,glibc-final-with-bootstrap-bash)
+                   ,@(fold alist-delete %boot1-inputs
+                           '("gcc" "libc")))))
     (package-with-bootstrap-guile
-     (package-with-explicit-inputs bash
-                                   `(("gcc" ,gcc)
-                                     ("libc" ,glibc-final-with-bootstrap-bash)
-                                     ,@(fold alist-delete %boot1-inputs
-                                             '("gcc" "libc")))
-                                   (current-source-location)))))
+     (package-with-explicit-inputs bash inputs
+                                   (current-source-location)
+                                   #:guile %bootstrap-guile))))
 
 (define gettext-boot0
   ;; A minimal gettext used during bootstrap.
   (let ((gettext-minimal
-         (package (inherit gnu-gettext)
+         (package (inherit gettext-minimal)
            (name "gettext-boot0")
            (inputs '())                           ;zero dependencies
            (arguments
             (substitute-keyword-arguments
                 `(#:tests? #f
-                  ,@(package-arguments gnu-gettext))
+                  ,@(package-arguments gettext-minimal))
               ((#:phases phases)
                `(modify-phases ,phases
                   ;; Build only the tools.
@@ -472,7 +639,7 @@ exec ~a/bin/~a-~a -B~a/lib -Wl,-dynamic-linker -Wl,~a/~a \"$@\"~%"
 
 (define glibc-final
   ;; The final glibc, which embeds the statically-linked Bash built above.
-  (package (inherit glibc-final-with-bootstrap-bash)
+  (package/inherit glibc-final-with-bootstrap-bash
     (name "glibc")
     (inputs `(("static-bash" ,static-bash-for-glibc)
               ,@(alist-delete
@@ -488,7 +655,7 @@ exec ~a/bin/~a-~a -B~a/lib -Wl,-dynamic-linker -Wl,~a/~a \"$@\"~%"
     ;; if 'allowed-references' were per-output.
     (arguments
      `(#:allowed-references
-       ,(cons* `(,gcc-boot0 "lib") (linux-libre-headers-boot0)
+       ,(cons* `(,gcc-boot0 "lib") (kernel-headers-boot0)
                static-bash-for-glibc
                (package-outputs glibc-final-with-bootstrap-bash))
 
@@ -526,7 +693,7 @@ exec ~a/bin/~a-~a -B~a/lib -Wl,-dynamic-linker -Wl,~a/~a \"$@\"~%"
      (arguments
       `(#:guile ,%bootstrap-guile
         #:implicit-inputs? #f
-
+        #:allowed-references ("out")
         #:out-of-source? #t
         #:phases (alist-cons-before
                   'configure 'chdir
@@ -548,6 +715,25 @@ exec ~a/bin/~a-~a -B~a/lib -Wl,-dynamic-linker -Wl,~a/~a \"$@\"~%"
      (propagated-inputs '())
      (synopsis "GNU C++ standard library (intermediate)"))))
 
+(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)
@@ -562,7 +748,7 @@ exec ~a/bin/~a-~a -B~a/lib -Wl,-dynamic-linker -Wl,~a/~a \"$@\"~%"
      `(#:guile ,%bootstrap-guile
        #:implicit-inputs? #f
 
-       #:allowed-references ("out" "lib"
+       #:allowed-references ("out" "lib" ,zlib-final
                              ,glibc-final ,static-bash-for-glibc)
 
        ;; Things like libasan.so and libstdc++.so NEED ld.so for some
@@ -582,18 +768,16 @@ exec ~a/bin/~a-~a -B~a/lib -Wl,-dynamic-linker -Wl,~a/~a \"$@\"~%"
                 ((_ 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)))
+            ;; 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)))))
 
@@ -605,20 +789,15 @@ exec ~a/bin/~a-~a -B~a/lib -Wl,-dynamic-linker -Wl,~a/~a \"$@\"~%"
                      ("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)
@@ -628,11 +807,17 @@ 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)))
+  (let ((bash (package
+                (inherit bash)
+                (arguments
+                 `(#:disallowed-references
+                   ,(assoc-ref %boot3-inputs "coreutils&co")
+                   ,@(package-arguments bash))))))
+    (package-with-bootstrap-guile
+     (package-with-explicit-inputs (static-libgcc-package bash)
+                                   %boot3-inputs
+                                   (current-source-location)
+                                   #:guile %bootstrap-guile))))
 
 (define %boot4-inputs
   ;; Now use the final Bash.
@@ -640,8 +825,10 @@ 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)))
@@ -660,46 +847,6 @@ exec ~a/bin/~a-~a -B~a/lib -Wl,-dynamic-linker -Wl,~a/~a \"$@\"~%"
                                               (current-source-location)
                                               #:guile %bootstrap-guile))))))
 
-(define (locale-proof-package p)
-  "Return a new package based on P that ignores 'LOCPATH'.  The result is a
-\"locale-proof\" package in the sense that it cannot end up loading locale
-data that is not in the format its libc expects.  This is useful because the
-locale binary format may change incompatibly between libc versions."
-  (package
-    (inherit p)
-    (name (string-append (package-name p) "-lp"))
-    (build-system trivial-build-system)
-    (inputs `(("original" ,p)
-              ("bash" ,bash-final)))
-    (outputs '("out"))
-    (arguments
-     '(#:modules ((guix build utils))
-       #:builder
-       (begin
-         (use-modules (guix build utils))
-
-         (let* ((out      (assoc-ref %outputs "out"))
-                (bin      (string-append out "/bin"))
-                (bash     (assoc-ref %build-inputs "bash"))
-                (binaries (assoc-ref %build-inputs "original"))
-                (programs (find-files (string-append binaries "/bin"))))
-           (define (wrap-program program)
-             (let ((base (basename program)))
-               (call-with-output-file base
-                 (lambda (port)
-                   (format port "#!~a/bin/sh
-# Unset 'LOCPATH' so that the program does not end up loading incompatible
-# locale data.
-unset LOCPATH
-exec \"~a\" \"$@\"\n"
-                           bash program)))
-               (chmod base #o755)))
-
-           (mkdir-p bin)
-           (with-directory-excursion bin
-             (for-each wrap-program programs)
-             #t)))))))
-
 (define-public ld-wrapper
   ;; The final 'ld' wrapper, which uses the final Guile and Binutils.
   (package (inherit ld-wrapper-boot3)
@@ -710,40 +857,11 @@ exec \"~a\" \"$@\"\n"
                       '("guile" "bash"))))))
 
 (define %boot5-inputs
-  ;; Now with UTF-8 locales.  Since the locale binary format differs between
-  ;; libc versions, we have to rebuild some of the packages so that they use
-  ;; the new libc, which allows them to load locale data from
-  ;; GLIBC-UTF8-LOCALES-FINAL (remember that the bootstrap binaries were built
-  ;; with an older libc, which cannot load the new locale format.)  See
+  ;; 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>.
-  (let ((new-libc-package (compose package-with-bootstrap-guile
-                                   (cut package-with-explicit-inputs <>
-                                        %boot4-inputs
-                                        (current-source-location)
-                                        #:guile %bootstrap-guile))))
-    `(("locales" ,glibc-utf8-locales-final)
-      ("ld-wrapper" ,ld-wrapper)
-      ("binutils" ,binutils-final)
-      ("bash" ,bash-final)
-      ("make" ,(new-libc-package gnu-make))
-
-      ;; Some test suites (grep, Gnulib) use 'diff' to compare files in locale
-      ;; encoding, so we need support this.
-      ("diffutils" ,(new-libc-package diffutils))
-      ("findutils" ,(new-libc-package findutils))
-
-      ;; Grep's test suite uses 'timeout' from Coreutils to execute command,
-      ;; and yet these commands need to see the valid 'LOCPATH'.
-      ("coreutils" ,(new-libc-package coreutils-minimal))
-
-      ;; We just wrap the remaining binaries (tar, gzip, xz, etc.)  so that
-      ;; they ignore 'LOCPATH' (if they did not, they would be hit by an
-      ;; assertion failure in loadlocale.c.)
-      ("coreutils&co" ,(locale-proof-package %bootstrap-coreutils&co))
-
-      ,@(fold alist-delete %boot4-inputs
-              '("coreutils&co" "findutils" "diffutils" "make"
-                "bash" "binutils-cross" "ld-wrapper")))))
+  `(("locales" ,glibc-utf8-locales-final)
+    ,@%boot4-inputs))
 
 (define gnu-make-final
   ;; The final GNU Make, which uses the final Guile.
@@ -771,7 +889,9 @@ exec \"~a\" \"$@\"\n"
   ;; 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)))
@@ -880,7 +1000,7 @@ COREUTILS-FINAL vs. COREUTILS, etc."
      "This package provides a complete GCC tool chain for C/C++ development to
 be installed in user profiles.  This includes GCC, as well as libc (headers
 and binaries, plus debugging symbols in the 'debug' output), and Binutils.")
-    (home-page "http://gcc.gnu.org/")
+    (home-page "https://gcc.gnu.org/")
     (outputs '("out" "debug"))
 
     ;; The main raison d'être of this "meta-package" is (1) to conveniently
@@ -893,12 +1013,18 @@ and binaries, plus debugging symbols in the 'debug' output), and Binutils.")
               ("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))
 
 (define-public gcc-toolchain-5
-  (gcc-toolchain gcc-5))
+  (gcc-toolchain gcc-final))
+
+(define-public gcc-toolchain-6
+  (gcc-toolchain gcc-6))
+
+(define-public gcc-toolchain-7
+  (gcc-toolchain gcc-7))
 
 ;;; commencement.scm ends here