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))
143 (snippet #f))) ;discard snippet for Guile 3.0 support
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 (inherit (package-source gash-utils))
176 (snippet #f))) ;discard snippet for Guile 3.0 support
178 `(#:implicit-inputs? #f
180 #:guile ,%bootstrap-guile
181 #:imported-modules ((guix build gnu-bootstrap)
182 ,@%gnu-build-system-modules)
185 (use-modules (guix build gnu-bootstrap))
186 (modify-phases %standard-phases
187 (add-after 'unpack 'set-load-path
188 (lambda* (#:key inputs #:allow-other-keys)
189 (let ((gash (assoc-ref inputs "gash")))
190 (add-to-load-path (string-append gash "/share/guile/site/"
191 (effective-version))))
193 (add-before 'configure 'pre-configure
195 (format #t "Creating gash/commands/testb.scm~%")
196 (copy-file "gash/commands/test.scm"
197 "gash/commands/testb.scm")
198 (substitute* "gash/commands/testb.scm"
199 (("gash commands test") "gash commands testb")
200 (("apply test [(]cdr") "apply test/bracket (cdr"))
201 (for-each (lambda (script)
202 (let ((target (string-append "scripts/"
204 (format #t "Creating scripts/~a~%" target)
205 (copy-file "scripts/template.in" target)
207 (("@UTILITY@") script))))
208 '("awk" "basename" "cat" "chmod" "cmp" "command"
209 "compress" "cp" "cut" "diff" "dirname" "expr"
210 "false" "find" "grep" "head" "ln" "ls" "mkdir"
211 "mv" "printf" "pwd" "reboot" "rm" "rmdir"
212 "sed" "sleep" "sort" "tar" "test" "touch" "tr"
213 "true" "uname" "uniq" "wc" "which"))
214 (format #t "Creating scripts/[.in~%")
215 (copy-file "scripts/template.in" "scripts/[.in")
216 (substitute* "scripts/[.in"
217 (("@UTILITY@") "testb"))
218 (delete-file "scripts/template.in")
221 (bootstrap-configure ,(package-version gash-utils)
223 (replace 'build (bootstrap-build "gash"))
224 (replace 'install (bootstrap-install "gash" "scripts"))
225 ;; XXX: The scripts should add Gash to their load paths and
226 ;; this phase should not exist.
227 (add-after 'install 'copy-gash
228 (lambda* (#:key inputs outputs #:allow-other-keys)
229 (let* ((out (assoc-ref outputs "out"))
230 (moddir (string-append out "/share/guile/site/"
231 (effective-version)))
232 (godir (string-append out "/lib/guile/"
235 (gash (assoc-ref inputs "gash"))
236 (gash-moddir (string-append gash "/share/guile/site/"
237 (effective-version)))
238 (gash-godir (string-append gash "/lib/guile/"
241 (copy-file (string-append gash-moddir "/gash/compat.scm")
242 (string-append moddir "/gash/compat.scm"))
243 (copy-recursively (string-append gash-moddir "/gash/compat")
244 (string-append moddir "/gash/compat"))
245 (copy-file (string-append gash-godir "/gash/compat.go")
246 (string-append godir "/gash/compat.go"))
247 (copy-recursively (string-append gash-godir "/gash/compat")
248 (string-append godir "/gash/compat"))
250 (inputs `(("gash" ,gash-boot)
251 ("guile" ,%bootstrap-guile)))
252 (native-inputs `(("bootar" ,bootar)))))
254 (define (%boot-gash-inputs)
255 `(("bash" , gash-boot) ; gnu-build-system wants "bash"
256 ("coreutils" , gash-utils-boot)
258 ("guile" ,%bootstrap-guile)))
260 (define %bootstrap-mes-rewired
263 (name "bootstrap-mes-rewired")
266 (native-inputs `(("mes" ,%bootstrap-mes)
267 ("gash" ,gash-boot)))
269 (propagated-inputs '())
271 (build-system trivial-build-system)
273 `(#:guile ,%bootstrap-guile
274 #:modules ((guix build utils))
277 (use-modules (guix build utils)
280 (let* ((mes (assoc-ref %build-inputs "mes"))
281 (gash (assoc-ref %build-inputs "gash"))
282 (mes-bin (string-append mes "/bin"))
283 (guile (string-append mes-bin "/mes"))
284 (mes-module (string-append mes "/share/mes/module"))
285 (out (assoc-ref %outputs "out"))
286 (bin (string-append out "/bin"))
287 (mescc (string-append bin "/mescc"))
288 (module (string-append out "/share/mes/module")))
289 (define (rewire file)
292 (("/gnu/store[^ ]+mes-minimal-[^/)}\"]*") out)
293 (("/gnu/store[^ ]+guile-[^/]*/bin/guile") guile)
294 (("/gnu/store[^ ]+bash-[^/)}\"]*") gash)))
297 (for-each (lambda (file) (install-file file bin))
298 (find-files mes-bin))
300 (copy-recursively (string-append mes-module "/mes")
301 (string-append module "/mes"))
302 (copy-recursively (string-append mes-module "/srfi")
303 (string-append module "/srfi"))
305 ;; Cannot easily rewire "mes" because it
306 ;; contains NUL characters; would require
307 ;; remove-store-references alike trick
308 (filter (negate (cut string-suffix? "/mes" <>))
310 (rewire (string-append module "/mes/boot-0.scm"))
313 (with-output-to-file mescc
315 (display (string-append
322 MES_PREFIX=${MES_REWIRED_PREFIX-" out "/share/mes}
324 export MES MES_PREFIX
326 MES_ARENA=${MES_REWIRED_ARENA-10000000}
327 MES_MAX_ARENA=${MES_REWIRED_ARENA-10000000}
328 MES_STACK=${MES_REWIRED_STACK-1000000}
329 export MES_ARENA MES_MAX_ARENA MES_STACK
331 $MES -e '(mescc)' module/mescc.scm -- \"$@\"
335 (with-directory-excursion module
336 (chmod "mes/base.mes" #o644)
337 (copy-file "mes/base.mes" "mes/base.mes.orig")
338 (let ((base.mes (open-file "mes/base.mes" "a")))
340 ;; A fixed map, from Mes 0.21, required to bootstrap Mes 0.21
341 (define (map f h . t)
343 (and (pair? t) (null? (car t)))
344 (and (pair? t) (pair? (cdr t)) (null? (cadr t)))) '()
345 (if (null? t) (cons (f (car h)) (map f (cdr h)))
347 (cons (f (car h) (caar t)) (map f (cdr h) (cdar t)))
349 (cons (f (car h) (caar t) (caadr t)) (map f (cdr h) (cdar t) (cdadr t)))
350 (error 'unsupported (cons* 'map-4: f h t))b )))))
354 (chmod "mes/guile.mes" #o644)
355 (copy-file "mes/guile.mes" "mes/guile.mes.orig")
356 (let ((guile.mes (open-file "mes/guile.mes" "a")))
358 ;; After booting guile.scm; use Mes 0.21; especially: MesCC 0.21
359 (let* ((self (car (command-line)))
360 (prefix (dirname (dirname self))))
361 (set! %moduledir (string-append prefix \"/mes/module/\"))
362 (setenv \"%numbered_arch\" \"true\"))
375 (uri (string-append "mirror://gnu/mes/"
376 "mes-" version ".tar.gz"))
379 "0p1jsrrmcbc0zrvbvnjbb6iyxr0in71km293q8qj6gnar6bw09av"))))
381 (propagated-inputs '())
383 `(("nyacc-source" ,(origin (inherit (package-source nyacc))
385 ("mes" ,%bootstrap-mes-rewired)
386 ("mescc-tools" ,%bootstrap-mescc-tools)
387 ,@(%boot-gash-inputs)))
389 `(#:implicit-inputs? #f
391 #:guile ,%bootstrap-guile
392 #:strip-binaries? #f ; binutil's strip b0rkes MesCC/M1/hex2 binaries
394 (modify-phases %standard-phases
395 (add-after 'unpack 'unpack-seeds
397 (let ((nyacc-source (assoc-ref %build-inputs "nyacc-source")))
398 (with-directory-excursion ".."
399 (invoke "tar" "-xvf" nyacc-source)))))
401 (lambda* (#:key outputs #:allow-other-keys)
402 (let ((out (assoc-ref %outputs "out"))
403 (gash (assoc-ref %build-inputs "bash"))
404 (mes (assoc-ref %build-inputs "mes"))
405 (dir (with-directory-excursion ".." (getcwd))))
406 (setenv "AR" (string-append "gash " (getcwd) "/scripts/mesar"))
407 (setenv "BASH" (string-append gash "/bin/bash"))
408 (setenv "CC" (string-append mes "/bin/mescc"))
409 (setenv "GUILE_LOAD_PATH"
411 mes "/share/mes/module"
412 ":" dir "/nyacc-0.99.0/module"))
413 (invoke "gash" "configure.sh"
414 (string-append "--prefix=" out)
415 (string-append "--host=i686-linux-gnu")))))
418 (invoke "sh" "bootstrap.sh")))
422 (substitute* "install.sh" ; show some progress
424 (("^( *)((cp|mkdir|tar) [^']*[^\\])\n" all space cmd)
425 (string-append space "echo '" cmd "'\n"
427 (invoke "sh" "install.sh")
428 ;; Keep ASCII output, for friendlier comparison and bisection
429 (let* ((out (assoc-ref %outputs "out"))
430 (cache (string-append out "/lib/cache")))
431 (define (objects-in-dir dir)
434 (and (equal? (dirname name) dir)
435 (or (string-suffix? ".o" name)
436 (string-suffix? ".s" name))))))
437 (for-each (lambda (x) (install-file x cache))
438 (append (objects-in-dir ".")
439 (objects-in-dir "mescc-lib"))))
442 (list (search-path-specification
443 (variable "C_INCLUDE_PATH")
444 (files '("include")))
445 (search-path-specification
446 (variable "LIBRARY_PATH")
448 (search-path-specification
449 (variable "MES_PREFIX")
455 ;; Pristine tcc cannot be built by MesCC, we are keeping a delta of 11
456 ;; patches. In a very early and rough form they were presented to the
457 ;; TinyCC developers, who at the time showed no interest in supporting the
458 ;; bootstrappable effort; we will try again later. These patches have been
459 ;; ported to 0.9.27, alas the resulting tcc is buggy. Once MesCC is more
460 ;; mature, this package should use the 0.9.27 sources (or later).
464 (version "0.9.26-1103-g6e62e0e")
468 "http://lilypond.org/janneke/mes/20191117/"
469 "/tcc-" version ".tar.gz"))
472 "1qbybw7mxbgkv3sazvz1v7c8byq998vk8f1h25ik8w3d2l63lxng"))))
473 (build-system gnu-build-system)
474 (supported-systems '("i686-linux" "x86_64-linux"))
476 (propagated-inputs '())
479 ("nyacc-source" ,(origin (inherit (package-source nyacc))
481 ("mescc-tools" ,%bootstrap-mescc-tools)
482 ,@(%boot-gash-inputs)))
484 `(#:implicit-inputs? #f
485 #:guile ,%bootstrap-guile
486 #:validate-runpath? #f ; no dynamic executables
487 #:strip-binaries? #f ; no strip yet
489 (modify-phases %standard-phases
490 (add-after 'unpack 'unpack-seeds
491 (lambda* (#:key outputs #:allow-other-keys)
492 (let ((nyacc-source (assoc-ref %build-inputs "nyacc-source")))
493 (with-directory-excursion ".."
494 (invoke "tar" "-xvf" nyacc-source)))))
496 (lambda* (#:key outputs #:allow-other-keys)
497 (let* ((out (assoc-ref %outputs "out"))
498 (dir (with-directory-excursion ".." (getcwd)))
499 (interpreter "/lib/mes-loader"))
501 (setenv "prefix" out)
502 (setenv "GUILE_LOAD_PATH"
503 (string-append dir "/nyacc-0.99.0/module"))
505 (substitute* "conftest.c"
508 (invoke "sh" "configure"
510 (string-append "--prefix=" out)
511 (string-append "--elfinterp=" interpreter)
516 (substitute* "bootstrap.sh" ; Show some progress
517 (("^( *)((cp|ls|mkdir|rm|[.]/tcc|[.]/[$][{PROGRAM_PREFIX[}]tcc) [^\"]*[^\\])\n" all space cmd)
518 (string-append space "echo \"" cmd "\"\n"
520 (invoke "sh" "bootstrap.sh")))
524 (system* "./tcc" "--help") ; --help exits 1
525 ;; (invoke "sh" "test.sh" "mes/scaffold/tests/30-strlen")
526 ;; (invoke "sh" "-x" "test.sh" "mes/scaffold/tinycc/00_assignment")
527 ;; TODO: add sensible check target (without depending on make)
528 ;; (invoke "sh" "check.sh")
532 (substitute* "install.sh" ; Show some progress
533 (("^( *)((cp|ls|mkdir|rm|tar|./[$][{PROGRAM_PREFIX[}]tcc) [^\"]*[^\\])\n" all space cmd)
534 (string-append space "echo \"" cmd "\"\n"
537 (invoke "sh" "install.sh"))))))
539 (list (search-path-specification
540 (variable "C_INCLUDE_PATH")
541 (files '("include")))
542 (search-path-specification
543 (variable "LIBRARY_PATH")
544 (files '("lib")))))))
547 ;; The initial gzip. We keep this scripted gzip build before building make
548 ;; to soften the dependency on Gash Core Utils gzip.
552 (name "gzip-mesboot")
555 (uri (string-append "mirror://gnu/gzip/gzip-" version ".tar"))
558 "1rhgk2vvmdvnn6vygf0dja92ryyng00knl0kz5srb77k2kryjb2d"))))
559 (supported-systems '("i686-linux" "x86_64-linux"))
561 (propagated-inputs '())
562 (native-inputs `(("tcc" ,tcc-boot0)
563 ,@(%boot-gash-inputs)))
565 `(#:implicit-inputs? #f
566 #:guile ,%bootstrap-guile
567 #:strip-binaries? #f ; no strip yet
569 (modify-phases %standard-phases
571 (add-after 'unpack 'scripted-patch
573 (substitute* "util.c"
574 (("^char [*]strlwr" all) (string-append all "_tcc_cannot_handle_dupe")))
578 (let ((files '("bits" "crypt" "deflate" "getopt" "gzip"
579 "inflate" "lzw" "trees" "unlzh" "unlzw"
580 "unpack" "unzip" "util" "zip")))
582 (invoke "tcc" "-c" "-D NO_UTIME=1" "-D HAVE_UNISTD_H=1"
583 (string-append x ".c")))
584 (for-each compile files)
586 (cons* "tcc" "-o" "gzip"
587 (map (lambda (x) (string-append x ".o")) files)))
588 (link "gzip" "gunzip"))))
591 (let* ((out (assoc-ref %outputs "out"))
592 (bin (string-append out "/bin")))
593 (install-file "gzip" bin)
594 (install-file "gunzip" bin))))
597 (invoke "./gzip" "--version")))
599 (delete 'compress-documentation))))))
601 (define gnu-make-mesboot0
605 (name "make-mesboot0")
609 (uri (string-append "mirror://gnu/make/make-" version ".tar.gz"))
612 "1pb7fb7fqf9wz9najm85qdma1xhxzf1rhj5gwrlzdsz2zm0hpcv4"))))
613 (supported-systems '("i686-linux" "x86_64-linux"))
615 (propagated-inputs '())
616 (native-inputs `(("tcc" ,tcc-boot0)
617 ,@(%boot-gash-inputs)))
619 `(#:implicit-inputs? #f
620 #:guile ,%bootstrap-guile
621 #:configure-flags '("CC=tcc"
624 "--build=i686-unknown-linux-gnu"
625 "--host=i686-unknown-linux-gnu"
627 #:modules ((guix build gnu-build-system)
630 #:strip-binaries? #f ; no strip yet
632 (modify-phases %standard-phases
633 (add-after 'unpack 'scripted-patch
635 (substitute* "build.sh.in"
636 (("@LIBOBJS@") "getloadavg.o")
637 (("@REMOTE@") "stub"))
639 (add-after 'configure 'configure-fixup
641 (substitute* "make.h"
642 (("^extern long int lseek.*" all) (string-append "// " all)))
646 (invoke "sh" "./build.sh")))
647 (replace 'check ; proper check needs awk
649 (invoke "./make" "--version")))
652 (let* ((out (assoc-ref %outputs "out"))
653 (bin (string-append out "/bin")))
654 (install-file "make" bin)))))))))
656 (define (%boot-tcc0-inputs)
657 `(("make" ,gnu-make-mesboot0)
659 ,@(%boot-gash-inputs)))
661 (define bzip2-mesboot
665 (name "bzip2-mesboot")
666 (version (package-version bzip2))
667 (source (bootstrap-origin (package-source bzip2)))
668 (supported-systems '("i686-linux" "x86_64-linux"))
670 (propagated-inputs '())
671 (native-inputs (%boot-tcc0-inputs))
674 `(#:implicit-inputs? #f
675 #:guile ,%bootstrap-guile
677 #:tests? #f ; check is naive, also checks non-built PROGRAMS
678 #:strip-binaries? #f ; no strip yet
679 #:make-flags (list "CC=tcc -I ." "AR=tcc -ar" "bzip2"
680 (string-append "PREFIX="
681 (assoc-ref %outputs "out")))
683 (modify-phases %standard-phases
684 (add-after 'unpack 'scripted-patch
686 (substitute* "Makefile"
688 (string-append "\t#" all)))
689 (substitute* "bzip2.c"
690 (("struct utimbuf uTimBuf;" all)
691 (string-append "// " all))
693 (string-append "// " all))
694 (("retVal = utime [(] dstName, &uTimBuf [)];" all)
695 (string-append "retVal = 0; // " all)))
699 (with-output-to-file "utime.h"
701 #define fchown(filedes, owner, group) 0
702 #define fchmod(filedes, mode) 0
707 (invoke "./bzip2" "--help")))
708 ;; FIXME: no compressing gzip yet
709 (delete 'compress-documentation))))))
711 (define bash-mesboot0
714 (inherit static-bash)
715 (name "bash-mesboot0")
719 (uri (string-append "mirror://gnu/bash/bash-"
723 "1r1z2qdw3rz668nxrzwa14vk2zcn00hw7mpjn384picck49d80xs"))))
725 (propagated-inputs '())
726 (native-inputs (%boot-tcc0-inputs))
729 `(#:implicit-inputs? #f
730 #:guile ,%bootstrap-guile
732 #:strip-binaries? #f ; no strip yet
734 (list "--build=i686-unknown-linux-gnu"
735 "--host=i686-unknown-linux-gnu"
737 "--without-bash-malloc"
740 "--disable-help-builtin"
742 "--disable-net-redirections"
745 ;; Pretend 'dlopen' is missing so we don't build loadable
746 ;; modules and related code.
747 "ac_cv_func_dlopen=no")
748 #:make-flags '("bash")
750 (modify-phases %standard-phases
751 (add-before 'configure 'setenv
753 (let* ((gash (assoc-ref %build-inputs "bash"))
754 (shell (string-append gash "/bin/gash")))
755 (setenv "CONFIG_SHELL" shell)
756 (setenv "SHELL" shell)
759 (setenv "AR" "tcc -ar")
760 (setenv "CFLAGS" "-D _POSIX_VERSION=1")
762 (add-after 'unpack 'scripted-patch
764 (substitute* "Makefile.in"
765 (("mksyntax\\.c\n") "mksyntax.c -lgetopt\n")
766 (("buildversion[.]o\n") "buildversion.o -lgetopt\n")
768 (("\tsize ") "#\tsize"))
769 (substitute* "lib/sh/oslib.c"
770 (("int name, namelen;") "char *name; int namelen;"))
771 (substitute* "lib/sh/snprintf.c"
772 (("^#if (defined [(]HAVE_LOCALE_H[)])" all define) (string-append "#if 0 //" define)))
773 (substitute* "configure"
774 ((" egrep") " grep"))
777 (lambda* (#:key configure-flags #:allow-other-keys)
778 (let ((configure-flags (filter (lambda (x)
779 (and (not (string-prefix? "CONFIG_SHELL=" x))
780 (not (string-prefix? "SHELL=" x))))
782 (format (current-error-port)
783 "running ./configure ~a\n" (string-join configure-flags)))
784 (apply invoke (cons "./configure" configure-flags))))
785 (add-after 'configure 'configure-fixups
787 (substitute* "config.h"
788 (("#define GETCWD_BROKEN 1") "#undef GETCWD_BROKEN"))
789 (let ((config.h (open-file "config.h" "a")))
790 (display (string-append "
791 // tcc: error: undefined symbol 'enable_hostname_completion'
792 #define enable_hostname_completion(on_or_off) 0
794 // /gnu/store/cq0cmv35s9dhilx14zaghlc08gpc0hwr-tcc-boot0-0.9.26-6.c004e9a/lib/libc.a: error: 'sigprocmask' defined twice
795 #define HAVE_POSIX_SIGNALS 1
796 #define endpwent(x) 0
803 (invoke "./bash" "--version")))
806 (let* ((out (assoc-ref %outputs "out"))
807 (bin (string-append out "/bin")))
809 (copy-file "bash" (string-append bin "/bash"))
810 (copy-file "bash" (string-append bin "/sh"))
820 (inherit (package-source tcc))
821 ;; `patches' needs XZ
822 ;; (patches (search-patches "tcc-boot-0.9.27.patch"))
824 (build-system gnu-build-system)
826 (propagated-inputs '())
827 (native-inputs `(;;("boot-patch" ,(search-patch "tcc-boot-0.9.27.patch"))
828 ("bzip2" ,bzip2-mesboot)
829 ,@(%boot-tcc0-inputs)))
831 `(#:implicit-inputs? #f
832 #:guile ,%bootstrap-guile
833 #:validate-runpath? #f ; no dynamic executables
834 #:strip-binaries? #f ; no strip yet
836 (modify-phases %standard-phases
837 ;; tar xvf ..bz2 gives
838 ;; bzip2: PANIC -- internal consistency error
840 (lambda* (#:key source #:allow-other-keys)
841 (copy-file source "tarball.tar.bz2")
842 (invoke "bzip2" "-d" "tarball.tar.bz2")
843 (invoke "tar" "xvf" "tarball.tar")
844 (chdir (string-append "tcc-" ,version))
847 ;; (add-after 'unpack 'apply-boot-patch
848 ;; (lambda* (#:key inputs #:allow-other-keys)
849 ;; (let ((patch-file (assoc-ref inputs "boot-patch")))
850 ;; (invoke "patch" "-p1" "-i" patch-file))))
851 (add-after 'unpack 'scripted-patch
852 (lambda* (#:key inputs #:allow-other-keys)
853 (substitute* "libtcc.c"
854 (("s->alacarte_link = 1;" all)
856 s->static_link = 1;")))
859 (lambda* (#:key outputs #:allow-other-keys)
860 (let* ((out (assoc-ref %outputs "out"))
861 (tcc (assoc-ref %build-inputs "tcc"))
862 (libc (assoc-ref %build-inputs "libc"))
863 (interpreter "/mes/loader"))
864 (invoke "sh" "configure"
865 (string-append "--cc=tcc")
866 (string-append "--cpu=i386")
867 (string-append "--prefix=" out)
868 (string-append "--elfinterp=" interpreter)
869 (string-append "--crtprefix=" tcc "/lib")
870 (string-append "--sysincludepaths=" tcc "/include")
871 (string-append "--libpaths=" tcc "/lib")))))
873 (lambda* (#:key outputs #:allow-other-keys)
874 (let* ((out (assoc-ref %outputs "out"))
875 (tcc (assoc-ref %build-inputs "tcc"))
876 (libc (assoc-ref %build-inputs "libc"))
877 (interpreter "/mes/loader"))
883 "-D" "TCC_TARGET_I386=1"
884 "-D" "CONFIG_TCC_STATIC=1"
885 "-D" "CONFIG_USE_LIBGCC=1"
886 "-D" (string-append "CONFIG_TCCDIR=\"" out "/lib/tcc\"")
887 "-D" (string-append "CONFIG_TCC_CRTPREFIX=\"" out "/lib:{B}/lib:.\"")
888 "-D" (string-append "CONFIG_TCC_CRTPREFIX=\"" out "/lib:{B}/lib:.\"")
889 "-D" (string-append "CONFIG_TCC_ELFINTERP=\"" interpreter "\"")
890 "-D" (string-append "CONFIG_TCC_LIBPATHS=\"" tcc "/lib:{B}/lib:.\"")
891 "-D" (string-append "CONFIG_TCC_SYSINCLUDEPATHS=\""
892 tcc "/include" ":/include:{B}/include\"")
893 "-D" (string-append "TCC_LIBGCC=\"" tcc "/lib/libc.a\"")
898 ;; FIXME: add sensible check target (without depending on make)
900 (= 1 (status:exit-val (system* "./tcc" "--help")))))
902 (lambda* (#:key outputs #:allow-other-keys)
903 (let ((out (assoc-ref %outputs "out"))
904 (tcc (assoc-ref %build-inputs "tcc")))
906 (mkdir-p (string-append out "/bin"))
907 (copy-file "tcc" (string-append out "/bin/tcc"))
908 (mkdir-p (string-append out "/lib/tcc"))
909 (copy-recursively (string-append tcc "/include")
910 (string-append out "/include"))
911 (copy-recursively (string-append tcc "/lib")
912 (string-append out "/lib"))
913 (invoke "tcc" "-D" "TCC_TARGET_I386=1" "-c" "-o" "libtcc1.o" "lib/libtcc1.c")
914 (invoke "tcc" "-ar" "rc" "libtcc1.a" "libtcc1.o")
915 (copy-file "libtcc1.a" (string-append out "/lib/libtcc1.a"))
916 (delete-file (string-append out "/lib/tcc/libtcc1.a"))
917 (copy-file "libtcc1.a" (string-append out "/lib/tcc/libtcc1.a"))
920 (define diffutils-mesboot
921 ;; The initial diffutils.
924 (name "diffutils-mesboot")
928 (uri (string-append "mirror://gnu/diffutils/diffutils-"
932 "1mirn5i825bn5w7rh6mgn0r8aj9xqanav95dwcl1b8sn82f4iwnm"))))
933 (supported-systems '("i686-linux" "x86_64-linux"))
935 (propagated-inputs '())
936 (native-inputs (%boot-tcc0-inputs))
938 `(#:implicit-inputs? #f
939 #:guile ,%bootstrap-guile
941 #:tests? #f ; check is naive, also checks non-built PROGRAMS
942 #:strip-binaries? #f ; no strip yet
944 (modify-phases %standard-phases
945 (add-before 'configure 'remove-diff3-sdiff
946 (lambda* (#:key outputs #:allow-other-keys)
947 (substitute* "Makefile.in"
948 (("PROGRAMS = .*" all) "PROGRAMS = cmp diff"))))
949 (replace 'configure ; needs classic invocation of configure
950 (lambda* (#:key configure-flags #:allow-other-keys)
951 (let* ((out (assoc-ref %outputs "out"))
952 (bash (assoc-ref %build-inputs "bash"))
953 (shell (string-append bash "/bin/bash")))
954 (setenv "CONFIG_SHELL" shell)
957 (format (current-error-port)
958 "running ./configure ~a\n" (string-join configure-flags))
959 (apply invoke (cons "./configure" configure-flags)))))
962 (let* ((out (assoc-ref %outputs "out"))
963 (bin (string-append out "/bin")))
965 (install-file "cmp" bin)
966 (install-file "diff" bin)
969 (define patch-mesboot
970 ;; The initial patch.
973 (name "patch-mesboot")
977 (uri (string-append "mirror://gnu/patch/patch-"
981 "12nv7jx3gxfp50y11nxzlnmqqrpicjggw6pcsq0wyavkkm3cddgc"))))
982 (supported-systems '("i686-linux" "x86_64-linux"))
984 (propagated-inputs '())
985 (native-inputs (%boot-tcc0-inputs))
987 `(#:implicit-inputs? #f
988 #:guile ,%bootstrap-guile
990 #:tests? #f ; check is naive, also checks non-built PROGRAMS
991 #:strip-binaries? #f ; no strip yet
992 #:configure-flags '("AR=tcc -ar" "CC=tcc" "LD-tcc")
994 (modify-phases %standard-phases
995 (add-after 'unpack 'scripted-patch
997 ;; avoid another segfault
999 (("while [(]p_end >= 0[)]" all)
1000 "p_end = -1;\nwhile (0)"))
1002 ;; FIXME: no compressing gzip yet
1003 (delete 'compress-documentation))))))
1005 (define sed-mesboot0
1009 (name "sed-mesboot0")
1013 (uri (string-append "mirror://gnu/sed/sed-"
1017 "1hyv7i82jd0q18xcql51ylc8jwadp3gb3irgcqlis3v61p35jsv2"))))
1018 (supported-systems '("i686-linux" "x86_64-linux"))
1020 (propagated-inputs '())
1021 (native-inputs (%boot-tcc0-inputs))
1023 `(#:implicit-inputs? #f
1024 #:guile ,%bootstrap-guile
1025 #:parallel-build? #f
1026 #:configure-flags '("CC=tcc")
1027 #:make-flags '("CC=tcc" "extra_objs=" "DEFS=-D HAVE_BCOPY")
1028 #:strip-binaries? #f ; no strip yet
1030 (modify-phases %standard-phases
1031 (add-after 'unpack 'scripted-patch
1033 (let* ((out (assoc-ref %outputs "out"))
1034 (bash (assoc-ref %build-inputs "bash"))
1035 (shell (string-append bash "/bin/bash")))
1036 (substitute* "configure"
1037 (("/bin/sh") shell))
1041 (invoke "./sed" "--version")))
1044 (let* ((out (assoc-ref %outputs "out"))
1045 (bin (string-append out "/bin")))
1046 (install-file "sed" bin)
1049 (define (%boot-tcc-inputs)
1050 `(("bash" ,bash-mesboot0)
1051 ("bzip2" ,bzip2-mesboot)
1052 ("diffutils" ,diffutils-mesboot)
1053 ("gzip" ,gzip-mesboot)
1054 ("patch" ,patch-mesboot)
1055 ("sed" ,sed-mesboot0)
1057 ,@(alist-delete "tcc" (%boot-tcc0-inputs))))
1059 (define binutils-mesboot0
1060 ;; The initial Binutils
1063 (name "binutils-mesboot0")
1067 (uri (string-append "mirror://gnu/binutils/binutils-"
1071 "1w8xp7k44bkijr974x9918i4p1sw4g2fcd5mxvspkjpg38m214ds"))))
1073 (propagated-inputs '())
1074 (native-inputs (%boot-tcc-inputs))
1075 (supported-systems '("i686-linux" "x86_64-linux"))
1077 `(#:implicit-inputs? #f
1078 #:guile ,%bootstrap-guile
1079 #:tests? #f ; runtest: command not found
1080 #:parallel-build? #f
1081 #:strip-binaries? #f ; no strip yet
1083 (let ((out (assoc-ref %outputs "out")))
1087 "--build=i386-unknown-linux"
1088 "--host=i386-unknown-linux"
1089 "--target=i386-unknown-linux"
1091 ,(string-append "--prefix=" out)))
1093 (modify-phases %standard-phases
1094 (add-before 'configure 'setenv
1096 (let* ((out (assoc-ref %outputs "out"))
1097 (bash (assoc-ref %build-inputs "bash"))
1098 (shell (string-append bash "/bin/bash")))
1099 (setenv "CONFIG_SHELL" shell)
1100 (setenv "SHELL" shell)
1101 (setenv "AR" "tcc -ar")
1102 (setenv "RANLIB" "true")
1103 (setenv "CC" "tcc -D __GLIBC_MINOR__=6")
1105 (add-after 'unpack 'scripted-patch
1106 (lambda* (#:key inputs #:allow-other-keys)
1107 (substitute* "bfd/configure"
1108 (("^sed -e '/SRC-POTFILES.*" all)
1109 "echo -e 'all:\\n\\ttrue\\n\\ninstall:\\n\\ttrue\\n' > po/Makefile\n"))
1111 (replace 'configure ; needs classic invocation of configure
1112 (lambda* (#:key configure-flags #:allow-other-keys)
1113 (format (current-error-port)
1114 "running ./configure ~a\n" (string-join configure-flags))
1115 (apply system* "./configure" configure-flags)
1116 (substitute* "config.status"
1117 (("[.]//dev/null") "/dev/null"))
1118 (invoke "sh" "./config.status"))))))))
1120 (define gcc-core-mesboot0
1121 ;; Gcc-2.95.3 is the most recent GCC that is supported by what the Mes C
1122 ;; Library v0.16 offers. Gcc-3.x (and 4.x) place higher demands on a C
1123 ;; library, such as dir.h/struct DIR/readdir, locales, signals... Also,
1124 ;; with gcc-2.95.3, binutils (2.14.0, 2.20.1a) and glibc-2.2.5 we found a
1125 ;; GNU toolchain triplet "that works".
1128 (name "gcc-core-mesboot0")
1132 (uri (string-append "mirror://gnu/gcc/gcc-2.95.3/gcc-core-"
1135 ;; `patches' needs XZ
1136 ;; (patches (search-patches "gcc-boot-2.95.3.patch"))
1139 "1xvfy4pqhrd5v2cv8lzf63iqg92k09g6z9n2ah6ndd4h17k1x0an"))))
1140 (supported-systems '("i686-linux" "x86_64-linux"))
1142 (propagated-inputs '())
1143 (native-inputs `(("boot-patch" ,(search-patch "gcc-boot-2.95.3.patch"))
1144 ("binutils" ,binutils-mesboot0)
1145 ,@(%boot-tcc-inputs)))
1148 `(#:implicit-inputs? #f
1149 #:guile ,%bootstrap-guile
1151 #:parallel-build? #f
1152 #:strip-binaries? #f
1154 (let ((out (assoc-ref %outputs "out")))
1158 "--build=i686-unknown-linux-gnu"
1159 "--host=i686-unknown-linux-gnu"
1160 ,(string-append "--prefix=" out)))
1162 `("CC=tcc -static -D __GLIBC_MINOR__=6"
1163 "OLDCC=tcc -static -D __GLIBC_MINOR__=6"
1164 "CC_FOR_BUILD=tcc -static -D __GLIBC_MINOR__=6"
1167 ,(string-append "LIBGCC2_INCLUDES=-I "
1168 (assoc-ref %build-inputs "tcc")
1171 ,(string-append "BOOT_LDFLAGS="
1172 " -B" (assoc-ref %build-inputs "tcc")
1174 #:modules ((guix build gnu-build-system)
1178 (modify-phases %standard-phases
1179 (add-after 'unpack 'apply-boot-patch
1180 (lambda* (#:key inputs #:allow-other-keys)
1181 (let ((patch-file (assoc-ref inputs "boot-patch")))
1182 (system* "patch" "--force" "-p1" "-i" patch-file)
1184 (add-before 'configure 'setenv
1185 (lambda* (#:key outputs #:allow-other-keys)
1186 (let* ((out (assoc-ref outputs "out"))
1187 (bash (assoc-ref %build-inputs "bash"))
1188 (shell (string-append bash "/bin/bash"))
1189 (tcc (assoc-ref %build-inputs "tcc"))
1190 (cppflags " -D __GLIBC_MINOR__=6"))
1191 (setenv "CONFIG_SHELL" shell)
1192 (setenv "CPPFLAGS" cppflags)
1193 (setenv "CC" (string-append "tcc" cppflags))
1194 (setenv "CC_FOR_BUILD" (string-append "tcc" cppflags))
1195 (setenv "CPP" (string-append "tcc -E" cppflags))
1196 (with-output-to-file "config.cache"
1199 ac_cv_c_float_format='IEEE (little-endian)'
1202 (replace 'configure ; needs classic invocation of configure
1203 (lambda* (#:key configure-flags #:allow-other-keys)
1204 (format (current-error-port)
1205 "running ./configure ~a\n" (string-join configure-flags))
1206 (apply invoke "./configure" configure-flags)))
1207 (add-after 'configure 'remove-info
1209 ;; no info at this stage
1210 (delete-file-recursively "texinfo")
1211 (invoke "touch" "gcc/cpp.info" "gcc/gcc.info")))
1212 (add-after 'install 'install2
1213 (lambda* (#:key outputs #:allow-other-keys)
1214 (let* ((tcc (assoc-ref %build-inputs "tcc"))
1215 (tcc-lib (string-append tcc "/lib/x86-mes-gcc"))
1216 (out (assoc-ref outputs "out"))
1217 (gcc-dir (string-append
1218 out "/lib/gcc-lib/i686-unknown-linux-gnu/2.95.3")))
1220 (with-directory-excursion "tmp"
1221 (invoke "ar" "x" (string-append "../gcc/libgcc2.a"))
1222 (invoke "ar" "x" (string-append tcc "/lib/libtcc1.a"))
1223 (apply invoke "ar" "r" (string-append gcc-dir "/libgcc.a")
1224 (find-files "." "\\.o")))
1225 (copy-file "gcc/libgcc2.a" (string-append out "/lib/libgcc2.a"))
1226 (copy-file (string-append tcc "/lib/libtcc1.a")
1227 (string-append out "/lib/libtcc1.a"))
1228 (invoke "ar" "x" (string-append tcc "/lib/libtcc1.a"))
1229 (invoke "ar" "x" (string-append tcc "/lib/libc.a"))
1230 (invoke "ar" "r" (string-append gcc-dir "/libc.a")
1231 "libc.o" "libtcc1.o")
1233 (native-search-paths
1234 (list (search-path-specification
1235 (variable "C_INCLUDE_PATH")
1238 ;; Needed to get things like GCC's <stddef.h>.
1239 "lib/gcc-lib/i686-unknown-linux-gnu/2.95.3/include")))
1240 (search-path-specification
1241 (variable "LIBRARY_PATH")
1242 (files '("lib")))))))
1244 (define (%boot-mesboot-core-inputs)
1245 `(("binutils" ,binutils-mesboot0)
1246 ("gawk" ,gawk-mesboot0)
1247 ("gcc" ,gcc-core-mesboot0)
1248 ,@(alist-delete "tcc" (%boot-tcc-inputs))))
1250 (define mesboot-headers
1253 (name "mesboot-headers")
1254 (supported-systems '("i686-linux" "x86_64-linux"))
1256 (propagated-inputs '())
1257 (native-inputs `(("kernel-headers" ,%bootstrap-linux-libre-headers)
1258 ,@(%boot-tcc-inputs)))
1260 `(#:implicit-inputs? #f
1261 #:guile ,%bootstrap-guile
1263 #:strip-binaries? #f
1265 (modify-phases %standard-phases
1269 (lambda* (#:key outputs #:allow-other-keys)
1270 (let* ((out (assoc-ref outputs "out"))
1271 (include (string-append out "/include"))
1272 (headers (assoc-ref %build-inputs "kernel-headers")))
1274 (copy-recursively "include" out)
1275 (copy-recursively headers out)
1278 (define gawk-mesboot0
1279 ;; The initial Gawk.
1282 (name "gawk-mesboot0")
1286 (uri (string-append "mirror://gnu/gawk/gawk-"
1290 "087s7vpc8zawn3l7bwv9f44bf59rc398hvaiid63klw6fkbvabr3"))))
1291 (supported-systems '("i686-linux" "x86_64-linux"))
1293 (propagated-inputs '())
1294 (native-inputs (%boot-tcc-inputs))
1296 `(#:implicit-inputs? #f
1297 #:guile ,%bootstrap-guile
1298 #:configure-flags '("--build=i686-unknown-linux-gnu"
1299 "--host=i686-unknown-linux-gnu"
1301 #:make-flags '("gawk")
1302 #:parallel-build? #f
1303 #:parallel-tests? #f
1304 #:strip-binaries? #f ; no strip yet
1306 (modify-phases %standard-phases
1307 (add-after 'unpack 'scripted-patch
1309 (substitute* "Makefile.in"
1310 (("date ") "echo today ")
1311 ((" autoheader") "true")
1313 (substitute* "test/Makefile.in"
1314 (("^bigtest:.*") "bigtest: basic\n")
1315 (("( |\t)(childin|convfmt|fflush|longwrds|math|negexp)" all sep) sep))))
1316 (add-before 'configure 'setenv
1318 (let* ((out (assoc-ref %outputs "out"))
1319 (bash (assoc-ref %build-inputs "bash"))
1320 (shell (string-append bash "/bin/bash")))
1321 (setenv "CONFIG_SHELL" shell)
1322 (setenv "SHELL" shell)
1324 (setenv "CPP" "tcc -E")
1326 (setenv "ac_cv_func_getpgrp_void" "yes")
1327 (setenv "ac_cv_func_tzset" "yes"))
1329 (replace 'configure ; needs classic invocation of configure
1330 (lambda* (#:key configure-flags #:allow-other-keys)
1331 (let* ((out (assoc-ref %outputs "out"))
1334 ,(string-append "--prefix=" out))))
1335 (format (current-error-port) "running ./configure ~a\n" (string-join configure-flags))
1336 (system* "touch" "configure") ; aclocal.m4 is newer than configure
1337 (apply invoke (cons "./configure" configure-flags)))))
1339 (lambda* (#:key outputs #:allow-other-keys)
1340 (let* ((out (assoc-ref outputs "out"))
1341 (bin (string-append out "/bin")))
1342 (install-file "gawk" bin)
1343 (symlink "gawk" (string-append bin "/awk"))
1346 (define glibc-mesboot0
1347 ;; GNU C Library 2.2.5 is the most recent glibc that we managed to build
1348 ;; using gcc-2.95.3. Newer versions (2.3.x, 2.6, 2.1x) seem to need a newer
1352 (name "glibc-mesboot0")
1356 (uri (string-append "mirror://gnu/glibc/glibc-"
1360 ;; (patches (search-patches "glibc-boot-2.2.5.patch"))
1363 "1vl48i16gx6h68whjyhgnn1s57vqq32f9ygfa2fls7pdkbsqvp2q"))))
1364 (supported-systems '("i686-linux" "x86_64-linux"))
1366 (propagated-inputs '())
1367 (native-inputs `(("boot-patch" ,(search-patch "glibc-boot-2.2.5.patch"))
1368 ("system-patch" ,(search-patch "glibc-bootstrap-system-2.2.5.patch"))
1369 ("headers" ,mesboot-headers)
1370 ,@(%boot-mesboot-core-inputs)))
1373 `(#:implicit-inputs? #f
1374 #:guile ,%bootstrap-guile
1376 #:strip-binaries? #f
1377 #:validate-runpath? #f ; no dynamic executables
1378 #:parallel-build? #f ; gcc-2.95.3 ICEs on massively parallel builds
1379 #:make-flags (list (string-append
1381 (assoc-ref %build-inputs "bash")
1384 (let ((out (assoc-ref %outputs "out"))
1385 (headers (assoc-ref %build-inputs "headers")))
1386 `("--disable-shared"
1388 "--disable-sanity-checks"
1389 "--build=i686-unknown-linux-gnu"
1390 "--host=i686-unknown-linux-gnu"
1391 ,(string-append "--with-headers=" headers "/include")
1392 "--enable-static-nss"
1393 "--without-__thread"
1397 ,(string-append "--prefix=" out)))
1399 (modify-phases %standard-phases
1400 (add-after 'unpack 'apply-boot-patch
1401 (lambda* (#:key inputs #:allow-other-keys)
1402 (and (let ((patch (assoc-ref inputs "boot-patch")))
1403 (invoke "patch" "--force" "-p1" "-i" patch))
1404 (let ((patch (assoc-ref inputs "system-patch")))
1405 (invoke "patch" "--force" "-p1" "-i" patch)))))
1406 (add-before 'configure 'setenv
1407 (lambda* (#:key outputs #:allow-other-keys)
1408 (let* ((out (assoc-ref outputs "out"))
1409 (bash (assoc-ref %build-inputs "bash"))
1410 (shell (string-append bash "/bin/bash"))
1411 (gcc (assoc-ref %build-inputs "gcc"))
1412 (headers (assoc-ref %build-inputs "headers"))
1413 (cppflags (string-append
1415 " -D MES_BOOTSTRAP=1"
1416 " -D BOOTSTRAP_GLIBC=1"))
1417 (cflags (string-append " -L " (getcwd))))
1418 (setenv "CONFIG_SHELL" shell)
1419 (setenv "SHELL" shell)
1420 (setenv "CPP" (string-append gcc "/bin/gcc -E " cppflags))
1421 (setenv "CC" (string-append gcc "/bin/gcc " cppflags cflags))
1423 (replace 'configure ; needs classic invocation of configure
1424 (lambda* (#:key configure-flags #:allow-other-keys)
1425 (format (current-error-port)
1426 "running ./configure ~a\n" (string-join configure-flags))
1427 (apply invoke "./configure" configure-flags)))
1428 (add-after 'configure 'fixup-configure
1430 (let* ((out (assoc-ref %outputs "out"))
1431 (bash (assoc-ref %build-inputs "bash"))
1432 (shell (string-append bash "/bin/bash")))
1433 (substitute* "config.make"
1434 (("INSTALL = scripts/") "INSTALL = $(..)./scripts/"))
1435 (substitute* "config.make"
1436 (("INSTALL = scripts/") "INSTALL = $(..)./scripts/")
1437 (("BASH = ") (string-append
1442 (define gcc-mesboot0
1444 (inherit gcc-core-mesboot0)
1445 (name "gcc-mesboot0")
1446 (native-inputs `(("boot-patch" ,(search-patch "gcc-boot-2.95.3.patch"))
1447 ;; Packages are given in an order that's relevant for
1448 ;; #include_next purposes.
1449 ("libc" ,glibc-mesboot0)
1450 ("kernel-headers" ,%bootstrap-linux-libre-headers)
1451 ,@(%boot-mesboot-core-inputs)))
1453 (substitute-keyword-arguments (package-arguments gcc-core-mesboot0)
1455 `(modify-phases ,phases
1458 (setenv "CONFIG_SHELL" (which "sh"))
1459 (with-output-to-file "config.cache"
1462 ac_cv_c_float_format='IEEE (little-endian)'
1466 (lambda* (#:key outputs #:allow-other-keys)
1467 (let* ((out (assoc-ref outputs "out"))
1468 (gcc-dir (string-append
1469 out "/lib/gcc-lib/i686-unknown-linux-gnu/2.95.3")))
1472 (zero? (system (string-append "set -x; cd tmp && ar x ../gcc/libgcc2.a")))
1473 (zero? (system (string-append "set -x; cd tmp && ar r " gcc-dir "/libgcc.a *.o")))
1474 (copy-file "gcc/libgcc2.a" (string-append out "/lib/libgcc2.a"))))))))
1475 ((#:configure-flags configure-flags)
1476 `(let ((out (assoc-ref %outputs "out")))
1477 `("--disable-shared"
1479 "--build=i686-unknown-linux-gnu"
1480 "--host=i686-unknown-linux-gnu"
1481 ,(string-append "--prefix=" out))))
1482 ((#:make-flags make-flags)
1483 `(let ((gcc (assoc-ref %build-inputs "gcc")))
1485 ,(string-append "LIBGCC2_INCLUDES=-I " gcc "/include")
1486 "LANGUAGES=c")))))))
1488 (define (%boot-mesboot0-inputs)
1489 `(("gcc" ,gcc-mesboot0)
1490 ("kernel-headers" ,%bootstrap-linux-libre-headers)
1491 ("libc" ,glibc-mesboot0)
1492 ,@(alist-delete "gcc" (%boot-mesboot-core-inputs))))
1495 ;; Initial tar with support for xz compression.
1498 (name "tar-mesboot")
1502 (uri (string-append "mirror://gnu/tar/tar-"
1506 "19nvix64y95n5v6rr5g9g3fn08zz85cb5anzd7csfv4a4sz9lw4y"))))
1507 (supported-systems '("i686-linux" "x86_64-linux"))
1509 (propagated-inputs '())
1510 (native-inputs (%boot-mesboot0-inputs))
1512 `(#:implicit-inputs? #f
1513 #:guile ,%bootstrap-guile
1514 #:parallel-build? #f
1515 #:tests? #f ; check is naive, also checks non-built PROGRAMS
1516 #:strip-binaries? #f ; no strip yet
1517 #:configure-flags '("--build=i686-unknown-linux-gnu"
1518 "--host=i686-unknown-linux-gnu"
1521 (modify-phases %standard-phases
1523 (lambda* (#:key configure-flags #:allow-other-keys)
1524 (let* ((out (assoc-ref %outputs "out"))
1525 (bash (assoc-ref %build-inputs "bash"))
1526 (shell (string-append bash "/bin/bash")))
1527 (setenv "CONFIG_SHELL" shell)
1528 (setenv "SHELL" shell)
1529 (setenv "LIBS" "-lc -lnss_files -lnss_dns -lresolv")
1530 (setenv "gl_cv_func_rename_dest_works" "yes")
1531 (format (current-error-port)
1532 "running ./configure ~a\n" (string-join configure-flags))
1533 (apply invoke (cons "./configure" configure-flags)))))
1534 (add-after 'unpack 'scripted-patch
1536 (let* ((bash (assoc-ref %build-inputs "bash"))
1537 (shell (string-append bash "/bin/bash")))
1538 (substitute* "configure"
1539 ((" /bin/sh") shell)))
1540 (substitute* "Makefile.in"
1541 (("^SUBDIRS = doc") "SUBDIRS ="))
1545 (let* ((out (assoc-ref %outputs "out"))
1546 (bin (string-append out "/bin")))
1547 (install-file "src/tar" bin)
1550 (define grep-mesboot
1551 ;; The initial grep.
1554 (name "grep-mesboot")
1558 (uri (string-append "mirror://gnu/grep/grep-"
1562 "1w862l80lgc5mxvpiy4cfwk761d6xxavn0m3xd2l7xs2kmzvp6lq"))))
1563 (supported-systems '("i686-linux" "x86_64-linux"))
1565 (propagated-inputs '())
1566 (native-inputs (%boot-mesboot0-inputs))
1568 `(#:implicit-inputs? #f
1569 #:guile ,%bootstrap-guile
1570 #:parallel-build? #f
1572 (modify-phases %standard-phases
1573 (add-before 'configure 'patch-configure
1575 (let* ((bash (assoc-ref %build-inputs "bash"))
1576 (shell (string-append bash "/bin/bash")))
1577 (substitute* "configure"
1578 ((" [|][|] ./config.status") " || sh ./config.status")))))
1581 (let* ((out (assoc-ref %outputs "out"))
1582 (bin (string-append out "/bin")))
1583 (install-file "grep" bin)
1584 (symlink "grep" (string-append bin "/egrep"))
1585 (symlink "grep" (string-append bin "/fgrep"))
1588 (define binutils-mesboot1
1590 (inherit binutils-mesboot0)
1591 (name "binutils-mesboot1")
1592 (native-inputs (%boot-mesboot0-inputs))
1594 (substitute-keyword-arguments (package-arguments binutils-mesboot0)
1595 ((#:configure-flags configure-flags)
1596 '(let ((out (assoc-ref %outputs "out")))
1600 "--build=i686-unknown-linux-gnu"
1601 "--host=i686-unknown-linux-gnu"
1603 ,(string-append "--prefix=" out))))
1605 `(modify-phases ,phases
1608 (let* ((out (assoc-ref %outputs "out"))
1609 (bash (assoc-ref %build-inputs "bash"))
1610 (shell (string-append bash "/bin/bash")))
1611 (setenv "CONFIG_SHELL" shell)
1614 (define coreutils-mesboot0
1617 (name "coreutils-mesboot0")
1618 ;; The latest .gz release of Coreutils is 8.13; which does not build with gcc-2.95.3:
1619 ;; randperm.c: In function `sparse_swap':
1620 ;; randperm.c:117: invalid lvalue in unary `&'
1621 (version "5.0") ; 2003-04
1624 (uri (string-append "mirror://gnu/coreutils/coreutils-"
1628 "10wq6k66i8adr4k08p0xmg87ff4ypiazvwzlmi7myib27xgffz62"))))
1629 (native-inputs (%boot-mesboot0-inputs))
1630 (supported-systems '("i686-linux" "x86_64-linux"))
1632 (propagated-inputs '())
1634 `(#:implicit-inputs? #f
1635 #:tests? #f ; WARNING: `perl' is needed, ...
1636 #:parallel-build? #f
1637 #:strip-binaries? #f ; strip: unrecognized option `--only-keep-debug'
1638 #:guile ,%bootstrap-guile
1641 "LIBS=-lc -lnss_files -lnss_dns -lresolv"
1642 "ac_cv_func_gethostbyname=no"
1643 "gl_cv_func_rename_dest_works=yes")))))
1645 (define gnu-make-mesboot
1648 (name "make-mesboot")
1652 (uri (string-append "mirror://gnu/make/make-"
1656 "1rs2f9hmvy3q6zkl15jnlmnpgffm0bhw5ax0h5c7q604wqrip69x"))))
1657 (native-inputs (%boot-mesboot0-inputs))
1658 (supported-systems '("i686-linux" "x86_64-linux"))
1660 (propagated-inputs '())
1662 `(#:implicit-inputs? #f
1663 #:parallel-build? #f
1664 #:guile ,%bootstrap-guile
1665 #:configure-flags '("LIBS=-lc -lnss_files -lnss_dns -lresolv")
1667 (modify-phases %standard-phases
1670 (invoke "./make" "--version")))
1672 (lambda* (#:key outputs #:allow-other-keys)
1673 (let* ((out (assoc-ref outputs "out"))
1674 (bin (string-append out "/bin")))
1675 (install-file "make" bin)
1678 (define gawk-mesboot
1681 (name "gawk-mesboot")
1685 (uri (string-append "mirror://gnu/gawk/gawk-"
1689 "03d5y7jabq7p2s7ys9alay9446mm7i5g2wvy8nlicardgb6b6ii1"))))
1690 (native-inputs `(,@(%boot-mesboot0-inputs)
1691 ("mesboot-headers" ,mesboot-headers)))
1692 (supported-systems '("i686-linux" "x86_64-linux"))
1694 (propagated-inputs '())
1696 `(#:implicit-inputs? #f
1697 #:parallel-build? #f
1698 #:guile ,%bootstrap-guile
1699 #:configure-flags '("ac_cv_func_connect=no")
1700 #:make-flags '("gawk")
1702 (modify-phases %standard-phases
1705 (invoke "./gawk" "--version")))
1707 (lambda* (#:key outputs #:allow-other-keys)
1708 (let* ((out (assoc-ref outputs "out"))
1709 (bin (string-append out "/bin")))
1710 (install-file "gawk" bin)
1711 (symlink "gawk" (string-append bin "/awk"))
1717 (name "sed-mesboot")
1718 (version "4.0.6") ; 2003-04
1721 (uri (string-append "mirror://gnu/sed/sed-"
1725 "0861ij94cqc4vaaki6r2wlapwcmhpx4ggp4r70f46mb21a8fkvf1"))))
1726 (native-inputs (%boot-mesboot0-inputs))
1727 (supported-systems '("i686-linux" "x86_64-linux"))
1729 (propagated-inputs '())
1731 `(#:implicit-inputs? #f
1732 #:parallel-build? #f
1733 #:guile ,%bootstrap-guile
1734 #:tests? #f ; 8to7 fails
1736 (modify-phases %standard-phases
1737 (add-after 'unpack '/bin/sh
1739 (let* ((bash (assoc-ref %build-inputs "bash"))
1740 (shell (string-append bash "/bin/bash")))
1741 (substitute* "testsuite/Makefile.tests"
1742 (("^SHELL = /bin/sh")
1743 (string-append "SHELL = " shell)))
1746 (define bash-mesboot
1748 (inherit bash-mesboot0)
1750 (name "bash-mesboot")
1753 (uri (string-append "mirror://gnu/bash/bash-"
1757 "1jyz6snd63xjn6skk7za6psgidsd53k05cr3lksqybi0q6936syq"))))
1759 (propagated-inputs '())
1760 (native-inputs (%boot-mesboot0-inputs))
1763 `(#:implicit-inputs? #f
1764 #:guile ,%bootstrap-guile
1765 #:parallel-build? #f
1767 '("--build=i686-unknown-linux-gnu"
1768 "--host=i686-unknown-linux-gnu"
1770 "--without-bash-malloc"
1771 "--disable-readline"
1773 "--disable-help-builtin"
1774 "--disable-progcomp"
1775 "--disable-net-redirections"
1778 ;; Pretend 'dlopen' is missing so we don't build loadable
1779 ;; modules and related code.
1780 "ac_cv_func_dlopen=no")
1781 #:make-flags '("bash")
1783 (modify-phases %standard-phases
1784 (add-after 'unpack 'scripted-patch
1786 (substitute* "shell.c"
1789 (add-before 'configure 'setenv
1791 (setenv "AWK" "gawk")
1792 (setenv "LIBS" "-lc -lnss_files -lnss_dns -lresolv")
1793 (setenv "gl_cv_func_rename_dest_works" "yes")
1795 (add-after 'configure 'configure-fixups
1797 (let ((config.h (open-file "config.h" "a")))
1798 (display (string-append "
1799 #define enable_hostname_completion(on_or_off) 0
1806 (invoke "./bash" "--version")))
1809 (let* ((out (assoc-ref %outputs "out"))
1810 (bin (string-append out "/bin")))
1812 (copy-file "bash" (string-append bin "/bash"))
1813 (copy-file "bash" (string-append bin "/sh"))
1816 (define (%boot-mesboot1-inputs)
1817 `(("bash" ,bash-mesboot)
1818 ("binutils" ,binutils-mesboot1)
1819 ("coreutils" ,coreutils-mesboot0)
1820 ("gawk" ,gawk-mesboot)
1821 ("grep" ,grep-mesboot)
1822 ("make" ,gnu-make-mesboot)
1823 ("sed" ,sed-mesboot)
1824 ("tar" ,tar-mesboot)
1825 ,@(fold alist-delete (%boot-mesboot0-inputs)
1826 '("bash" "binutils" "bootar" "coreutils" "gash"
1827 "gawk" "grep" "guile" "make" "sed" "tar"))))
1835 (uri (string-append "mirror://gnu/gmp/gmp-" version
1838 "15rwq54fi3s11izas6g985y9jklm3xprfsmym3v1g6xr84bavqvv"))))))
1846 (uri (string-append "mirror://gnu/mpfr/mpfr-" version
1849 "0dxn4904dra50xa22hi047lj8kkpr41d6vb9sd4grca880c7wv94"))))))
1858 "mirror://gnu/mpc/mpc-" version ".tar.gz"))
1861 "1hzci2zrrd7v3g1jk35qindq05hbl0bhjcyyisq9z209xb3fqzb1"))))))
1863 (define gcc-core-mesboot1
1864 ;; GCC 4.6.4 is the latest modular distribution. This package is not
1865 ;; stricly needed, but very helpful for development because it builds
1866 ;; relatively fast. If this configures and builds then gcc-mesboot1 also
1869 (inherit gcc-mesboot0)
1870 (name "gcc-core-mesboot1")
1874 (uri (string-append "mirror://gnu/gcc/gcc-"
1875 version "/gcc-core-" version ".tar.gz"))
1878 "173kdb188qg79pcz073cj9967rs2vzanyjdjyxy9v0xb0p5sad75"))
1880 ;; (patches (search-patches "gcc-boot-4.6.4.patch"))
1882 (inputs `(("gmp-source" ,(package-source gmp-boot))
1883 ("mpfr-source" ,(package-source mpfr-boot))
1884 ("mpc-source" ,(package-source mpc-boot))))
1885 (native-inputs `(("boot-patch" ,(search-patch "gcc-boot-4.6.4.patch"))
1886 ,@(%boot-mesboot1-inputs)))
1888 `(#:implicit-inputs? #f
1889 #:guile ,%bootstrap-guile
1891 #:modules ((guix build gnu-build-system)
1894 #:parallel-build? #f ; for debugging
1896 (let* ((libc (assoc-ref %build-inputs "libc"))
1897 (ldflags (string-append
1899 "-Wl,-dynamic-linker "
1901 ,(glibc-dynamic-linker "i686-linux"))))
1902 (list (string-append "LDFLAGS=" ldflags)
1903 (string-append "LDFLAGS_FOR_TARGET=" ldflags)))
1905 (let ((out (assoc-ref %outputs "out"))
1906 (glibc (assoc-ref %build-inputs "libc")))
1907 (list (string-append "--prefix=" out)
1908 "--build=i686-unknown-linux-gnu"
1909 "--host=i686-unknown-linux-gnu"
1910 (string-append "--with-native-system-header-dir=" glibc "/include")
1911 (string-append "--with-build-sysroot=" glibc "/include")
1912 "--disable-bootstrap"
1913 "--disable-decimal-float"
1914 "--disable-libatomic"
1915 "--disable-libcilkrts"
1918 "--disable-libmudflap"
1919 "--disable-libquadmath"
1920 "--disable-libsanitizer"
1924 "--disable-lto-plugin"
1925 "--disable-multilib"
1928 "--enable-languages=c"
1931 "--enable-threads=single"
1932 "--disable-libstdcxx-pch"
1933 "--disable-build-with-cxx"))
1935 (modify-phases %standard-phases
1936 (add-after 'unpack 'apply-boot-patch
1937 (lambda* (#:key inputs #:allow-other-keys)
1938 (let ((patch-file (assoc-ref inputs "boot-patch")))
1939 (format (current-error-port) "patch file=~s\n" patch-file)
1940 (system* "patch" "--force" "-p1" "-i" patch-file))
1942 ;; c&p from commencement.scm:gcc-boot0
1943 (add-after 'unpack 'unpack-gmp&co
1944 (lambda* (#:key inputs #:allow-other-keys)
1945 (let ((gmp (assoc-ref %build-inputs "gmp-source"))
1946 (mpfr (assoc-ref %build-inputs "mpfr-source"))
1947 (mpc (assoc-ref %build-inputs "mpc-source")))
1949 ;; To reduce the set of pre-built bootstrap inputs, build
1950 ;; GMP & co. from GCC.
1951 (for-each (lambda (source)
1952 (or (invoke "tar" "xvf" source)
1953 (error "failed to unpack tarball"
1955 (list gmp mpfr mpc))
1957 ;; Create symlinks like `gmp' -> `gmp-x.y.z'.
1958 ,@(map (lambda (lib)
1959 ;; Drop trailing letters, as gmp-6.0.0a unpacks
1961 `(symlink ,(string-trim-right
1962 (package-full-name lib "-")
1964 ,(package-name lib)))
1965 (list gmp-boot mpfr-boot mpc-boot))
1967 (add-before 'configure 'setenv
1968 (lambda* (#:key outputs #:allow-other-keys)
1969 (let* ((out (assoc-ref outputs "out"))
1970 (binutils (assoc-ref %build-inputs "binutils"))
1971 (bash (assoc-ref %build-inputs "bash"))
1972 (gcc (assoc-ref %build-inputs "gcc"))
1973 (glibc (assoc-ref %build-inputs "libc"))
1974 (kernel-headers (assoc-ref %build-inputs "kernel-headers")))
1975 (setenv "CONFIG_SHELL" (string-append bash "/bin/sh"))
1976 (setenv "C_INCLUDE_PATH" (string-append
1977 gcc "/lib/gcc-lib/i686-unknown-linux-gnu/2.95.3/include"
1978 ":" kernel-headers "/include"
1979 ":" glibc "/include"
1980 ":" (getcwd) "/mpfr/src"))
1981 (setenv "LIBRARY_PATH" (string-append glibc "/lib"
1983 (format (current-error-port) "C_INCLUDE_PATH=~a\n" (getenv "C_INCLUDE_PATH"))
1984 (format (current-error-port) "LIBRARY_PATH=~a\n" (getenv "LIBRARY_PATH"))
1987 (define gcc-mesboot1
1989 (inherit gcc-core-mesboot1)
1990 (name "gcc-mesboot1")
1996 (uri (string-append "mirror://gnu/gcc/gcc-"
1997 version "/gcc-g++-" version ".tar.gz"))
2000 "1fqqk5zkmdg4vmqzdmip9i42q6b82i3f6yc0n86n9021cr7ms2k9"))))
2001 ,@(package-native-inputs gcc-core-mesboot1)))
2003 (substitute-keyword-arguments (package-arguments gcc-core-mesboot1)
2004 ((#:configure-flags configure-flags)
2005 `(let ((out (assoc-ref %outputs "out")))
2006 `("--enable-languages=c,c++"
2008 (negate (lambda (x) (string-prefix? "--enable-languages=" x)))
2009 ,configure-flags))))
2011 `(modify-phases ,phases
2012 (add-before 'unpack 'unpack-g++
2014 (let ((source-g++ (assoc-ref %build-inputs "gcc-g++")))
2015 (invoke "tar" "xvf" source-g++))
2019 (setenv "CONFIG_SHELL" (which "sh"))
2021 ;; Allow MPFR headers to be found.
2022 (setenv "C_INCLUDE_PATH"
2023 (string-append (getcwd) "/mpfr/src:"
2024 (getenv "C_INCLUDE_PATH")))
2026 ;; Set the C++ search path so that C headers can be found as
2027 ;; libstdc++ is being compiled.
2028 (setenv "CPLUS_INCLUDE_PATH" (getenv "C_INCLUDE_PATH"))
2031 (define (%boot-mesboot2-inputs)
2032 `(("gcc" ,gcc-mesboot1)
2033 ,@(alist-delete "gcc" (%boot-mesboot1-inputs))))
2036 ;; Finally, we can build xz.
2041 (source (bootstrap-origin
2044 (uri (list (string-append "http://tukaani.org/xz/xz-" version
2046 (string-append "http://multiprecision.org/guix/xz-"
2047 version ".tar.gz")))
2050 "0kf40ggbs1vaaj5s9k4csycahzqcf65n20pa6lngqhm6j0cj3agb")))))
2051 (supported-systems '("i686-linux" "x86_64-linux"))
2054 (propagated-inputs '())
2055 (native-inputs (%boot-mesboot2-inputs))
2057 `(#:implicit-inputs? #f
2058 #:guile ,%bootstrap-guile
2059 #:parallel-build? #f
2061 `("--disable-assembler"
2067 "--disable-lzmainfo"
2068 "--disable-lzma-links"
2072 "--disable-symbol-versions"
2073 ;; configure disqualifies BASH, CPP, GCC and GREP
2074 ;; all of which seem fine for the build
2075 "ac_cv_prog_cc_c99=-std=gnu9x"
2076 "ac_cv_path_GREP=grep"
2077 "gl_cv_posix_shell=bash"
2078 "ac_cv_have_decl_optreset=no"
2079 "CPPFLAGS=-D__GNUC__=1")))))
2081 (define hello-mesboot
2082 ;; Check for Scheme-only bootstrap.
2085 (name "hello-mesboot")
2086 (supported-systems '("i686-linux" "x86_64-linux"))
2088 (propagated-inputs '())
2089 (native-inputs (%boot-mesboot2-inputs))
2091 `(#:implicit-inputs? #f
2092 #:guile ,%bootstrap-guile
2093 #:parallel-build? #f
2094 ;; checking for grep that handles long lines and -e...
2095 ;; configure: error: no acceptable grep could be found
2096 #:configure-flags '("ac_cv_path_GREP=grep")
2098 (modify-phases %standard-phases
2101 (invoke "./hello"))))))))
2103 (define binutils-mesboot
2106 (name "binutils-mesboot")
2108 (source (bootstrap-origin
2111 (uri (string-append "mirror://gnu/binutils/binutils-"
2112 version ".tar.bz2"))
2113 (patches (search-patches "binutils-boot-2.20.1a.patch"))
2116 "0r7dr0brfpchh5ic0z9r4yxqn4ybzmlh25sbp30cacqk8nb7rlvi")))))
2118 (propagated-inputs '())
2119 (native-inputs `(("xz" ,xz-mesboot)
2120 ,@(%boot-mesboot2-inputs)))
2121 (supported-systems '("i686-linux" "x86_64-linux"))
2123 `(#:implicit-inputs? #f
2124 #:guile ,%bootstrap-guile
2125 #:tests? #f ; runtest: command not found
2126 #:parallel-build? #f
2127 #:strip-binaries? #f ; no strip yet
2136 "--build=i686-unknown-linux-gnu"
2137 "--host=i686-unknown-linux-gnu"
2139 ;; checking for grep that handles long lines and -e
2140 "ac_cv_path_GREP=grep")
2141 ;; FIXME: ac_cv_path_GREP=grep doesn't seem to be forwarded to
2142 ;; cascading configure's?
2143 #:make-flags '("ac_cv_path_GREP=grep")
2145 (modify-phases %standard-phases
2146 (add-after 'unpack 'scripted-patch
2148 ;; sed-mesboot0 cannot build these
2149 (copy-file "binutils/Makefile.in" "binutils/Makefile.in.orig")
2150 (substitute* "binutils/Makefile.in"
2151 ;; binutils/binutils uses an amazingly complex install
2152 ;; command, using FOR, SED, READ, IF, ECHO, SED, SED, AWK,
2153 ;; READ, and then LIBTOOL (to do something like
2154 ;; `mkdir $DESTDIR$bindir; cp readline $DESTDIR$bindir ...')
2156 ;; Some tool [debugme!] cannot handle two escaped newlines
2157 ;; (bash?), and the install stops after $(am__EXEEXT_11)
2158 ;; ("objcopy"), so $(am__EXEEXT_13) ("readelf") and others do
2159 ;; not get installed. Remove the stray newline:
2160 (("^\t@BUILD_NLMCONV@ @BUILD_SRCONV@ @BUILD_DLLTOOL@ @BUILD_WINDRES@ .*") ""))
2161 (substitute* "opcodes/Makefile.in"
2162 (("^SUBDIRS = [.] po") "SUBDIRS = ."))
2163 (substitute* "binutils/Makefile.in"
2164 (("^SUBDIRS = doc po") "SUBDIRS ="))
2165 (substitute* "gas/Makefile.in"
2166 (("^SUBDIRS = doc po") "SUBDIRS ="))
2167 (substitute* "gprof/Makefile.in"
2168 (("^SUBDIRS = po") "SUBDIRS ="))
2169 (substitute* "ld/Makefile.in"
2170 (("^SUBDIRS = po") "SUBDIRS ="))
2173 (define (%boot-mesboot3-inputs)
2174 `(("binutils" ,binutils-mesboot)
2176 ,@(alist-delete "binutils" (%boot-mesboot2-inputs))))
2178 (define glibc-headers-mesboot
2180 (inherit glibc-mesboot0)
2181 (name "glibc-headers-mesboot")
2183 (source (bootstrap-origin
2186 (uri (string-append "mirror://gnu/glibc/glibc-"
2189 (patches (search-patches "glibc-boot-2.16.0.patch"
2190 "glibc-bootstrap-system-2.16.0.patch"))
2193 "0vlz4x6cgz7h54qq4528q526qlhnsjzbsvgc4iizn76cb0bfanx7")))))
2194 (native-inputs `(("headers" ,mesboot-headers)
2195 ,@(%boot-mesboot3-inputs)))
2197 (substitute-keyword-arguments (package-arguments glibc-mesboot0)
2198 ((#:configure-flags configure-flags)
2199 `(let ((out (assoc-ref %outputs "out"))
2200 (headers (assoc-ref %build-inputs "headers")))
2202 (string-append "--prefix=" out)
2203 "--disable-obsolete-rpc"
2204 "--host=i686-unknown-linux-gnu"
2205 (string-append "--with-headers=" headers "/include")
2206 "--enable-static-nss"
2210 "--enable-add-ons=nptl"
2211 ;; avoid: configure: error: confusing output from nm -u
2212 "libc_cv_predef_stack_protector=no")))
2213 ((#:make-flags make-flags)
2214 '(list "install-bootstrap-headers=yes" "install-headers"))
2216 `(modify-phases ,phases
2217 (delete 'apply-boot-patch)
2218 (delete 'fixup-configure)
2221 (lambda* (#:key source #:allow-other-keys)
2222 (invoke "tar" "xvf" source)
2223 (chdir (string-append "glibc-" ,version))
2226 (lambda* (#:key inputs #:allow-other-keys)
2227 (let* ((headers (assoc-ref inputs "headers"))
2228 (libc (assoc-ref inputs "libc"))
2229 (gcc (assoc-ref inputs "gcc"))
2230 (cppflags (string-append
2231 " -I " (getcwd) "/nptl/sysdeps/pthread/bits"
2232 " -D BOOTSTRAP_GLIBC=1"))
2233 (cflags (string-append " -L " (getcwd)
2234 " -L " libc "/lib")))
2235 (setenv "libc_cv_friendly_stddef" "yes")
2236 (setenv "CONFIG_SHELL" (which "sh"))
2237 (setenv "SHELL" (which "sh"))
2239 (setenv "CPP" (string-append gcc "/bin/gcc -E " cppflags))
2240 (setenv "CC" (string-append gcc "/bin/gcc " cppflags cflags))
2243 ;; avoid -fstack-protector
2244 (setenv "libc_cv_ssp" "false")
2245 (substitute* "configure"
2246 (("/bin/pwd") "pwd"))
2249 (lambda* (#:key outputs make-flags #:allow-other-keys)
2250 (let ((kernel-headers (assoc-ref %build-inputs "kernel-headers"))
2251 (out (assoc-ref outputs "out")))
2252 (and (apply invoke "make" make-flags)
2253 (copy-recursively kernel-headers out)
2256 (lambda* (#:key configure-flags #:allow-other-keys)
2257 (format (current-error-port) "running ../configure ~a\n" (string-join configure-flags))
2260 (apply invoke "../configure" configure-flags)))
2261 (add-after 'configure 'remove-sunrpc
2263 (let* ((out (assoc-ref %outputs "out"))
2264 (bash (assoc-ref %build-inputs "bash"))
2265 (shell (string-append bash "/bin/bash")))
2267 (let ((Makefile (open-file "Makefile" "a")))
2268 (display (string-append "
2274 (substitute* "../Makefile"
2275 (("^SHELL := /bin/sh") (string-append "SHELL := " shell)))
2276 (substitute* "../Makeconfig"
2277 (("^SHELL := /bin/sh") (string-append "SHELL := " shell)))
2278 (substitute* "../elf/Makefile"
2279 (("^SHELL := /bin/sh") (string-append "SHELL := " shell)))
2280 (invoke "make" (string-append (getcwd) "/sysd-sorted" ))
2281 (substitute* "sysd-sorted"
2286 (define glibc-mesboot
2288 (inherit glibc-headers-mesboot)
2289 (name "glibc-mesboot")
2290 (native-inputs `(("headers" ,glibc-headers-mesboot)
2291 ,@(%boot-mesboot3-inputs)))
2293 `(#:validate-runpath? #f ; fails when using --enable-shared
2294 ,@(substitute-keyword-arguments (package-arguments glibc-headers-mesboot)
2295 ((#:make-flags make-flags)
2296 `(let ((bash (assoc-ref %build-inputs "bash")))
2297 (list (string-append "SHELL=" bash "/bin/sh"))))
2299 `(modify-phases ,phases
2301 (lambda* (#:key outputs make-flags #:allow-other-keys)
2302 (let* ((kernel-headers (assoc-ref %build-inputs "kernel-headers"))
2303 (out (assoc-ref outputs "out"))
2304 (install-flags (cons "install" make-flags)))
2305 (and (apply invoke "make" install-flags)
2306 (copy-recursively kernel-headers out)
2309 (define (%boot-mesboot4-inputs)
2310 `(("libc" ,glibc-mesboot)
2311 ,@(alist-delete "libc" (%boot-mesboot3-inputs))))
2313 (define gcc-mesboot1-wrapper
2314 ;; We need this so gcc-mesboot1 can be used to create shared binaries that
2315 ;; have the correct interpreter, otherwise configuring gcc-mesboot using
2316 ;; --enable-shared will fail.
2318 (inherit gcc-mesboot1)
2319 (name "gcc-mesboot1-wrapper")
2322 (native-inputs `(("bash" ,bash-mesboot)
2323 ("coreutils" ,coreutils-mesboot0)
2324 ("libc" ,glibc-mesboot)
2325 ("gcc" ,gcc-mesboot1)))
2327 `(#:implicit-inputs? #f
2328 #:guile ,%bootstrap-guile
2330 (modify-phases %standard-phases
2335 (lambda* (#:key outputs #:allow-other-keys)
2336 (let* ((out (assoc-ref outputs "out"))
2337 (bash (assoc-ref %build-inputs "bash"))
2338 (libc (assoc-ref %build-inputs "libc"))
2339 (gcc (assoc-ref %build-inputs "gcc"))
2340 (bin (string-append out "/bin")))
2344 (let ((wrapper (string-append bin "/" program)))
2345 (with-output-to-file wrapper
2347 (display (string-append "#! " bash "/bin/bash
2348 exec " gcc "/bin/" program
2349 " -Wl,--dynamic-linker"
2350 ;; also for x86_64-linux, we are still on i686-linux
2351 " -Wl," libc ,(glibc-dynamic-linker "i686-linux")
2356 (chmod wrapper #o555)))))
2360 "i686-unknown-linux-gnu-cpp"
2361 "i686-unknown-linux-gnu-gcc"
2362 "i686-unknown-linux-gnu-g++"))
2365 (lambda* (#:key outputs #:allow-other-keys)
2366 (let* ((out (assoc-ref outputs "out"))
2367 (bin (string-append out "/bin"))
2368 (program (string-append bin "/gcc")))
2369 (invoke program "--help")))))))))
2373 (inherit gcc-mesboot1)
2374 (name "gcc-mesboot")
2375 (version (package-version gcc-4.9))
2376 (source (bootstrap-origin (package-source gcc-4.9)))
2377 (native-inputs `(("gcc-wrapper" ,gcc-mesboot1-wrapper)
2378 ("gcc" ,gcc-mesboot1)
2379 ("headers" ,glibc-headers-mesboot)
2380 ,@(%boot-mesboot4-inputs)))
2382 `(#:validate-runpath? #f
2383 ,@(substitute-keyword-arguments (package-arguments gcc-mesboot1)
2384 ((#:configure-flags configure-flags)
2385 `(let ((out (assoc-ref %outputs "out"))
2386 (glibc (assoc-ref %build-inputs "libc")))
2387 (list (string-append "--prefix=" out)
2388 "--build=i686-unknown-linux-gnu"
2389 "--host=i686-unknown-linux-gnu"
2391 "--with-host-libstdcxx=-lsupc++"
2393 (string-append "--with-native-system-header-dir=" glibc "/include")
2394 (string-append "--with-build-sysroot=" glibc "/include")
2396 "--disable-bootstrap"
2397 "--disable-decimal-float"
2398 "--disable-libatomic"
2399 "--disable-libcilkrts"
2402 "--disable-libmudflap"
2403 "--disable-libquadmath"
2404 "--disable-libsanitizer"
2408 "--disable-lto-plugin"
2409 "--disable-multilib"
2412 "--enable-languages=c,c++"
2416 "--enable-threads=single"
2418 ;; No pre-compiled libstdc++ headers, to save space.
2419 "--disable-libstdcxx-pch"
2422 "--disable-build-with-cxx")))
2424 `(modify-phases ,phases
2425 (delete 'apply-boot-patch)
2426 (delete 'unpack-g++) ; sadly, gcc-4.9.4 does not provide
2427 ; modular core/language downloads
2429 (lambda* (#:key outputs #:allow-other-keys)
2430 (let* ((out (assoc-ref outputs "out"))
2431 (binutils (assoc-ref %build-inputs "binutils"))
2432 (bash (assoc-ref %build-inputs "bash"))
2433 (gcc (assoc-ref %build-inputs "gcc"))
2434 (glibc (assoc-ref %build-inputs "libc"))
2435 (kernel-headers (assoc-ref %build-inputs "kernel-headers")))
2436 (setenv "CONFIG_SHELL" (string-append bash "/bin/sh"))
2437 (setenv "C_INCLUDE_PATH" (string-append
2438 gcc "/lib/gcc-lib/i686-unknown-linux-gnu/4.6.4/include"
2439 ":" kernel-headers "/include"
2440 ":" glibc "/include"
2441 ":" (getcwd) "/mpfr/src"))
2442 (setenv "CPLUS_INCLUDE_PATH" (string-append
2443 gcc "/lib/gcc-lib/i686-unknown-linux-gnu/4.6.4/include"
2444 ":" kernel-headers "/include"
2445 ":" glibc "/include"
2446 ":" (getcwd) "/mpfr/src"))
2447 (setenv "LIBRARY_PATH" (string-append glibc "/lib"
2449 (format (current-error-port) "C_INCLUDE_PATH=~a\n" (getenv "C_INCLUDE_PATH"))
2450 (format (current-error-port) "CPLUS_INCLUDE_PATH=~a\n" (getenv "CPLUS_INCLUDE_PATH"))
2451 (format (current-error-port) "LIBRARY_PATH=~a\n" (getenv "LIBRARY_PATH"))
2454 (define gcc-mesboot-wrapper
2455 ;; We need this so gcc-mesboot can be used to create shared binaries that
2456 ;; have the correct interpreter and runpath to libc.
2458 (inherit gcc-mesboot1-wrapper)
2459 (name "gcc-mesboot-wrapper")
2460 (version (package-version gcc-mesboot))
2463 (native-inputs `(("bash" ,bash-mesboot)
2464 ("coreutils" ,coreutils-mesboot0)
2465 ("libc" ,glibc-mesboot)
2466 ("gcc" ,gcc-mesboot)))))
2468 (define (%boot-mesboot5-inputs)
2469 `(("gcc-wrapper" ,gcc-mesboot-wrapper)
2470 ("gcc" ,gcc-mesboot)
2471 ,@(fold alist-delete (%boot-mesboot4-inputs) '("gcc" "gcc-wrapper"))))
2473 (define coreutils-mesboot
2476 (name "coreutils-mesboot")
2477 (source (bootstrap-origin (package-source coreutils)))
2478 (native-inputs (%boot-mesboot5-inputs))
2479 (supported-systems '("i686-linux" "x86_64-linux"))
2481 (propagated-inputs '())
2483 `(#:implicit-inputs? #f
2484 #:guile ,%bootstrap-guile
2487 (define (%boot-mesboot6-inputs)
2488 `(("coreutils" ,coreutils-mesboot)
2489 ,@(fold alist-delete (%boot-mesboot5-inputs)
2490 '("coreutils" "kernel-headers"))))
2492 (define (%bootstrap-inputs+toolchain)
2493 ;; The traditional bootstrap-inputs. For the i686-linux, x86_64-linux
2494 ;; Scheme-only bootstrap the actual reduced set with bootstrapped toolchain.
2495 (match (%current-system)
2496 ((or "i686-linux" "x86_64-linux")
2497 (%boot-mesboot6-inputs))
2499 (%bootstrap-inputs))))
2501 (define gnu-make-boot0
2504 (source (bootstrap-origin (package-source gnu-make)))
2507 `(#:guile ,%bootstrap-guile
2508 #:implicit-inputs? #f
2509 #:tests? #f ; cannot run "make check"
2510 ,@(substitute-keyword-arguments (package-arguments gnu-make)
2511 ((#:configure-flags flags ''())
2512 ;; The generated config.status has some problems due to the
2513 ;; bootstrap environment. Disable dependency tracking to work
2515 `(cons "--disable-dependency-tracking" ,flags))
2517 `(modify-phases ,phases
2520 (invoke "./build.sh")))
2522 (lambda* (#:key outputs #:allow-other-keys)
2523 (let* ((out (assoc-ref outputs "out"))
2524 (bin (string-append out "/bin")))
2525 (install-file "make" bin)
2527 (native-inputs '()) ; no need for 'pkg-config'
2528 (inputs (%bootstrap-inputs+toolchain))))
2533 (name "bzip2-boot0")
2536 `(("diffutils" ,diffutils-boot0)
2537 ("make" ,gnu-make-boot0)
2538 ,@(%bootstrap-inputs+toolchain)))
2540 `(#:guile ,%bootstrap-guile
2541 #:implicit-inputs? #f
2542 ,@(package-arguments bzip2)))))
2544 (define coreutils-boot0
2547 (source (bootstrap-origin (package-source coreutils)))
2548 (name "coreutils-boot0")
2551 `(("make" ,gnu-make-boot0)
2552 ,@(%bootstrap-inputs+toolchain)))
2555 #:implicit-inputs? #f
2556 #:guile ,%bootstrap-guile
2557 ,@(package-arguments coreutils)))))
2559 (define diffutils-boot0
2562 (name "diffutils-boot0")
2565 `(("make" ,gnu-make-boot0)
2566 ,@(%bootstrap-inputs+toolchain)))
2568 `(#:tests? #f ; the test suite needs diffutils
2569 #:guile ,%bootstrap-guile
2570 #:implicit-inputs? #f
2571 ,@(match (%current-system)
2572 ((or "arm-linux" "aarch64-linux")
2573 (substitute-keyword-arguments (package-arguments diffutils)
2574 ((#:configure-flags flags ''())
2575 ;; The generated config.status has some problems due to the
2576 ;; bootstrap environment. Disable dependency tracking to work
2578 `(cons "--disable-dependency-tracking" ,flags))))
2581 (define findutils-boot0
2584 (name "findutils-boot0")
2585 (source (bootstrap-origin (package-source findutils)))
2587 `(("make" ,gnu-make-boot0)
2588 ("diffutils" ,diffutils-boot0) ; for tests
2589 ,@(%bootstrap-inputs+toolchain)))
2591 `(#:implicit-inputs? #f
2592 #:guile ,%bootstrap-guile
2594 ;; The build system assumes we have done a mistake when time_t is 32-bit
2595 ;; on a 64-bit system. Ignore that for our bootstrap toolchain.
2596 ,@(substitute-keyword-arguments (package-arguments findutils)
2597 ((#:configure-flags flags ''())
2599 ,(if (target-64bit?)
2600 ''("TIME_T_32_BIT_OK=yes")
2602 ,(match (%current-system)
2603 ((or "arm-linux" "aarch64-linux")
2604 ''("--disable-dependency-tracking"))
2610 (inherit (@ (gnu packages file) file))
2614 ,,@(match (%current-system)
2615 ((or "arm-linux" "aarch64-linux")
2616 '("--disable-dependency-tracking"))
2622 (source (bootstrap-origin (package-source file)))
2625 `(("make" ,gnu-make-boot0)
2626 ,@(%bootstrap-inputs+toolchain)))
2628 `(#:tests? #f ; merge test fails
2629 #:implicit-inputs? #f
2630 #:guile ,%bootstrap-guile
2631 #:configure-flags '("--disable-bzlib")
2632 #:strip-binaries? #f
2633 #:validate-runpath? #f
2634 ,@(package-arguments file)))))
2639 (source (bootstrap-origin (package-source gawk)))
2643 `(("make" ,gnu-make-boot0)
2644 ,@(%bootstrap-inputs+toolchain)))
2647 #:implicit-inputs? #f
2648 #:guile ,%bootstrap-guile
2649 #:strip-binaries? #f
2650 #:validate-runpath? #f))))
2655 (source (bootstrap-origin (package-source patch)))
2656 (name "patch-boot0")
2659 `(("make" ,gnu-make-boot0)
2660 ,@(%bootstrap-inputs+toolchain)))
2662 `(#:tests? #f ; merge test fails
2663 #:implicit-inputs? #f
2664 #:guile ,%bootstrap-guile
2665 #:strip-binaries? #f
2666 #:validate-runpath? #f))))
2672 (source (bootstrap-origin (package-source sed)))
2675 `(("make" ,gnu-make-boot0)
2676 ,@(%bootstrap-inputs+toolchain)))
2678 `(#:implicit-inputs? #f
2680 #:guile ,%bootstrap-guile
2681 ,@(package-arguments sed)))))
2687 (source (bootstrap-origin (package-source tar)))
2690 `(("make" ,gnu-make-boot0)
2691 ,@(%bootstrap-inputs+toolchain)))
2693 `(#:implicit-inputs? #f
2695 #:guile ,%bootstrap-guile
2696 ,@(package-arguments tar)))))
2698 (define (%boot0-inputs)
2699 `(,@(match (%current-system)
2700 ((or "i686-linux" "x86_64-linux")
2701 `(("bzip2" ,bzip2-boot0)
2702 ("coreutils" ,coreutils-boot0)
2703 ("gawk" ,gawk-boot0)
2704 ("patch" ,patch-boot0)
2706 ("tar" ,tar-boot0)))
2708 ("make" ,gnu-make-boot0)
2709 ("diffutils" ,diffutils-boot0)
2710 ("findutils" ,findutils-boot0)
2711 ("file" ,file-boot0)
2712 ,@(%bootstrap-inputs+toolchain)))
2714 (define* (boot-triplet #:optional (system (%current-system)))
2715 ;; Return the triplet used to create the cross toolchain needed in the
2716 ;; first bootstrapping stage.
2717 (nix-system->gnu-triplet system "guix"))
2719 ;; Following Linux From Scratch, build a cross-toolchain in stage 0. That
2720 ;; toolchain actually targets the same OS and arch, but it has the advantage
2721 ;; of being independent of the libc and tools in
2722 ;; (%BOOTSTRAP-INPUTS+TOOLCHAIN), since GCC-BOOT0 (below) is built without any
2723 ;; reference to the target libc.
2725 (define binutils-boot0
2728 (source (bootstrap-origin (package-source binutils)))
2729 (name "binutils-cross-boot0")
2731 `(#:guile ,%bootstrap-guile
2732 #:implicit-inputs? #f
2734 #:modules ((guix build gnu-build-system)
2736 (ice-9 ftw)) ; for 'scandir'
2737 #:phases (modify-phases %standard-phases
2738 (add-after 'install 'add-symlinks
2739 (lambda* (#:key outputs #:allow-other-keys)
2740 ;; The cross-gcc invokes 'as', 'ld', etc, without the
2741 ;; triplet prefix, so add symlinks.
2742 (let ((out (assoc-ref outputs "out"))
2743 (triplet-prefix (string-append ,(boot-triplet) "-")))
2744 (define (has-triplet-prefix? name)
2745 (string-prefix? triplet-prefix name))
2746 (define (remove-triplet-prefix name)
2747 (substring name (string-length triplet-prefix)))
2748 (with-directory-excursion (string-append out "/bin")
2749 (for-each (lambda (name)
2750 (symlink name (remove-triplet-prefix name)))
2751 (scandir "." has-triplet-prefix?)))
2754 ,@(substitute-keyword-arguments (package-arguments binutils)
2755 ((#:configure-flags cf)
2756 `(cons ,(string-append "--target=" (boot-triplet))
2758 (inputs (%boot0-inputs))))
2760 (define libstdc++-boot0
2761 ;; GCC's libcc1 is always built as a shared library (the top-level
2762 ;; 'Makefile.def' forcefully adds --enable-shared) and thus needs to refer
2763 ;; to libstdc++.so. We cannot build libstdc++-5.3 because it relies on
2764 ;; C++14 features missing in some of our bootstrap compilers.
2765 (let ((lib (make-libstdc++ gcc-4.9)))
2768 (source (bootstrap-origin (package-source lib)))
2769 (name "libstdc++-boot0")
2771 `(#:guile ,%bootstrap-guile
2772 #:implicit-inputs? #f
2774 ;; XXX: libstdc++.so NEEDs ld.so for some reason.
2775 #:validate-runpath? #f
2777 ,@(match (%current-system)
2778 ((or "i686-linux" "x86_64-linux")
2779 (substitute-keyword-arguments (package-arguments lib)
2781 `(modify-phases ,phases
2782 (add-after 'unpack 'workaround-wrapper-bug
2783 ;; XXX: The crude gcc-cross-wrapper causes "g++ -v" to
2784 ;; fail, which in turn confuses the configure script.
2786 (substitute* "libstdc++-v3/configure"
2787 (("g\\+\\+ -v") "true"))
2789 (_ (package-arguments lib)))))
2790 (inputs (%boot0-inputs))
2791 (native-inputs '()))))
2796 (name "gcc-cross-boot0")
2797 (source (bootstrap-origin (package-source gcc)))
2799 `(#:guile ,%bootstrap-guile
2800 #:implicit-inputs? #f
2801 #:modules ((guix build gnu-build-system)
2806 ,@(substitute-keyword-arguments (package-arguments gcc)
2807 ((#:configure-flags flags)
2808 `(append (list ,(string-append "--target=" (boot-triplet))
2813 ;; Disable features not needed at this stage.
2815 "--enable-languages=c,c++"
2817 ;; libstdc++ cannot be built at this stage
2818 ;; ("Link tests are not allowed after
2819 ;; GCC_NO_EXECUTABLES.").
2820 "--disable-libstdc++-v3"
2823 "--disable-libmudflap"
2824 "--disable-libatomic"
2825 "--disable-libsanitizer"
2829 "--disable-libcilkrts"
2832 "--disable-libquadmath"
2833 "--disable-decimal-float")
2834 (remove (cut string-match
2835 "--(with-system-zlib|enable-languages.*)" <>)
2837 ((#:make-flags flags)
2838 `(let* ((libc (assoc-ref %build-inputs "libc"))
2839 (libc-native (or (assoc-ref %build-inputs "libc-native")
2841 `(,(string-append "LDFLAGS="
2842 "-Wl,-rpath=" libc-native "/lib "
2843 "-Wl,-dynamic-linker "
2844 "-Wl," libc-native ,(glibc-dynamic-linker
2845 (match (%current-system)
2846 ("x86_64-linux" "i686-linux")
2847 (_ (%current-system))))))))
2849 `(modify-phases ,phases
2850 (add-after 'unpack 'unpack-gmp&co
2851 (lambda* (#:key inputs #:allow-other-keys)
2852 (let ((gmp (assoc-ref %build-inputs "gmp-source"))
2853 (mpfr (assoc-ref %build-inputs "mpfr-source"))
2854 (mpc (assoc-ref %build-inputs "mpc-source")))
2856 ;; To reduce the set of pre-built bootstrap inputs, build
2857 ;; GMP & co. from GCC.
2858 (for-each (lambda (source)
2859 (invoke "tar" "xvf" source))
2860 (list gmp mpfr mpc))
2862 ;; Create symlinks like `gmp' -> `gmp-x.y.z'.
2863 ,@(map (lambda (lib)
2864 ;; Drop trailing letters, as gmp-6.0.0a unpacks
2866 `(symlink ,(string-trim-right
2867 (package-full-name lib "-")
2869 ,(package-name lib)))
2870 (list gmp-6.0 mpfr mpc))
2872 ,(match (%current-system)
2873 ((or "i686-linux" "x86_64-linux")
2874 '(add-before 'configure 'fix-libcc1
2875 (lambda* (#:key inputs #:allow-other-keys)
2876 ;; libcc1.so NEEDs libgcc_s.so, so provide one here
2877 ;; to placate the 'validate-runpath' phase.
2878 (substitute* "libcc1/Makefile.in"
2880 (string-append "la_LDFLAGS = -Wl,-rpath="
2881 (assoc-ref inputs "gcc") "/lib")))
2882 ;; XXX: "g++ -v" is broken (see also libstdc++ above).
2883 (substitute* "libcc1/configure"
2884 (("g\\+\\+ -v") "true"))
2886 (_ '(add-before 'configure 'return-true
2888 (add-after 'install 'symlink-libgcc_eh
2889 (lambda* (#:key outputs #:allow-other-keys)
2890 (let ((out (assoc-ref outputs "lib")))
2891 ;; Glibc wants to link against libgcc_eh, so provide
2893 (with-directory-excursion
2894 (string-append out "/lib/gcc/"
2896 "/" ,(package-version gcc))
2897 (symlink "libgcc.a" "libgcc_eh.a"))
2900 (inputs `(("gmp-source" ,(bootstrap-origin (package-source gmp-6.0)))
2901 ("mpfr-source" ,(bootstrap-origin (package-source mpfr)))
2902 ("mpc-source" ,(bootstrap-origin (package-source mpc)))
2903 ("binutils-cross" ,binutils-boot0)
2905 ;; The libstdc++ that libcc1 links against.
2906 ("libstdc++" ,libstdc++-boot0)
2908 ;; Call it differently so that the builder can check whether
2909 ;; the "libc" input is #f.
2910 ("libc-native" ,@(assoc-ref (%boot0-inputs) "libc"))
2911 ,@(alist-delete "libc" (%boot0-inputs))))
2913 ;; No need for the native-inputs to build the documentation at this stage.
2914 (native-inputs `())))
2920 (source (bootstrap-origin (package-source perl)))
2921 (inputs (%boot0-inputs))
2923 `(#:implicit-inputs? #f
2924 #:guile ,%bootstrap-guile
2925 #:validate-runpath? #f
2927 ;; At the very least, this must not depend on GCC & co.
2928 #:disallowed-references ,(list %bootstrap-binutils)
2930 ,@(substitute-keyword-arguments (package-arguments perl)
2932 `(modify-phases ,phases
2933 ;; Pthread support is missing in the bootstrap compiler
2934 ;; (broken spec file), so disable it.
2935 (add-before 'configure 'disable-pthreads
2937 (substitute* "Configure"
2938 (("^libswanted=(.*)pthread" _ before)
2939 (string-append "libswanted=" before)))
2941 ;; Do not configure with '-Dusethreads' since pthread
2942 ;; support is missing.
2943 ((#:configure-flags configure-flags)
2944 `(delete "-Dusethreads" ,configure-flags)))))))
2950 (source (bootstrap-origin (package-source m4)))
2951 (inputs (%boot0-inputs))
2953 `(#:guile ,%bootstrap-guile
2954 #:implicit-inputs? #f
2955 ,@(package-arguments m4)))))
2958 ;; This Bison is needed to build MiG so we need it early in the process.
2959 ;; Recent versions of Linux-Libre headers also depend on this.
2962 (name "bison-boot0")
2963 (propagated-inputs `(("m4" ,m4-boot0)))
2964 (native-inputs `(("perl" ,perl-boot0)))
2965 (inputs (%boot0-inputs)) ;remove Flex...
2967 `(#:tests? #f ;... and thus disable tests
2968 #:implicit-inputs? #f
2969 #:guile ,%bootstrap-guile
2971 ;; Zero timestamps in liby.a; this must be done
2972 ;; explicitly here because the bootstrap Binutils don't
2973 ;; do that (default is "cru".)
2974 #:make-flags `("ARFLAGS=crD"
2975 ,,(match (%current-system)
2976 ;; ranlib: '-D': No such file
2977 ((or "i686-linux" "x86_64-linux")
2980 "RANLIB=ranlib -D"))
2983 ,@(package-arguments bison)))))
2986 ;; This Flex is needed to build MiG as well as Linux-Libre headers.
2989 (native-inputs `(("bison" ,bison-boot0)))
2990 (propagated-inputs `(("m4" ,m4-boot0)))
2991 (inputs (%boot0-inputs))
2993 `(#:implicit-inputs? #f
2994 #:guile ,%bootstrap-guile
3000 (native-inputs `(("perl" ,perl-boot0)))
3001 (inputs (%boot0-inputs))
3003 `(#:implicit-inputs? #f
3004 #:guile ,%bootstrap-guile))))
3006 (define-syntax define/system-dependent
3008 "Bind IDENTIFIER to EXP, where the value of EXP is known to depend on
3009 '%current-system'. The definition ensures that (1) EXP is \"thunked\" so that
3010 it sees the right value of '%current-system', and (2) that its result is
3011 memoized as a function of '%current-system'."
3014 (with-syntax ((memoized (datum->syntax #'identifier
3016 (syntax->datum #'identifier)
3020 (mlambda (system) exp))
3021 (define-syntax identifier
3022 (identifier-syntax (memoized (%current-system))))))))))
3024 (define/system-dependent linux-libre-headers-boot0
3025 ;; Note: this is wrapped in a thunk to nicely handle circular dependencies
3026 ;; between (gnu packages linux) and this module. Additionally, memoize
3027 ;; the result to play well with further memoization and code that relies
3028 ;; on pointer identity; see <https://bugs.gnu.org/30155>.
3030 (inherit linux-libre-headers)
3032 `(#:guile ,%bootstrap-guile
3033 #:implicit-inputs? #f
3034 ,@(package-arguments linux-libre-headers)))
3036 `(("perl" ,perl-boot0)
3038 ;; Flex and Bison are required since version 4.16.
3039 ("flex" ,flex-boot0)
3040 ("bison" ,bison-boot0)
3042 ;; Rsync is required since version 5.3.
3043 ("rsync" ,rsync-boot0)
3044 ,@(%boot0-inputs)))))
3047 (package-with-explicit-inputs %boot0-inputs
3050 (define gnumach-headers-boot0
3052 (package-with-bootstrap-guile
3054 (inherit gnumach-headers)
3055 (version "1.8-116-g28b53508")
3056 (source (bootstrap-origin
3059 (uri (string-append "https://lilypond.org/janneke/hurd/"
3060 "gnumach-" version ".tar.gz"))
3063 "006i0zgwy81vxarpfm12vip4q6i5mgmi5mmy5ldvxp5hx9h3l0zg")))))
3064 (native-inputs '())))))
3067 (let* ((mig (package
3068 (inherit (package-with-bootstrap-guile mig))
3069 (native-inputs `(("bison" ,bison-boot0)
3070 ("flex" ,flex-boot0)))
3071 (inputs `(("flex" ,flex-boot0)))
3074 `(,(string-append "LDFLAGS=-Wl,-rpath="
3075 (assoc-ref %build-inputs "flex") "/lib/")))))))
3078 (define hurd-version-boot0 "0.9-229-ga1efcee8")
3079 (define hurd-source-boot0
3080 (let ((version hurd-version-boot0))
3084 (uri (string-append "https://lilypond.org/janneke/hurd/"
3085 "hurd-v" version ".tar.gz"))
3088 "0bq2q2jisxcy0kgcm6rz0z2fddwxxm7azsama7li28a2m08kdpzy"))))))
3090 (define hurd-headers-boot0
3091 (let ((hurd-headers (package (inherit hurd-headers)
3092 (version hurd-version-boot0)
3093 (source hurd-source-boot0)
3094 (native-inputs `(("mig" ,mig-boot0)))
3096 (with-boot0 (package-with-bootstrap-guile hurd-headers))))
3098 (define hurd-minimal-boot0
3099 (let ((hurd-minimal (package (inherit hurd-minimal)
3100 (version hurd-version-boot0)
3101 (source hurd-source-boot0)
3102 (native-inputs `(("mig" ,mig-boot0)))
3104 (with-boot0 (package-with-bootstrap-guile hurd-minimal))))
3106 (define/system-dependent hurd-core-headers-boot0
3107 ;; Return the Hurd and Mach headers as well as initial Hurd libraries for
3108 ;; the bootstrap environment.
3109 (package (inherit (package-with-bootstrap-guile hurd-core-headers))
3110 (arguments `(#:guile ,%bootstrap-guile
3111 ,@(package-arguments hurd-core-headers)))
3113 `(("gnumach-headers" ,gnumach-headers-boot0)
3114 ("hurd-headers" ,hurd-headers-boot0)
3115 ("hurd-minimal" ,hurd-minimal-boot0)
3116 ,@(%boot0-inputs)))))
3118 (define* (kernel-headers-boot0 #:optional (system (%current-system)))
3120 ("i586-gnu" hurd-core-headers-boot0)
3121 (_ linux-libre-headers-boot0)))
3123 (define texinfo-boot0
3124 ;; Texinfo used to build libc's manual.
3125 ;; We build without ncurses because it fails to build at this stage, and
3126 ;; because we don't need the stand-alone Info reader.
3127 ;; Also, use (%BOOT0-INPUTS) to avoid building Perl once more.
3131 (inputs `(,@(%boot0-inputs)
3132 ("perl" ,perl-boot0)))
3134 `(#:implicit-inputs? #f
3135 #:guile ,%bootstrap-guile
3137 ;; Some of Texinfo 6.1's tests would fail with "Couldn't set UTF-8
3138 ;; character type in locale" but we don't have a UTF-8 locale at this
3139 ;; stage, so skip them.
3142 (define expat-sans-tests
3145 (inputs (%boot0-inputs))
3147 ;; XXX: Linking 'runtestscpp' fails with things like:
3149 ;; ld: Dwarf Error: found dwarf version '3789', this reader only handles version 2 and 3 information.
3151 ;; Skip tests altogether.
3152 `(#:implicit-inputs? #f
3153 #:guile ,%bootstrap-guile
3155 ,@(substitute-keyword-arguments (package-arguments expat)
3156 ((#:configure-flags flags ''())
3157 ;; Since we're not passing the right -Wl,-rpath flags, build the
3158 ;; static library to avoid RUNPATH validation failure.
3159 `(cons "--disable-shared" ,flags))
3160 ((#:tests? _ #f) #f))))))
3162 (define python-boot0
3164 (inherit python-minimal)
3165 ;; We cannot use Python 3.7 and later here, because they require
3166 ;; pthreads, which is missing on non-x86 platforms at this stage.
3167 ;; Python 3.6 technically supports being built without threading
3168 ;; support, but requires additional patches.
3170 (source (bootstrap-origin
3173 (uri (string-append "https://www.python.org/ftp/python/"
3174 version "/Python-" version ".tar.xz"))
3177 "0jdh9pvx6m6lfz2liwvvhn7vks7qrysqgwn517fkpxb77b33fjn2"))
3178 (modules '((guix build utils)))
3181 ;; Delete the bundled copy of libexpat.
3182 (delete-file-recursively "Modules/expat")
3183 (substitute* "Modules/Setup.dist"
3184 ;; Link Expat instead of embedding the bundled one.
3185 (("^#pyexpat.*") "pyexpat pyexpat.c -lexpat\n"))
3189 ("expat" ,expat-sans-tests))) ;remove OpenSSL, zlib, etc.
3190 (native-inputs '()) ;and pkg-config
3192 `(#:implicit-inputs? #f
3193 #:guile ,%bootstrap-guile
3195 ,@(substitute-keyword-arguments (package-arguments python-minimal)
3196 ;; Disable features that cannot be built at this stage.
3197 ((#:configure-flags _ ''())
3198 `(list "--without-ensurepip"
3199 "--without-threads"))
3200 ;; Clear #:make-flags, such that changes to the regular
3201 ;; Python package won't interfere with this one.
3202 ((#:make-flags _ ''()) ''())
3204 ;; Remove the 'apply-alignment-patch' phase if present to avoid
3205 ;; rebuilding this package. TODO: for the next rebuild cycle,
3206 ;; consider inlining all the arguments instead of inheriting to
3207 ;; make it easier to patch Python without risking a full rebuild.
3208 ;; Or better yet, change to 'python-on-guile'.
3209 `(modify-phases ,@(list (match phases
3210 (('modify-phases original-phases
3212 ('add-after unpack apply-alignment-patch _))
3213 `(modify-phases ,original-phases ,@changes))
3215 (add-before 'configure 'disable-modules
3217 (substitute* "setup.py"
3218 ;; Disable ctypes, since it requires libffi.
3219 (("extensions\\.append\\(ctypes\\)") "")
3220 ;; Prevent the 'ossaudiodev' extension from being
3221 ;; built, since it requires Linux headers.
3225 ,@(if (hurd-system?)
3226 `((add-before 'build 'fix-regen
3227 (lambda* (#:key inputs #:allow-other-keys)
3228 (let ((libc (assoc-ref inputs "libc")))
3229 (substitute* "Lib/plat-generic/regen"
3230 (("/usr/include/") (string-append libc "/include/")))
3233 ((#:tests? _ #f) #f))))))
3235 (define/system-dependent ld-wrapper-boot0
3236 ;; The first 'ld' wrapper, defined with 'define/system-dependent' because
3237 ;; its calls '%boot0-inputs', whose result depends on (%current-system)
3239 ;; We need this so binaries on Hurd will have libmachuser and libhurduser
3240 ;; in their RUNPATH, otherwise validate-runpath will fail.
3241 (make-ld-wrapper "ld-wrapper-boot0"
3242 #:target boot-triplet
3243 #:binutils binutils-boot0
3244 #:guile %bootstrap-guile
3245 #:bash (car (assoc-ref (%boot0-inputs) "bash"))
3246 #:guile-for-build %bootstrap-guile))
3248 (define (%boot1-inputs)
3249 ;; 2nd stage inputs.
3250 `(("gcc" ,gcc-boot0)
3251 ("ld-wrapper-cross" ,ld-wrapper-boot0)
3252 ("binutils-cross" ,binutils-boot0)
3253 ,@(alist-delete "binutils" (%boot0-inputs))))
3255 (define glibc-final-with-bootstrap-bash
3256 ;; The final libc, "cross-built". If everything went well, the resulting
3257 ;; store path has no dependencies. Actually, the really-final libc is
3258 ;; built just below; the only difference is that this one uses the
3262 (name "glibc-intermediate")
3263 (source (bootstrap-origin (package-source glibc)))
3265 `(#:guile ,%bootstrap-guile
3266 #:implicit-inputs? #f
3268 ,@(substitute-keyword-arguments (package-arguments glibc)
3269 ((#:configure-flags flags)
3270 `(append (list ,(string-append "--host=" (boot-triplet))
3271 ,(string-append "--build="
3272 (nix-system->gnu-triplet))
3273 ,(if (hurd-system?) "--disable-werror"
3277 `(modify-phases ,phases
3278 (add-before 'configure 'pre-configure
3279 (lambda* (#:key inputs #:allow-other-keys)
3280 ;; Don't clobber CPATH with the bootstrap libc.
3281 (setenv "NATIVE_CPATH" (getenv "CPATH"))
3284 ;; Tell 'libpthread' where to find 'libihash' on Hurd systems.
3285 ,@(if (hurd-system?)
3286 '((substitute* '("sysdeps/mach/Makefile"
3287 "sysdeps/mach/hurd/Makefile")
3288 (("LDLIBS-pthread.so =.*")
3289 (string-append "LDLIBS-pthread.so = "
3290 (assoc-ref %build-inputs "kernel-headers")
3291 "/lib/libihash.a\n"))))
3294 ;; 'rpcgen' needs native libc headers to be built.
3295 (substitute* "sunrpc/Makefile"
3296 (("sunrpc-CPPFLAGS =.*" all)
3297 (string-append "CPATH = $(NATIVE_CPATH)\n"
3301 (propagated-inputs `(("kernel-headers" ,(kernel-headers-boot0))))
3303 `(("bison" ,bison-boot0)
3304 ("texinfo" ,texinfo-boot0)
3305 ("perl" ,perl-boot0)
3306 ("python" ,python-boot0)))
3308 `( ;; The boot inputs. That includes the bootstrap libc. We don't want
3309 ;; it in $CPATH, hence the 'pre-configure' phase above.
3312 ;; A native MiG is needed to build Glibc on Hurd.
3313 ,@(if (hurd-system?)
3314 `(("mig" ,mig-boot0))
3317 ;; A native GCC is needed to build `cross-rpcgen'.
3318 ("native-gcc" ,@(assoc-ref (%boot0-inputs) "gcc"))
3320 ;; Here, we use the bootstrap Bash, which is not satisfactory
3321 ;; because we don't want to depend on bootstrap tools.
3322 ("static-bash" ,@(assoc-ref (%boot0-inputs) "bash"))))))
3324 (define (cross-gcc-wrapper gcc binutils glibc bash)
3325 "Return a wrapper for the pseudo-cross toolchain GCC/BINUTILS/GLIBC
3326 that makes it available under the native tool names."
3327 (package (inherit gcc)
3328 (name (string-append (package-name gcc) "-wrapped"))
3330 (build-system trivial-build-system)
3333 `(#:guile ,%bootstrap-guile
3334 #:modules ((guix build utils))
3336 (use-modules (guix build utils))
3338 (let* ((binutils (assoc-ref %build-inputs "binutils"))
3339 (gcc (assoc-ref %build-inputs "gcc"))
3340 (libc (assoc-ref %build-inputs "libc"))
3341 (bash (assoc-ref %build-inputs "bash"))
3342 (out (assoc-ref %outputs "out"))
3343 (bindir (string-append out "/bin"))
3344 (triplet ,(boot-triplet)))
3345 (define (wrap-program program)
3346 ;; GCC-BOOT0 is a libc-less cross-compiler, so it
3347 ;; needs to be told where to find the crt files and
3348 ;; the dynamic linker.
3349 (call-with-output-file program
3351 (format p "#!~a/bin/bash
3352 exec ~a/bin/~a-~a -B~a/lib -Wl,-dynamic-linker -Wl,~a/~a \"$@\"~%"
3356 ,(glibc-dynamic-linker))))
3358 (chmod program #o555))
3361 (with-directory-excursion bindir
3362 (for-each (lambda (tool)
3363 (symlink (string-append binutils "/bin/"
3367 (for-each wrap-program '("gcc" "g++")))
3371 `(("binutils" ,binutils)
3377 (define/system-dependent gcc-boot0-intermediate-wrapped
3378 ;; Make the cross-tools GCC-BOOT0 and BINUTILS-BOOT0 available under the
3380 (cross-gcc-wrapper gcc-boot0 binutils-boot0
3381 glibc-final-with-bootstrap-bash
3382 (car (assoc-ref (%boot1-inputs) "bash"))))
3384 (define static-bash-for-glibc
3385 ;; A statically-linked Bash to be used by GLIBC-FINAL in system(3) & co.
3387 (inherit static-bash)
3388 (source (bootstrap-origin (package-source static-bash)))
3389 (inputs `(("gcc" ,gcc-boot0-intermediate-wrapped)
3390 ("libc" ,glibc-final-with-bootstrap-bash)
3391 ("libc:static" ,glibc-final-with-bootstrap-bash "static")
3392 ,@(fold alist-delete (%boot1-inputs)
3395 `(#:implicit-inputs? #f
3396 #:guile ,%bootstrap-guile
3398 ,@(substitute-keyword-arguments (package-arguments static-bash)
3399 ((#:configure-flags flags '())
3400 ;; Add a '-L' flag so that the pseudo-cross-ld of
3401 ;; BINUTILS-BOOT0 can find libc.a.
3403 (list (string-append "LDFLAGS=-static -L"
3404 (assoc-ref %build-inputs
3408 (define gettext-boot0
3409 ;; A minimal gettext used during bootstrap.
3411 (inherit gettext-minimal)
3412 (name "gettext-boot0")
3413 ;; Newer versions of GNU gettext depends on libxml2 and ncurses. To
3414 ;; simplify the dependency chain, we stick to this version here.
3415 (version "0.19.8.1")
3418 (uri (string-append "mirror://gnu/gettext/gettext-"
3422 "0hsw28f9q9xaggjlsdp2qmbp2rbd1mp0njzan2ld9kiqwkq2m57z"))))
3423 (inputs (%boot1-inputs)) ;zero dependencies
3425 `(#:implicit-inputs? #f
3426 #:guile ,%bootstrap-guile
3428 #:phases (modify-phases %standard-phases
3429 ;; Build only the tools.
3430 (add-after 'unpack 'chdir
3432 (chdir "gettext-tools")
3435 ;; Some test programs require pthreads, which we don't have.
3436 (add-before 'configure 'no-test-programs
3438 (substitute* "tests/Makefile.in"
3444 ;; The final glibc, which embeds the statically-linked Bash built above.
3445 ;; Use 'package/inherit' so we get the 'replacement' of 'glibc', if any.
3449 (source (bootstrap-origin (package-source glibc)))
3450 (inputs `(("static-bash" ,static-bash-for-glibc)
3453 (package-inputs glibc-final-with-bootstrap-bash))))
3455 ;; This time we need 'msgfmt' to install all the libc.mo files.
3456 (native-inputs `(,@(package-native-inputs glibc-final-with-bootstrap-bash)
3457 ("gettext" ,gettext-boot0)))
3460 (package-propagated-inputs glibc-final-with-bootstrap-bash))
3462 ;; The final libc only refers to itself, but the 'debug' output contains
3463 ;; references to GCC-BOOT0 and to the Linux headers. XXX: Would be great
3464 ;; if 'allowed-references' were per-output.
3466 `(#:allowed-references
3468 ,(kernel-headers-boot0)
3469 ,static-bash-for-glibc
3470 ,@(if (hurd-system?)
3471 `(,gnumach-headers-boot0
3472 ,hurd-headers-boot0)
3474 ,@(package-outputs glibc-final-with-bootstrap-bash))
3475 ,@(package-arguments glibc-final-with-bootstrap-bash)))))
3477 (define/system-dependent gcc-boot0-wrapped
3478 ;; Make the cross-tools GCC-BOOT0 and BINUTILS-BOOT0 available under the
3480 (cross-gcc-wrapper gcc-boot0 binutils-boot0 glibc-final
3481 (car (assoc-ref (%boot1-inputs) "bash"))))
3483 (define (%boot2-inputs)
3484 ;; 3rd stage inputs.
3485 `(("libc" ,glibc-final)
3486 ("libc:static" ,glibc-final "static")
3487 ("gcc" ,gcc-boot0-wrapped)
3488 ,@(fold alist-delete (%boot1-inputs) '("libc" "gcc" "linux-libre-headers"))))
3490 (define binutils-final
3493 (source (bootstrap-origin (package-source binutils)))
3495 `(#:guile ,%bootstrap-guile
3496 #:implicit-inputs? #f
3497 #:allowed-references ("out" ,glibc-final)
3498 ,@(package-arguments binutils)))
3499 (inputs (%boot2-inputs))))
3502 ;; Intermediate libstdc++ that will allow us to build the final GCC
3503 ;; (remember that GCC-BOOT0 cannot build libstdc++.)
3504 (let ((lib (make-libstdc++ gcc)))
3507 (source (bootstrap-origin (package-source lib)))
3509 `(#:guile ,%bootstrap-guile
3510 #:implicit-inputs? #f
3511 #:allowed-references ("out")
3513 ;; XXX: libstdc++.so NEEDs ld.so for some reason.
3514 #:validate-runpath? #f
3516 ;; All of the package arguments from 'make-libstdc++
3517 ;; except for the configure-flags.
3518 ,@(package-arguments lib)
3519 #:configure-flags `("--disable-shared"
3520 "--disable-libstdcxx-dual-abi"
3521 "--disable-libstdcxx-threads"
3522 "--disable-libstdcxx-pch"
3523 ,(string-append "--with-gxx-include-dir="
3524 (assoc-ref %outputs "out")
3527 (inputs (%boot2-inputs))
3528 (synopsis "GNU C++ standard library (intermediate)"))))
3531 ;; Zlib used by GCC-FINAL.
3535 `(#:guile ,%bootstrap-guile
3536 #:implicit-inputs? #f
3537 #:allowed-references ("out" ,glibc-final)
3538 ,@(package-arguments zlib)))
3539 (inputs (%boot2-inputs))))
3541 (define/system-dependent ld-wrapper-boot3
3542 ;; A linker wrapper that uses the bootstrap Guile.
3543 (make-ld-wrapper "ld-wrapper-boot3"
3544 #:binutils binutils-final
3545 #:guile %bootstrap-guile
3546 #:bash (car (assoc-ref (%boot2-inputs) "bash"))
3547 #:guile-for-build %bootstrap-guile))
3551 (package (inherit gcc-boot0)
3554 ;; XXX: Currently #:allowed-references applies to all the outputs but the
3555 ;; "debug" output contains disallowed references, notably
3556 ;; linux-libre-headers. Disable the debugging output to work around that.
3557 (outputs (delete "debug" (package-outputs gcc-boot0)))
3560 `(#:guile ,%bootstrap-guile
3561 #:implicit-inputs? #f
3563 #:allowed-references ("out" "lib" ,zlib-final
3564 ,glibc-final ,static-bash-for-glibc)
3566 ;; Things like libasan.so and libstdc++.so NEED ld.so for some
3567 ;; reason, but it is not in their RUNPATH. This is a false
3568 ;; positive, so turn it off.
3569 #:validate-runpath? #f
3571 ,@(substitute-keyword-arguments (package-arguments gcc)
3572 ((#:make-flags flags)
3573 ;; Since $LIBRARY_PATH is not honored, add the relevant flags.
3574 `(let ((zlib (assoc-ref %build-inputs "zlib")))
3576 (if (string-prefix? "LDFLAGS=" flag)
3577 (string-append flag " -L"
3578 (assoc-ref %build-inputs "libstdc++")
3579 "/lib -L" zlib "/lib -Wl,-rpath="
3583 ;; Build again GMP & co. within GCC's build process, because it's hard
3584 ;; to do outside (because GCC-BOOT0 is a cross-compiler, and thus
3585 ;; doesn't honor $LIBRARY_PATH, which breaks `gnu-build-system'.)
3587 `(modify-phases ,phases
3588 (add-after 'unpack 'unpack-gmp&co
3589 (lambda* (#:key inputs #:allow-other-keys)
3590 (let ((gmp (assoc-ref %build-inputs "gmp-source"))
3591 (mpfr (assoc-ref %build-inputs "mpfr-source"))
3592 (mpc (assoc-ref %build-inputs "mpc-source")))
3594 ;; To reduce the set of pre-built bootstrap inputs, build
3595 ;; GMP & co. from GCC.
3596 (for-each (lambda (source)
3597 (invoke "tar" "xvf" source))
3598 (list gmp mpfr mpc))
3600 ;; Create symlinks like `gmp' -> `gmp-x.y.z'.
3601 ,@(map (lambda (lib)
3602 ;; Drop trailing letters, as gmp-6.0.0a unpacks
3604 `(symlink ,(string-trim-right
3605 (package-full-name lib "-")
3607 ,(package-name lib)))
3608 (list gmp-6.0 mpfr mpc))
3611 ;; This time we want Texinfo, so we get the manual. Add
3612 ;; STATIC-BASH-FOR-GLIBC so that it's used in the final shebangs of
3613 ;; scripts such as 'mkheaders' and 'fixinc.sh' (XXX: who cares about these
3615 (native-inputs `(("texinfo" ,texinfo-boot0)
3616 ("perl" ,perl-boot0) ;for manpages
3617 ("static-bash" ,static-bash-for-glibc)
3618 ,@(package-native-inputs gcc-boot0)))
3620 (inputs `(("gmp-source" ,(bootstrap-origin (package-source gmp-6.0)))
3621 ("mpfr-source" ,(package-source mpfr))
3622 ("mpc-source" ,(package-source mpc))
3623 ("ld-wrapper" ,ld-wrapper-boot3)
3624 ("binutils" ,binutils-final)
3625 ("libstdc++" ,libstdc++)
3626 ("zlib" ,zlib-final)
3627 ,@(%boot2-inputs)))))
3629 (define (%boot3-inputs)
3630 ;; 4th stage inputs.
3631 `(("gcc" ,gcc-final)
3632 ("ld-wrapper" ,ld-wrapper-boot3)
3633 ,@(alist-delete "gcc" (%boot2-inputs))))
3636 ;; Link with `-static-libgcc' to make sure we don't retain a reference
3637 ;; to the bootstrap GCC. Use "bash-minimal" to avoid an extra dependency
3638 ;; on Readline and ncurses.
3639 (let ((bash (static-libgcc-package bash-minimal)))
3642 (source (bootstrap-origin (package-source bash)))
3643 (inputs (%boot3-inputs))
3645 `(#:implicit-inputs? #f
3646 #:guile ,%bootstrap-guile
3648 #:disallowed-references ,(assoc-ref (%boot3-inputs) "coreutils&co")
3650 ,@(package-arguments bash))))))
3652 (define (%boot4-inputs)
3653 ;; Now use the final Bash.
3654 `(("bash" ,bash-final)
3655 ,@(alist-delete "bash" (%boot3-inputs))))
3658 (package-with-explicit-inputs %boot4-inputs %bootstrap-guile))
3660 (define-public guile-final
3661 ;; This package must be public because other modules refer to it. However,
3662 ;; mark it as hidden so that 'fold-packages' ignores it.
3663 (with-boot4 (hidden-package
3664 (package-with-bootstrap-guile guile-3.0/fixed))))
3666 (define glibc-utf8-locales-final
3667 ;; Now that we have GUILE-FINAL, build the UTF-8 locales. They are needed
3668 ;; by the build processes afterwards so their 'scm_to_locale_string' works
3669 ;; with the full range of Unicode codepoints (remember
3670 ;; 'scm_to_locale_string' is called every time a string is passed to a C
3673 (inherit glibc-utf8-locales)
3675 `(("glibc" ,glibc-final)
3676 ("gzip" ,(with-boot4 gzip))))))
3678 (define-public ld-wrapper
3679 ;; The final 'ld' wrapper, which uses the final Guile and Binutils.
3680 (make-ld-wrapper "ld-wrapper"
3681 #:binutils binutils-final
3685 (define (%boot5-inputs)
3686 ;; Now with UTF-8 locales. Remember that the bootstrap binaries were built
3687 ;; with an older libc, which cannot load the new locale format. See
3688 ;; <https://lists.gnu.org/archive/html/guix-devel/2015-08/msg00737.html>.
3689 `(("locales" ,glibc-utf8-locales-final)
3693 (package-with-explicit-inputs %boot5-inputs))
3695 (define gnu-make-final
3696 ;; The final GNU Make, which uses the final Guile.
3697 (let ((pkg-config (package
3698 (inherit %pkg-config) ;the native pkg-config
3699 (inputs `(("guile" ,guile-final)
3702 `(#:implicit-inputs? #f
3703 ,@(package-arguments pkg-config))))))
3705 (inherit (package-with-bootstrap-guile gnu-make))
3706 (inputs `(("guile" ,guile-final)
3708 (native-inputs `(("pkg-config" ,pkg-config)))
3710 `(#:implicit-inputs? #f
3711 ,@(package-arguments gnu-make))))))
3714 (define coreutils-final
3715 ;; The final Coreutils. Treat them specially because some packages, such as
3716 ;; Findutils, keep a reference to the Coreutils they were built with.
3717 (with-boot5 (package-with-bootstrap-guile
3719 (inherit coreutils-minimal)
3720 (name "coreutils")))
3721 ;; Use the final Guile, linked against the
3722 ;; final libc with working iconv, so that
3723 ;; 'substitute*' works well when touching
3724 ;; test files in Gettext.
3728 ;; The final grep. Gzip holds a reference to it (via zgrep), so it must be
3729 ;; built before gzip.
3730 (let ((grep (with-boot5 (package-with-bootstrap-guile grep))))
3731 (package/inherit grep
3732 (inputs (alist-delete "pcre" (package-inputs grep)))
3733 (native-inputs `(("perl" ,perl-boot0))))))
3735 (define (%boot6-inputs)
3736 ;; Now use the final Coreutils.
3737 `(("coreutils" ,coreutils-final)
3738 ("grep" ,grep-final)
3742 (package-with-explicit-inputs %boot6-inputs))
3746 (let ((sed (with-boot6 (package-with-bootstrap-guile sed))))
3747 (package/inherit sed (native-inputs `(("perl" ,perl-boot0))))))
3749 (define-public %final-inputs
3750 ;; Final derivations used as implicit inputs by 'gnu-build-system'. We
3751 ;; still use 'package-with-bootstrap-guile' so that the bootstrap tools are
3752 ;; used for origins that have patches, thereby avoiding circular
3754 (let ((finalize (compose with-boot6
3755 package-with-bootstrap-guile)))
3756 `(,@(map (match-lambda
3758 (list name (finalize package))))
3764 ("diffutils" ,diffutils)
3766 ("findutils" ,findutils)
3769 ("grep" ,grep-final)
3770 ("coreutils" ,coreutils-final)
3771 ("make" ,gnu-make-final)
3772 ("bash" ,bash-final)
3773 ("ld-wrapper" ,ld-wrapper)
3774 ("binutils" ,binutils-final)
3776 ("libc" ,glibc-final)
3777 ("libc:static" ,glibc-final "static")
3778 ("locales" ,glibc-utf8-locales-final))))
3780 (define-public canonical-package
3781 (let ((name->package (fold (lambda (input result)
3783 ((_ package . outputs)
3784 (vhash-cons (package-full-name package)
3787 `(("guile" ,guile-final)
3790 "Return the 'canonical' variant of PACKAGE---i.e., if PACKAGE is one of
3791 the implicit inputs of 'gnu-build-system', return that one, otherwise return
3794 The goal is to avoid duplication in cases like GUILE-FINAL vs. GUILE-2.2,
3795 COREUTILS-FINAL vs. COREUTILS, etc."
3796 ;; XXX: This doesn't handle dependencies of the final inputs, such as
3797 ;; libunistring, GMP, etc.
3798 (match (vhash-assoc (package-full-name package) name->package)
3800 ;; In general we want CANON, except if we're cross-compiling: CANON
3801 ;; uses explicit inputs, so it is "anchored" in the bootstrapped
3802 ;; process, with dependencies on things that cannot be
3804 (if (%current-target-system)
3814 ;; Using the following procedure, a gcc toolchain targeting glibc-2.27 can be
3815 ;; instantiated like this:
3817 ;; (define-public gcc-glibc-2.27-toolchain
3818 ;; (make-gcc-toolchain gcc glibc-2.27))
3820 (define* (make-gcc-toolchain gcc
3823 "Return a complete toolchain for GCC. If LIBC is specified, target that libc."
3824 (let ((gcc (if libc (make-gcc-libc gcc libc) gcc))
3825 (libc (if libc libc glibc-final)))
3827 (name (string-append (package-name gcc) "-toolchain"))
3828 (version (package-version gcc))
3830 (build-system trivial-build-system)
3832 '(#:modules ((guix build union))
3834 (use-modules (ice-9 match)
3839 (let ((out (assoc-ref %outputs "out")))
3841 (filter-map (match-lambda
3842 (("libc-debug" . _) #f)
3843 (("libc-static" . _) #f)
3844 ((_ . directory) directory))
3847 (union-build (assoc-ref %outputs "debug")
3848 (list (assoc-ref %build-inputs
3850 (union-build (assoc-ref %outputs "static")
3851 (list (assoc-ref %build-inputs
3855 (native-search-paths (package-native-search-paths gcc))
3856 (search-paths (package-search-paths gcc))
3858 (license (package-license gcc))
3859 (synopsis "Complete GCC tool chain for C/C++ development")
3861 "This package provides a complete GCC tool chain for C/C++ development to
3862 be installed in user profiles. This includes GCC, as well as libc (headers and
3863 binaries, plus debugging symbols in the @code{debug} output), and Binutils.")
3864 (home-page "https://gcc.gnu.org/")
3865 (outputs '("out" "debug" "static"))
3867 ;; The main raison d'être of this "meta-package" is (1) to conveniently
3868 ;; install everything that we need, and (2) to make sure ld-wrapper comes
3869 ;; before Binutils' ld in the user's profile.
3870 (inputs `(("gcc" ,gcc)
3871 ("ld-wrapper" ,(car (assoc-ref %final-inputs "ld-wrapper")))
3872 ("binutils" ,binutils-final)
3874 ("libc-debug" ,libc "debug")
3875 ("libc-static" ,libc "static"))))))
3877 (define-public gcc-toolchain
3878 (make-gcc-toolchain gcc-final))
3880 (define-public gcc-toolchain-4.8
3881 (make-gcc-toolchain gcc-4.8))
3883 (define-public gcc-toolchain-4.9
3884 (make-gcc-toolchain gcc-4.9))
3886 (define-public gcc-toolchain-5
3887 (make-gcc-toolchain gcc-5))
3889 (define-public gcc-toolchain-6
3890 (make-gcc-toolchain gcc-6))
3892 (define-public gcc-toolchain-7
3895 (define-public gcc-toolchain-8
3896 (make-gcc-toolchain gcc-8))
3898 (define-public gcc-toolchain-9
3899 (make-gcc-toolchain gcc-9))
3901 (define-public gcc-toolchain-10
3902 (make-gcc-toolchain gcc-10))
3904 ;; Provide the Fortran toolchain package only for the version of gfortran that
3905 ;; is used by Guix internally to build Fortran libraries, because combining
3906 ;; code compiled with different versions can cause problems.
3908 (define-public gfortran-toolchain
3909 (package (inherit (make-gcc-toolchain gfortran))
3910 (synopsis "Complete GCC tool chain for Fortran development")
3911 (description "This package provides a complete GCC tool chain for
3912 Fortran development to be installed in user profiles. This includes
3913 gfortran, as well as libc (headers and binaries, plus debugging symbols
3914 in the @code{debug} output), and binutils.")))
3917 ;;; commencement.scm ends here