gnu: commencement: Add gash-core-utils-boot.
[jackhill/guix/guix.git] / gnu / packages / commencement.scm
index d173f5a..bf320c1 100644 (file)
@@ -1,12 +1,12 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2014 Andreas Enge <andreas@enge.fr>
 ;;; Copyright © 2012 Nikita Karetnikov <nikita@karetnikov.org>
 ;;; Copyright © 2014, 2015, 2017 Mark H Weaver <mhw@netris.org>
 ;;; Copyright © 2017, 2018, 2019 Efraim Flashner <efraim@flashner.co.il>
 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
-;;; Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
-;;; Copyright © 2019 Marius Bakke <mbakke@fastmail.com>
+;;; Copyright © 2018, 2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
+;;; Copyright © 2019, 2020 Marius Bakke <mbakke@fastmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -24,8 +24,6 @@
 ;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
 
 (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 python)
   #:use-module (gnu packages linux)
   #:use-module (gnu packages hurd)
+  #:use-module (gnu packages shells)
   #:use-module (gnu packages texinfo)
   #:use-module (gnu packages pkg-config)
+  #:use-module (gnu packages rsync)
   #:use-module (gnu packages xml)
   #:use-module (guix packages)
   #:use-module (guix download)
   #:use-module (guix build-system gnu)
+  #:use-module (guix build-system guile)
   #:use-module (guix build-system trivial)
   #:use-module (guix memoization)
   #:use-module (guix utils)
   #:use-module (srfi srfi-1)
-  #:use-module (srfi srfi-26)
   #:use-module (ice-9 vlist)
   #:use-module (ice-9 match)
-  #:use-module (ice-9 regex)
   #:export (make-gcc-toolchain))
 
 ;;; Commentary:
 ;;;
 ;;; Code:
 
+(define %bootstrap-guile+guild
+  ;; This package combines %bootstrap-guile with guild, which is not included
+  ;; in %bootstrap-guile.  Guild is needed to build gash-boot and
+  ;; gash-core-utils-boot because it is dependency of the Guile build system.
+  (package
+    (name "guile-bootstrap+guild")
+    (version "2.0")
+    (source (bootstrap-origin (package-source guile-2.0)))
+    (native-inputs `(("bash" ,(bootstrap-executable "bash" (%current-system)))
+                     ("tar" ,(bootstrap-executable "tar" (%current-system)))
+                     ("xz" ,(bootstrap-executable "xz" (%current-system)))
+                     ("guile" ,%bootstrap-guile)))
+    (build-system trivial-build-system)
+    (arguments
+     `(#:guile ,%bootstrap-guile
+       #:modules ((guix build utils))
+       #:builder (begin
+                   (use-modules (guix build utils))
+                   (let ((guile-source (assoc-ref %build-inputs "source"))
+                         (bin (string-append (getcwd) "/bin"))
+                         (tar (assoc-ref %build-inputs "tar"))
+                         (xz (assoc-ref %build-inputs "xz")))
+                     (mkdir-p bin)
+                     (setenv "PATH" bin)
+                     (with-directory-excursion bin
+                       (copy-file tar "tar")
+                       (copy-file xz "xz")
+                       (setenv "PATH" bin))
+                     (let* ((out (assoc-ref %outputs "out"))
+                            (out-bin (string-append out "/bin"))
+                            (guile (assoc-ref %build-inputs "guile"))
+                            (bash (assoc-ref %build-inputs "bash")))
+                       (mkdir-p out-bin)
+                       (with-directory-excursion out-bin
+                         (symlink (string-append guile "/bin/guile")
+                                  "guile")
+                         (invoke "tar" "--strip-components=2"
+                                 "-xvf" guile-source
+                                 (string-append "guile-"
+                                                ,(package-version guile-2.0)
+                                                "/meta/guild.in"))
+                         (copy-file "guild.in" "guild")
+                         (substitute* "guild"
+                           (("#!/bin/sh") (string-append "#! " bash))
+                           (("@installed_guile@") (string-append out-bin "/guile")))
+                         (chmod "guild" #o555)))))))
+    (synopsis "Bootstrap Guile plus Guild")
+    (description "Bootstrap Guile with added Guild")
+    (home-page #f)
+    (license (package-license guile-2.0))
+    (native-search-paths
+     (list (search-path-specification
+            (variable "GUILE_LOAD_PATH")
+            (files '("share/guile/site/2.0")))
+           (search-path-specification
+            (variable "GUILE_LOAD_COMPILED_PATH")
+            (files '("lib/guile/2.0/site-ccache")))))))
+
+(define gash-boot
+  (package
+    (inherit gash)
+    (name "gash-boot")
+    (version "0.2.0")
+    (source (bootstrap-origin
+             (origin (inherit (package-source gash))
+                     (modules '((guix build utils)
+                                (srfi srfi-26)))
+                     (snippet
+                      '(begin
+                         ;; Remove Guix'y files that we cannot compile.
+                         (delete-file "guix.scm")
+                         (delete-file-recursively "tests")
+                         #t)))))
+    (build-system guile-build-system)
+    (native-inputs `(("bash" ,(bootstrap-executable "bash" (%current-system)))
+                     ("tar" ,(bootstrap-executable "tar" (%current-system)))
+                     ("xz" ,(bootstrap-executable "xz" (%current-system)))
+                     ("guile-source" ,(bootstrap-origin
+                                       (package-source guile-2.0)))))
+    (inputs `(("guile" ,%bootstrap-guile+guild)))
+    (arguments
+     `(#:implicit-inputs? #f
+       #:guile ,%bootstrap-guile+guild
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'unpack-guile-source
+           (lambda _
+             (let ((guile-source (assoc-ref %build-inputs "guile-source"))
+                   (bin (string-append (getcwd) "/zee-bin")))
+               (mkdir-p bin)
+               (with-directory-excursion bin
+                 (invoke "tar" "--strip-components=2"
+
+                         "-xvf" guile-source
+                         (string-append "guile-"
+                                        ,(package-version guile-2.0)
+                                        "/meta/guild.in"))
+                 (copy-file "guild.in" "guild")
+                 (chmod "guild" #o555))
+               #t)))
+         (add-before 'unpack 'set-path
+           (lambda _
+             (let ((bash (assoc-ref %build-inputs "bash"))
+                   (tar (assoc-ref %build-inputs "tar"))
+                   (xz (assoc-ref %build-inputs "xz"))
+                   (bin (string-append (getcwd) "/zee-bin")))
+               (mkdir-p bin)
+               (setenv "PATH" (string-append bin ":" (getenv "PATH")))
+               (copy-file bash (string-append bin "/bash"))
+               (copy-file bash (string-append bin "/sh"))
+               (copy-file tar (string-append bin "/tar"))
+               (copy-file xz (string-append bin "/xz"))
+               #t)))
+         (add-after 'build 'build-scripts
+           (lambda _
+             (let* ((guile (assoc-ref %build-inputs "guile"))
+                    (guile (string-append guile "/bin/guile"))
+                    (out (assoc-ref %outputs "out"))
+                    (effective "2.0")
+                    (moddir (string-append out "/share/guile/site/" effective "/"))
+                    (godir (string-append out "/lib/guile/" effective "/site-ccache/")))
+               (copy-file "scripts/gash.in" "scripts/gash")
+               (chmod "scripts/gash" #o555)
+               (substitute* "scripts/gash"
+                 (("@GUILE@") guile)
+                 (("@MODDIR@") moddir)
+                 (("@GODIR") godir))
+               #t)))
+         (add-after 'install 'install-scripts
+           (lambda _
+             (let* ((out (assoc-ref %outputs "out"))
+                    (bin (string-append out "/bin")))
+               (install-file "scripts/gash" bin)
+               (copy-file "scripts/gash" "scripts/sh")
+               (install-file "scripts/sh" bin)
+               (copy-file "scripts/gash" "scripts/bash")
+               (install-file "scripts/bash" bin)
+               #t))))))))
+
+(define gash-core-utils-boot
+  (package
+    (inherit gash-core-utils)
+    (name "gash-core-utils-boot")
+    (version "0.0.213-3f6eb")
+    (source (bootstrap-origin
+             (origin
+               (method url-fetch)
+               (uri (string-append "http://lilypond.org/janneke/"
+                                   "/gash-core-utils-" version ".tar.gz"))
+               (modules '((guix build utils)))
+               (snippet
+                '(begin
+                   ;; The Guile build system compiles *.scm; avoid
+                   ;; compiling included lalr.
+                   (delete-file "guix.scm")
+                   (delete-file-recursively "tests")
+                   (substitute* "system/base/lalr.scm"
+                     (("system/base/lalr.upstream.scm") "lalr.upstream.scm"))
+                   #t))
+               (sha256
+                (base32
+                 "0601c9hqbjrjjsllr2m3zmkglkd53d97in7a5c22ikd8islddp76")))))
+    (build-system guile-build-system)
+    (native-inputs `(("bash" ,(bootstrap-executable "bash" (%current-system)))
+                     ("tar" ,(bootstrap-executable "tar" (%current-system)))
+                     ("xz" ,(bootstrap-executable "xz" (%current-system)))
+                     ("guile-source" ,(bootstrap-origin
+                                       (package-source guile-2.0)))
+                     ;; We need the 2.0.9 lalr for %bootstrap-guile
+                     ("lalr.upstream"
+                      ,(origin
+                         (method url-fetch)
+                         (uri (string-append "http://git.savannah.gnu.org/cgit/guile.git/plain/module/system/base/lalr.upstream.scm?h=v2.0.9"))
+                         (file-name "lalr.upstream.scm")
+                         (sha256
+                          (base32
+                           "0h7gyjj8nr2qrgzwma146s7l22scp8bbcqzdy9wqf12bgyhbw7d5"))))))
+    (inputs `(("guile" ,%bootstrap-guile+guild)
+              ("gash" ,gash-boot)))
+    (arguments
+     `(#:implicit-inputs? #f
+       #:guile ,%bootstrap-guile+guild
+       #:not-compiled-file-regexp "upstream\\.scm$"
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'unpack-guile-source
+           (lambda _
+             (let ((guile-source (assoc-ref %build-inputs "guile-source"))
+                   (bin (string-append (getcwd) "/zee-bin")))
+               (mkdir-p bin)
+               (with-directory-excursion bin
+                 (invoke "tar" "--strip-components=2"
+
+                         "-xvf" guile-source
+                         (string-append "guile-"
+                                        ,(package-version guile-2.0)
+                                        "/meta/guild.in"))
+                 (copy-file "guild.in" "guild")
+                 (chmod "guild" #o555))
+               #t)))
+         (add-before 'unpack 'set-path
+           (lambda _
+             (let ((bash (assoc-ref %build-inputs "bash"))
+                   (tar (assoc-ref %build-inputs "tar"))
+                   (xz (assoc-ref %build-inputs "xz"))
+                   (bin (string-append (getcwd) "/zee-bin")))
+               (mkdir-p bin)
+               (setenv "PATH" (string-append bin ":" (getenv "PATH")))
+               (copy-file bash (string-append bin "/bash"))
+               (copy-file bash (string-append bin "/sh"))
+               (copy-file tar (string-append bin "/tar"))
+               (copy-file xz (string-append bin "/xz"))
+               #t)))
+         (add-before 'build 'set-env
+           (lambda _
+             (let ((gash (assoc-ref %build-inputs "gash")))
+               (setenv "LANG" "C")
+               (setenv "LC_ALL" "C")
+               (setenv "GUILE_LOAD_PATH"
+                       (string-append (getcwd)
+                                      ":" (getcwd) "/system/base"
+                                      ":" gash "/share/guile/2.0"))
+               (setenv "GUILE_LOAD_COMPILED_PATH"
+                       (string-append ".:" gash "/lib/guile/2.0/site-ccache/"))
+               (format (current-error-port)
+                       "GUILE_LOAD_PATH=~s\n" (getenv "GUILE_LOAD_PATH"))
+               #t)))
+         (add-before 'build 'replace-lalr.upstream
+           (lambda _
+             (let ((lalr.upstream (assoc-ref %build-inputs "lalr.upstream")))
+               (copy-file lalr.upstream "system/base/lalr.upstream.scm")
+               #t)))
+         (add-after 'build 'build-scripts
+           (lambda _
+             (let* ((guile (assoc-ref %build-inputs "guile"))
+                    (guile (string-append guile "/bin/guile"))
+                    (gash (string-append guile "gash"))
+                    (out (assoc-ref %outputs "out"))
+                    (effective "2.0")
+                    (guilemoduledir (string-append gash "/share/guile/site/" effective "/"))
+                    (guileobjectdir (string-append gash "/lib/guile/" effective "/site-ccache/"))
+                    (gashmoduledir (string-append out "/share/guile/site/" effective "/"))
+                    (gashobjectdir (string-append out "/lib/guile/" effective "/site-ccache/"))
+                    (bin (string-append out "/bin")))
+               (define (wrap name)
+                 (copy-file "command.in" name)
+                 (chmod name #o555)
+                 (substitute* name
+                   (("@GUILE@") guile)
+                   (("@guilemoduledir@") guilemoduledir)
+                   (("@guileobjectdir") guileobjectdir)
+                   (("@gashmoduledir@") gashmoduledir)
+                   (("@gashobjectdir") gashobjectdir)
+                   (("@command@") name))
+                 (install-file name bin))
+               (mkdir-p bin)
+               (with-directory-excursion "bin"
+                 (for-each wrap '("awk"
+                                  "basename"
+                                  "cat"
+                                  "chmod"
+                                  "cmp"
+                                  "compress"
+                                  "cp"
+                                  "cut"
+                                  "diff"
+                                  "dirname"
+                                  "expr"
+                                  "false"
+                                  "find"
+                                  "grep"
+                                  "gzip"
+                                  "head"
+                                  "ln"
+                                  "ls"
+                                  "mkdir"
+                                  "mv"
+                                  "pwd"
+                                  "reboot"
+                                  "rm"
+                                  "rmdir"
+                                  "sed"
+                                  "sleep"
+                                  "sort"
+                                  "tar"
+                                  "test"
+                                  "touch"
+                                  "tr"
+                                  "true"
+                                  "uname"
+                                  "uniq"
+                                  "wc"
+                                  "which")))
+               (with-directory-excursion bin
+                 (copy-file "grep" "fgrep")
+                 (copy-file "grep" "egrep")
+                 (copy-file "test" "["))
+               #t))))))))
+
+(define (%boot-gash-inputs)
+  `(("bash" , gash-boot)                ; gnu-build-system wants "bash"
+    ("coreutils" , gash-core-utils-boot)
+    ("guile" ,%bootstrap-guile)
+    ("guile+guild" ,%bootstrap-guile+guild)))
+
 (define mes-boot
   (package
     (inherit mes)
            (lambda _
              (invoke "sh" "install.sh"))))))
     (native-search-paths
-     ;; Use the language-specific variables rather than 'CPATH' because they
-     ;; are equivalent to '-isystem' whereas 'CPATH' is equivalent to '-I'.
-     ;; The intent is to allow headers that are in the search path to be
-     ;; 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")
             (files '("share/mes/include")))
              (lambda _
                (invoke "sh" "install.sh"))))))
       (native-search-paths
-       ;; Use the language-specific variables rather than 'CPATH' because they
-       ;; are equivalent to '-isystem' whereas 'CPATH' is equivalent to '-I'.
-       ;; The intent is to allow headers that are in the search path to be
-       ;; 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")
               (files '("include")))
@@ -627,18 +921,14 @@ ac_cv_c_float_format='IEEE (little-endian)'
                        (string-append tcc-lib "/libc+gnu.o")
                        (string-append tcc-lib "/libtcc1.o"))
                (invoke "ls" "-ltrF" gcc-dir)
-               (copy-recursively (string-append tcc "/include")
-                                 (string-append out "/include"))
                #t))))))
     (native-search-paths
-     ;; Use the language-specific variables rather than 'CPATH' because they
-     ;; are equivalent to '-isystem' whereas 'CPATH' is equivalent to '-I'.
-     ;; The intent is to allow headers that are in the search path to be
-     ;; 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")
-            (files '("include" "/lib/gcc-lib/i686-unknown-linux-gnu/2.95.3/include")))
+            (files '("include"
+
+                     ;; Needed to get things like GCC's <stddef.h>.
+                     "lib/gcc-lib/i686-unknown-linux-gnu/2.95.3/include")))
            (search-path-specification
             (variable "LIBRARY_PATH")
             (files '("lib")))))))
@@ -669,16 +959,7 @@ ac_cv_c_float_format='IEEE (little-endian)'
                (mkdir-p include)
                (copy-recursively "include" out)
                (copy-recursively headers out)
-               #t))))))
-    (native-search-paths
-     ;; Use the language-specific variables rather than 'CPATH' because they
-     ;; are equivalent to '-isystem' whereas 'CPATH' is equivalent to '-I'.
-     ;; The intent is to allow headers that are in the search path to be
-     ;; 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")
-            (files '("include")))))))
+               #t))))))))
 
 (define glibc-mesboot0
   ;; GNU C Library 2.2.5 is the most recent glibc that we managed to build
@@ -760,67 +1041,37 @@ ac_cv_c_float_format='IEEE (little-endian)'
            (lambda* (#:key configure-flags #:allow-other-keys)
              (format (current-error-port)
                      "running ./configure ~a\n" (string-join configure-flags))
-             (apply invoke "./configure" configure-flags))))))
-    (native-search-paths
-     ;; Use the language-specific variables rather than 'CPATH' because they
-     ;; are equivalent to '-isystem' whereas 'CPATH' is equivalent to '-I'.
-     ;; The intent is to allow headers that are in the search path to be
-     ;; 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")
-            (files '("include")))
-           (search-path-specification
-            (variable "CPLUS_INCLUDE_PATH")
-            (files '("include")))
-           (search-path-specification
-            (variable "LIBRARY_PATH")
-            (files '("lib")))))))
+             (apply invoke "./configure" configure-flags))))))))
 
 (define gcc-mesboot0
   (package
     (inherit gcc-core-mesboot)
     (name "gcc-mesboot0")
     (native-inputs `(("binutils" ,binutils-mesboot0)
-                     ("gcc" ,gcc-core-mesboot)
+
+                     ;; Packages are given in an order that's relevant for
+                     ;; #include_next purposes.
                      ("libc" ,glibc-mesboot0)
+                     ("kernel-headers" ,%bootstrap-linux-libre-headers)
+                     ("gcc" ,gcc-core-mesboot)
 
                      ("bash" ,%bootstrap-coreutils&co)
                      ("coreutils" ,%bootstrap-coreutils&co)
                      ("diffutils" ,diffutils-mesboot)
-                     ("kernel-headers" ,%bootstrap-linux-libre-headers)
                      ("make" ,make-mesboot0)))
     (arguments
      (substitute-keyword-arguments (package-arguments gcc-core-mesboot)
        ((#:phases phases)
         `(modify-phases ,phases
            (replace 'setenv
-             (lambda* (#:key outputs #:allow-other-keys)
-               (let ((out (assoc-ref outputs "out"))
-                     (bash (assoc-ref %build-inputs "bash"))
-                     (gcc (assoc-ref %build-inputs "gcc"))
-                     (glibc (assoc-ref %build-inputs "libc"))
-                     (kernel-headers (assoc-ref %build-inputs "kernel-headers")))
-                 (setenv "CONFIG_SHELL" (string-append bash "/bin/sh"))
-                 (format (current-error-port) "C_INCLUDE_PATH=~a\n" (getenv "C_INCLUDE_PATH"))
-                 (setenv "C_INCLUDE_PATH" (string-append
-                                           gcc "/lib/gcc-lib/i686-unknown-linux-gnu/2.95.3/include"
-                                           ":" kernel-headers "/include"
-                                           ":" glibc "/include"))
-                 (format (current-error-port) "C_INCLUDE_PATH=~a\n" (getenv "C_INCLUDE_PATH"))
-                 (format (current-error-port) "LIBRARY_PATH=~a\n" (getenv "LIBRARY_PATH"))
-                 ;; FIXME: add glibc dirs to paths manually
-                 (setenv "LIBRARY_PATH" (string-join
-                                         (list (string-append glibc "/lib")
-                                               (getenv "LIBRARY_PATH"))
-                                         ":"))
-                 (format (current-error-port) "LIBRARY_PATH=~a\n" (getenv "LIBRARY_PATH"))
-                 (with-output-to-file "config.cache"
-                   (lambda _
-                     (display "
+             (lambda _
+               (setenv "CONFIG_SHELL" (which "sh"))
+               (with-output-to-file "config.cache"
+                 (lambda _
+                   (display "
 ac_cv_c_float_format='IEEE (little-endian)'
 ")))
-                 #t)))
+               #t))
            (replace 'install2
              (lambda* (#:key outputs #:allow-other-keys)
                (let* ((out (assoc-ref outputs "out"))
@@ -938,7 +1189,7 @@ ac_cv_c_float_format='IEEE (little-endian)'
   (package
     (inherit gcc-mesboot0)
     (name "gcc-mesboot1")
-    (version "4.7.4")
+    (version (package-version gcc-4.7))
     (source (bootstrap-origin
              (origin (inherit (package-source gcc-4.7))
                      (patches (search-patches "gcc-boot-4.7.4.patch")))))
@@ -946,13 +1197,14 @@ ac_cv_c_float_format='IEEE (little-endian)'
               ("mpfr-source" ,(package-source mpfr-boot))
               ("mpc-source" ,(package-source mpc-boot))))
     (native-inputs `(("binutils" ,binutils-mesboot)
-                     ("gcc" ,gcc-mesboot0)
+
                      ("libc" ,glibc-mesboot0)
+                     ("kernel-headers" ,%bootstrap-linux-libre-headers)
+                     ("gcc" ,gcc-mesboot0)
 
                      ("bash" ,%bootstrap-coreutils&co)
                      ("coreutils" ,%bootstrap-coreutils&co)
                      ("diffutils" ,diffutils-mesboot)
-                     ("kernel-headers" ,%bootstrap-linux-libre-headers)
                      ("make" ,make-mesboot)))
     (arguments
      (substitute-keyword-arguments (package-arguments gcc-core-mesboot)
@@ -994,24 +1246,18 @@ ac_cv_c_float_format='IEEE (little-endian)'
                  #t)))
            (delete 'remove-info)
            (replace 'setenv
-             (lambda* (#:key outputs #:allow-other-keys)
-               (let* ((out (assoc-ref outputs "out"))
-                      (binutils (assoc-ref %build-inputs "binutils"))
-                      (bash (assoc-ref %build-inputs "bash"))
-                      (gcc (assoc-ref %build-inputs "gcc"))
-                      (glibc (assoc-ref %build-inputs "libc"))
-                      (kernel-headers (assoc-ref %build-inputs "kernel-headers")))
-                 (setenv "CONFIG_SHELL" (string-append bash "/bin/sh"))
-                 (setenv "C_INCLUDE_PATH" (string-append
-                                           gcc "/lib/gcc-lib/i686-unknown-linux-gnu/2.95.3/include"
-                                           ":" kernel-headers "/include"
-                                           ":" glibc "/include"
-                                           ":" (getcwd) "/mpfr/src"))
-                 (setenv "LIBRARY_PATH" (string-append glibc "/lib"
-                                                       ":" gcc "/lib"))
-                 (format (current-error-port) "C_INCLUDE_PATH=~a\n" (getenv "C_INCLUDE_PATH"))
-                 (format (current-error-port) "LIBRARY_PATH=~a\n" (getenv "LIBRARY_PATH"))
-                 #t)))
+             (lambda _
+               (setenv "CONFIG_SHELL" (which "sh"))
+
+               ;; Allow MPFR headers to be found.
+               (setenv "C_INCLUDE_PATH"
+                       (string-append (getcwd) "/mpfr/src:"
+                                      (getenv "C_INCLUDE_PATH")))
+
+               ;; Set the C++ search path so that C headers can be found as
+               ;; libstdc++ is being compiled.
+               (setenv "CPLUS_INCLUDE_PATH" (getenv "C_INCLUDE_PATH"))
+               #t))
            (delete 'install2)))
        ((#:configure-flags configure-flags)
         `(let ((out (assoc-ref %outputs "out"))
@@ -1158,22 +1404,18 @@ exec " gcc "/bin/" program
        ((#:phases phases)
         `(modify-phases ,phases
            (replace 'setenv
-             (lambda* (#:key outputs #:allow-other-keys)
-               (let* ((out (assoc-ref outputs "out"))
-                      (headers (assoc-ref %build-inputs "headers"))
-                      (bash (assoc-ref %build-inputs "bash"))
-                      (coreutils (assoc-ref %build-inputs "coreutils"))
-                      (libc (assoc-ref %build-inputs "libc"))
-                      (gcc (assoc-ref %build-inputs "gcc"))
+             (lambda* (#:key inputs #:allow-other-keys)
+               (let* ((headers  (assoc-ref inputs "headers"))
+                      (libc     (assoc-ref inputs "libc"))
+                      (gcc      (assoc-ref inputs "gcc"))
                       (cppflags (string-append
                                  " -I " (getcwd) "/nptl/sysdeps/pthread/bits"
                                  " -D BOOTSTRAP_GLIBC=1"))
                       (cflags (string-append " -L " (getcwd)
                                              " -L " libc "/lib")))
                  (setenv "libc_cv_friendly_stddef" "yes")
-                 (setenv "CONFIG_SHELL" (string-append bash "/bin/sh"))
-                 (setenv "SHELL" (getenv "CONFIG_SHELL"))
-                 (format (current-error-port) "CONFIG_SHELL=~s\n" (getenv "CONFIG_SHELL"))
+                 (setenv "CONFIG_SHELL" (which "sh"))
+                 (setenv "SHELL" (which "sh"))
 
                  (setenv "CPP" (string-append gcc "/bin/gcc -E " cppflags))
                  (setenv "CC" (string-append gcc "/bin/gcc " cppflags cflags))
@@ -1181,10 +1423,7 @@ exec " gcc "/bin/" program
                  ;; avoid -fstack-protector
                  (setenv "libc_cv_ssp" "false")
                  (substitute* "configure"
-                   (("/bin/pwd") (string-append coreutils "/bin/pwd")))
-                 (setenv "C_INCLUDE_PATH" (string-append libc "/include"
-                                                         headers "/include"))
-                 (setenv "LIBRARY_PATH" (string-append libc "/lib"))
+                   (("/bin/pwd") "pwd"))
                  #t)))
            (replace 'install
              (lambda* (#:key outputs make-flags #:allow-other-keys)
@@ -1244,38 +1483,24 @@ exec " gcc "/bin/" program
                           (install-flags (cons "install" make-flags)))
                      (apply invoke "make" install-flags)
                      (copy-recursively kernel-headers out)
-                     #t))))))))
-    (native-search-paths ;; FIXME: move to glibc-mesboot0
-     ;; Use the language-specific variables rather than 'CPATH' because they
-     ;; are equivalent to '-isystem' whereas 'CPATH' is equivalent to '-I'.
-     ;; The intent is to allow headers that are in the search path to be
-     ;; 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")
-            (files '("include")))
-           (search-path-specification
-            (variable "CPLUS_INCLUDE_PATH")
-            (files '("include")))
-           (search-path-specification
-            (variable "LIBRARY_PATH")
-            (files '("lib")))))))
+                     #t))))))))))
 
 (define gcc-mesboot
   (package
     (inherit gcc-mesboot1)
     (name "gcc-mesboot")
-    (version "4.9.4")
+    (version (package-version gcc-4.9))
     (source (bootstrap-origin (package-source gcc-4.9)))
     (native-inputs `(("binutils" ,binutils-mesboot)
+
+                     ("libc" ,glibc-mesboot)
+                     ("kernel-headers" ,%bootstrap-linux-libre-headers)
                      ("gcc-wrapper" ,gcc-mesboot1-wrapper)
                      ("gcc" ,gcc-mesboot1)
-                     ("libc" ,glibc-mesboot)
 
                      ("bash" ,%bootstrap-coreutils&co)
                      ("coreutils" ,%bootstrap-coreutils&co)
                      ("diffutils" ,diffutils-mesboot)
-                     ("kernel-headers" ,%bootstrap-linux-libre-headers)
                      ("make" ,make-mesboot)))
     (arguments
      `(#:validate-runpath? #f
@@ -1318,34 +1543,7 @@ exec " gcc "/bin/" program
                      "--disable-libstdcxx-pch"
 
                      ;; for libcpp ...
-                     "--disable-build-with-cxx")))
-           ((#:phases phases)
-            `(modify-phases ,phases
-               (replace 'setenv
-                 (lambda* (#:key outputs #:allow-other-keys)
-                   (let* ((out (assoc-ref outputs "out"))
-                          (binutils (assoc-ref %build-inputs "binutils"))
-                          (bash (assoc-ref %build-inputs "bash"))
-                          (gcc (assoc-ref %build-inputs "gcc"))
-                          (glibc (assoc-ref %build-inputs "libc"))
-                          (kernel-headers (assoc-ref %build-inputs "kernel-headers")))
-                     (setenv "CONFIG_SHELL" (string-append bash "/bin/sh"))
-                     (setenv "C_INCLUDE_PATH" (string-append
-                                               gcc "/lib/gcc-lib/i686-unknown-linux-gnu/4.7.4/include"
-                                               ":" kernel-headers "/include"
-                                               ":" glibc "/include"
-                                               ":" (getcwd) "/mpfr/src"))
-                     (setenv "CPLUS_INCLUDE_PATH" (string-append
-                                                   gcc "/lib/gcc-lib/i686-unknown-linux-gnu/4.7.4/include"
-                                                   ":" kernel-headers "/include"
-                                                   ":" glibc "/include"
-                                                   ":" (getcwd) "/mpfr/src"))
-                     (setenv "LIBRARY_PATH" (string-append glibc "/lib"
-                                                           ":" gcc "/lib"))
-                     (format (current-error-port) "C_INCLUDE_PATH=~a\n" (getenv "C_INCLUDE_PATH"))
-                     (format (current-error-port) "CPLUS_INCLUDE_PATH=~a\n" (getenv "CPLUS_INCLUDE_PATH"))
-                     (format (current-error-port) "LIBRARY_PATH=~a\n" (getenv "LIBRARY_PATH"))
-                     #t))))))))))
+                     "--disable-build-with-cxx"))))))))
 
 (define gcc-mesboot-wrapper
   ;; We need this so gcc-mesboot can be used to create shared binaries that
@@ -1412,6 +1610,11 @@ exec " gcc "/bin/" program
        #:implicit-inputs? #f
        #:tests? #f                                ; cannot run "make check"
        ,@(substitute-keyword-arguments (package-arguments gnu-make)
+           ((#:configure-flags flags ''())
+            ;; The generated config.status has some problems due to the
+            ;; bootstrap environment.  Disable dependency tracking to work
+            ;; around it.
+            `(cons "--disable-dependency-tracking" ,flags))
            ((#:phases phases)
             `(modify-phases ,phases
                (replace 'build
@@ -1766,6 +1969,15 @@ exec " gcc "/bin/" program
        #:guile ,%bootstrap-guile
        #:tests? #f))))
 
+(define rsync-boot0
+  (package
+    (inherit rsync)
+    (native-inputs `(("perl" ,perl-boot0)))
+    (inputs (%boot0-inputs))
+    (arguments
+     `(#:implicit-inputs? #f
+       #:guile ,%bootstrap-guile))))
+
 (define linux-libre-headers-boot0
   (mlambda ()
     "Return Linux-Libre header files for the bootstrap environment."
@@ -1785,6 +1997,9 @@ exec " gcc "/bin/" program
          ;; Flex and Bison are required since version 4.16.
          ("flex" ,flex-boot0)
          ("bison" ,bison-boot0)
+
+         ;; Rsync is required since version 5.3.
+         ("rsync" ,rsync-boot0)
          ,@(%boot0-inputs))))))
 
 (define with-boot0
@@ -2298,15 +2513,6 @@ exec ~a/bin/~a-~a -B~a/lib -Wl,-dynamic-linker -Wl,~a/~a \"$@\"~%"
                                            char-set:letter)
                                          ,(package-name lib)))
                              (list gmp-6.0 mpfr mpc))
-                      #t)))
-                (add-before 'configure 'treat-glibc-as-system-header
-                  (lambda* (#:key inputs #:allow-other-keys)
-                    (let ((libc (assoc-ref inputs "libc")))
-                      ;; Make sure Glibc is treated as a "system header" so
-                      ;; #include_next does the right thing.
-                      (for-each (lambda (var)
-                                  (setenv var (string-append libc "/include")))
-                                '("C_INCLUDE_PATH" "CPLUS_INCLUDE_PATH"))
                       #t))))))))
 
     ;; This time we want Texinfo, so we get the manual.  Add