1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2014 Andreas Enge <andreas@enge.fr>
4 ;;; Copyright © 2012 Nikita Karetnikov <nikita@karetnikov.org>
5 ;;; Copyright © 2014, 2015, 2017 Mark H Weaver <mhw@netris.org>
6 ;;; Copyright © 2017, 2018, 2019 Efraim Flashner <efraim@flashner.co.il>
7 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
8 ;;; Copyright © 2018, 2019, 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
9 ;;; Copyright © 2019, 2020 Marius Bakke <mbakke@fastmail.com>
10 ;;; Copyright © 2020 Timothy Sample <samplet@ngyro.com>
12 ;;; This file is part of GNU Guix.
14 ;;; GNU Guix is free software; you can redistribute it and/or modify it
15 ;;; under the terms of the GNU General Public License as published by
16 ;;; the Free Software Foundation; either version 3 of the License, or (at
17 ;;; your option) any later version.
19 ;;; GNU Guix is distributed in the hope that it will be useful, but
20 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
21 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 ;;; GNU General Public License for more details.
24 ;;; You should have received a copy of the GNU General Public License
25 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
27 (define-module (gnu packages commencement)
28 #:use-module (gnu packages)
29 #:use-module (gnu packages bootstrap)
30 #:use-module (gnu packages base)
31 #:use-module (gnu packages bash)
32 #:use-module (gnu packages c)
33 #:use-module (gnu packages gcc)
34 #:use-module (gnu packages m4)
35 #:use-module (gnu packages gawk)
36 #:use-module (gnu packages bison)
37 #:use-module (gnu packages flex)
38 #:use-module (gnu packages guile)
39 #:use-module (gnu packages gettext)
40 #:use-module (gnu packages multiprecision)
41 #:use-module (gnu packages compression)
42 #:use-module (gnu packages mes)
43 #:use-module (gnu packages perl)
44 #:use-module (gnu packages python)
45 #:use-module (gnu packages linux)
46 #:use-module (gnu packages hurd)
47 #:use-module (gnu packages shells)
48 #:use-module (gnu packages texinfo)
49 #:use-module (gnu packages pkg-config)
50 #:use-module (gnu packages rsync)
51 #:use-module (gnu packages xml)
52 #:use-module (guix packages)
53 #:use-module (guix download)
54 #:use-module (guix build-system gnu)
55 #:use-module (guix build-system trivial)
56 #:use-module ((guix licenses) #:prefix license:)
57 #:use-module (guix memoization)
58 #:use-module (guix utils)
59 #:use-module (srfi srfi-1)
60 #:use-module (ice-9 vlist)
61 #:use-module (ice-9 match)
62 #:export (make-gcc-toolchain))
66 ;;; This is the commencement, this is where things start. Before the
67 ;;; commencement, of course, there's the 'bootstrap' module, which provides us
68 ;;; with the initial binaries. This module uses those bootstrap binaries to
69 ;;; actually build up the whole tool chain that make up the implicit inputs of
70 ;;; 'gnu-build-system'.
72 ;;; To avoid circular dependencies, this module should not be imported
73 ;;; directly from anywhere.
75 ;;; Below, we frequently use "inherit" to create modified packages. The
76 ;;; reason why we use "inherit" instead of "package/inherit" is because we do
77 ;;; not want these commencement packages to inherit grafts. By definition,
78 ;;; these packages are not depended on at run time by any of the packages we
79 ;;; use. Thus it does not make sense to inherit grafts. Furthermore, those
80 ;;; grafts would often lead to extra overhead for users who would end up
81 ;;; downloading those "-boot0" packages just to build package replacements
82 ;;; that are in fact not going to be used.
92 (uri (list (string-append
93 "mirror://gnu/guix/mirror/bootar-" version ".ses")
95 "https://files.ngyro.com/bootar/bootar-"
99 "0mvp6vgx0q316fvy3z2lddlc5xgq5np3bm1fypgvj6dnayibg9np"))))
100 (build-system gnu-build-system)
102 `(#:implicit-inputs? #f
104 #:guile ,%bootstrap-guile
105 #:imported-modules ((guix build gnu-bootstrap)
106 ,@%gnu-build-system-modules)
109 (use-modules (guix build gnu-bootstrap))
110 (modify-phases %standard-phases
112 (lambda* (#:key inputs #:allow-other-keys)
113 (let* ((source (assoc-ref inputs "source"))
114 (guile-dir (assoc-ref inputs "guile"))
115 (guile (string-append guile-dir "/bin/guile")))
116 (invoke guile "--no-auto-compile" source)
119 (replace 'configure (bootstrap-configure ,version "." "scripts"))
120 (replace 'build (bootstrap-build "."))
121 (replace 'install (bootstrap-install "." "scripts"))))))
122 (inputs `(("guile" ,%bootstrap-guile)))
123 (home-page "https://git.ngyro.com/bootar")
124 (synopsis "Tar decompression and extraction in Guile Scheme")
125 (description "Bootar is a simple Tar extractor written in Guile
126 Scheme. It supports running 'tar xvf' on uncompressed tarballs or
127 tarballs that are compressed with BZip2, GZip, or XZ. It also provides
128 standalone scripts for 'bzip2', 'gzip', and 'xz' that each support
129 decompression to standard output.
131 What makes this special is that Bootar is distributed as a
132 self-extracting Scheme (SES) program. That is, a little script that
133 outputs the source code of Bootar. This makes it possible to go from
134 pure Scheme to Tar and decompression in one easy step.")
135 (license license:gpl3+)))
142 (inherit (package-source gash))
145 `(#:implicit-inputs? #f
147 #:guile ,%bootstrap-guile
148 #:imported-modules ((guix build gnu-bootstrap)
149 ,@%gnu-build-system-modules)
152 (use-modules (guix build gnu-bootstrap))
153 (modify-phases %standard-phases
155 (bootstrap-configure ,(package-version gash) "gash" "scripts"))
156 (replace 'build (bootstrap-build "gash"))
157 (replace 'install (bootstrap-install "gash" "scripts"))
158 (add-after 'install 'install-symlinks
159 (lambda* (#:key outputs #:allow-other-keys)
160 (let ((out (assoc-ref outputs "out")))
161 (symlink (string-append out "/bin/gash")
162 (string-append out "/bin/sh"))
163 (symlink (string-append out "/bin/gash")
164 (string-append out "/bin/bash"))
166 (inputs `(("guile" ,%bootstrap-guile)))
167 (native-inputs `(("bootar" ,bootar)))))
169 (define gash-utils-boot
172 (name "gash-utils-boot")
174 `(#:implicit-inputs? #f
176 #:guile ,%bootstrap-guile
177 #:imported-modules ((guix build gnu-bootstrap)
178 ,@%gnu-build-system-modules)
181 (use-modules (guix build gnu-bootstrap))
182 (modify-phases %standard-phases
183 (add-after 'unpack 'set-load-path
184 (lambda* (#:key inputs #:allow-other-keys)
185 (let ((gash (assoc-ref inputs "gash")))
186 (add-to-load-path (string-append gash "/share/guile/site/"
187 (effective-version))))
189 (add-before 'configure 'pre-configure
191 (format #t "Creating gash/commands/testb.scm~%")
192 (copy-file "gash/commands/test.scm"
193 "gash/commands/testb.scm")
194 (substitute* "gash/commands/testb.scm"
195 (("gash commands test") "gash commands testb")
196 (("apply test [(]cdr") "apply test/bracket (cdr"))
197 (for-each (lambda (script)
198 (let ((target (string-append "scripts/"
200 (format #t "Creating scripts/~a~%" target)
201 (copy-file "scripts/template.in" target)
203 (("@UTILITY@") script))))
204 '("awk" "basename" "cat" "chmod" "cmp" "command"
205 "compress" "cp" "cut" "diff" "dirname" "expr"
206 "false" "find" "grep" "head" "ln" "ls" "mkdir"
207 "mv" "printf" "pwd" "reboot" "rm" "rmdir"
208 "sed" "sleep" "sort" "tar" "test" "touch" "tr"
209 "true" "uname" "uniq" "wc" "which"))
210 (format #t "Creating scripts/[.in~%")
211 (copy-file "scripts/template.in" "scripts/[.in")
212 (substitute* "scripts/[.in"
213 (("@UTILITY@") "testb"))
214 (delete-file "scripts/template.in")
217 (bootstrap-configure ,(package-version gash-utils)
219 (replace 'build (bootstrap-build "gash"))
220 (replace 'install (bootstrap-install "gash" "scripts"))
221 ;; XXX: The scripts should add Gash to their load paths and
222 ;; this phase should not exist.
223 (add-after 'install 'copy-gash
224 (lambda* (#:key inputs outputs #:allow-other-keys)
225 (let* ((out (assoc-ref outputs "out"))
226 (moddir (string-append out "/share/guile/site/"
227 (effective-version)))
228 (godir (string-append out "/lib/guile/"
231 (gash (assoc-ref inputs "gash"))
232 (gash-moddir (string-append gash "/share/guile/site/"
233 (effective-version)))
234 (gash-godir (string-append gash "/lib/guile/"
237 (copy-file (string-append gash-moddir "/gash/compat.scm")
238 (string-append moddir "/gash/compat.scm"))
239 (copy-recursively (string-append gash-moddir "/gash/compat")
240 (string-append moddir "/gash/compat"))
241 (copy-file (string-append gash-godir "/gash/compat.go")
242 (string-append godir "/gash/compat.go"))
243 (copy-recursively (string-append gash-godir "/gash/compat")
244 (string-append godir "/gash/compat"))
246 (inputs `(("gash" ,gash-boot)
247 ("guile" ,%bootstrap-guile)))
248 (native-inputs `(("bootar" ,bootar)))))
250 (define (%boot-gash-inputs)
251 `(("bash" , gash-boot) ; gnu-build-system wants "bash"
252 ("coreutils" , gash-utils-boot)
254 ("guile" ,%bootstrap-guile)))
256 (define %bootstrap-mes-rewired
259 (name "bootstrap-mes-rewired")
262 (native-inputs `(("mes" ,%bootstrap-mes)
263 ("gash" ,gash-boot)))
265 (propagated-inputs '())
267 (build-system trivial-build-system)
269 `(#:guile ,%bootstrap-guile
270 #:modules ((guix build utils))
273 (use-modules (guix build utils)
276 (let* ((mes (assoc-ref %build-inputs "mes"))
277 (gash (assoc-ref %build-inputs "gash"))
278 (mes-bin (string-append mes "/bin"))
279 (guile (string-append mes-bin "/mes"))
280 (mes-module (string-append mes "/share/mes/module"))
281 (out (assoc-ref %outputs "out"))
282 (bin (string-append out "/bin"))
283 (mescc (string-append bin "/mescc"))
284 (module (string-append out "/share/mes/module")))
285 (define (rewire file)
288 (("/gnu/store[^ ]+mes-minimal-[^/)}\"]*") out)
289 (("/gnu/store[^ ]+guile-[^/]*/bin/guile") guile)
290 (("/gnu/store[^ ]+bash-[^/)}\"]*") gash)))
293 (for-each (lambda (file) (install-file file bin))
294 (find-files mes-bin))
296 (copy-recursively (string-append mes-module "/mes")
297 (string-append module "/mes"))
298 (copy-recursively (string-append mes-module "/srfi")
299 (string-append module "/srfi"))
301 ;; Cannot easily rewire "mes" because it
302 ;; contains NUL characters; would require
303 ;; remove-store-references alike trick
304 (filter (negate (cut string-suffix? "/mes" <>))
306 (rewire (string-append module "/mes/boot-0.scm"))
309 (with-output-to-file mescc
311 (display (string-append
318 MES_PREFIX=${MES_REWIRED_PREFIX-" out "/share/mes}
320 export MES MES_PREFIX
322 MES_ARENA=${MES_REWIRED_ARENA-10000000}
323 MES_MAX_ARENA=${MES_REWIRED_ARENA-10000000}
324 MES_STACK=${MES_REWIRED_STACK-1000000}
325 export MES_ARENA MES_MAX_ARENA MES_STACK
327 $MES -e '(mescc)' module/mescc.scm -- \"$@\"
331 (with-directory-excursion module
332 (chmod "mes/base.mes" #o644)
333 (copy-file "mes/base.mes" "mes/base.mes.orig")
334 (let ((base.mes (open-file "mes/base.mes" "a")))
336 ;; A fixed map, from Mes 0.21, required to bootstrap Mes 0.21
337 (define (map f h . t)
339 (and (pair? t) (null? (car t)))
340 (and (pair? t) (pair? (cdr t)) (null? (cadr t)))) '()
341 (if (null? t) (cons (f (car h)) (map f (cdr h)))
343 (cons (f (car h) (caar t)) (map f (cdr h) (cdar t)))
345 (cons (f (car h) (caar t) (caadr t)) (map f (cdr h) (cdar t) (cdadr t)))
346 (error 'unsupported (cons* 'map-4: f h t))b )))))
350 (chmod "mes/guile.mes" #o644)
351 (copy-file "mes/guile.mes" "mes/guile.mes.orig")
352 (let ((guile.mes (open-file "mes/guile.mes" "a")))
354 ;; After booting guile.scm; use Mes 0.21; especially: MesCC 0.21
355 (let* ((self (car (command-line)))
356 (prefix (dirname (dirname self))))
357 (set! %moduledir (string-append prefix \"/mes/module/\"))
358 (setenv \"%numbered_arch\" \"true\"))
371 (uri (string-append "mirror://gnu/mes/"
372 "mes-" version ".tar.gz"))
375 "0p1jsrrmcbc0zrvbvnjbb6iyxr0in71km293q8qj6gnar6bw09av"))))
377 (propagated-inputs '())
379 `(("nyacc-source" ,(origin (inherit (package-source nyacc))
381 ("mes" ,%bootstrap-mes-rewired)
382 ("mescc-tools" ,%bootstrap-mescc-tools)
383 ,@(%boot-gash-inputs)))
385 `(#:implicit-inputs? #f
387 #:guile ,%bootstrap-guile
388 #:strip-binaries? #f ; binutil's strip b0rkes MesCC/M1/hex2 binaries
390 (modify-phases %standard-phases
391 (add-after 'unpack 'unpack-seeds
393 (let ((nyacc-source (assoc-ref %build-inputs "nyacc-source")))
394 (with-directory-excursion ".."
395 (invoke "tar" "-xvf" nyacc-source)))))
397 (lambda* (#:key outputs #:allow-other-keys)
398 (let ((out (assoc-ref %outputs "out"))
399 (gash (assoc-ref %build-inputs "bash"))
400 (mes (assoc-ref %build-inputs "mes"))
401 (dir (with-directory-excursion ".." (getcwd))))
402 (setenv "AR" (string-append "gash " (getcwd) "/scripts/mesar"))
403 (setenv "BASH" (string-append gash "/bin/bash"))
404 (setenv "CC" (string-append mes "/bin/mescc"))
405 (setenv "GUILE_LOAD_PATH"
407 mes "/share/mes/module"
408 ":" dir "/nyacc-0.99.0/module"))
409 (invoke "gash" "configure.sh"
410 (string-append "--prefix=" out)
411 (string-append "--host=i686-linux-gnu")))))
414 (invoke "sh" "bootstrap.sh")))
418 (substitute* "install.sh" ; show some progress
420 (("^( *)((cp|mkdir|tar) [^']*[^\\])\n" all space cmd)
421 (string-append space "echo '" cmd "'\n"
423 (invoke "sh" "install.sh")
424 ;; Keep ASCII output, for friendlier comparison and bisection
425 (let* ((out (assoc-ref %outputs "out"))
426 (cache (string-append out "/lib/cache")))
427 (define (objects-in-dir dir)
430 (and (equal? (dirname name) dir)
431 (or (string-suffix? ".o" name)
432 (string-suffix? ".s" name))))))
433 (for-each (lambda (x) (install-file x cache))
434 (append (objects-in-dir ".")
435 (objects-in-dir "mescc-lib"))))
438 (list (search-path-specification
439 (variable "C_INCLUDE_PATH")
440 (files '("include")))
441 (search-path-specification
442 (variable "LIBRARY_PATH")
444 (search-path-specification
445 (variable "MES_PREFIX")
451 ;; Pristine tcc cannot be built by MesCC, we are keeping a delta of 11
452 ;; patches. In a very early and rough form they were presented to the
453 ;; TinyCC developers, who at the time showed no interest in supporting the
454 ;; bootstrappable effort; we will try again later. These patches have been
455 ;; ported to 0.9.27, alas the resulting tcc is buggy. Once MesCC is more
456 ;; mature, this package should use the 0.9.27 sources (or later).
460 (version "0.9.26-1103-g6e62e0e")
464 "http://lilypond.org/janneke/mes/20191117/"
465 "/tcc-" version ".tar.gz"))
468 "1qbybw7mxbgkv3sazvz1v7c8byq998vk8f1h25ik8w3d2l63lxng"))))
469 (build-system gnu-build-system)
470 (supported-systems '("i686-linux" "x86_64-linux"))
472 (propagated-inputs '())
475 ("nyacc-source" ,(origin (inherit (package-source nyacc))
477 ("mescc-tools" ,%bootstrap-mescc-tools)
478 ,@(%boot-gash-inputs)))
480 `(#:implicit-inputs? #f
481 #:guile ,%bootstrap-guile
482 #:validate-runpath? #f ; no dynamic executables
483 #:strip-binaries? #f ; no strip yet
485 (modify-phases %standard-phases
486 (add-after 'unpack 'unpack-seeds
487 (lambda* (#:key outputs #:allow-other-keys)
488 (let ((nyacc-source (assoc-ref %build-inputs "nyacc-source")))
489 (with-directory-excursion ".."
490 (invoke "tar" "-xvf" nyacc-source)))))
492 (lambda* (#:key outputs #:allow-other-keys)
493 (let* ((out (assoc-ref %outputs "out"))
494 (dir (with-directory-excursion ".." (getcwd)))
495 (interpreter "/lib/mes-loader"))
497 (setenv "prefix" out)
498 (setenv "GUILE_LOAD_PATH"
499 (string-append dir "/nyacc-0.99.0/module"))
501 (substitute* "conftest.c"
504 (invoke "sh" "configure"
506 (string-append "--prefix=" out)
507 (string-append "--elfinterp=" interpreter)
512 (substitute* "bootstrap.sh" ; Show some progress
513 (("^( *)((cp|ls|mkdir|rm|[.]/tcc|[.]/[$][{PROGRAM_PREFIX[}]tcc) [^\"]*[^\\])\n" all space cmd)
514 (string-append space "echo \"" cmd "\"\n"
516 (invoke "sh" "bootstrap.sh")))
520 (system* "./tcc" "--help") ; --help exits 1
521 ;; (invoke "sh" "test.sh" "mes/scaffold/tests/30-strlen")
522 ;; (invoke "sh" "-x" "test.sh" "mes/scaffold/tinycc/00_assignment")
523 ;; TODO: add sensible check target (without depending on make)
524 ;; (invoke "sh" "check.sh")
528 (substitute* "install.sh" ; Show some progress
529 (("^( *)((cp|ls|mkdir|rm|tar|./[$][{PROGRAM_PREFIX[}]tcc) [^\"]*[^\\])\n" all space cmd)
530 (string-append space "echo \"" cmd "\"\n"
533 (invoke "sh" "install.sh"))))))
535 (list (search-path-specification
536 (variable "C_INCLUDE_PATH")
537 (files '("include")))
538 (search-path-specification
539 (variable "LIBRARY_PATH")
540 (files '("lib")))))))
543 ;; The initial gzip. We keep this scripted gzip build before building make
544 ;; to soften the dependency on Gash Core Utils gzip.
548 (name "gzip-mesboot")
551 (uri (string-append "mirror://gnu/gzip/gzip-" version ".tar"))
554 "1rhgk2vvmdvnn6vygf0dja92ryyng00knl0kz5srb77k2kryjb2d"))))
555 (supported-systems '("i686-linux" "x86_64-linux"))
557 (propagated-inputs '())
558 (native-inputs `(("tcc" ,tcc-boot0)
559 ,@(%boot-gash-inputs)))
561 `(#:implicit-inputs? #f
562 #:guile ,%bootstrap-guile
563 #:strip-binaries? #f ; no strip yet
565 (modify-phases %standard-phases
567 (add-after 'unpack 'scripted-patch
569 (substitute* "util.c"
570 (("^char [*]strlwr" all) (string-append all "_tcc_cannot_handle_dupe")))
574 (let ((files '("bits" "crypt" "deflate" "getopt" "gzip"
575 "inflate" "lzw" "trees" "unlzh" "unlzw"
576 "unpack" "unzip" "util" "zip")))
578 (invoke "tcc" "-c" "-D NO_UTIME=1" "-D HAVE_UNISTD_H=1"
579 (string-append x ".c")))
580 (for-each compile files)
582 (cons* "tcc" "-o" "gzip"
583 (map (lambda (x) (string-append x ".o")) files)))
584 (link "gzip" "gunzip"))))
587 (let* ((out (assoc-ref %outputs "out"))
588 (bin (string-append out "/bin")))
589 (install-file "gzip" bin)
590 (install-file "gunzip" bin))))
593 (invoke "./gzip" "--version")))
595 (delete 'compress-documentation))))))
597 (define gnu-make-mesboot0
601 (name "make-mesboot0")
605 (uri (string-append "mirror://gnu/make/make-" version ".tar.gz"))
608 "1pb7fb7fqf9wz9najm85qdma1xhxzf1rhj5gwrlzdsz2zm0hpcv4"))))
609 (supported-systems '("i686-linux" "x86_64-linux"))
611 (propagated-inputs '())
612 (native-inputs `(("tcc" ,tcc-boot0)
613 ,@(%boot-gash-inputs)))
615 `(#:implicit-inputs? #f
616 #:guile ,%bootstrap-guile
617 #:configure-flags '("CC=tcc"
620 "--build=i686-unknown-linux-gnu"
621 "--host=i686-unknown-linux-gnu"
623 #:modules ((guix build gnu-build-system)
626 #:strip-binaries? #f ; no strip yet
628 (modify-phases %standard-phases
629 (add-after 'unpack 'scripted-patch
631 (substitute* "build.sh.in"
632 (("@LIBOBJS@") "getloadavg.o")
633 (("@REMOTE@") "stub"))
635 (add-after 'configure 'configure-fixup
637 (substitute* "make.h"
638 (("^extern long int lseek.*" all) (string-append "// " all)))
642 (invoke "sh" "./build.sh")))
643 (replace 'check ; proper check needs awk
645 (invoke "./make" "--version")))
648 (let* ((out (assoc-ref %outputs "out"))
649 (bin (string-append out "/bin")))
650 (install-file "make" bin)))))))))
652 (define (%boot-tcc0-inputs)
653 `(("make" ,gnu-make-mesboot0)
655 ,@(%boot-gash-inputs)))
657 (define bzip2-mesboot
661 (name "bzip2-mesboot")
662 (version (package-version bzip2))
663 (source (bootstrap-origin (package-source bzip2)))
664 (supported-systems '("i686-linux" "x86_64-linux"))
666 (propagated-inputs '())
667 (native-inputs (%boot-tcc0-inputs))
670 `(#:implicit-inputs? #f
671 #:guile ,%bootstrap-guile
673 #:tests? #f ; check is naive, also checks non-built PROGRAMS
674 #:strip-binaries? #f ; no strip yet
675 #:make-flags (list "CC=tcc -I ." "AR=tcc -ar" "bzip2"
676 (string-append "PREFIX="
677 (assoc-ref %outputs "out")))
679 (modify-phases %standard-phases
680 (add-after 'unpack 'scripted-patch
682 (substitute* "Makefile"
684 (string-append "\t#" all)))
685 (substitute* "bzip2.c"
686 (("struct utimbuf uTimBuf;" all)
687 (string-append "// " all))
689 (string-append "// " all))
690 (("retVal = utime [(] dstName, &uTimBuf [)];" all)
691 (string-append "retVal = 0; // " all)))
695 (with-output-to-file "utime.h"
697 #define fchown(filedes, owner, group) 0
698 #define fchmod(filedes, mode) 0
703 (invoke "./bzip2" "--help")))
704 ;; FIXME: no compressing gzip yet
705 (delete 'compress-documentation))))))
707 (define bash-mesboot0
710 (inherit static-bash)
711 (name "bash-mesboot0")
715 (uri (string-append "mirror://gnu/bash/bash-"
719 "1r1z2qdw3rz668nxrzwa14vk2zcn00hw7mpjn384picck49d80xs"))))
721 (propagated-inputs '())
722 (native-inputs (%boot-tcc0-inputs))
725 `(#:implicit-inputs? #f
726 #:guile ,%bootstrap-guile
728 #:strip-binaries? #f ; no strip yet
730 (list "--build=i686-unknown-linux-gnu"
731 "--host=i686-unknown-linux-gnu"
733 "--without-bash-malloc"
736 "--disable-help-builtin"
738 "--disable-net-redirections"
741 ;; Pretend 'dlopen' is missing so we don't build loadable
742 ;; modules and related code.
743 "ac_cv_func_dlopen=no")
744 #:make-flags '("bash")
746 (modify-phases %standard-phases
747 (add-before 'configure 'setenv
749 (let* ((gash (assoc-ref %build-inputs "bash"))
750 (shell (string-append gash "/bin/gash")))
751 (setenv "CONFIG_SHELL" shell)
752 (setenv "SHELL" shell)
755 (setenv "AR" "tcc -ar")
756 (setenv "CFLAGS" "-D _POSIX_VERSION=1")
758 (add-after 'unpack 'scripted-patch
760 (substitute* "Makefile.in"
761 (("mksyntax\\.c\n") "mksyntax.c -lgetopt\n")
762 (("buildversion[.]o\n") "buildversion.o -lgetopt\n")
764 (("\tsize ") "#\tsize"))
765 (substitute* "lib/sh/oslib.c"
766 (("int name, namelen;") "char *name; int namelen;"))
767 (substitute* "lib/sh/snprintf.c"
768 (("^#if (defined [(]HAVE_LOCALE_H[)])" all define) (string-append "#if 0 //" define)))
769 (substitute* "configure"
770 ((" egrep") " grep"))
773 (lambda* (#:key configure-flags #:allow-other-keys)
774 (let ((configure-flags (filter (lambda (x)
775 (and (not (string-prefix? "CONFIG_SHELL=" x))
776 (not (string-prefix? "SHELL=" x))))
778 (format (current-error-port)
779 "running ./configure ~a\n" (string-join configure-flags)))
780 (apply invoke (cons "./configure" configure-flags))))
781 (add-after 'configure 'configure-fixups
783 (substitute* "config.h"
784 (("#define GETCWD_BROKEN 1") "#undef GETCWD_BROKEN"))
785 (let ((config.h (open-file "config.h" "a")))
786 (display (string-append "
787 // tcc: error: undefined symbol 'enable_hostname_completion'
788 #define enable_hostname_completion(on_or_off) 0
790 // /gnu/store/cq0cmv35s9dhilx14zaghlc08gpc0hwr-tcc-boot0-0.9.26-6.c004e9a/lib/libc.a: error: 'sigprocmask' defined twice
791 #define HAVE_POSIX_SIGNALS 1
792 #define endpwent(x) 0
799 (invoke "./bash" "--version")))
802 (let* ((out (assoc-ref %outputs "out"))
803 (bin (string-append out "/bin")))
805 (copy-file "bash" (string-append bin "/bash"))
806 (copy-file "bash" (string-append bin "/sh"))
816 (inherit (package-source tcc))
817 ;; `patches' needs XZ
818 ;; (patches (search-patches "tcc-boot-0.9.27.patch"))
820 (build-system gnu-build-system)
822 (propagated-inputs '())
823 (native-inputs `(;;("boot-patch" ,(search-patch "tcc-boot-0.9.27.patch"))
824 ("bzip2" ,bzip2-mesboot)
825 ,@(%boot-tcc0-inputs)))
827 `(#:implicit-inputs? #f
828 #:guile ,%bootstrap-guile
829 #:validate-runpath? #f ; no dynamic executables
830 #:strip-binaries? #f ; no strip yet
832 (modify-phases %standard-phases
833 ;; tar xvf ..bz2 gives
834 ;; bzip2: PANIC -- internal consistency error
836 (lambda* (#:key source #:allow-other-keys)
837 (copy-file source "tarball.tar.bz2")
838 (invoke "bzip2" "-d" "tarball.tar.bz2")
839 (invoke "tar" "xvf" "tarball.tar")
840 (chdir (string-append "tcc-" ,version))
843 ;; (add-after 'unpack 'apply-boot-patch
844 ;; (lambda* (#:key inputs #:allow-other-keys)
845 ;; (let ((patch-file (assoc-ref inputs "boot-patch")))
846 ;; (invoke "patch" "-p1" "-i" patch-file))))
847 (add-after 'unpack 'scripted-patch
848 (lambda* (#:key inputs #:allow-other-keys)
849 (substitute* "libtcc.c"
850 (("s->alacarte_link = 1;" all)
852 s->static_link = 1;")))
855 (lambda* (#:key outputs #:allow-other-keys)
856 (let* ((out (assoc-ref %outputs "out"))
857 (tcc (assoc-ref %build-inputs "tcc"))
858 (libc (assoc-ref %build-inputs "libc"))
859 (interpreter "/mes/loader"))
860 (invoke "sh" "configure"
861 (string-append "--cc=tcc")
862 (string-append "--cpu=i386")
863 (string-append "--prefix=" out)
864 (string-append "--elfinterp=" interpreter)
865 (string-append "--crtprefix=" tcc "/lib")
866 (string-append "--sysincludepaths=" tcc "/include")
867 (string-append "--libpaths=" tcc "/lib")))))
869 (lambda* (#:key outputs #:allow-other-keys)
870 (let* ((out (assoc-ref %outputs "out"))
871 (tcc (assoc-ref %build-inputs "tcc"))
872 (libc (assoc-ref %build-inputs "libc"))
873 (interpreter "/mes/loader"))
879 "-D" "TCC_TARGET_I386=1"
880 "-D" "CONFIG_TCC_STATIC=1"
881 "-D" "CONFIG_USE_LIBGCC=1"
882 "-D" (string-append "CONFIG_TCCDIR=\"" out "/lib/tcc\"")
883 "-D" (string-append "CONFIG_TCC_CRTPREFIX=\"" out "/lib:{B}/lib:.\"")
884 "-D" (string-append "CONFIG_TCC_CRTPREFIX=\"" out "/lib:{B}/lib:.\"")
885 "-D" (string-append "CONFIG_TCC_ELFINTERP=\"" interpreter "\"")
886 "-D" (string-append "CONFIG_TCC_LIBPATHS=\"" tcc "/lib:{B}/lib:.\"")
887 "-D" (string-append "CONFIG_TCC_SYSINCLUDEPATHS=\""
888 tcc "/include" ":/include:{B}/include\"")
889 "-D" (string-append "TCC_LIBGCC=\"" tcc "/lib/libc.a\"")
894 ;; FIXME: add sensible check target (without depending on make)
896 (= 1 (status:exit-val (system* "./tcc" "--help")))))
898 (lambda* (#:key outputs #:allow-other-keys)
899 (let ((out (assoc-ref %outputs "out"))
900 (tcc (assoc-ref %build-inputs "tcc")))
902 (mkdir-p (string-append out "/bin"))
903 (copy-file "tcc" (string-append out "/bin/tcc"))
904 (mkdir-p (string-append out "/lib/tcc"))
905 (copy-recursively (string-append tcc "/include")
906 (string-append out "/include"))
907 (copy-recursively (string-append tcc "/lib")
908 (string-append out "/lib"))
909 (invoke "tcc" "-D" "TCC_TARGET_I386=1" "-c" "-o" "libtcc1.o" "lib/libtcc1.c")
910 (invoke "tcc" "-ar" "rc" "libtcc1.a" "libtcc1.o")
911 (copy-file "libtcc1.a" (string-append out "/lib/libtcc1.a"))
912 (delete-file (string-append out "/lib/tcc/libtcc1.a"))
913 (copy-file "libtcc1.a" (string-append out "/lib/tcc/libtcc1.a"))
916 (define diffutils-mesboot
917 ;; The initial diffutils.
920 (name "diffutils-mesboot")
924 (uri (string-append "mirror://gnu/diffutils/diffutils-"
928 "1mirn5i825bn5w7rh6mgn0r8aj9xqanav95dwcl1b8sn82f4iwnm"))))
929 (supported-systems '("i686-linux" "x86_64-linux"))
931 (propagated-inputs '())
932 (native-inputs (%boot-tcc0-inputs))
934 `(#:implicit-inputs? #f
935 #:guile ,%bootstrap-guile
937 #:tests? #f ; check is naive, also checks non-built PROGRAMS
938 #:strip-binaries? #f ; no strip yet
940 (modify-phases %standard-phases
941 (add-before 'configure 'remove-diff3-sdiff
942 (lambda* (#:key outputs #:allow-other-keys)
943 (substitute* "Makefile.in"
944 (("PROGRAMS = .*" all) "PROGRAMS = cmp diff"))))
945 (replace 'configure ; needs classic invocation of configure
946 (lambda* (#:key configure-flags #:allow-other-keys)
947 (let* ((out (assoc-ref %outputs "out"))
948 (bash (assoc-ref %build-inputs "bash"))
949 (shell (string-append bash "/bin/bash")))
950 (setenv "CONFIG_SHELL" shell)
953 (format (current-error-port)
954 "running ./configure ~a\n" (string-join configure-flags))
955 (apply invoke (cons "./configure" configure-flags)))))
958 (let* ((out (assoc-ref %outputs "out"))
959 (bin (string-append out "/bin")))
961 (install-file "cmp" bin)
962 (install-file "diff" bin)
965 (define patch-mesboot
966 ;; The initial patch.
969 (name "patch-mesboot")
973 (uri (string-append "mirror://gnu/patch/patch-"
977 "12nv7jx3gxfp50y11nxzlnmqqrpicjggw6pcsq0wyavkkm3cddgc"))))
978 (supported-systems '("i686-linux" "x86_64-linux"))
980 (propagated-inputs '())
981 (native-inputs (%boot-tcc0-inputs))
983 `(#:implicit-inputs? #f
984 #:guile ,%bootstrap-guile
986 #:tests? #f ; check is naive, also checks non-built PROGRAMS
987 #:strip-binaries? #f ; no strip yet
988 #:configure-flags '("AR=tcc -ar" "CC=tcc" "LD-tcc")
990 (modify-phases %standard-phases
991 (add-after 'unpack 'scripted-patch
993 ;; avoid another segfault
995 (("while [(]p_end >= 0[)]" all)
996 "p_end = -1;\nwhile (0)"))
998 ;; FIXME: no compressing gzip yet
999 (delete 'compress-documentation))))))
1001 (define sed-mesboot0
1005 (name "sed-mesboot0")
1009 (uri (string-append "mirror://gnu/sed/sed-"
1013 "1hyv7i82jd0q18xcql51ylc8jwadp3gb3irgcqlis3v61p35jsv2"))))
1014 (supported-systems '("i686-linux" "x86_64-linux"))
1016 (propagated-inputs '())
1017 (native-inputs (%boot-tcc0-inputs))
1019 `(#:implicit-inputs? #f
1020 #:guile ,%bootstrap-guile
1021 #:parallel-build? #f
1022 #:configure-flags '("CC=tcc")
1023 #:make-flags '("CC=tcc" "extra_objs=" "DEFS=-D HAVE_BCOPY")
1024 #:strip-binaries? #f ; no strip yet
1026 (modify-phases %standard-phases
1027 (add-after 'unpack 'scripted-patch
1029 (let* ((out (assoc-ref %outputs "out"))
1030 (bash (assoc-ref %build-inputs "bash"))
1031 (shell (string-append bash "/bin/bash")))
1032 (substitute* "configure"
1033 (("/bin/sh") shell))
1037 (invoke "./sed" "--version")))
1040 (let* ((out (assoc-ref %outputs "out"))
1041 (bin (string-append out "/bin")))
1042 (install-file "sed" bin)
1045 (define (%boot-tcc-inputs)
1046 `(("bash" ,bash-mesboot0)
1047 ("bzip2" ,bzip2-mesboot)
1048 ("diffutils" ,diffutils-mesboot)
1049 ("gzip" ,gzip-mesboot)
1050 ("patch" ,patch-mesboot)
1051 ("sed" ,sed-mesboot0)
1053 ,@(alist-delete "tcc" (%boot-tcc0-inputs))))
1055 (define binutils-mesboot0
1056 ;; The initial Binutils
1059 (name "binutils-mesboot0")
1063 (uri (string-append "mirror://gnu/binutils/binutils-"
1067 "1w8xp7k44bkijr974x9918i4p1sw4g2fcd5mxvspkjpg38m214ds"))))
1069 (propagated-inputs '())
1070 (native-inputs (%boot-tcc-inputs))
1071 (supported-systems '("i686-linux" "x86_64-linux"))
1073 `(#:implicit-inputs? #f
1074 #:guile ,%bootstrap-guile
1075 #:tests? #f ; runtest: command not found
1076 #:parallel-build? #f
1077 #:strip-binaries? #f ; no strip yet
1079 (let ((out (assoc-ref %outputs "out")))
1083 "--build=i386-unknown-linux"
1084 "--host=i386-unknown-linux"
1085 "--target=i386-unknown-linux"
1087 ,(string-append "--prefix=" out)))
1089 (modify-phases %standard-phases
1090 (add-before 'configure 'setenv
1092 (let* ((out (assoc-ref %outputs "out"))
1093 (bash (assoc-ref %build-inputs "bash"))
1094 (shell (string-append bash "/bin/bash")))
1095 (setenv "CONFIG_SHELL" shell)
1096 (setenv "SHELL" shell)
1097 (setenv "AR" "tcc -ar")
1098 (setenv "RANLIB" "true")
1099 (setenv "CC" "tcc -D __GLIBC_MINOR__=6")
1101 (add-after 'unpack 'scripted-patch
1102 (lambda* (#:key inputs #:allow-other-keys)
1103 (substitute* "bfd/configure"
1104 (("^sed -e '/SRC-POTFILES.*" all)
1105 "echo -e 'all:\\n\\ttrue\\n\\ninstall:\\n\\ttrue\\n' > po/Makefile\n"))
1107 (replace 'configure ; needs classic invocation of configure
1108 (lambda* (#:key configure-flags #:allow-other-keys)
1109 (format (current-error-port)
1110 "running ./configure ~a\n" (string-join configure-flags))
1111 (apply system* "./configure" configure-flags)
1112 (substitute* "config.status"
1113 (("[.]//dev/null") "/dev/null"))
1114 (invoke "sh" "./config.status"))))))))
1116 (define gcc-core-mesboot0
1117 ;; Gcc-2.95.3 is the most recent GCC that is supported by what the Mes C
1118 ;; Library v0.16 offers. Gcc-3.x (and 4.x) place higher demands on a C
1119 ;; library, such as dir.h/struct DIR/readdir, locales, signals... Also,
1120 ;; with gcc-2.95.3, binutils (2.14.0, 2.20.1a) and glibc-2.2.5 we found a
1121 ;; GNU toolchain triplet "that works".
1124 (name "gcc-core-mesboot0")
1128 (uri (string-append "mirror://gnu/gcc/gcc-2.95.3/gcc-core-"
1131 ;; `patches' needs XZ
1132 ;; (patches (search-patches "gcc-boot-2.95.3.patch"))
1135 "1xvfy4pqhrd5v2cv8lzf63iqg92k09g6z9n2ah6ndd4h17k1x0an"))))
1136 (supported-systems '("i686-linux" "x86_64-linux"))
1138 (propagated-inputs '())
1139 (native-inputs `(("boot-patch" ,(search-patch "gcc-boot-2.95.3.patch"))
1140 ("binutils" ,binutils-mesboot0)
1141 ,@(%boot-tcc-inputs)))
1144 `(#:implicit-inputs? #f
1145 #:guile ,%bootstrap-guile
1147 #:parallel-build? #f
1148 #:strip-binaries? #f
1150 (let ((out (assoc-ref %outputs "out")))
1154 "--build=i686-unknown-linux-gnu"
1155 "--host=i686-unknown-linux-gnu"
1156 ,(string-append "--prefix=" out)))
1158 `("CC=tcc -static -D __GLIBC_MINOR__=6"
1159 "OLDCC=tcc -static -D __GLIBC_MINOR__=6"
1160 "CC_FOR_BUILD=tcc -static -D __GLIBC_MINOR__=6"
1163 ,(string-append "LIBGCC2_INCLUDES=-I "
1164 (assoc-ref %build-inputs "tcc")
1167 ,(string-append "BOOT_LDFLAGS="
1168 " -B" (assoc-ref %build-inputs "tcc")
1170 #:modules ((guix build gnu-build-system)
1174 (modify-phases %standard-phases
1175 (add-after 'unpack 'apply-boot-patch
1176 (lambda* (#:key inputs #:allow-other-keys)
1177 (let ((patch-file (assoc-ref inputs "boot-patch")))
1178 (system* "patch" "--force" "-p1" "-i" patch-file)
1180 (add-before 'configure 'setenv
1181 (lambda* (#:key outputs #:allow-other-keys)
1182 (let* ((out (assoc-ref outputs "out"))
1183 (bash (assoc-ref %build-inputs "bash"))
1184 (shell (string-append bash "/bin/bash"))
1185 (tcc (assoc-ref %build-inputs "tcc"))
1186 (cppflags " -D __GLIBC_MINOR__=6"))
1187 (setenv "CONFIG_SHELL" shell)
1188 (setenv "CPPFLAGS" cppflags)
1189 (setenv "CC" (string-append "tcc" cppflags))
1190 (setenv "CC_FOR_BUILD" (string-append "tcc" cppflags))
1191 (setenv "CPP" (string-append "tcc -E" cppflags))
1192 (with-output-to-file "config.cache"
1195 ac_cv_c_float_format='IEEE (little-endian)'
1198 (replace 'configure ; needs classic invocation of configure
1199 (lambda* (#:key configure-flags #:allow-other-keys)
1200 (format (current-error-port)
1201 "running ./configure ~a\n" (string-join configure-flags))
1202 (apply invoke "./configure" configure-flags)))
1203 (add-after 'configure 'remove-info
1205 ;; no info at this stage
1206 (delete-file-recursively "texinfo")
1207 (invoke "touch" "gcc/cpp.info" "gcc/gcc.info")))
1208 (add-after 'install 'install2
1209 (lambda* (#:key outputs #:allow-other-keys)
1210 (let* ((tcc (assoc-ref %build-inputs "tcc"))
1211 (tcc-lib (string-append tcc "/lib/x86-mes-gcc"))
1212 (out (assoc-ref outputs "out"))
1213 (gcc-dir (string-append
1214 out "/lib/gcc-lib/i686-unknown-linux-gnu/2.95.3")))
1216 (with-directory-excursion "tmp"
1217 (invoke "ar" "x" (string-append "../gcc/libgcc2.a"))
1218 (invoke "ar" "x" (string-append tcc "/lib/libtcc1.a"))
1219 (apply invoke "ar" "r" (string-append gcc-dir "/libgcc.a")
1220 (find-files "." "\\.o")))
1221 (copy-file "gcc/libgcc2.a" (string-append out "/lib/libgcc2.a"))
1222 (copy-file (string-append tcc "/lib/libtcc1.a")
1223 (string-append out "/lib/libtcc1.a"))
1224 (invoke "ar" "x" (string-append tcc "/lib/libtcc1.a"))
1225 (invoke "ar" "x" (string-append tcc "/lib/libc.a"))
1226 (invoke "ar" "r" (string-append gcc-dir "/libc.a")
1227 "libc.o" "libtcc1.o")
1229 (native-search-paths
1230 (list (search-path-specification
1231 (variable "C_INCLUDE_PATH")
1234 ;; Needed to get things like GCC's <stddef.h>.
1235 "lib/gcc-lib/i686-unknown-linux-gnu/2.95.3/include")))
1236 (search-path-specification
1237 (variable "LIBRARY_PATH")
1238 (files '("lib")))))))
1240 (define (%boot-mesboot-core-inputs)
1241 `(("binutils" ,binutils-mesboot0)
1242 ("gawk" ,gawk-mesboot0)
1243 ("gcc" ,gcc-core-mesboot0)
1244 ,@(alist-delete "tcc" (%boot-tcc-inputs))))
1246 (define mesboot-headers
1249 (name "mesboot-headers")
1250 (supported-systems '("i686-linux" "x86_64-linux"))
1252 (propagated-inputs '())
1253 (native-inputs `(("kernel-headers" ,%bootstrap-linux-libre-headers)
1254 ,@(%boot-tcc-inputs)))
1256 `(#:implicit-inputs? #f
1257 #:guile ,%bootstrap-guile
1259 #:strip-binaries? #f
1261 (modify-phases %standard-phases
1265 (lambda* (#:key outputs #:allow-other-keys)
1266 (let* ((out (assoc-ref outputs "out"))
1267 (include (string-append out "/include"))
1268 (headers (assoc-ref %build-inputs "kernel-headers")))
1270 (copy-recursively "include" out)
1271 (copy-recursively headers out)
1274 (define gawk-mesboot0
1275 ;; The initial Gawk.
1278 (name "gawk-mesboot0")
1282 (uri (string-append "mirror://gnu/gawk/gawk-"
1286 "087s7vpc8zawn3l7bwv9f44bf59rc398hvaiid63klw6fkbvabr3"))))
1287 (supported-systems '("i686-linux" "x86_64-linux"))
1289 (propagated-inputs '())
1290 (native-inputs (%boot-tcc-inputs))
1292 `(#:implicit-inputs? #f
1293 #:guile ,%bootstrap-guile
1294 #:configure-flags '("--build=i686-unknown-linux-gnu"
1295 "--host=i686-unknown-linux-gnu"
1297 #:make-flags '("gawk")
1298 #:parallel-build? #f
1299 #:parallel-tests? #f
1300 #:strip-binaries? #f ; no strip yet
1302 (modify-phases %standard-phases
1303 (add-after 'unpack 'scripted-patch
1305 (substitute* "Makefile.in"
1306 (("date ") "echo today ")
1307 ((" autoheader") "true")
1309 (substitute* "test/Makefile.in"
1310 (("^bigtest:.*") "bigtest: basic\n")
1311 (("( |\t)(childin|convfmt|fflush|longwrds|math|negexp)" all sep) sep))))
1312 (add-before 'configure 'setenv
1314 (let* ((out (assoc-ref %outputs "out"))
1315 (bash (assoc-ref %build-inputs "bash"))
1316 (shell (string-append bash "/bin/bash")))
1317 (setenv "CONFIG_SHELL" shell)
1318 (setenv "SHELL" shell)
1320 (setenv "CPP" "tcc -E")
1322 (setenv "ac_cv_func_getpgrp_void" "yes")
1323 (setenv "ac_cv_func_tzset" "yes"))
1325 (replace 'configure ; needs classic invocation of configure
1326 (lambda* (#:key configure-flags #:allow-other-keys)
1327 (let* ((out (assoc-ref %outputs "out"))
1330 ,(string-append "--prefix=" out))))
1331 (format (current-error-port) "running ./configure ~a\n" (string-join configure-flags))
1332 (system* "touch" "configure") ; aclocal.m4 is newer than configure
1333 (apply invoke (cons "./configure" configure-flags)))))
1335 (lambda* (#:key outputs #:allow-other-keys)
1336 (let* ((out (assoc-ref outputs "out"))
1337 (bin (string-append out "/bin")))
1338 (install-file "gawk" bin)
1339 (symlink "gawk" (string-append bin "/awk"))
1342 (define glibc-mesboot0
1343 ;; GNU C Library 2.2.5 is the most recent glibc that we managed to build
1344 ;; using gcc-2.95.3. Newer versions (2.3.x, 2.6, 2.1x) seem to need a newer
1348 (name "glibc-mesboot0")
1352 (uri (string-append "mirror://gnu/glibc/glibc-"
1356 ;; (patches (search-patches "glibc-boot-2.2.5.patch"))
1359 "1vl48i16gx6h68whjyhgnn1s57vqq32f9ygfa2fls7pdkbsqvp2q"))))
1360 (supported-systems '("i686-linux" "x86_64-linux"))
1362 (propagated-inputs '())
1363 (native-inputs `(("boot-patch" ,(search-patch "glibc-boot-2.2.5.patch"))
1364 ("system-patch" ,(search-patch "glibc-bootstrap-system-2.2.5.patch"))
1365 ("headers" ,mesboot-headers)
1366 ,@(%boot-mesboot-core-inputs)))
1369 `(#:implicit-inputs? #f
1370 #:guile ,%bootstrap-guile
1372 #:strip-binaries? #f
1373 #:validate-runpath? #f ; no dynamic executables
1374 #:parallel-build? #f ; gcc-2.95.3 ICEs on massively parallel builds
1375 #:make-flags (list (string-append
1377 (assoc-ref %build-inputs "bash")
1380 (let ((out (assoc-ref %outputs "out"))
1381 (headers (assoc-ref %build-inputs "headers")))
1382 `("--disable-shared"
1384 "--disable-sanity-checks"
1385 "--build=i686-unknown-linux-gnu"
1386 "--host=i686-unknown-linux-gnu"
1387 ,(string-append "--with-headers=" headers "/include")
1388 "--enable-static-nss"
1389 "--without-__thread"
1393 ,(string-append "--prefix=" out)))
1395 (modify-phases %standard-phases
1396 (add-after 'unpack 'apply-boot-patch
1397 (lambda* (#:key inputs #:allow-other-keys)
1398 (and (let ((patch (assoc-ref inputs "boot-patch")))
1399 (invoke "patch" "--force" "-p1" "-i" patch))
1400 (let ((patch (assoc-ref inputs "system-patch")))
1401 (invoke "patch" "--force" "-p1" "-i" patch)))))
1402 (add-before 'configure 'setenv
1403 (lambda* (#:key outputs #:allow-other-keys)
1404 (let* ((out (assoc-ref outputs "out"))
1405 (bash (assoc-ref %build-inputs "bash"))
1406 (shell (string-append bash "/bin/bash"))
1407 (gcc (assoc-ref %build-inputs "gcc"))
1408 (headers (assoc-ref %build-inputs "headers"))
1409 (cppflags (string-append
1411 " -D MES_BOOTSTRAP=1"
1412 " -D BOOTSTRAP_GLIBC=1"))
1413 (cflags (string-append " -L " (getcwd))))
1414 (setenv "CONFIG_SHELL" shell)
1415 (setenv "SHELL" shell)
1416 (setenv "CPP" (string-append gcc "/bin/gcc -E " cppflags))
1417 (setenv "CC" (string-append gcc "/bin/gcc " cppflags cflags))
1419 (replace 'configure ; needs classic invocation of configure
1420 (lambda* (#:key configure-flags #:allow-other-keys)
1421 (format (current-error-port)
1422 "running ./configure ~a\n" (string-join configure-flags))
1423 (apply invoke "./configure" configure-flags)))
1424 (add-after 'configure 'fixup-configure
1426 (let* ((out (assoc-ref %outputs "out"))
1427 (bash (assoc-ref %build-inputs "bash"))
1428 (shell (string-append bash "/bin/bash")))
1429 (substitute* "config.make"
1430 (("INSTALL = scripts/") "INSTALL = $(..)./scripts/"))
1431 (substitute* "config.make"
1432 (("INSTALL = scripts/") "INSTALL = $(..)./scripts/")
1433 (("BASH = ") (string-append
1438 (define gcc-mesboot0
1440 (inherit gcc-core-mesboot0)
1441 (name "gcc-mesboot0")
1442 (native-inputs `(("boot-patch" ,(search-patch "gcc-boot-2.95.3.patch"))
1443 ;; Packages are given in an order that's relevant for
1444 ;; #include_next purposes.
1445 ("libc" ,glibc-mesboot0)
1446 ("kernel-headers" ,%bootstrap-linux-libre-headers)
1447 ,@(%boot-mesboot-core-inputs)))
1449 (substitute-keyword-arguments (package-arguments gcc-core-mesboot0)
1451 `(modify-phases ,phases
1454 (setenv "CONFIG_SHELL" (which "sh"))
1455 (with-output-to-file "config.cache"
1458 ac_cv_c_float_format='IEEE (little-endian)'
1462 (lambda* (#:key outputs #:allow-other-keys)
1463 (let* ((out (assoc-ref outputs "out"))
1464 (gcc-dir (string-append
1465 out "/lib/gcc-lib/i686-unknown-linux-gnu/2.95.3")))
1468 (zero? (system (string-append "set -x; cd tmp && ar x ../gcc/libgcc2.a")))
1469 (zero? (system (string-append "set -x; cd tmp && ar r " gcc-dir "/libgcc.a *.o")))
1470 (copy-file "gcc/libgcc2.a" (string-append out "/lib/libgcc2.a"))))))))
1471 ((#:configure-flags configure-flags)
1472 `(let ((out (assoc-ref %outputs "out")))
1473 `("--disable-shared"
1475 "--build=i686-unknown-linux-gnu"
1476 "--host=i686-unknown-linux-gnu"
1477 ,(string-append "--prefix=" out))))
1478 ((#:make-flags make-flags)
1479 `(let ((gcc (assoc-ref %build-inputs "gcc")))
1481 ,(string-append "LIBGCC2_INCLUDES=-I " gcc "/include")
1482 "LANGUAGES=c")))))))
1484 (define (%boot-mesboot0-inputs)
1485 `(("gcc" ,gcc-mesboot0)
1486 ("kernel-headers" ,%bootstrap-linux-libre-headers)
1487 ("libc" ,glibc-mesboot0)
1488 ,@(alist-delete "gcc" (%boot-mesboot-core-inputs))))
1491 ;; Initial tar with support for xz compression.
1494 (name "tar-mesboot")
1498 (uri (string-append "mirror://gnu/tar/tar-"
1502 "19nvix64y95n5v6rr5g9g3fn08zz85cb5anzd7csfv4a4sz9lw4y"))))
1503 (supported-systems '("i686-linux" "x86_64-linux"))
1505 (propagated-inputs '())
1506 (native-inputs (%boot-mesboot0-inputs))
1508 `(#:implicit-inputs? #f
1509 #:guile ,%bootstrap-guile
1510 #:parallel-build? #f
1511 #:tests? #f ; check is naive, also checks non-built PROGRAMS
1512 #:strip-binaries? #f ; no strip yet
1513 #:configure-flags '("--build=i686-unknown-linux-gnu"
1514 "--host=i686-unknown-linux-gnu"
1517 (modify-phases %standard-phases
1519 (lambda* (#:key configure-flags #:allow-other-keys)
1520 (let* ((out (assoc-ref %outputs "out"))
1521 (bash (assoc-ref %build-inputs "bash"))
1522 (shell (string-append bash "/bin/bash")))
1523 (setenv "CONFIG_SHELL" shell)
1524 (setenv "SHELL" shell)
1525 (setenv "LIBS" "-lc -lnss_files -lnss_dns -lresolv")
1526 (setenv "gl_cv_func_rename_dest_works" "yes")
1527 (format (current-error-port)
1528 "running ./configure ~a\n" (string-join configure-flags))
1529 (apply invoke (cons "./configure" configure-flags)))))
1530 (add-after 'unpack 'scripted-patch
1532 (let* ((bash (assoc-ref %build-inputs "bash"))
1533 (shell (string-append bash "/bin/bash")))
1534 (substitute* "configure"
1535 ((" /bin/sh") shell)))
1536 (substitute* "Makefile.in"
1537 (("^SUBDIRS = doc") "SUBDIRS ="))
1541 (let* ((out (assoc-ref %outputs "out"))
1542 (bin (string-append out "/bin")))
1543 (install-file "src/tar" bin)
1546 (define grep-mesboot
1547 ;; The initial grep.
1550 (name "grep-mesboot")
1554 (uri (string-append "mirror://gnu/grep/grep-"
1558 "1w862l80lgc5mxvpiy4cfwk761d6xxavn0m3xd2l7xs2kmzvp6lq"))))
1559 (supported-systems '("i686-linux" "x86_64-linux"))
1561 (propagated-inputs '())
1562 (native-inputs (%boot-mesboot0-inputs))
1564 `(#:implicit-inputs? #f
1565 #:guile ,%bootstrap-guile
1566 #:parallel-build? #f
1568 (modify-phases %standard-phases
1569 (add-before 'configure 'patch-configure
1571 (let* ((bash (assoc-ref %build-inputs "bash"))
1572 (shell (string-append bash "/bin/bash")))
1573 (substitute* "configure"
1574 ((" [|][|] ./config.status") " || sh ./config.status")))))
1577 (let* ((out (assoc-ref %outputs "out"))
1578 (bin (string-append out "/bin")))
1579 (install-file "grep" bin)
1580 (symlink "grep" (string-append bin "/egrep"))
1581 (symlink "grep" (string-append bin "/fgrep"))
1584 (define binutils-mesboot1
1586 (inherit binutils-mesboot0)
1587 (name "binutils-mesboot1")
1588 (native-inputs (%boot-mesboot0-inputs))
1590 (substitute-keyword-arguments (package-arguments binutils-mesboot0)
1591 ((#:configure-flags configure-flags)
1592 '(let ((out (assoc-ref %outputs "out")))
1596 "--build=i686-unknown-linux-gnu"
1597 "--host=i686-unknown-linux-gnu"
1599 ,(string-append "--prefix=" out))))
1601 `(modify-phases ,phases
1604 (let* ((out (assoc-ref %outputs "out"))
1605 (bash (assoc-ref %build-inputs "bash"))
1606 (shell (string-append bash "/bin/bash")))
1607 (setenv "CONFIG_SHELL" shell)
1610 (define coreutils-mesboot0
1613 (name "coreutils-mesboot0")
1614 ;; The latest .gz release of Coreutils is 8.13; which does not build with gcc-2.95.3:
1615 ;; randperm.c: In function `sparse_swap':
1616 ;; randperm.c:117: invalid lvalue in unary `&'
1617 (version "5.0") ; 2003-04
1620 (uri (string-append "mirror://gnu/coreutils/coreutils-"
1624 "10wq6k66i8adr4k08p0xmg87ff4ypiazvwzlmi7myib27xgffz62"))))
1625 (native-inputs (%boot-mesboot0-inputs))
1626 (supported-systems '("i686-linux" "x86_64-linux"))
1628 (propagated-inputs '())
1630 `(#:implicit-inputs? #f
1631 #:tests? #f ; WARNING: `perl' is needed, ...
1632 #:parallel-build? #f
1633 #:strip-binaries? #f ; strip: unrecognized option `--only-keep-debug'
1634 #:guile ,%bootstrap-guile
1637 "LIBS=-lc -lnss_files -lnss_dns -lresolv"
1638 "ac_cv_func_gethostbyname=no"
1639 "gl_cv_func_rename_dest_works=yes")))))
1641 (define gnu-make-mesboot
1644 (name "make-mesboot")
1648 (uri (string-append "mirror://gnu/make/make-"
1652 "1rs2f9hmvy3q6zkl15jnlmnpgffm0bhw5ax0h5c7q604wqrip69x"))))
1653 (native-inputs (%boot-mesboot0-inputs))
1654 (supported-systems '("i686-linux" "x86_64-linux"))
1656 (propagated-inputs '())
1658 `(#:implicit-inputs? #f
1659 #:parallel-build? #f
1660 #:guile ,%bootstrap-guile
1661 #:configure-flags '("LIBS=-lc -lnss_files -lnss_dns -lresolv")
1663 (modify-phases %standard-phases
1666 (invoke "./make" "--version")))
1668 (lambda* (#:key outputs #:allow-other-keys)
1669 (let* ((out (assoc-ref outputs "out"))
1670 (bin (string-append out "/bin")))
1671 (install-file "make" bin)
1674 (define gawk-mesboot
1677 (name "gawk-mesboot")
1681 (uri (string-append "mirror://gnu/gawk/gawk-"
1685 "03d5y7jabq7p2s7ys9alay9446mm7i5g2wvy8nlicardgb6b6ii1"))))
1686 (native-inputs `(,@(%boot-mesboot0-inputs)
1687 ("mesboot-headers" ,mesboot-headers)))
1688 (supported-systems '("i686-linux" "x86_64-linux"))
1690 (propagated-inputs '())
1692 `(#:implicit-inputs? #f
1693 #:parallel-build? #f
1694 #:guile ,%bootstrap-guile
1695 #:configure-flags '("ac_cv_func_connect=no")
1696 #:make-flags '("gawk")
1698 (modify-phases %standard-phases
1701 (invoke "./gawk" "--version")))
1703 (lambda* (#:key outputs #:allow-other-keys)
1704 (let* ((out (assoc-ref outputs "out"))
1705 (bin (string-append out "/bin")))
1706 (install-file "gawk" bin)
1707 (symlink "gawk" (string-append bin "/awk"))
1713 (name "sed-mesboot")
1714 (version "4.0.6") ; 2003-04
1717 (uri (string-append "mirror://gnu/sed/sed-"
1721 "0861ij94cqc4vaaki6r2wlapwcmhpx4ggp4r70f46mb21a8fkvf1"))))
1722 (native-inputs (%boot-mesboot0-inputs))
1723 (supported-systems '("i686-linux" "x86_64-linux"))
1725 (propagated-inputs '())
1727 `(#:implicit-inputs? #f
1728 #:parallel-build? #f
1729 #:guile ,%bootstrap-guile
1730 #:tests? #f ; 8to7 fails
1732 (modify-phases %standard-phases
1733 (add-after 'unpack '/bin/sh
1735 (let* ((bash (assoc-ref %build-inputs "bash"))
1736 (shell (string-append bash "/bin/bash")))
1737 (substitute* "testsuite/Makefile.tests"
1738 (("^SHELL = /bin/sh")
1739 (string-append "SHELL = " shell)))
1742 (define bash-mesboot
1744 (inherit bash-mesboot0)
1746 (name "bash-mesboot")
1749 (uri (string-append "mirror://gnu/bash/bash-"
1753 "1jyz6snd63xjn6skk7za6psgidsd53k05cr3lksqybi0q6936syq"))))
1755 (propagated-inputs '())
1756 (native-inputs (%boot-mesboot0-inputs))
1759 `(#:implicit-inputs? #f
1760 #:guile ,%bootstrap-guile
1761 #:parallel-build? #f
1763 '("--build=i686-unknown-linux-gnu"
1764 "--host=i686-unknown-linux-gnu"
1766 "--without-bash-malloc"
1767 "--disable-readline"
1769 "--disable-help-builtin"
1770 "--disable-progcomp"
1771 "--disable-net-redirections"
1774 ;; Pretend 'dlopen' is missing so we don't build loadable
1775 ;; modules and related code.
1776 "ac_cv_func_dlopen=no")
1777 #:make-flags '("bash")
1779 (modify-phases %standard-phases
1780 (add-after 'unpack 'scripted-patch
1782 (substitute* "shell.c"
1785 (add-before 'configure 'setenv
1787 (setenv "AWK" "gawk")
1788 (setenv "LIBS" "-lc -lnss_files -lnss_dns -lresolv")
1789 (setenv "gl_cv_func_rename_dest_works" "yes")
1791 (add-after 'configure 'configure-fixups
1793 (let ((config.h (open-file "config.h" "a")))
1794 (display (string-append "
1795 #define enable_hostname_completion(on_or_off) 0
1802 (invoke "./bash" "--version")))
1805 (let* ((out (assoc-ref %outputs "out"))
1806 (bin (string-append out "/bin")))
1808 (copy-file "bash" (string-append bin "/bash"))
1809 (copy-file "bash" (string-append bin "/sh"))
1812 (define (%boot-mesboot1-inputs)
1813 `(("bash" ,bash-mesboot)
1814 ("binutils" ,binutils-mesboot1)
1815 ("coreutils" ,coreutils-mesboot0)
1816 ("gawk" ,gawk-mesboot)
1817 ("grep" ,grep-mesboot)
1818 ("make" ,gnu-make-mesboot)
1819 ("sed" ,sed-mesboot)
1820 ("tar" ,tar-mesboot)
1821 ,@(fold alist-delete (%boot-mesboot0-inputs)
1822 '("bash" "binutils" "bootar" "coreutils" "gash"
1823 "gawk" "grep" "guile" "make" "sed" "tar"))))
1831 (uri (string-append "mirror://gnu/gmp/gmp-" version
1834 "15rwq54fi3s11izas6g985y9jklm3xprfsmym3v1g6xr84bavqvv"))))))
1842 (uri (string-append "mirror://gnu/mpfr/mpfr-" version
1845 "0dxn4904dra50xa22hi047lj8kkpr41d6vb9sd4grca880c7wv94"))))))
1854 "mirror://gnu/mpc/mpc-" version ".tar.gz"))
1857 "1hzci2zrrd7v3g1jk35qindq05hbl0bhjcyyisq9z209xb3fqzb1"))))))
1859 (define gcc-core-mesboot1
1860 ;; GCC 4.6.4 is the latest modular distribution. This package is not
1861 ;; stricly needed, but very helpful for development because it builds
1862 ;; relatively fast. If this configures and builds then gcc-mesboot1 also
1865 (inherit gcc-mesboot0)
1866 (name "gcc-core-mesboot1")
1870 (uri (string-append "mirror://gnu/gcc/gcc-"
1871 version "/gcc-core-" version ".tar.gz"))
1874 "173kdb188qg79pcz073cj9967rs2vzanyjdjyxy9v0xb0p5sad75"))
1876 ;; (patches (search-patches "gcc-boot-4.6.4.patch"))
1878 (inputs `(("gmp-source" ,(package-source gmp-boot))
1879 ("mpfr-source" ,(package-source mpfr-boot))
1880 ("mpc-source" ,(package-source mpc-boot))))
1881 (native-inputs `(("boot-patch" ,(search-patch "gcc-boot-4.6.4.patch"))
1882 ,@(%boot-mesboot1-inputs)))
1884 `(#:implicit-inputs? #f
1885 #:guile ,%bootstrap-guile
1887 #:modules ((guix build gnu-build-system)
1890 #:parallel-build? #f ; for debugging
1892 (let* ((libc (assoc-ref %build-inputs "libc"))
1893 (ldflags (string-append
1895 "-Wl,-dynamic-linker "
1897 ,(glibc-dynamic-linker "i686-linux"))))
1898 (list (string-append "LDFLAGS=" ldflags)
1899 (string-append "LDFLAGS_FOR_TARGET=" ldflags)))
1901 (let ((out (assoc-ref %outputs "out"))
1902 (glibc (assoc-ref %build-inputs "libc")))
1903 (list (string-append "--prefix=" out)
1904 "--build=i686-unknown-linux-gnu"
1905 "--host=i686-unknown-linux-gnu"
1906 (string-append "--with-native-system-header-dir=" glibc "/include")
1907 (string-append "--with-build-sysroot=" glibc "/include")
1908 "--disable-bootstrap"
1909 "--disable-decimal-float"
1910 "--disable-libatomic"
1911 "--disable-libcilkrts"
1914 "--disable-libmudflap"
1915 "--disable-libquadmath"
1916 "--disable-libsanitizer"
1920 "--disable-lto-plugin"
1921 "--disable-multilib"
1924 "--enable-languages=c"
1927 "--enable-threads=single"
1928 "--disable-libstdcxx-pch"
1929 "--disable-build-with-cxx"))
1931 (modify-phases %standard-phases
1932 (add-after 'unpack 'apply-boot-patch
1933 (lambda* (#:key inputs #:allow-other-keys)
1934 (let ((patch-file (assoc-ref inputs "boot-patch")))
1935 (format (current-error-port) "patch file=~s\n" patch-file)
1936 (system* "patch" "--force" "-p1" "-i" patch-file))
1938 ;; c&p from commencement.scm:gcc-boot0
1939 (add-after 'unpack 'unpack-gmp&co
1940 (lambda* (#:key inputs #:allow-other-keys)
1941 (let ((gmp (assoc-ref %build-inputs "gmp-source"))
1942 (mpfr (assoc-ref %build-inputs "mpfr-source"))
1943 (mpc (assoc-ref %build-inputs "mpc-source")))
1945 ;; To reduce the set of pre-built bootstrap inputs, build
1946 ;; GMP & co. from GCC.
1947 (for-each (lambda (source)
1948 (or (invoke "tar" "xvf" source)
1949 (error "failed to unpack tarball"
1951 (list gmp mpfr mpc))
1953 ;; Create symlinks like `gmp' -> `gmp-x.y.z'.
1954 ,@(map (lambda (lib)
1955 ;; Drop trailing letters, as gmp-6.0.0a unpacks
1957 `(symlink ,(string-trim-right
1958 (package-full-name lib "-")
1960 ,(package-name lib)))
1961 (list gmp-boot mpfr-boot mpc-boot))
1963 (add-before 'configure 'setenv
1964 (lambda* (#:key outputs #:allow-other-keys)
1965 (let* ((out (assoc-ref outputs "out"))
1966 (binutils (assoc-ref %build-inputs "binutils"))
1967 (bash (assoc-ref %build-inputs "bash"))
1968 (gcc (assoc-ref %build-inputs "gcc"))
1969 (glibc (assoc-ref %build-inputs "libc"))
1970 (kernel-headers (assoc-ref %build-inputs "kernel-headers")))
1971 (setenv "CONFIG_SHELL" (string-append bash "/bin/sh"))
1972 (setenv "C_INCLUDE_PATH" (string-append
1973 gcc "/lib/gcc-lib/i686-unknown-linux-gnu/2.95.3/include"
1974 ":" kernel-headers "/include"
1975 ":" glibc "/include"
1976 ":" (getcwd) "/mpfr/src"))
1977 (setenv "LIBRARY_PATH" (string-append glibc "/lib"
1979 (format (current-error-port) "C_INCLUDE_PATH=~a\n" (getenv "C_INCLUDE_PATH"))
1980 (format (current-error-port) "LIBRARY_PATH=~a\n" (getenv "LIBRARY_PATH"))
1983 (define gcc-mesboot1
1985 (inherit gcc-core-mesboot1)
1986 (name "gcc-mesboot1")
1992 (uri (string-append "mirror://gnu/gcc/gcc-"
1993 version "/gcc-g++-" version ".tar.gz"))
1996 "1fqqk5zkmdg4vmqzdmip9i42q6b82i3f6yc0n86n9021cr7ms2k9"))))
1997 ,@(package-native-inputs gcc-core-mesboot1)))
1999 (substitute-keyword-arguments (package-arguments gcc-core-mesboot1)
2000 ((#:configure-flags configure-flags)
2001 `(let ((out (assoc-ref %outputs "out")))
2002 `("--enable-languages=c,c++"
2004 (negate (lambda (x) (string-prefix? "--enable-languages=" x)))
2005 ,configure-flags))))
2007 `(modify-phases ,phases
2008 (add-before 'unpack 'unpack-g++
2010 (let ((source-g++ (assoc-ref %build-inputs "gcc-g++")))
2011 (invoke "tar" "xvf" source-g++))
2015 (setenv "CONFIG_SHELL" (which "sh"))
2017 ;; Allow MPFR headers to be found.
2018 (setenv "C_INCLUDE_PATH"
2019 (string-append (getcwd) "/mpfr/src:"
2020 (getenv "C_INCLUDE_PATH")))
2022 ;; Set the C++ search path so that C headers can be found as
2023 ;; libstdc++ is being compiled.
2024 (setenv "CPLUS_INCLUDE_PATH" (getenv "C_INCLUDE_PATH"))
2027 (define (%boot-mesboot2-inputs)
2028 `(("gcc" ,gcc-mesboot1)
2029 ,@(alist-delete "gcc" (%boot-mesboot1-inputs))))
2032 ;; Finally, we can build xz.
2037 (source (bootstrap-origin
2040 (uri (list (string-append "http://tukaani.org/xz/xz-" version
2042 (string-append "http://multiprecision.org/guix/xz-"
2043 version ".tar.gz")))
2046 "0kf40ggbs1vaaj5s9k4csycahzqcf65n20pa6lngqhm6j0cj3agb")))))
2047 (supported-systems '("i686-linux" "x86_64-linux"))
2050 (propagated-inputs '())
2051 (native-inputs (%boot-mesboot2-inputs))
2053 `(#:implicit-inputs? #f
2054 #:guile ,%bootstrap-guile
2055 #:parallel-build? #f
2057 `("--disable-assembler"
2063 "--disable-lzmainfo"
2064 "--disable-lzma-links"
2068 "--disable-symbol-versions"
2069 ;; configure disqualifies BASH, CPP, GCC and GREP
2070 ;; all of which seem fine for the build
2071 "ac_cv_prog_cc_c99=-std=gnu9x"
2072 "ac_cv_path_GREP=grep"
2073 "gl_cv_posix_shell=bash"
2074 "ac_cv_have_decl_optreset=no"
2075 "CPPFLAGS=-D__GNUC__=1")))))
2077 (define hello-mesboot
2078 ;; Check for Scheme-only bootstrap.
2081 (name "hello-mesboot")
2082 (supported-systems '("i686-linux" "x86_64-linux"))
2084 (propagated-inputs '())
2085 (native-inputs (%boot-mesboot2-inputs))
2087 `(#:implicit-inputs? #f
2088 #:guile ,%bootstrap-guile
2089 #:parallel-build? #f
2090 ;; checking for grep that handles long lines and -e...
2091 ;; configure: error: no acceptable grep could be found
2092 #:configure-flags '("ac_cv_path_GREP=grep")
2094 (modify-phases %standard-phases
2097 (invoke "./hello"))))))))
2099 (define binutils-mesboot
2102 (name "binutils-mesboot")
2104 (source (bootstrap-origin
2107 (uri (string-append "mirror://gnu/binutils/binutils-"
2108 version ".tar.bz2"))
2109 (patches (search-patches "binutils-boot-2.20.1a.patch"))
2112 "0r7dr0brfpchh5ic0z9r4yxqn4ybzmlh25sbp30cacqk8nb7rlvi")))))
2114 (propagated-inputs '())
2115 (native-inputs `(("xz" ,xz-mesboot)
2116 ,@(%boot-mesboot2-inputs)))
2117 (supported-systems '("i686-linux" "x86_64-linux"))
2119 `(#:implicit-inputs? #f
2120 #:guile ,%bootstrap-guile
2121 #:tests? #f ; runtest: command not found
2122 #:parallel-build? #f
2123 #:strip-binaries? #f ; no strip yet
2132 "--build=i686-unknown-linux-gnu"
2133 "--host=i686-unknown-linux-gnu"
2135 ;; checking for grep that handles long lines and -e
2136 "ac_cv_path_GREP=grep")
2137 ;; FIXME: ac_cv_path_GREP=grep doesn't seem to be forwarded to
2138 ;; cascading configure's?
2139 #:make-flags '("ac_cv_path_GREP=grep")
2141 (modify-phases %standard-phases
2142 (add-after 'unpack 'scripted-patch
2144 ;; sed-mesboot0 cannot build these
2145 (copy-file "binutils/Makefile.in" "binutils/Makefile.in.orig")
2146 (substitute* "binutils/Makefile.in"
2147 ;; binutils/binutils uses an amazingly complex install
2148 ;; command, using FOR, SED, READ, IF, ECHO, SED, SED, AWK,
2149 ;; READ, and then LIBTOOL (to do something like
2150 ;; `mkdir $DESTDIR$bindir; cp readline $DESTDIR$bindir ...')
2152 ;; Some tool [debugme!] cannot handle two escaped newlines
2153 ;; (bash?), and the install stops after $(am__EXEEXT_11)
2154 ;; ("objcopy"), so $(am__EXEEXT_13) ("readelf") and others do
2155 ;; not get installed. Remove the stray newline:
2156 (("^\t@BUILD_NLMCONV@ @BUILD_SRCONV@ @BUILD_DLLTOOL@ @BUILD_WINDRES@ .*") ""))
2157 (substitute* "opcodes/Makefile.in"
2158 (("^SUBDIRS = [.] po") "SUBDIRS = ."))
2159 (substitute* "binutils/Makefile.in"
2160 (("^SUBDIRS = doc po") "SUBDIRS ="))
2161 (substitute* "gas/Makefile.in"
2162 (("^SUBDIRS = doc po") "SUBDIRS ="))
2163 (substitute* "gprof/Makefile.in"
2164 (("^SUBDIRS = po") "SUBDIRS ="))
2165 (substitute* "ld/Makefile.in"
2166 (("^SUBDIRS = po") "SUBDIRS ="))
2169 (define (%boot-mesboot3-inputs)
2170 `(("binutils" ,binutils-mesboot)
2172 ,@(alist-delete "binutils" (%boot-mesboot2-inputs))))
2174 (define glibc-headers-mesboot
2176 (inherit glibc-mesboot0)
2177 (name "glibc-headers-mesboot")
2179 (source (bootstrap-origin
2182 (uri (string-append "mirror://gnu/glibc/glibc-"
2185 (patches (search-patches "glibc-boot-2.16.0.patch"
2186 "glibc-bootstrap-system-2.16.0.patch"))
2189 "0vlz4x6cgz7h54qq4528q526qlhnsjzbsvgc4iizn76cb0bfanx7")))))
2190 (native-inputs `(("headers" ,mesboot-headers)
2191 ,@(%boot-mesboot3-inputs)))
2193 (substitute-keyword-arguments (package-arguments glibc-mesboot0)
2194 ((#:configure-flags configure-flags)
2195 `(let ((out (assoc-ref %outputs "out"))
2196 (headers (assoc-ref %build-inputs "headers")))
2198 (string-append "--prefix=" out)
2199 "--disable-obsolete-rpc"
2200 "--host=i686-unknown-linux-gnu"
2201 (string-append "--with-headers=" headers "/include")
2202 "--enable-static-nss"
2206 "--enable-add-ons=nptl"
2207 ;; avoid: configure: error: confusing output from nm -u
2208 "libc_cv_predef_stack_protector=no")))
2209 ((#:make-flags make-flags)
2210 '(list "install-bootstrap-headers=yes" "install-headers"))
2212 `(modify-phases ,phases
2213 (delete 'apply-boot-patch)
2214 (delete 'fixup-configure)
2217 (lambda* (#:key source #:allow-other-keys)
2218 (invoke "tar" "xvf" source)
2219 (chdir (string-append "glibc-" ,version))
2222 (lambda* (#:key inputs #:allow-other-keys)
2223 (let* ((headers (assoc-ref inputs "headers"))
2224 (libc (assoc-ref inputs "libc"))
2225 (gcc (assoc-ref inputs "gcc"))
2226 (cppflags (string-append
2227 " -I " (getcwd) "/nptl/sysdeps/pthread/bits"
2228 " -D BOOTSTRAP_GLIBC=1"))
2229 (cflags (string-append " -L " (getcwd)
2230 " -L " libc "/lib")))
2231 (setenv "libc_cv_friendly_stddef" "yes")
2232 (setenv "CONFIG_SHELL" (which "sh"))
2233 (setenv "SHELL" (which "sh"))
2235 (setenv "CPP" (string-append gcc "/bin/gcc -E " cppflags))
2236 (setenv "CC" (string-append gcc "/bin/gcc " cppflags cflags))
2239 ;; avoid -fstack-protector
2240 (setenv "libc_cv_ssp" "false")
2241 (substitute* "configure"
2242 (("/bin/pwd") "pwd"))
2245 (lambda* (#:key outputs make-flags #:allow-other-keys)
2246 (let ((kernel-headers (assoc-ref %build-inputs "kernel-headers"))
2247 (out (assoc-ref outputs "out")))
2248 (and (apply invoke "make" make-flags)
2249 (copy-recursively kernel-headers out)
2252 (lambda* (#:key configure-flags #:allow-other-keys)
2253 (format (current-error-port) "running ../configure ~a\n" (string-join configure-flags))
2256 (apply invoke "../configure" configure-flags)))
2257 (add-after 'configure 'remove-sunrpc
2259 (let* ((out (assoc-ref %outputs "out"))
2260 (bash (assoc-ref %build-inputs "bash"))
2261 (shell (string-append bash "/bin/bash")))
2263 (let ((Makefile (open-file "Makefile" "a")))
2264 (display (string-append "
2270 (substitute* "../Makefile"
2271 (("^SHELL := /bin/sh") (string-append "SHELL := " shell)))
2272 (substitute* "../Makeconfig"
2273 (("^SHELL := /bin/sh") (string-append "SHELL := " shell)))
2274 (substitute* "../elf/Makefile"
2275 (("^SHELL := /bin/sh") (string-append "SHELL := " shell)))
2276 (invoke "make" (string-append (getcwd) "/sysd-sorted" ))
2277 (substitute* "sysd-sorted"
2282 (define glibc-mesboot
2284 (inherit glibc-headers-mesboot)
2285 (name "glibc-mesboot")
2286 (native-inputs `(("headers" ,glibc-headers-mesboot)
2287 ,@(%boot-mesboot3-inputs)))
2289 `(#:validate-runpath? #f ; fails when using --enable-shared
2290 ,@(substitute-keyword-arguments (package-arguments glibc-headers-mesboot)
2291 ((#:make-flags make-flags)
2292 `(let ((bash (assoc-ref %build-inputs "bash")))
2293 (list (string-append "SHELL=" bash "/bin/sh"))))
2295 `(modify-phases ,phases
2297 (lambda* (#:key outputs make-flags #:allow-other-keys)
2298 (let* ((kernel-headers (assoc-ref %build-inputs "kernel-headers"))
2299 (out (assoc-ref outputs "out"))
2300 (install-flags (cons "install" make-flags)))
2301 (and (apply invoke "make" install-flags)
2302 (copy-recursively kernel-headers out)
2305 (define (%boot-mesboot4-inputs)
2306 `(("libc" ,glibc-mesboot)
2307 ,@(alist-delete "libc" (%boot-mesboot3-inputs))))
2309 (define gcc-mesboot1-wrapper
2310 ;; We need this so gcc-mesboot1 can be used to create shared binaries that
2311 ;; have the correct interpreter, otherwise configuring gcc-mesboot using
2312 ;; --enable-shared will fail.
2314 (inherit gcc-mesboot1)
2315 (name "gcc-mesboot1-wrapper")
2318 (native-inputs `(("bash" ,bash-mesboot)
2319 ("coreutils" ,coreutils-mesboot0)
2320 ("libc" ,glibc-mesboot)
2321 ("gcc" ,gcc-mesboot1)))
2323 `(#:implicit-inputs? #f
2324 #:guile ,%bootstrap-guile
2326 (modify-phases %standard-phases
2331 (lambda* (#:key outputs #:allow-other-keys)
2332 (let* ((out (assoc-ref outputs "out"))
2333 (bash (assoc-ref %build-inputs "bash"))
2334 (libc (assoc-ref %build-inputs "libc"))
2335 (gcc (assoc-ref %build-inputs "gcc"))
2336 (bin (string-append out "/bin")))
2340 (let ((wrapper (string-append bin "/" program)))
2341 (with-output-to-file wrapper
2343 (display (string-append "#! " bash "/bin/bash
2344 exec " gcc "/bin/" program
2345 " -Wl,--dynamic-linker"
2346 ;; also for x86_64-linux, we are still on i686-linux
2347 " -Wl," libc ,(glibc-dynamic-linker "i686-linux")
2352 (chmod wrapper #o555)))))
2356 "i686-unknown-linux-gnu-cpp"
2357 "i686-unknown-linux-gnu-gcc"
2358 "i686-unknown-linux-gnu-g++"))
2361 (lambda* (#:key outputs #:allow-other-keys)
2362 (let* ((out (assoc-ref outputs "out"))
2363 (bin (string-append out "/bin"))
2364 (program (string-append bin "/gcc")))
2365 (invoke program "--help")))))))))
2369 (inherit gcc-mesboot1)
2370 (name "gcc-mesboot")
2371 (version (package-version gcc-4.9))
2372 (source (bootstrap-origin (package-source gcc-4.9)))
2373 (native-inputs `(("gcc-wrapper" ,gcc-mesboot1-wrapper)
2374 ("gcc" ,gcc-mesboot1)
2375 ("headers" ,glibc-headers-mesboot)
2376 ,@(%boot-mesboot4-inputs)))
2378 `(#:validate-runpath? #f
2379 ,@(substitute-keyword-arguments (package-arguments gcc-mesboot1)
2380 ((#:configure-flags configure-flags)
2381 `(let ((out (assoc-ref %outputs "out"))
2382 (glibc (assoc-ref %build-inputs "libc")))
2383 (list (string-append "--prefix=" out)
2384 "--build=i686-unknown-linux-gnu"
2385 "--host=i686-unknown-linux-gnu"
2387 "--with-host-libstdcxx=-lsupc++"
2389 (string-append "--with-native-system-header-dir=" glibc "/include")
2390 (string-append "--with-build-sysroot=" glibc "/include")
2392 "--disable-bootstrap"
2393 "--disable-decimal-float"
2394 "--disable-libatomic"
2395 "--disable-libcilkrts"
2398 "--disable-libmudflap"
2399 "--disable-libquadmath"
2400 "--disable-libsanitizer"
2404 "--disable-lto-plugin"
2405 "--disable-multilib"
2408 "--enable-languages=c,c++"
2412 "--enable-threads=single"
2414 ;; No pre-compiled libstdc++ headers, to save space.
2415 "--disable-libstdcxx-pch"
2418 "--disable-build-with-cxx")))
2420 `(modify-phases ,phases
2421 (delete 'apply-boot-patch)
2422 (delete 'unpack-g++) ; sadly, gcc-4.9.4 does not provide
2423 ; modular core/language downloads
2425 (lambda* (#:key outputs #:allow-other-keys)
2426 (let* ((out (assoc-ref outputs "out"))
2427 (binutils (assoc-ref %build-inputs "binutils"))
2428 (bash (assoc-ref %build-inputs "bash"))
2429 (gcc (assoc-ref %build-inputs "gcc"))
2430 (glibc (assoc-ref %build-inputs "libc"))
2431 (kernel-headers (assoc-ref %build-inputs "kernel-headers")))
2432 (setenv "CONFIG_SHELL" (string-append bash "/bin/sh"))
2433 (setenv "C_INCLUDE_PATH" (string-append
2434 gcc "/lib/gcc-lib/i686-unknown-linux-gnu/4.6.4/include"
2435 ":" kernel-headers "/include"
2436 ":" glibc "/include"
2437 ":" (getcwd) "/mpfr/src"))
2438 (setenv "CPLUS_INCLUDE_PATH" (string-append
2439 gcc "/lib/gcc-lib/i686-unknown-linux-gnu/4.6.4/include"
2440 ":" kernel-headers "/include"
2441 ":" glibc "/include"
2442 ":" (getcwd) "/mpfr/src"))
2443 (setenv "LIBRARY_PATH" (string-append glibc "/lib"
2445 (format (current-error-port) "C_INCLUDE_PATH=~a\n" (getenv "C_INCLUDE_PATH"))
2446 (format (current-error-port) "CPLUS_INCLUDE_PATH=~a\n" (getenv "CPLUS_INCLUDE_PATH"))
2447 (format (current-error-port) "LIBRARY_PATH=~a\n" (getenv "LIBRARY_PATH"))
2450 (define gcc-mesboot-wrapper
2451 ;; We need this so gcc-mesboot can be used to create shared binaries that
2452 ;; have the correct interpreter and runpath to libc.
2454 (inherit gcc-mesboot1-wrapper)
2455 (name "gcc-mesboot-wrapper")
2456 (version (package-version gcc-mesboot))
2459 (native-inputs `(("bash" ,bash-mesboot)
2460 ("coreutils" ,coreutils-mesboot0)
2461 ("libc" ,glibc-mesboot)
2462 ("gcc" ,gcc-mesboot)))))
2464 (define (%boot-mesboot5-inputs)
2465 `(("gcc-wrapper" ,gcc-mesboot-wrapper)
2466 ("gcc" ,gcc-mesboot)
2467 ,@(fold alist-delete (%boot-mesboot4-inputs) '("gcc" "gcc-wrapper"))))
2469 (define coreutils-mesboot
2472 (name "coreutils-mesboot")
2473 (source (bootstrap-origin (package-source coreutils)))
2474 (native-inputs (%boot-mesboot5-inputs))
2475 (supported-systems '("i686-linux" "x86_64-linux"))
2477 (propagated-inputs '())
2479 `(#:implicit-inputs? #f
2480 #:guile ,%bootstrap-guile
2483 (define (%boot-mesboot6-inputs)
2484 `(("coreutils" ,coreutils-mesboot)
2485 ,@(fold alist-delete (%boot-mesboot5-inputs)
2486 '("coreutils" "kernel-headers"))))
2488 (define (%bootstrap-inputs+toolchain)
2489 ;; The traditional bootstrap-inputs. For the i686-linux, x86_64-linux
2490 ;; Scheme-only bootstrap the actual reduced set with bootstrapped toolchain.
2491 (match (%current-system)
2492 ((or "i686-linux" "x86_64-linux")
2493 (%boot-mesboot6-inputs))
2495 (%bootstrap-inputs))))
2497 (define gnu-make-boot0
2500 (source (bootstrap-origin (package-source gnu-make)))
2503 `(#:guile ,%bootstrap-guile
2504 #:implicit-inputs? #f
2505 #:tests? #f ; cannot run "make check"
2506 ,@(substitute-keyword-arguments (package-arguments gnu-make)
2507 ((#:configure-flags flags ''())
2508 ;; The generated config.status has some problems due to the
2509 ;; bootstrap environment. Disable dependency tracking to work
2511 `(cons "--disable-dependency-tracking" ,flags))
2513 `(modify-phases ,phases
2516 (invoke "./build.sh")))
2518 (lambda* (#:key outputs #:allow-other-keys)
2519 (let* ((out (assoc-ref outputs "out"))
2520 (bin (string-append out "/bin")))
2521 (install-file "make" bin)
2523 (native-inputs '()) ; no need for 'pkg-config'
2524 (inputs (%bootstrap-inputs+toolchain))))
2529 (name "bzip2-boot0")
2532 `(("diffutils" ,diffutils-boot0)
2533 ("make" ,gnu-make-boot0)
2534 ,@(%bootstrap-inputs+toolchain)))
2536 `(#:guile ,%bootstrap-guile
2537 #:implicit-inputs? #f
2538 ,@(package-arguments bzip2)))))
2540 (define coreutils-boot0
2543 (source (bootstrap-origin (package-source coreutils)))
2544 (name "coreutils-boot0")
2547 `(("make" ,gnu-make-boot0)
2548 ,@(%bootstrap-inputs+toolchain)))
2551 #:implicit-inputs? #f
2552 #:guile ,%bootstrap-guile
2553 ,@(package-arguments coreutils)))))
2555 (define diffutils-boot0
2558 (name "diffutils-boot0")
2561 `(("make" ,gnu-make-boot0)
2562 ,@(%bootstrap-inputs+toolchain)))
2564 `(#:tests? #f ; the test suite needs diffutils
2565 #:guile ,%bootstrap-guile
2566 #:implicit-inputs? #f
2567 ,@(match (%current-system)
2568 ((or "arm-linux" "aarch64-linux")
2569 (substitute-keyword-arguments (package-arguments diffutils)
2570 ((#:configure-flags flags ''())
2571 ;; The generated config.status has some problems due to the
2572 ;; bootstrap environment. Disable dependency tracking to work
2574 `(cons "--disable-dependency-tracking" ,flags))))
2577 (define findutils-boot0
2580 (name "findutils-boot0")
2581 (source (bootstrap-origin (package-source findutils)))
2583 `(("make" ,gnu-make-boot0)
2584 ("diffutils" ,diffutils-boot0) ; for tests
2585 ,@(%bootstrap-inputs+toolchain)))
2587 `(#:implicit-inputs? #f
2588 #:guile ,%bootstrap-guile
2590 ;; The build system assumes we have done a mistake when time_t is 32-bit
2591 ;; on a 64-bit system. Ignore that for our bootstrap toolchain.
2592 ,@(substitute-keyword-arguments (package-arguments findutils)
2593 ((#:configure-flags flags ''())
2595 ,(if (target-64bit?)
2596 ''("TIME_T_32_BIT_OK=yes")
2598 ,(match (%current-system)
2599 ((or "arm-linux" "aarch64-linux")
2600 ''("--disable-dependency-tracking"))
2606 (inherit (@ (gnu packages file) file))
2610 ,,@(match (%current-system)
2611 ((or "arm-linux" "aarch64-linux")
2612 '("--disable-dependency-tracking"))
2618 (source (bootstrap-origin (package-source file)))
2621 `(("make" ,gnu-make-boot0)
2622 ,@(%bootstrap-inputs+toolchain)))
2624 `(#:tests? #f ; merge test fails
2625 #:implicit-inputs? #f
2626 #:guile ,%bootstrap-guile
2627 #:configure-flags '("--disable-bzlib")
2628 #:strip-binaries? #f
2629 #:validate-runpath? #f
2630 ,@(package-arguments file)))))
2635 (source (bootstrap-origin (package-source gawk)))
2639 `(("make" ,gnu-make-boot0)
2640 ,@(%bootstrap-inputs+toolchain)))
2643 #:implicit-inputs? #f
2644 #:guile ,%bootstrap-guile
2645 #:strip-binaries? #f
2646 #:validate-runpath? #f))))
2651 (source (bootstrap-origin (package-source patch)))
2652 (name "patch-boot0")
2655 `(("make" ,gnu-make-boot0)
2656 ,@(%bootstrap-inputs+toolchain)))
2658 `(#:tests? #f ; merge test fails
2659 #:implicit-inputs? #f
2660 #:guile ,%bootstrap-guile
2661 #:strip-binaries? #f
2662 #:validate-runpath? #f))))
2668 (source (bootstrap-origin (package-source sed)))
2671 `(("make" ,gnu-make-boot0)
2672 ,@(%bootstrap-inputs+toolchain)))
2674 `(#:implicit-inputs? #f
2676 #:guile ,%bootstrap-guile
2677 ,@(package-arguments sed)))))
2683 (source (bootstrap-origin (package-source tar)))
2686 `(("make" ,gnu-make-boot0)
2687 ,@(%bootstrap-inputs+toolchain)))
2689 `(#:implicit-inputs? #f
2691 #:guile ,%bootstrap-guile
2692 ,@(package-arguments tar)))))
2694 (define (%boot0-inputs)
2695 `(,@(match (%current-system)
2696 ((or "i686-linux" "x86_64-linux")
2697 `(("bzip2" ,bzip2-boot0)
2698 ("coreutils" ,coreutils-boot0)
2699 ("gawk" ,gawk-boot0)
2700 ("patch" ,patch-boot0)
2702 ("tar" ,tar-boot0)))
2704 ("make" ,gnu-make-boot0)
2705 ("diffutils" ,diffutils-boot0)
2706 ("findutils" ,findutils-boot0)
2707 ("file" ,file-boot0)
2708 ,@(%bootstrap-inputs+toolchain)))
2710 (define* (boot-triplet #:optional (system (%current-system)))
2711 ;; Return the triplet used to create the cross toolchain needed in the
2712 ;; first bootstrapping stage.
2713 (nix-system->gnu-triplet system "guix"))
2715 ;; Following Linux From Scratch, build a cross-toolchain in stage 0. That
2716 ;; toolchain actually targets the same OS and arch, but it has the advantage
2717 ;; of being independent of the libc and tools in
2718 ;; (%BOOTSTRAP-INPUTS+TOOLCHAIN), since GCC-BOOT0 (below) is built without any
2719 ;; reference to the target libc.
2721 (define binutils-boot0
2724 (source (bootstrap-origin (package-source binutils)))
2725 (name "binutils-cross-boot0")
2727 `(#:guile ,%bootstrap-guile
2728 #:implicit-inputs? #f
2730 #:modules ((guix build gnu-build-system)
2732 (ice-9 ftw)) ; for 'scandir'
2733 #:phases (modify-phases %standard-phases
2734 (add-after 'install 'add-symlinks
2735 (lambda* (#:key outputs #:allow-other-keys)
2736 ;; The cross-gcc invokes 'as', 'ld', etc, without the
2737 ;; triplet prefix, so add symlinks.
2738 (let ((out (assoc-ref outputs "out"))
2739 (triplet-prefix (string-append ,(boot-triplet) "-")))
2740 (define (has-triplet-prefix? name)
2741 (string-prefix? triplet-prefix name))
2742 (define (remove-triplet-prefix name)
2743 (substring name (string-length triplet-prefix)))
2744 (with-directory-excursion (string-append out "/bin")
2745 (for-each (lambda (name)
2746 (symlink name (remove-triplet-prefix name)))
2747 (scandir "." has-triplet-prefix?)))
2750 ,@(substitute-keyword-arguments (package-arguments binutils)
2751 ((#:configure-flags cf)
2752 `(cons ,(string-append "--target=" (boot-triplet))
2754 (inputs (%boot0-inputs))))
2756 (define libstdc++-boot0
2757 ;; GCC's libcc1 is always built as a shared library (the top-level
2758 ;; 'Makefile.def' forcefully adds --enable-shared) and thus needs to refer
2759 ;; to libstdc++.so. We cannot build libstdc++-5.3 because it relies on
2760 ;; C++14 features missing in some of our bootstrap compilers.
2761 (let ((lib (make-libstdc++ gcc-4.9)))
2764 (source (bootstrap-origin (package-source lib)))
2765 (name "libstdc++-boot0")
2767 `(#:guile ,%bootstrap-guile
2768 #:implicit-inputs? #f
2770 ;; XXX: libstdc++.so NEEDs ld.so for some reason.
2771 #:validate-runpath? #f
2773 ,@(match (%current-system)
2774 ((or "i686-linux" "x86_64-linux")
2775 (substitute-keyword-arguments (package-arguments lib)
2777 `(modify-phases ,phases
2778 (add-after 'unpack 'workaround-wrapper-bug
2779 ;; XXX: The crude gcc-cross-wrapper causes "g++ -v" to
2780 ;; fail, which in turn confuses the configure script.
2782 (substitute* "libstdc++-v3/configure"
2783 (("g\\+\\+ -v") "true"))
2785 (_ (package-arguments lib)))))
2786 (inputs (%boot0-inputs))
2787 (native-inputs '()))))
2792 (name "gcc-cross-boot0")
2793 (source (bootstrap-origin (package-source gcc)))
2795 `(#:guile ,%bootstrap-guile
2796 #:implicit-inputs? #f
2797 #:modules ((guix build gnu-build-system)
2802 ,@(substitute-keyword-arguments (package-arguments gcc)
2803 ((#:configure-flags flags)
2804 `(append (list ,(string-append "--target=" (boot-triplet))
2809 ;; Disable features not needed at this stage.
2811 "--enable-languages=c,c++"
2813 ;; libstdc++ cannot be built at this stage
2814 ;; ("Link tests are not allowed after
2815 ;; GCC_NO_EXECUTABLES.").
2816 "--disable-libstdc++-v3"
2819 "--disable-libmudflap"
2820 "--disable-libatomic"
2821 "--disable-libsanitizer"
2825 "--disable-libcilkrts"
2828 "--disable-libquadmath"
2829 "--disable-decimal-float")
2830 (remove (cut string-match
2831 "--(with-system-zlib|enable-languages.*)" <>)
2833 ((#:make-flags flags)
2834 `(let* ((libc (assoc-ref %build-inputs "libc"))
2835 (libc-native (or (assoc-ref %build-inputs "libc-native")
2837 `(,(string-append "LDFLAGS="
2838 "-Wl,-rpath=" libc-native "/lib "
2839 "-Wl,-dynamic-linker "
2840 "-Wl," libc-native ,(glibc-dynamic-linker
2841 (match (%current-system)
2842 ("x86_64-linux" "i686-linux")
2843 (_ (%current-system))))))))
2845 `(modify-phases ,phases
2846 (add-after 'unpack 'unpack-gmp&co
2847 (lambda* (#:key inputs #:allow-other-keys)
2848 (let ((gmp (assoc-ref %build-inputs "gmp-source"))
2849 (mpfr (assoc-ref %build-inputs "mpfr-source"))
2850 (mpc (assoc-ref %build-inputs "mpc-source")))
2852 ;; To reduce the set of pre-built bootstrap inputs, build
2853 ;; GMP & co. from GCC.
2854 (for-each (lambda (source)
2855 (invoke "tar" "xvf" source))
2856 (list gmp mpfr mpc))
2858 ;; Create symlinks like `gmp' -> `gmp-x.y.z'.
2859 ,@(map (lambda (lib)
2860 ;; Drop trailing letters, as gmp-6.0.0a unpacks
2862 `(symlink ,(string-trim-right
2863 (package-full-name lib "-")
2865 ,(package-name lib)))
2866 (list gmp-6.0 mpfr mpc))
2868 ,(match (%current-system)
2869 ((or "i686-linux" "x86_64-linux")
2870 '(add-before 'configure 'fix-libcc1
2871 (lambda* (#:key inputs #:allow-other-keys)
2872 ;; libcc1.so NEEDs libgcc_s.so, so provide one here
2873 ;; to placate the 'validate-runpath' phase.
2874 (substitute* "libcc1/Makefile.in"
2876 (string-append "la_LDFLAGS = -Wl,-rpath="
2877 (assoc-ref inputs "gcc") "/lib")))
2878 ;; XXX: "g++ -v" is broken (see also libstdc++ above).
2879 (substitute* "libcc1/configure"
2880 (("g\\+\\+ -v") "true"))
2882 (_ '(add-before 'configure 'return-true
2884 (add-after 'install 'symlink-libgcc_eh
2885 (lambda* (#:key outputs #:allow-other-keys)
2886 (let ((out (assoc-ref outputs "lib")))
2887 ;; Glibc wants to link against libgcc_eh, so provide
2889 (with-directory-excursion
2890 (string-append out "/lib/gcc/"
2892 "/" ,(package-version gcc))
2893 (symlink "libgcc.a" "libgcc_eh.a"))
2896 (inputs `(("gmp-source" ,(bootstrap-origin (package-source gmp-6.0)))
2897 ("mpfr-source" ,(bootstrap-origin (package-source mpfr)))
2898 ("mpc-source" ,(bootstrap-origin (package-source mpc)))
2899 ("binutils-cross" ,binutils-boot0)
2901 ;; The libstdc++ that libcc1 links against.
2902 ("libstdc++" ,libstdc++-boot0)
2904 ;; Call it differently so that the builder can check whether
2905 ;; the "libc" input is #f.
2906 ("libc-native" ,@(assoc-ref (%boot0-inputs) "libc"))
2907 ,@(alist-delete "libc" (%boot0-inputs))))
2909 ;; No need for the native-inputs to build the documentation at this stage.
2910 (native-inputs `())))
2916 (source (bootstrap-origin (package-source perl)))
2917 (inputs (%boot0-inputs))
2919 `(#:implicit-inputs? #f
2920 #:guile ,%bootstrap-guile
2921 #:validate-runpath? #f
2923 ;; At the very least, this must not depend on GCC & co.
2924 #:disallowed-references ,(list %bootstrap-binutils)
2926 ,@(substitute-keyword-arguments (package-arguments perl)
2928 `(modify-phases ,phases
2929 ;; Pthread support is missing in the bootstrap compiler
2930 ;; (broken spec file), so disable it.
2931 (add-before 'configure 'disable-pthreads
2933 (substitute* "Configure"
2934 (("^libswanted=(.*)pthread" _ before)
2935 (string-append "libswanted=" before)))
2937 ;; Do not configure with '-Dusethreads' since pthread
2938 ;; support is missing.
2939 ((#:configure-flags configure-flags)
2940 `(delete "-Dusethreads" ,configure-flags)))))))
2946 (source (bootstrap-origin (package-source m4)))
2947 (inputs (%boot0-inputs))
2949 `(#:guile ,%bootstrap-guile
2950 #:implicit-inputs? #f
2951 ,@(package-arguments m4)))))
2954 ;; This Bison is needed to build MiG so we need it early in the process.
2955 ;; Recent versions of Linux-Libre headers also depend on this.
2958 (name "bison-boot0")
2959 (propagated-inputs `(("m4" ,m4-boot0)))
2960 (native-inputs `(("perl" ,perl-boot0)))
2961 (inputs (%boot0-inputs)) ;remove Flex...
2963 `(#:tests? #f ;... and thus disable tests
2964 #:implicit-inputs? #f
2965 #:guile ,%bootstrap-guile
2967 ;; Zero timestamps in liby.a; this must be done
2968 ;; explicitly here because the bootstrap Binutils don't
2969 ;; do that (default is "cru".)
2970 #:make-flags `("ARFLAGS=crD"
2971 ,,(match (%current-system)
2972 ;; ranlib: '-D': No such file
2973 ((or "i686-linux" "x86_64-linux")
2976 "RANLIB=ranlib -D"))
2979 ,@(package-arguments bison)))))
2982 ;; This Flex is needed to build MiG as well as Linux-Libre headers.
2985 (native-inputs `(("bison" ,bison-boot0)))
2986 (propagated-inputs `(("m4" ,m4-boot0)))
2987 (inputs (%boot0-inputs))
2989 `(#:implicit-inputs? #f
2990 #:guile ,%bootstrap-guile
2996 (native-inputs `(("perl" ,perl-boot0)))
2997 (inputs (%boot0-inputs))
2999 `(#:implicit-inputs? #f
3000 #:guile ,%bootstrap-guile))))
3002 (define-syntax define/system-dependent
3004 "Bind IDENTIFIER to EXP, where the value of EXP is known to depend on
3005 '%current-system'. The definition ensures that (1) EXP is \"thunked\" so that
3006 it sees the right value of '%current-system', and (2) that its result is
3007 memoized as a function of '%current-system'."
3010 (with-syntax ((memoized (datum->syntax #'identifier
3012 (syntax->datum #'identifier)
3016 (mlambda (system) exp))
3017 (define-syntax identifier
3018 (identifier-syntax (memoized (%current-system))))))))))
3020 (define/system-dependent linux-libre-headers-boot0
3021 ;; Note: this is wrapped in a thunk to nicely handle circular dependencies
3022 ;; between (gnu packages linux) and this module. Additionally, memoize
3023 ;; the result to play well with further memoization and code that relies
3024 ;; on pointer identity; see <https://bugs.gnu.org/30155>.
3026 (inherit linux-libre-headers)
3028 `(#:guile ,%bootstrap-guile
3029 #:implicit-inputs? #f
3030 ,@(package-arguments linux-libre-headers)))
3032 `(("perl" ,perl-boot0)
3034 ;; Flex and Bison are required since version 4.16.
3035 ("flex" ,flex-boot0)
3036 ("bison" ,bison-boot0)
3038 ;; Rsync is required since version 5.3.
3039 ("rsync" ,rsync-boot0)
3040 ,@(%boot0-inputs)))))
3043 (package-with-explicit-inputs %boot0-inputs
3046 (define gnumach-headers-boot0
3048 (package-with-bootstrap-guile
3050 (inherit gnumach-headers)
3051 (version "1.8-116-g28b53508")
3052 (source (bootstrap-origin
3055 (uri (string-append "https://lilypond.org/janneke/hurd/"
3056 "gnumach-" version ".tar.gz"))
3059 "006i0zgwy81vxarpfm12vip4q6i5mgmi5mmy5ldvxp5hx9h3l0zg")))))
3060 (native-inputs '())))))
3063 (let* ((mig (package
3064 (inherit (package-with-bootstrap-guile mig))
3065 (native-inputs `(("bison" ,bison-boot0)
3066 ("flex" ,flex-boot0)))
3067 (inputs `(("flex" ,flex-boot0)))
3070 `(,(string-append "LDFLAGS=-Wl,-rpath="
3071 (assoc-ref %build-inputs "flex") "/lib/")))))))
3074 (define hurd-version-boot0 "0.9-229-ga1efcee8")
3075 (define hurd-source-boot0
3076 (let ((version hurd-version-boot0))
3080 (uri (string-append "https://lilypond.org/janneke/hurd/"
3081 "hurd-v" version ".tar.gz"))
3084 "0bq2q2jisxcy0kgcm6rz0z2fddwxxm7azsama7li28a2m08kdpzy"))))))
3086 (define hurd-headers-boot0
3087 (let ((hurd-headers (package (inherit hurd-headers)
3088 (version hurd-version-boot0)
3089 (source hurd-source-boot0)
3090 (native-inputs `(("mig" ,mig-boot0)))
3092 (with-boot0 (package-with-bootstrap-guile hurd-headers))))
3094 (define hurd-minimal-boot0
3095 (let ((hurd-minimal (package (inherit hurd-minimal)
3096 (version hurd-version-boot0)
3097 (source hurd-source-boot0)
3098 (native-inputs `(("mig" ,mig-boot0)))
3100 (with-boot0 (package-with-bootstrap-guile hurd-minimal))))
3102 (define/system-dependent hurd-core-headers-boot0
3103 ;; Return the Hurd and Mach headers as well as initial Hurd libraries for
3104 ;; the bootstrap environment.
3105 (package (inherit (package-with-bootstrap-guile hurd-core-headers))
3106 (arguments `(#:guile ,%bootstrap-guile
3107 ,@(package-arguments hurd-core-headers)))
3109 `(("gnumach-headers" ,gnumach-headers-boot0)
3110 ("hurd-headers" ,hurd-headers-boot0)
3111 ("hurd-minimal" ,hurd-minimal-boot0)
3112 ,@(%boot0-inputs)))))
3114 (define* (kernel-headers-boot0 #:optional (system (%current-system)))
3116 ("i586-gnu" hurd-core-headers-boot0)
3117 (_ linux-libre-headers-boot0)))
3119 (define texinfo-boot0
3120 ;; Texinfo used to build libc's manual.
3121 ;; We build without ncurses because it fails to build at this stage, and
3122 ;; because we don't need the stand-alone Info reader.
3123 ;; Also, use (%BOOT0-INPUTS) to avoid building Perl once more.
3127 (inputs `(,@(%boot0-inputs)
3128 ("perl" ,perl-boot0)))
3130 `(#:implicit-inputs? #f
3131 #:guile ,%bootstrap-guile
3133 ;; Some of Texinfo 6.1's tests would fail with "Couldn't set UTF-8
3134 ;; character type in locale" but we don't have a UTF-8 locale at this
3135 ;; stage, so skip them.
3138 (define expat-sans-tests
3141 (inputs (%boot0-inputs))
3143 ;; XXX: Linking 'runtestscpp' fails with things like:
3145 ;; ld: Dwarf Error: found dwarf version '3789', this reader only handles version 2 and 3 information.
3147 ;; Skip tests altogether.
3148 `(#:implicit-inputs? #f
3149 #:guile ,%bootstrap-guile
3151 ,@(substitute-keyword-arguments (package-arguments expat)
3152 ((#:configure-flags flags ''())
3153 ;; Since we're not passing the right -Wl,-rpath flags, build the
3154 ;; static library to avoid RUNPATH validation failure.
3155 `(cons "--disable-shared" ,flags))
3156 ((#:tests? _ #f) #f))))))
3158 (define python-boot0
3160 (inherit python-minimal)
3161 ;; We cannot use Python 3.7 and later here, because they require
3162 ;; pthreads, which is missing on non-x86 platforms at this stage.
3163 ;; Python 3.6 technically supports being built without threading
3164 ;; support, but requires additional patches.
3166 (source (bootstrap-origin
3169 (uri (string-append "https://www.python.org/ftp/python/"
3170 version "/Python-" version ".tar.xz"))
3173 "0jdh9pvx6m6lfz2liwvvhn7vks7qrysqgwn517fkpxb77b33fjn2"))
3174 (modules '((guix build utils)))
3177 ;; Delete the bundled copy of libexpat.
3178 (delete-file-recursively "Modules/expat")
3179 (substitute* "Modules/Setup.dist"
3180 ;; Link Expat instead of embedding the bundled one.
3181 (("^#pyexpat.*") "pyexpat pyexpat.c -lexpat\n"))
3185 ("expat" ,expat-sans-tests))) ;remove OpenSSL, zlib, etc.
3186 (native-inputs '()) ;and pkg-config
3188 `(#:implicit-inputs? #f
3189 #:guile ,%bootstrap-guile
3191 ,@(substitute-keyword-arguments (package-arguments python-minimal)
3192 ;; Disable features that cannot be built at this stage.
3193 ((#:configure-flags _ ''())
3194 `(list "--without-ensurepip"
3195 "--without-threads"))
3196 ;; Clear #:make-flags, such that changes to the regular
3197 ;; Python package won't interfere with this one.
3198 ((#:make-flags _ ''()) ''())
3200 ;; Remove the 'apply-alignment-patch' phase if present to avoid
3201 ;; rebuilding this package. TODO: for the next rebuild cycle,
3202 ;; consider inlining all the arguments instead of inheriting to
3203 ;; make it easier to patch Python without risking a full rebuild.
3204 ;; Or better yet, change to 'python-on-guile'.
3205 `(modify-phases ,@(list (match phases
3206 (('modify-phases original-phases
3208 ('add-after unpack apply-alignment-patch _))
3209 `(modify-phases ,original-phases ,@changes))
3211 (add-before 'configure 'disable-modules
3213 (substitute* "setup.py"
3214 ;; Disable ctypes, since it requires libffi.
3215 (("extensions\\.append\\(ctypes\\)") "")
3216 ;; Prevent the 'ossaudiodev' extension from being
3217 ;; built, since it requires Linux headers.
3221 ,@(if (hurd-system?)
3222 `((add-before 'build 'fix-regen
3223 (lambda* (#:key inputs #:allow-other-keys)
3224 (let ((libc (assoc-ref inputs "libc")))
3225 (substitute* "Lib/plat-generic/regen"
3226 (("/usr/include/") (string-append libc "/include/")))
3229 ((#:tests? _ #f) #f))))))
3231 (define/system-dependent ld-wrapper-boot0
3232 ;; The first 'ld' wrapper, defined with 'define/system-dependent' because
3233 ;; its calls '%boot0-inputs', whose result depends on (%current-system)
3235 ;; We need this so binaries on Hurd will have libmachuser and libhurduser
3236 ;; in their RUNPATH, otherwise validate-runpath will fail.
3237 (make-ld-wrapper "ld-wrapper-boot0"
3238 #:target boot-triplet
3239 #:binutils binutils-boot0
3240 #:guile %bootstrap-guile
3241 #:bash (car (assoc-ref (%boot0-inputs) "bash"))
3242 #:guile-for-build %bootstrap-guile))
3244 (define (%boot1-inputs)
3245 ;; 2nd stage inputs.
3246 `(("gcc" ,gcc-boot0)
3247 ("ld-wrapper-cross" ,ld-wrapper-boot0)
3248 ("binutils-cross" ,binutils-boot0)
3249 ,@(alist-delete "binutils" (%boot0-inputs))))
3251 (define glibc-final-with-bootstrap-bash
3252 ;; The final libc, "cross-built". If everything went well, the resulting
3253 ;; store path has no dependencies. Actually, the really-final libc is
3254 ;; built just below; the only difference is that this one uses the
3258 (name "glibc-intermediate")
3259 (source (bootstrap-origin (package-source glibc)))
3261 `(#:guile ,%bootstrap-guile
3262 #:implicit-inputs? #f
3264 ,@(substitute-keyword-arguments (package-arguments glibc)
3265 ((#:configure-flags flags)
3266 `(append (list ,(string-append "--host=" (boot-triplet))
3267 ,(string-append "--build="
3268 (nix-system->gnu-triplet))
3269 ,(if (hurd-system?) "--disable-werror"
3273 `(modify-phases ,phases
3274 (add-before 'configure 'pre-configure
3275 (lambda* (#:key inputs #:allow-other-keys)
3276 ;; Don't clobber CPATH with the bootstrap libc.
3277 (setenv "NATIVE_CPATH" (getenv "CPATH"))
3280 ;; Tell 'libpthread' where to find 'libihash' on Hurd systems.
3281 ,@(if (hurd-system?)
3282 '((substitute* '("sysdeps/mach/Makefile"
3283 "sysdeps/mach/hurd/Makefile")
3284 (("LDLIBS-pthread.so =.*")
3285 (string-append "LDLIBS-pthread.so = "
3286 (assoc-ref %build-inputs "kernel-headers")
3287 "/lib/libihash.a\n"))))
3290 ;; 'rpcgen' needs native libc headers to be built.
3291 (substitute* "sunrpc/Makefile"
3292 (("sunrpc-CPPFLAGS =.*" all)
3293 (string-append "CPATH = $(NATIVE_CPATH)\n"
3297 (propagated-inputs `(("kernel-headers" ,(kernel-headers-boot0))))
3299 `(("bison" ,bison-boot0)
3300 ("texinfo" ,texinfo-boot0)
3301 ("perl" ,perl-boot0)
3302 ("python" ,python-boot0)))
3304 `( ;; The boot inputs. That includes the bootstrap libc. We don't want
3305 ;; it in $CPATH, hence the 'pre-configure' phase above.
3308 ;; A native MiG is needed to build Glibc on Hurd.
3309 ,@(if (hurd-system?)
3310 `(("mig" ,mig-boot0))
3313 ;; A native GCC is needed to build `cross-rpcgen'.
3314 ("native-gcc" ,@(assoc-ref (%boot0-inputs) "gcc"))
3316 ;; Here, we use the bootstrap Bash, which is not satisfactory
3317 ;; because we don't want to depend on bootstrap tools.
3318 ("static-bash" ,@(assoc-ref (%boot0-inputs) "bash"))))))
3320 (define (cross-gcc-wrapper gcc binutils glibc bash)
3321 "Return a wrapper for the pseudo-cross toolchain GCC/BINUTILS/GLIBC
3322 that makes it available under the native tool names."
3323 (package (inherit gcc)
3324 (name (string-append (package-name gcc) "-wrapped"))
3326 (build-system trivial-build-system)
3329 `(#:guile ,%bootstrap-guile
3330 #:modules ((guix build utils))
3332 (use-modules (guix build utils))
3334 (let* ((binutils (assoc-ref %build-inputs "binutils"))
3335 (gcc (assoc-ref %build-inputs "gcc"))
3336 (libc (assoc-ref %build-inputs "libc"))
3337 (bash (assoc-ref %build-inputs "bash"))
3338 (out (assoc-ref %outputs "out"))
3339 (bindir (string-append out "/bin"))
3340 (triplet ,(boot-triplet)))
3341 (define (wrap-program program)
3342 ;; GCC-BOOT0 is a libc-less cross-compiler, so it
3343 ;; needs to be told where to find the crt files and
3344 ;; the dynamic linker.
3345 (call-with-output-file program
3347 (format p "#!~a/bin/bash
3348 exec ~a/bin/~a-~a -B~a/lib -Wl,-dynamic-linker -Wl,~a/~a \"$@\"~%"
3352 ,(glibc-dynamic-linker))))
3354 (chmod program #o555))
3357 (with-directory-excursion bindir
3358 (for-each (lambda (tool)
3359 (symlink (string-append binutils "/bin/"
3363 (for-each wrap-program '("gcc" "g++")))
3367 `(("binutils" ,binutils)
3373 (define/system-dependent gcc-boot0-intermediate-wrapped
3374 ;; Make the cross-tools GCC-BOOT0 and BINUTILS-BOOT0 available under the
3376 (cross-gcc-wrapper gcc-boot0 binutils-boot0
3377 glibc-final-with-bootstrap-bash
3378 (car (assoc-ref (%boot1-inputs) "bash"))))
3380 (define static-bash-for-glibc
3381 ;; A statically-linked Bash to be used by GLIBC-FINAL in system(3) & co.
3383 (inherit static-bash)
3384 (source (bootstrap-origin (package-source static-bash)))
3385 (inputs `(("gcc" ,gcc-boot0-intermediate-wrapped)
3386 ("libc" ,glibc-final-with-bootstrap-bash)
3387 ("libc:static" ,glibc-final-with-bootstrap-bash "static")
3388 ,@(fold alist-delete (%boot1-inputs)
3391 `(#:implicit-inputs? #f
3392 #:guile ,%bootstrap-guile
3394 ,@(substitute-keyword-arguments (package-arguments static-bash)
3395 ((#:configure-flags flags '())
3396 ;; Add a '-L' flag so that the pseudo-cross-ld of
3397 ;; BINUTILS-BOOT0 can find libc.a.
3399 (list (string-append "LDFLAGS=-static -L"
3400 (assoc-ref %build-inputs
3404 (define gettext-boot0
3405 ;; A minimal gettext used during bootstrap.
3407 (inherit gettext-minimal)
3408 (name "gettext-boot0")
3409 ;; Newer versions of GNU gettext depends on libxml2 and ncurses. To
3410 ;; simplify the dependency chain, we stick to this version here.
3411 (version "0.19.8.1")
3414 (uri (string-append "mirror://gnu/gettext/gettext-"
3418 "0hsw28f9q9xaggjlsdp2qmbp2rbd1mp0njzan2ld9kiqwkq2m57z"))))
3419 (inputs (%boot1-inputs)) ;zero dependencies
3421 `(#:implicit-inputs? #f
3422 #:guile ,%bootstrap-guile
3424 #:phases (modify-phases %standard-phases
3425 ;; Build only the tools.
3426 (add-after 'unpack 'chdir
3428 (chdir "gettext-tools")
3431 ;; Some test programs require pthreads, which we don't have.
3432 (add-before 'configure 'no-test-programs
3434 (substitute* "tests/Makefile.in"
3440 ;; The final glibc, which embeds the statically-linked Bash built above.
3441 ;; Use 'package/inherit' so we get the 'replacement' of 'glibc', if any.
3445 (source (bootstrap-origin (package-source glibc)))
3446 (inputs `(("static-bash" ,static-bash-for-glibc)
3449 (package-inputs glibc-final-with-bootstrap-bash))))
3451 ;; This time we need 'msgfmt' to install all the libc.mo files.
3452 (native-inputs `(,@(package-native-inputs glibc-final-with-bootstrap-bash)
3453 ("gettext" ,gettext-boot0)))
3456 (package-propagated-inputs glibc-final-with-bootstrap-bash))
3458 ;; The final libc only refers to itself, but the 'debug' output contains
3459 ;; references to GCC-BOOT0 and to the Linux headers. XXX: Would be great
3460 ;; if 'allowed-references' were per-output.
3462 `(#:allowed-references
3464 ,(kernel-headers-boot0)
3465 ,static-bash-for-glibc
3466 ,@(if (hurd-system?)
3467 `(,gnumach-headers-boot0
3468 ,hurd-headers-boot0)
3470 ,@(package-outputs glibc-final-with-bootstrap-bash))
3471 ,@(package-arguments glibc-final-with-bootstrap-bash)))))
3473 (define/system-dependent gcc-boot0-wrapped
3474 ;; Make the cross-tools GCC-BOOT0 and BINUTILS-BOOT0 available under the
3476 (cross-gcc-wrapper gcc-boot0 binutils-boot0 glibc-final
3477 (car (assoc-ref (%boot1-inputs) "bash"))))
3479 (define (%boot2-inputs)
3480 ;; 3rd stage inputs.
3481 `(("libc" ,glibc-final)
3482 ("libc:static" ,glibc-final "static")
3483 ("gcc" ,gcc-boot0-wrapped)
3484 ,@(fold alist-delete (%boot1-inputs) '("libc" "gcc" "linux-libre-headers"))))
3486 (define binutils-final
3489 (source (bootstrap-origin (package-source binutils)))
3491 `(#:guile ,%bootstrap-guile
3492 #:implicit-inputs? #f
3493 #:allowed-references ("out" ,glibc-final)
3494 ,@(package-arguments binutils)))
3495 (inputs (%boot2-inputs))))
3498 ;; Intermediate libstdc++ that will allow us to build the final GCC
3499 ;; (remember that GCC-BOOT0 cannot build libstdc++.)
3500 (let ((lib (make-libstdc++ gcc)))
3503 (source (bootstrap-origin (package-source lib)))
3505 `(#:guile ,%bootstrap-guile
3506 #:implicit-inputs? #f
3507 #:allowed-references ("out")
3509 ;; XXX: libstdc++.so NEEDs ld.so for some reason.
3510 #:validate-runpath? #f
3512 ;; All of the package arguments from 'make-libstdc++
3513 ;; except for the configure-flags.
3514 ,@(package-arguments lib)
3515 #:configure-flags `("--disable-shared"
3516 "--disable-libstdcxx-dual-abi"
3517 "--disable-libstdcxx-threads"
3518 "--disable-libstdcxx-pch"
3519 ,(string-append "--with-gxx-include-dir="
3520 (assoc-ref %outputs "out")
3523 (inputs (%boot2-inputs))
3524 (synopsis "GNU C++ standard library (intermediate)"))))
3527 ;; Zlib used by GCC-FINAL.
3531 `(#:guile ,%bootstrap-guile
3532 #:implicit-inputs? #f
3533 #:allowed-references ("out" ,glibc-final)
3534 ,@(package-arguments zlib)))
3535 (inputs (%boot2-inputs))))
3537 (define/system-dependent ld-wrapper-boot3
3538 ;; A linker wrapper that uses the bootstrap Guile.
3539 (make-ld-wrapper "ld-wrapper-boot3"
3540 #:binutils binutils-final
3541 #:guile %bootstrap-guile
3542 #:bash (car (assoc-ref (%boot2-inputs) "bash"))
3543 #:guile-for-build %bootstrap-guile))
3547 (package (inherit gcc-boot0)
3550 ;; XXX: Currently #:allowed-references applies to all the outputs but the
3551 ;; "debug" output contains disallowed references, notably
3552 ;; linux-libre-headers. Disable the debugging output to work around that.
3553 (outputs (delete "debug" (package-outputs gcc-boot0)))
3556 `(#:guile ,%bootstrap-guile
3557 #:implicit-inputs? #f
3559 #:allowed-references ("out" "lib" ,zlib-final
3560 ,glibc-final ,static-bash-for-glibc)
3562 ;; Things like libasan.so and libstdc++.so NEED ld.so for some
3563 ;; reason, but it is not in their RUNPATH. This is a false
3564 ;; positive, so turn it off.
3565 #:validate-runpath? #f
3567 ,@(substitute-keyword-arguments (package-arguments gcc)
3568 ((#:make-flags flags)
3569 ;; Since $LIBRARY_PATH is not honored, add the relevant flags.
3570 `(let ((zlib (assoc-ref %build-inputs "zlib")))
3572 (if (string-prefix? "LDFLAGS=" flag)
3573 (string-append flag " -L"
3574 (assoc-ref %build-inputs "libstdc++")
3575 "/lib -L" zlib "/lib -Wl,-rpath="
3579 ;; Build again GMP & co. within GCC's build process, because it's hard
3580 ;; to do outside (because GCC-BOOT0 is a cross-compiler, and thus
3581 ;; doesn't honor $LIBRARY_PATH, which breaks `gnu-build-system'.)
3583 `(modify-phases ,phases
3584 (add-after 'unpack 'unpack-gmp&co
3585 (lambda* (#:key inputs #:allow-other-keys)
3586 (let ((gmp (assoc-ref %build-inputs "gmp-source"))
3587 (mpfr (assoc-ref %build-inputs "mpfr-source"))
3588 (mpc (assoc-ref %build-inputs "mpc-source")))
3590 ;; To reduce the set of pre-built bootstrap inputs, build
3591 ;; GMP & co. from GCC.
3592 (for-each (lambda (source)
3593 (invoke "tar" "xvf" source))
3594 (list gmp mpfr mpc))
3596 ;; Create symlinks like `gmp' -> `gmp-x.y.z'.
3597 ,@(map (lambda (lib)
3598 ;; Drop trailing letters, as gmp-6.0.0a unpacks
3600 `(symlink ,(string-trim-right
3601 (package-full-name lib "-")
3603 ,(package-name lib)))
3604 (list gmp-6.0 mpfr mpc))
3607 ;; This time we want Texinfo, so we get the manual. Add
3608 ;; STATIC-BASH-FOR-GLIBC so that it's used in the final shebangs of
3609 ;; scripts such as 'mkheaders' and 'fixinc.sh' (XXX: who cares about these
3611 (native-inputs `(("texinfo" ,texinfo-boot0)
3612 ("perl" ,perl-boot0) ;for manpages
3613 ("static-bash" ,static-bash-for-glibc)
3614 ,@(package-native-inputs gcc-boot0)))
3616 (inputs `(("gmp-source" ,(bootstrap-origin (package-source gmp-6.0)))
3617 ("mpfr-source" ,(package-source mpfr))
3618 ("mpc-source" ,(package-source mpc))
3619 ("ld-wrapper" ,ld-wrapper-boot3)
3620 ("binutils" ,binutils-final)
3621 ("libstdc++" ,libstdc++)
3622 ("zlib" ,zlib-final)
3623 ,@(%boot2-inputs)))))
3625 (define (%boot3-inputs)
3626 ;; 4th stage inputs.
3627 `(("gcc" ,gcc-final)
3628 ("ld-wrapper" ,ld-wrapper-boot3)
3629 ,@(alist-delete "gcc" (%boot2-inputs))))
3632 ;; Link with `-static-libgcc' to make sure we don't retain a reference
3633 ;; to the bootstrap GCC. Use "bash-minimal" to avoid an extra dependency
3634 ;; on Readline and ncurses.
3635 (let ((bash (static-libgcc-package bash-minimal)))
3638 (source (bootstrap-origin (package-source bash)))
3639 (inputs (%boot3-inputs))
3641 `(#:implicit-inputs? #f
3642 #:guile ,%bootstrap-guile
3644 #:disallowed-references ,(assoc-ref (%boot3-inputs) "coreutils&co")
3646 ,@(package-arguments bash))))))
3648 (define (%boot4-inputs)
3649 ;; Now use the final Bash.
3650 `(("bash" ,bash-final)
3651 ,@(alist-delete "bash" (%boot3-inputs))))
3654 (package-with-explicit-inputs %boot4-inputs %bootstrap-guile))
3656 (define-public guile-final
3657 ;; This package must be public because other modules refer to it. However,
3658 ;; mark it as hidden so that 'fold-packages' ignores it.
3659 (with-boot4 (hidden-package
3660 (package-with-bootstrap-guile guile-3.0/fixed))))
3662 (define glibc-utf8-locales-final
3663 ;; Now that we have GUILE-FINAL, build the UTF-8 locales. They are needed
3664 ;; by the build processes afterwards so their 'scm_to_locale_string' works
3665 ;; with the full range of Unicode codepoints (remember
3666 ;; 'scm_to_locale_string' is called every time a string is passed to a C
3669 (inherit glibc-utf8-locales)
3671 `(("glibc" ,glibc-final)
3672 ("gzip" ,(with-boot4 gzip))))))
3674 (define-public ld-wrapper
3675 ;; The final 'ld' wrapper, which uses the final Guile and Binutils.
3676 (make-ld-wrapper "ld-wrapper"
3677 #:binutils binutils-final
3681 (define (%boot5-inputs)
3682 ;; Now with UTF-8 locales. Remember that the bootstrap binaries were built
3683 ;; with an older libc, which cannot load the new locale format. See
3684 ;; <https://lists.gnu.org/archive/html/guix-devel/2015-08/msg00737.html>.
3685 `(("locales" ,glibc-utf8-locales-final)
3689 (package-with-explicit-inputs %boot5-inputs))
3691 (define gnu-make-final
3692 ;; The final GNU Make, which uses the final Guile.
3693 (let ((pkg-config (package
3694 (inherit %pkg-config) ;the native pkg-config
3695 (inputs `(("guile" ,guile-final)
3698 `(#:implicit-inputs? #f
3699 ,@(package-arguments pkg-config))))))
3701 (inherit (package-with-bootstrap-guile gnu-make))
3702 (inputs `(("guile" ,guile-final)
3704 (native-inputs `(("pkg-config" ,pkg-config)))
3706 `(#:implicit-inputs? #f
3707 ,@(package-arguments gnu-make))))))
3710 (define coreutils-final
3711 ;; The final Coreutils. Treat them specially because some packages, such as
3712 ;; Findutils, keep a reference to the Coreutils they were built with.
3713 (with-boot5 (package-with-bootstrap-guile
3715 (inherit coreutils-minimal)
3716 (name "coreutils")))
3717 ;; Use the final Guile, linked against the
3718 ;; final libc with working iconv, so that
3719 ;; 'substitute*' works well when touching
3720 ;; test files in Gettext.
3724 ;; The final grep. Gzip holds a reference to it (via zgrep), so it must be
3725 ;; built before gzip.
3726 (let ((grep (with-boot5 (package-with-bootstrap-guile grep))))
3727 (package/inherit grep
3728 (inputs (alist-delete "pcre" (package-inputs grep)))
3729 (native-inputs `(("perl" ,perl-boot0))))))
3731 (define (%boot6-inputs)
3732 ;; Now use the final Coreutils.
3733 `(("coreutils" ,coreutils-final)
3734 ("grep" ,grep-final)
3738 (package-with-explicit-inputs %boot6-inputs))
3742 (let ((sed (with-boot6 (package-with-bootstrap-guile sed))))
3743 (package/inherit sed (native-inputs `(("perl" ,perl-boot0))))))
3745 (define-public %final-inputs
3746 ;; Final derivations used as implicit inputs by 'gnu-build-system'. We
3747 ;; still use 'package-with-bootstrap-guile' so that the bootstrap tools are
3748 ;; used for origins that have patches, thereby avoiding circular
3750 (let ((finalize (compose with-boot6
3751 package-with-bootstrap-guile)))
3752 `(,@(map (match-lambda
3754 (list name (finalize package))))
3760 ("diffutils" ,diffutils)
3762 ("findutils" ,findutils)
3765 ("grep" ,grep-final)
3766 ("coreutils" ,coreutils-final)
3767 ("make" ,gnu-make-final)
3768 ("bash" ,bash-final)
3769 ("ld-wrapper" ,ld-wrapper)
3770 ("binutils" ,binutils-final)
3772 ("libc" ,glibc-final)
3773 ("libc:static" ,glibc-final "static")
3774 ("locales" ,glibc-utf8-locales-final))))
3776 (define-public canonical-package
3777 (let ((name->package (fold (lambda (input result)
3779 ((_ package . outputs)
3780 (vhash-cons (package-full-name package)
3783 `(("guile" ,guile-final)
3786 "Return the 'canonical' variant of PACKAGE---i.e., if PACKAGE is one of
3787 the implicit inputs of 'gnu-build-system', return that one, otherwise return
3790 The goal is to avoid duplication in cases like GUILE-FINAL vs. GUILE-2.2,
3791 COREUTILS-FINAL vs. COREUTILS, etc."
3792 ;; XXX: This doesn't handle dependencies of the final inputs, such as
3793 ;; libunistring, GMP, etc.
3794 (match (vhash-assoc (package-full-name package) name->package)
3796 ;; In general we want CANON, except if we're cross-compiling: CANON
3797 ;; uses explicit inputs, so it is "anchored" in the bootstrapped
3798 ;; process, with dependencies on things that cannot be
3800 (if (%current-target-system)
3810 ;; Using the following procedure, a gcc toolchain targeting glibc-2.27 can be
3811 ;; instantiated like this:
3813 ;; (define-public gcc-glibc-2.27-toolchain
3814 ;; (make-gcc-toolchain gcc glibc-2.27))
3816 (define* (make-gcc-toolchain gcc
3819 "Return a complete toolchain for GCC. If LIBC is specified, target that libc."
3820 (let ((gcc (if libc (make-gcc-libc gcc libc) gcc))
3821 (libc (if libc libc glibc-final)))
3823 (name (string-append (package-name gcc) "-toolchain"))
3824 (version (package-version gcc))
3826 (build-system trivial-build-system)
3828 '(#:modules ((guix build union))
3830 (use-modules (ice-9 match)
3835 (let ((out (assoc-ref %outputs "out")))
3837 (filter-map (match-lambda
3838 (("libc-debug" . _) #f)
3839 (("libc-static" . _) #f)
3840 ((_ . directory) directory))
3843 (union-build (assoc-ref %outputs "debug")
3844 (list (assoc-ref %build-inputs
3846 (union-build (assoc-ref %outputs "static")
3847 (list (assoc-ref %build-inputs
3851 (native-search-paths (package-native-search-paths gcc))
3852 (search-paths (package-search-paths gcc))
3854 (license (package-license gcc))
3855 (synopsis "Complete GCC tool chain for C/C++ development")
3857 "This package provides a complete GCC tool chain for C/C++ development to
3858 be installed in user profiles. This includes GCC, as well as libc (headers and
3859 binaries, plus debugging symbols in the @code{debug} output), and Binutils.")
3860 (home-page "https://gcc.gnu.org/")
3861 (outputs '("out" "debug" "static"))
3863 ;; The main raison d'être of this "meta-package" is (1) to conveniently
3864 ;; install everything that we need, and (2) to make sure ld-wrapper comes
3865 ;; before Binutils' ld in the user's profile.
3866 (inputs `(("gcc" ,gcc)
3867 ("ld-wrapper" ,(car (assoc-ref %final-inputs "ld-wrapper")))
3868 ("binutils" ,binutils-final)
3870 ("libc-debug" ,libc "debug")
3871 ("libc-static" ,libc "static"))))))
3873 (define-public gcc-toolchain
3874 (make-gcc-toolchain gcc-final))
3876 (define-public gcc-toolchain-4.8
3877 (make-gcc-toolchain gcc-4.8))
3879 (define-public gcc-toolchain-4.9
3880 (make-gcc-toolchain gcc-4.9))
3882 (define-public gcc-toolchain-5
3883 (make-gcc-toolchain gcc-5))
3885 (define-public gcc-toolchain-6
3886 (make-gcc-toolchain gcc-6))
3888 (define-public gcc-toolchain-7
3891 (define-public gcc-toolchain-8
3892 (make-gcc-toolchain gcc-8))
3894 (define-public gcc-toolchain-9
3895 (make-gcc-toolchain gcc-9))
3897 (define-public gcc-toolchain-10
3898 (make-gcc-toolchain gcc-10))
3900 ;; Provide the Fortran toolchain package only for the version of gfortran that
3901 ;; is used by Guix internally to build Fortran libraries, because combining
3902 ;; code compiled with different versions can cause problems.
3904 (define-public gfortran-toolchain
3905 (package (inherit (make-gcc-toolchain gfortran))
3906 (synopsis "Complete GCC tool chain for Fortran development")
3907 (description "This package provides a complete GCC tool chain for
3908 Fortran development to be installed in user profiles. This includes
3909 gfortran, as well as libc (headers and binaries, plus debugging symbols
3910 in the @code{debug} output), and binutils.")))
3913 ;;; commencement.scm ends here