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>
11 ;;; Copyright © 2020 Guy Fleury Iteriteka <gfleury@disroot.org>
12 ;;; Copyright © 2021 Chris Marusich <cmmarusich@gmail.com>
14 ;;; This file is part of GNU Guix.
16 ;;; GNU Guix is free software; you can redistribute it and/or modify it
17 ;;; under the terms of the GNU General Public License as published by
18 ;;; the Free Software Foundation; either version 3 of the License, or (at
19 ;;; your option) any later version.
21 ;;; GNU Guix is distributed in the hope that it will be useful, but
22 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
23 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 ;;; GNU General Public License for more details.
26 ;;; You should have received a copy of the GNU General Public License
27 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
29 (define-module (gnu packages commencement)
30 #:use-module (gnu packages)
31 #:use-module (gnu packages bootstrap)
32 #:use-module (gnu packages base)
33 #:use-module (gnu packages bash)
34 #:use-module (gnu packages c)
35 #:use-module (gnu packages gcc)
36 #:use-module (gnu packages m4)
37 #:use-module (gnu packages gawk)
38 #:use-module (gnu packages bison)
39 #:use-module (gnu packages flex)
40 #:use-module (gnu packages guile)
41 #:use-module (gnu packages gettext)
42 #:use-module (gnu packages multiprecision)
43 #:use-module (gnu packages compression)
44 #:use-module (gnu packages mes)
45 #:use-module (gnu packages perl)
46 #:use-module (gnu packages python)
47 #:use-module (gnu packages linux)
48 #:use-module (gnu packages hurd)
49 #:use-module (gnu packages shells)
50 #:use-module (gnu packages texinfo)
51 #:use-module (gnu packages pkg-config)
52 #:use-module (gnu packages rsync)
53 #:use-module (gnu packages xml)
54 #:use-module (guix packages)
55 #:use-module (guix download)
56 #:use-module (guix build-system gnu)
57 #:use-module (guix build-system trivial)
58 #:use-module ((guix licenses) #:prefix license:)
59 #:use-module (guix memoization)
60 #:use-module (guix utils)
61 #:use-module (srfi srfi-1)
62 #:use-module (ice-9 vlist)
63 #:use-module (ice-9 match)
64 #:export (make-gcc-toolchain))
68 ;;; This is the commencement, this is where things start. Before the
69 ;;; commencement, of course, there's the 'bootstrap' module, which provides us
70 ;;; with the initial binaries. This module uses those bootstrap binaries to
71 ;;; actually build up the whole tool chain that make up the implicit inputs of
72 ;;; 'gnu-build-system'.
74 ;;; To avoid circular dependencies, this module should not be imported
75 ;;; directly from anywhere.
77 ;;; Below, we frequently use "inherit" to create modified packages. The
78 ;;; reason why we use "inherit" instead of "package/inherit" is because we do
79 ;;; not want these commencement packages to inherit grafts. By definition,
80 ;;; these packages are not depended on at run time by any of the packages we
81 ;;; use. Thus it does not make sense to inherit grafts. Furthermore, those
82 ;;; grafts would often lead to extra overhead for users who would end up
83 ;;; downloading those "-boot0" packages just to build package replacements
84 ;;; that are in fact not going to be used.
94 (uri (list (string-append
95 "mirror://gnu/guix/mirror/bootar-" version ".ses")
97 "https://files.ngyro.com/bootar/bootar-"
101 "0mvp6vgx0q316fvy3z2lddlc5xgq5np3bm1fypgvj6dnayibg9np"))))
102 (build-system gnu-build-system)
104 `(#:implicit-inputs? #f
106 #:guile ,%bootstrap-guile
107 #:imported-modules ((guix build gnu-bootstrap)
108 ,@%gnu-build-system-modules)
111 (use-modules (guix build gnu-bootstrap))
112 (modify-phases %standard-phases
114 (lambda* (#:key inputs #:allow-other-keys)
115 (let* ((source (assoc-ref inputs "source"))
116 (guile-dir (assoc-ref inputs "guile"))
117 (guile (string-append guile-dir "/bin/guile")))
118 (invoke guile "--no-auto-compile" source)
121 (replace 'configure (bootstrap-configure ,version "." "scripts"))
122 (replace 'build (bootstrap-build "."))
123 (replace 'install (bootstrap-install "." "scripts"))))))
124 (inputs `(("guile" ,%bootstrap-guile)))
125 (home-page "https://git.ngyro.com/bootar")
126 (synopsis "Tar decompression and extraction in Guile Scheme")
127 (description "Bootar is a simple Tar extractor written in Guile
128 Scheme. It supports running 'tar xvf' on uncompressed tarballs or
129 tarballs that are compressed with BZip2, GZip, or XZ. It also provides
130 standalone scripts for 'bzip2', 'gzip', and 'xz' that each support
131 decompression to standard output.
133 What makes this special is that Bootar is distributed as a
134 self-extracting Scheme (SES) program. That is, a little script that
135 outputs the source code of Bootar. This makes it possible to go from
136 pure Scheme to Tar and decompression in one easy step.")
137 (license license:gpl3+)))
144 (inherit (package-source gash))
145 (snippet #f))) ;discard snippet for Guile 3.0 support
147 `(#:implicit-inputs? #f
149 #:guile ,%bootstrap-guile
150 #:imported-modules ((guix build gnu-bootstrap)
151 ,@%gnu-build-system-modules)
154 (use-modules (guix build gnu-bootstrap))
155 (modify-phases %standard-phases
157 (bootstrap-configure ,(package-version gash) "gash" "scripts"))
158 (replace 'build (bootstrap-build "gash"))
159 (replace 'install (bootstrap-install "gash" "scripts"))
160 (add-after 'install 'install-symlinks
161 (lambda* (#:key outputs #:allow-other-keys)
162 (let ((out (assoc-ref outputs "out")))
163 (symlink (string-append out "/bin/gash")
164 (string-append out "/bin/sh"))
165 (symlink (string-append out "/bin/gash")
166 (string-append out "/bin/bash"))
168 (inputs `(("guile" ,%bootstrap-guile)))
169 (native-inputs `(("bootar" ,bootar)))))
171 (define gash-utils-boot
174 (name "gash-utils-boot")
176 (inherit (package-source gash-utils))
178 (snippet #f))) ;discard snippet for Guile 3.0 support
180 `(#:implicit-inputs? #f
182 #:guile ,%bootstrap-guile
183 #:imported-modules ((guix build gnu-bootstrap)
184 ,@%gnu-build-system-modules)
187 (use-modules (guix build gnu-bootstrap))
188 (modify-phases %standard-phases
189 (add-after 'unpack 'set-load-path
190 (lambda* (#:key inputs #:allow-other-keys)
191 (let ((gash (assoc-ref inputs "gash")))
192 (add-to-load-path (string-append gash "/share/guile/site/"
193 (effective-version))))
195 (add-before 'configure 'pre-configure
197 (format #t "Creating gash/commands/testb.scm~%")
198 (copy-file "gash/commands/test.scm"
199 "gash/commands/testb.scm")
200 (substitute* "gash/commands/testb.scm"
201 (("gash commands test") "gash commands testb")
202 (("apply test [(]cdr") "apply test/bracket (cdr"))
203 (for-each (lambda (script)
204 (let ((target (string-append "scripts/"
206 (format #t "Creating scripts/~a~%" target)
207 (copy-file "scripts/template.in" target)
209 (("@UTILITY@") script))))
210 '("awk" "basename" "cat" "chmod" "cmp" "command"
211 "compress" "cp" "cut" "diff" "dirname" "expr"
212 "false" "find" "grep" "head" "ln" "ls" "mkdir"
213 "mv" "printf" "pwd" "reboot" "rm" "rmdir"
214 "sed" "sleep" "sort" "tar" "test" "touch" "tr"
215 "true" "uname" "uniq" "wc" "which"))
216 (format #t "Creating scripts/[.in~%")
217 (copy-file "scripts/template.in" "scripts/[.in")
218 (substitute* "scripts/[.in"
219 (("@UTILITY@") "testb"))
220 (delete-file "scripts/template.in")
223 (bootstrap-configure ,(package-version gash-utils)
225 (replace 'build (bootstrap-build "gash"))
226 (replace 'install (bootstrap-install "gash" "scripts"))
227 ;; XXX: The scripts should add Gash to their load paths and
228 ;; this phase should not exist.
229 (add-after 'install 'copy-gash
230 (lambda* (#:key inputs outputs #:allow-other-keys)
231 (let* ((out (assoc-ref outputs "out"))
232 (moddir (string-append out "/share/guile/site/"
233 (effective-version)))
234 (godir (string-append out "/lib/guile/"
237 (gash (assoc-ref inputs "gash"))
238 (gash-moddir (string-append gash "/share/guile/site/"
239 (effective-version)))
240 (gash-godir (string-append gash "/lib/guile/"
243 (copy-file (string-append gash-moddir "/gash/compat.scm")
244 (string-append moddir "/gash/compat.scm"))
245 (copy-recursively (string-append gash-moddir "/gash/compat")
246 (string-append moddir "/gash/compat"))
247 (copy-file (string-append gash-godir "/gash/compat.go")
248 (string-append godir "/gash/compat.go"))
249 (copy-recursively (string-append gash-godir "/gash/compat")
250 (string-append godir "/gash/compat"))
252 (inputs `(("gash" ,gash-boot)
253 ("guile" ,%bootstrap-guile)))
254 (native-inputs `(("bootar" ,bootar)))))
256 (define (%boot-gash-inputs)
257 `(("bash" , gash-boot) ; gnu-build-system wants "bash"
258 ("coreutils" , gash-utils-boot)
260 ("guile" ,%bootstrap-guile)))
262 (define %bootstrap-mes-rewired
265 (name "bootstrap-mes-rewired")
268 (native-inputs `(("mes" ,%bootstrap-mes)
269 ("gash" ,gash-boot)))
271 (propagated-inputs '())
273 (build-system trivial-build-system)
275 `(#:guile ,%bootstrap-guile
276 #:modules ((guix build utils))
279 (use-modules (guix build utils)
282 (let* ((mes (assoc-ref %build-inputs "mes"))
283 (gash (assoc-ref %build-inputs "gash"))
284 (mes-bin (string-append mes "/bin"))
285 (guile (string-append mes-bin "/mes"))
286 (mes-module (string-append mes "/share/mes/module"))
287 (out (assoc-ref %outputs "out"))
288 (bin (string-append out "/bin"))
289 (mescc (string-append bin "/mescc"))
290 (module (string-append out "/share/mes/module")))
291 (define (rewire file)
294 (("/gnu/store[^ ]+mes-minimal-[^/)}\"]*") out)
295 (("/gnu/store[^ ]+guile-[^/]*/bin/guile") guile)
296 (("/gnu/store[^ ]+bash-[^/)}\"]*") gash)))
299 (for-each (lambda (file) (install-file file bin))
300 (find-files mes-bin))
302 (copy-recursively (string-append mes-module "/mes")
303 (string-append module "/mes"))
304 (copy-recursively (string-append mes-module "/srfi")
305 (string-append module "/srfi"))
307 ;; Cannot easily rewire "mes" because it
308 ;; contains NUL characters; would require
309 ;; remove-store-references alike trick
310 (filter (negate (cut string-suffix? "/mes" <>))
312 (rewire (string-append module "/mes/boot-0.scm"))
315 (with-output-to-file mescc
317 (display (string-append
324 MES_PREFIX=${MES_REWIRED_PREFIX-" out "/share/mes}
326 export MES MES_PREFIX
328 MES_ARENA=${MES_REWIRED_ARENA-10000000}
329 MES_MAX_ARENA=${MES_REWIRED_ARENA-10000000}
330 MES_STACK=${MES_REWIRED_STACK-1000000}
331 export MES_ARENA MES_MAX_ARENA MES_STACK
333 $MES -e '(mescc)' module/mescc.scm -- \"$@\"
337 (with-directory-excursion module
338 (chmod "mes/base.mes" #o644)
339 (copy-file "mes/base.mes" "mes/base.mes.orig")
340 (let ((base.mes (open-file "mes/base.mes" "a")))
342 ;; A fixed map, from Mes 0.21, required to bootstrap Mes 0.21
343 (define (map f h . t)
345 (and (pair? t) (null? (car t)))
346 (and (pair? t) (pair? (cdr t)) (null? (cadr t)))) '()
347 (if (null? t) (cons (f (car h)) (map f (cdr h)))
349 (cons (f (car h) (caar t)) (map f (cdr h) (cdar t)))
351 (cons (f (car h) (caar t) (caadr t)) (map f (cdr h) (cdar t) (cdadr t)))
352 (error 'unsupported (cons* 'map-4: f h t))b )))))
356 (chmod "mes/guile.mes" #o644)
357 (copy-file "mes/guile.mes" "mes/guile.mes.orig")
358 (let ((guile.mes (open-file "mes/guile.mes" "a")))
360 ;; After booting guile.scm; use Mes 0.21; especially: MesCC 0.21
361 (let* ((self (car (command-line)))
362 (prefix (dirname (dirname self))))
363 (set! %moduledir (string-append prefix \"/mes/module/\"))
364 (setenv \"%numbered_arch\" \"true\"))
377 (uri (string-append "mirror://gnu/mes/"
378 "mes-" version ".tar.gz"))
381 "0p1jsrrmcbc0zrvbvnjbb6iyxr0in71km293q8qj6gnar6bw09av"))))
383 (propagated-inputs '())
385 `(("nyacc-source" ,(origin (inherit (package-source nyacc-0.99))
387 ("mes" ,%bootstrap-mes-rewired)
388 ("mescc-tools" ,%bootstrap-mescc-tools)
389 ,@(%boot-gash-inputs)))
391 `(#:implicit-inputs? #f
393 #:guile ,%bootstrap-guile
394 #:strip-binaries? #f ; binutil's strip b0rkes MesCC/M1/hex2 binaries
396 (modify-phases %standard-phases
397 (add-after 'unpack 'unpack-seeds
399 (let ((nyacc-source (assoc-ref %build-inputs "nyacc-source")))
400 (with-directory-excursion ".."
401 (invoke "tar" "-xvf" nyacc-source)))))
403 (lambda* (#:key outputs #:allow-other-keys)
404 (let ((out (assoc-ref %outputs "out"))
405 (gash (assoc-ref %build-inputs "bash"))
406 (mes (assoc-ref %build-inputs "mes"))
407 (dir (with-directory-excursion ".." (getcwd))))
408 (setenv "AR" (string-append "gash " (getcwd) "/scripts/mesar"))
409 (setenv "BASH" (string-append gash "/bin/bash"))
410 (setenv "CC" (string-append mes "/bin/mescc"))
411 (setenv "GUILE_LOAD_PATH"
413 mes "/share/mes/module"
414 ":" dir "/nyacc-0.99.0/module"))
415 (invoke "gash" "configure.sh"
416 (string-append "--prefix=" out)
417 (string-append "--host=i686-linux-gnu")))))
420 (invoke "sh" "bootstrap.sh")))
424 (substitute* "install.sh" ; show some progress
426 (("^( *)((cp|mkdir|tar) [^']*[^\\])\n" all space cmd)
427 (string-append space "echo '" cmd "'\n"
429 (invoke "sh" "install.sh")
430 ;; Keep ASCII output, for friendlier comparison and bisection
431 (let* ((out (assoc-ref %outputs "out"))
432 (cache (string-append out "/lib/cache")))
433 (define (objects-in-dir dir)
436 (and (equal? (dirname name) dir)
437 (or (string-suffix? ".o" name)
438 (string-suffix? ".s" name))))))
439 (for-each (lambda (x) (install-file x cache))
440 (append (objects-in-dir ".")
441 (objects-in-dir "mescc-lib"))))
444 (list (search-path-specification
445 (variable "C_INCLUDE_PATH")
446 (files '("include")))
447 (search-path-specification
448 (variable "LIBRARY_PATH")
450 (search-path-specification
451 (variable "MES_PREFIX")
457 ;; Pristine tcc cannot be built by MesCC, we are keeping a delta of 11
458 ;; patches. In a very early and rough form they were presented to the
459 ;; TinyCC developers, who at the time showed no interest in supporting the
460 ;; bootstrappable effort; we will try again later. These patches have been
461 ;; ported to 0.9.27, alas the resulting tcc is buggy. Once MesCC is more
462 ;; mature, this package should use the 0.9.27 sources (or later).
466 (version "0.9.26-1103-g6e62e0e")
470 "http://lilypond.org/janneke/mes/20191117/"
471 "/tcc-" version ".tar.gz"))
474 "1qbybw7mxbgkv3sazvz1v7c8byq998vk8f1h25ik8w3d2l63lxng"))))
475 (build-system gnu-build-system)
476 (supported-systems '("i686-linux" "x86_64-linux"))
478 (propagated-inputs '())
481 ("nyacc-source" ,(origin (inherit (package-source nyacc-0.99))
483 ("mescc-tools" ,%bootstrap-mescc-tools)
484 ,@(%boot-gash-inputs)))
486 `(#:implicit-inputs? #f
487 #:guile ,%bootstrap-guile
488 #:validate-runpath? #f ; no dynamic executables
489 #:strip-binaries? #f ; no strip yet
491 (modify-phases %standard-phases
492 (add-after 'unpack 'unpack-seeds
493 (lambda* (#:key outputs #:allow-other-keys)
494 (let ((nyacc-source (assoc-ref %build-inputs "nyacc-source")))
495 (with-directory-excursion ".."
496 (invoke "tar" "-xvf" nyacc-source)))))
498 (lambda* (#:key outputs #:allow-other-keys)
499 (let* ((out (assoc-ref %outputs "out"))
500 (dir (with-directory-excursion ".." (getcwd)))
501 (interpreter "/lib/mes-loader"))
503 (setenv "prefix" out)
504 (setenv "GUILE_LOAD_PATH"
505 (string-append dir "/nyacc-0.99.0/module"))
507 (substitute* "conftest.c"
510 (invoke "sh" "configure"
512 (string-append "--prefix=" out)
513 (string-append "--elfinterp=" interpreter)
518 (substitute* "bootstrap.sh" ; Show some progress
519 (("^( *)((cp|ls|mkdir|rm|[.]/tcc|[.]/[$][{PROGRAM_PREFIX[}]tcc) [^\"]*[^\\])\n" all space cmd)
520 (string-append space "echo \"" cmd "\"\n"
522 (invoke "sh" "bootstrap.sh")))
526 (system* "./tcc" "--help") ; --help exits 1
527 ;; (invoke "sh" "test.sh" "mes/scaffold/tests/30-strlen")
528 ;; (invoke "sh" "-x" "test.sh" "mes/scaffold/tinycc/00_assignment")
529 ;; TODO: add sensible check target (without depending on make)
530 ;; (invoke "sh" "check.sh")
534 (substitute* "install.sh" ; Show some progress
535 (("^( *)((cp|ls|mkdir|rm|tar|./[$][{PROGRAM_PREFIX[}]tcc) [^\"]*[^\\])\n" all space cmd)
536 (string-append space "echo \"" cmd "\"\n"
539 (invoke "sh" "install.sh"))))))
541 (list (search-path-specification
542 (variable "C_INCLUDE_PATH")
543 (files '("include")))
544 (search-path-specification
545 (variable "LIBRARY_PATH")
546 (files '("lib")))))))
549 ;; The initial gzip. We keep this scripted gzip build before building make
550 ;; to soften the dependency on Gash Core Utils gzip.
554 (name "gzip-mesboot")
557 (uri (string-append "mirror://gnu/gzip/gzip-" version ".tar"))
560 "1rhgk2vvmdvnn6vygf0dja92ryyng00knl0kz5srb77k2kryjb2d"))))
561 (supported-systems '("i686-linux" "x86_64-linux"))
563 (propagated-inputs '())
564 (native-inputs `(("tcc" ,tcc-boot0)
565 ,@(%boot-gash-inputs)))
567 `(#:implicit-inputs? #f
568 #:guile ,%bootstrap-guile
569 #:strip-binaries? #f ; no strip yet
571 (modify-phases %standard-phases
573 (add-after 'unpack 'scripted-patch
575 (substitute* "util.c"
576 (("^char [*]strlwr" all) (string-append all "_tcc_cannot_handle_dupe")))
580 (let ((files '("bits" "crypt" "deflate" "getopt" "gzip"
581 "inflate" "lzw" "trees" "unlzh" "unlzw"
582 "unpack" "unzip" "util" "zip")))
584 (invoke "tcc" "-c" "-D NO_UTIME=1" "-D HAVE_UNISTD_H=1"
585 (string-append x ".c")))
586 (for-each compile files)
588 (cons* "tcc" "-o" "gzip"
589 (map (lambda (x) (string-append x ".o")) files)))
590 (link "gzip" "gunzip"))))
593 (let* ((out (assoc-ref %outputs "out"))
594 (bin (string-append out "/bin")))
595 (install-file "gzip" bin)
596 (install-file "gunzip" bin))))
599 (invoke "./gzip" "--version")))
601 (delete 'compress-documentation))))))
603 (define gnu-make-mesboot0
607 (name "make-mesboot0")
611 (uri (string-append "mirror://gnu/make/make-" version ".tar.gz"))
614 "1pb7fb7fqf9wz9najm85qdma1xhxzf1rhj5gwrlzdsz2zm0hpcv4"))))
615 (supported-systems '("i686-linux" "x86_64-linux"))
617 (propagated-inputs '())
618 (native-inputs `(("tcc" ,tcc-boot0)
619 ,@(%boot-gash-inputs)))
621 `(#:implicit-inputs? #f
622 #:guile ,%bootstrap-guile
623 #:configure-flags '("CC=tcc"
626 "--build=i686-unknown-linux-gnu"
627 "--host=i686-unknown-linux-gnu"
629 #:modules ((guix build gnu-build-system)
632 #:strip-binaries? #f ; no strip yet
634 (modify-phases %standard-phases
635 (add-after 'unpack 'scripted-patch
637 (substitute* "build.sh.in"
638 (("@LIBOBJS@") "getloadavg.o")
639 (("@REMOTE@") "stub"))
641 (add-after 'configure 'configure-fixup
643 (substitute* "make.h"
644 (("^extern long int lseek.*" all) (string-append "// " all)))
648 (invoke "sh" "./build.sh")))
649 (replace 'check ; proper check needs awk
651 (invoke "./make" "--version")))
654 (let* ((out (assoc-ref %outputs "out"))
655 (bin (string-append out "/bin")))
656 (install-file "make" bin)))))))))
658 (define (%boot-tcc0-inputs)
659 `(("make" ,gnu-make-mesboot0)
661 ,@(%boot-gash-inputs)))
663 (define bzip2-mesboot
667 (name "bzip2-mesboot")
668 (version (package-version bzip2))
669 (source (bootstrap-origin (package-source bzip2)))
670 (supported-systems '("i686-linux" "x86_64-linux"))
672 (propagated-inputs '())
673 (native-inputs (%boot-tcc0-inputs))
676 `(#:implicit-inputs? #f
677 #:guile ,%bootstrap-guile
679 #:tests? #f ; check is naive, also checks non-built PROGRAMS
680 #:strip-binaries? #f ; no strip yet
681 #:make-flags (list "CC=tcc -I ." "AR=tcc -ar" "bzip2"
682 (string-append "PREFIX="
683 (assoc-ref %outputs "out")))
685 (modify-phases %standard-phases
686 (add-after 'unpack 'scripted-patch
688 (substitute* "Makefile"
690 (string-append "\t#" all)))
691 (substitute* "bzip2.c"
692 (("struct utimbuf uTimBuf;" all)
693 (string-append "// " all))
695 (string-append "// " all))
696 (("retVal = utime [(] dstName, &uTimBuf [)];" all)
697 (string-append "retVal = 0; // " all)))
701 (with-output-to-file "utime.h"
703 #define fchown(filedes, owner, group) 0
704 #define fchmod(filedes, mode) 0
709 (invoke "./bzip2" "--help")))
710 ;; FIXME: no compressing gzip yet
711 (delete 'compress-documentation))))))
713 (define bash-mesboot0
716 (inherit static-bash)
717 (name "bash-mesboot0")
721 (uri (string-append "mirror://gnu/bash/bash-"
725 "1r1z2qdw3rz668nxrzwa14vk2zcn00hw7mpjn384picck49d80xs"))))
727 (propagated-inputs '())
728 (native-inputs (%boot-tcc0-inputs))
731 `(#:implicit-inputs? #f
732 #:guile ,%bootstrap-guile
734 #:strip-binaries? #f ; no strip yet
736 (list "--build=i686-unknown-linux-gnu"
737 "--host=i686-unknown-linux-gnu"
739 "--without-bash-malloc"
742 "--disable-help-builtin"
744 "--disable-net-redirections"
747 ;; Pretend 'dlopen' is missing so we don't build loadable
748 ;; modules and related code.
749 "ac_cv_func_dlopen=no")
750 #:make-flags '("bash")
752 (modify-phases %standard-phases
753 (add-before 'configure 'setenv
755 (let* ((gash (assoc-ref %build-inputs "bash"))
756 (shell (string-append gash "/bin/gash")))
757 (setenv "CONFIG_SHELL" shell)
758 (setenv "SHELL" shell)
761 (setenv "AR" "tcc -ar")
762 (setenv "CFLAGS" "-D _POSIX_VERSION=1")
764 (add-after 'unpack 'scripted-patch
766 (substitute* "Makefile.in"
767 (("mksyntax\\.c\n") "mksyntax.c -lgetopt\n")
768 (("buildversion[.]o\n") "buildversion.o -lgetopt\n")
770 (("\tsize ") "#\tsize"))
771 (substitute* "lib/sh/oslib.c"
772 (("int name, namelen;") "char *name; int namelen;"))
773 (substitute* "lib/sh/snprintf.c"
774 (("^#if (defined [(]HAVE_LOCALE_H[)])" all define) (string-append "#if 0 //" define)))
775 (substitute* "configure"
776 ((" egrep") " grep"))
779 (lambda* (#:key configure-flags #:allow-other-keys)
780 (let ((configure-flags (filter (lambda (x)
781 (and (not (string-prefix? "CONFIG_SHELL=" x))
782 (not (string-prefix? "SHELL=" x))))
784 (format (current-error-port)
785 "running ./configure ~a\n" (string-join configure-flags)))
786 (apply invoke (cons "./configure" configure-flags))))
787 (add-after 'configure 'configure-fixups
789 (substitute* "config.h"
790 (("#define GETCWD_BROKEN 1") "#undef GETCWD_BROKEN"))
791 (let ((config.h (open-file "config.h" "a")))
792 (display (string-append
793 ;; XXX TODO: remove nested ,(string-append ...) and
794 ;; store file name on next rebuild cycle
796 // tcc: error: undefined symbol 'enable_hostname_completion'
797 #define enable_hostname_completion(on_or_off) 0
799 // /gnu/store/" "cq0cmv35s9dhilx14zaghlc08gpc0hwr-tcc-boot0-0.9.26-6.c004e9a/lib/libc.a: error: 'sigprocmask' defined twice
800 #define HAVE_POSIX_SIGNALS 1
801 #define endpwent(x) 0
808 (invoke "./bash" "--version")))
811 (let* ((out (assoc-ref %outputs "out"))
812 (bin (string-append out "/bin")))
814 (copy-file "bash" (string-append bin "/bash"))
815 (copy-file "bash" (string-append bin "/sh"))
825 (inherit (package-source tcc))
826 ;; `patches' needs XZ
827 ;; (patches (search-patches "tcc-boot-0.9.27.patch"))
829 (build-system gnu-build-system)
831 (propagated-inputs '())
832 (native-inputs `(;;("boot-patch" ,(search-patch "tcc-boot-0.9.27.patch"))
833 ("bzip2" ,bzip2-mesboot)
834 ,@(%boot-tcc0-inputs)))
836 `(#:implicit-inputs? #f
837 #:guile ,%bootstrap-guile
838 #:validate-runpath? #f ; no dynamic executables
839 #:strip-binaries? #f ; no strip yet
841 (modify-phases %standard-phases
842 ;; tar xvf ..bz2 gives
843 ;; bzip2: PANIC -- internal consistency error
845 (lambda* (#:key source #:allow-other-keys)
846 (copy-file source "tarball.tar.bz2")
847 (invoke "bzip2" "-d" "tarball.tar.bz2")
848 (invoke "tar" "xvf" "tarball.tar")
849 (chdir (string-append "tcc-" ,version))
852 ;; (add-after 'unpack 'apply-boot-patch
853 ;; (lambda* (#:key inputs #:allow-other-keys)
854 ;; (let ((patch-file (assoc-ref inputs "boot-patch")))
855 ;; (invoke "patch" "-p1" "-i" patch-file))))
856 (add-after 'unpack 'scripted-patch
857 (lambda* (#:key inputs #:allow-other-keys)
858 (substitute* "libtcc.c"
859 (("s->alacarte_link = 1;" all)
861 s->static_link = 1;")))
864 (lambda* (#:key outputs #:allow-other-keys)
865 (let* ((out (assoc-ref %outputs "out"))
866 (tcc (assoc-ref %build-inputs "tcc"))
867 (libc (assoc-ref %build-inputs "libc"))
868 (interpreter "/mes/loader"))
869 (invoke "sh" "configure"
870 (string-append "--cc=tcc")
871 (string-append "--cpu=i386")
872 (string-append "--prefix=" out)
873 (string-append "--elfinterp=" interpreter)
874 (string-append "--crtprefix=" tcc "/lib")
875 (string-append "--sysincludepaths=" tcc "/include")
876 (string-append "--libpaths=" tcc "/lib")))))
878 (lambda* (#:key outputs #:allow-other-keys)
879 (let* ((out (assoc-ref %outputs "out"))
880 (tcc (assoc-ref %build-inputs "tcc"))
881 (libc (assoc-ref %build-inputs "libc"))
882 (interpreter "/mes/loader"))
888 "-D" "TCC_TARGET_I386=1"
889 "-D" "CONFIG_TCC_STATIC=1"
890 "-D" "CONFIG_USE_LIBGCC=1"
891 "-D" (string-append "CONFIG_TCCDIR=\"" out "/lib/tcc\"")
892 "-D" (string-append "CONFIG_TCC_CRTPREFIX=\"" out "/lib:{B}/lib:.\"")
893 "-D" (string-append "CONFIG_TCC_CRTPREFIX=\"" out "/lib:{B}/lib:.\"")
894 "-D" (string-append "CONFIG_TCC_ELFINTERP=\"" interpreter "\"")
895 "-D" (string-append "CONFIG_TCC_LIBPATHS=\"" tcc "/lib:{B}/lib:.\"")
896 "-D" (string-append "CONFIG_TCC_SYSINCLUDEPATHS=\""
897 tcc "/include" ":/include:{B}/include\"")
898 "-D" (string-append "TCC_LIBGCC=\"" tcc "/lib/libc.a\"")
903 ;; FIXME: add sensible check target (without depending on make)
905 (= 1 (status:exit-val (system* "./tcc" "--help")))))
907 (lambda* (#:key outputs #:allow-other-keys)
908 (let ((out (assoc-ref %outputs "out"))
909 (tcc (assoc-ref %build-inputs "tcc")))
911 (mkdir-p (string-append out "/bin"))
912 (copy-file "tcc" (string-append out "/bin/tcc"))
913 (mkdir-p (string-append out "/lib/tcc"))
914 (copy-recursively (string-append tcc "/include")
915 (string-append out "/include"))
916 (copy-recursively (string-append tcc "/lib")
917 (string-append out "/lib"))
918 (invoke "tcc" "-D" "TCC_TARGET_I386=1" "-c" "-o" "libtcc1.o" "lib/libtcc1.c")
919 (invoke "tcc" "-ar" "rc" "libtcc1.a" "libtcc1.o")
920 (copy-file "libtcc1.a" (string-append out "/lib/libtcc1.a"))
921 (delete-file (string-append out "/lib/tcc/libtcc1.a"))
922 (copy-file "libtcc1.a" (string-append out "/lib/tcc/libtcc1.a"))
925 (define diffutils-mesboot
926 ;; The initial diffutils.
929 (name "diffutils-mesboot")
933 (uri (string-append "mirror://gnu/diffutils/diffutils-"
937 "1mirn5i825bn5w7rh6mgn0r8aj9xqanav95dwcl1b8sn82f4iwnm"))))
938 (supported-systems '("i686-linux" "x86_64-linux"))
940 (propagated-inputs '())
941 (native-inputs (%boot-tcc0-inputs))
943 `(#:implicit-inputs? #f
944 #:guile ,%bootstrap-guile
946 #:tests? #f ; check is naive, also checks non-built PROGRAMS
947 #:strip-binaries? #f ; no strip yet
949 (modify-phases %standard-phases
950 (add-before 'configure 'remove-diff3-sdiff
951 (lambda* (#:key outputs #:allow-other-keys)
952 (substitute* "Makefile.in"
953 (("PROGRAMS = .*" all) "PROGRAMS = cmp diff"))))
954 (replace 'configure ; needs classic invocation of configure
955 (lambda* (#:key configure-flags #:allow-other-keys)
956 (let* ((out (assoc-ref %outputs "out"))
957 (bash (assoc-ref %build-inputs "bash"))
958 (shell (string-append bash "/bin/bash")))
959 (setenv "CONFIG_SHELL" shell)
962 (format (current-error-port)
963 "running ./configure ~a\n" (string-join configure-flags))
964 (apply invoke (cons "./configure" configure-flags)))))
967 (let* ((out (assoc-ref %outputs "out"))
968 (bin (string-append out "/bin")))
970 (install-file "cmp" bin)
971 (install-file "diff" bin)
974 (define patch-mesboot
975 ;; The initial patch.
978 (name "patch-mesboot")
982 (uri (string-append "mirror://gnu/patch/patch-"
986 "12nv7jx3gxfp50y11nxzlnmqqrpicjggw6pcsq0wyavkkm3cddgc"))))
987 (supported-systems '("i686-linux" "x86_64-linux"))
989 (propagated-inputs '())
990 (native-inputs (%boot-tcc0-inputs))
992 `(#:implicit-inputs? #f
993 #:guile ,%bootstrap-guile
995 #:tests? #f ; check is naive, also checks non-built PROGRAMS
996 #:strip-binaries? #f ; no strip yet
997 #:configure-flags '("AR=tcc -ar" "CC=tcc" "LD-tcc")
999 (modify-phases %standard-phases
1000 (add-after 'unpack 'scripted-patch
1002 ;; avoid another segfault
1003 (substitute* "pch.c"
1004 (("while [(]p_end >= 0[)]" all)
1005 "p_end = -1;\nwhile (0)"))
1007 ;; FIXME: no compressing gzip yet
1008 (delete 'compress-documentation))))))
1010 (define sed-mesboot0
1014 (name "sed-mesboot0")
1018 (uri (string-append "mirror://gnu/sed/sed-"
1022 "1hyv7i82jd0q18xcql51ylc8jwadp3gb3irgcqlis3v61p35jsv2"))))
1023 (supported-systems '("i686-linux" "x86_64-linux"))
1025 (propagated-inputs '())
1026 (native-inputs (%boot-tcc0-inputs))
1028 `(#:implicit-inputs? #f
1029 #:guile ,%bootstrap-guile
1030 #:parallel-build? #f
1031 #:configure-flags '("CC=tcc")
1032 #:make-flags '("CC=tcc" "extra_objs=" "DEFS=-D HAVE_BCOPY")
1033 #:strip-binaries? #f ; no strip yet
1035 (modify-phases %standard-phases
1036 (add-after 'unpack 'scripted-patch
1038 (let* ((out (assoc-ref %outputs "out"))
1039 (bash (assoc-ref %build-inputs "bash"))
1040 (shell (string-append bash "/bin/bash")))
1041 (substitute* "configure"
1042 (("/bin/sh") shell))
1046 (invoke "./sed" "--version")))
1049 (let* ((out (assoc-ref %outputs "out"))
1050 (bin (string-append out "/bin")))
1051 (install-file "sed" bin)
1054 (define (%boot-tcc-inputs)
1055 `(("bash" ,bash-mesboot0)
1056 ("bzip2" ,bzip2-mesboot)
1057 ("diffutils" ,diffutils-mesboot)
1058 ("gzip" ,gzip-mesboot)
1059 ("patch" ,patch-mesboot)
1060 ("sed" ,sed-mesboot0)
1062 ,@(alist-delete "tcc" (%boot-tcc0-inputs))))
1064 (define binutils-mesboot0
1065 ;; The initial Binutils
1068 (name "binutils-mesboot0")
1072 (uri (string-append "mirror://gnu/binutils/binutils-"
1076 "1w8xp7k44bkijr974x9918i4p1sw4g2fcd5mxvspkjpg38m214ds"))))
1078 (propagated-inputs '())
1079 (native-inputs (%boot-tcc-inputs))
1080 (supported-systems '("i686-linux" "x86_64-linux"))
1082 `(#:implicit-inputs? #f
1083 #:guile ,%bootstrap-guile
1084 #:tests? #f ; runtest: command not found
1085 #:parallel-build? #f
1086 #:strip-binaries? #f ; no strip yet
1088 (let ((out (assoc-ref %outputs "out")))
1092 "--build=i386-unknown-linux"
1093 "--host=i386-unknown-linux"
1094 "--target=i386-unknown-linux"
1096 ,(string-append "--prefix=" out)))
1098 (modify-phases %standard-phases
1099 (add-before 'configure 'setenv
1101 (let* ((out (assoc-ref %outputs "out"))
1102 (bash (assoc-ref %build-inputs "bash"))
1103 (shell (string-append bash "/bin/bash")))
1104 (setenv "CONFIG_SHELL" shell)
1105 (setenv "SHELL" shell)
1106 (setenv "AR" "tcc -ar")
1107 (setenv "RANLIB" "true")
1108 (setenv "CC" "tcc -D __GLIBC_MINOR__=6")
1110 (add-after 'unpack 'scripted-patch
1111 (lambda* (#:key inputs #:allow-other-keys)
1112 (substitute* "bfd/configure"
1113 (("^sed -e '/SRC-POTFILES.*" all)
1114 "echo -e 'all:\\n\\ttrue\\n\\ninstall:\\n\\ttrue\\n' > po/Makefile\n"))
1116 (replace 'configure ; needs classic invocation of configure
1117 (lambda* (#:key configure-flags #:allow-other-keys)
1118 (format (current-error-port)
1119 "running ./configure ~a\n" (string-join configure-flags))
1120 (apply system* "./configure" configure-flags)
1121 (substitute* "config.status"
1122 (("[.]//dev/null") "/dev/null"))
1123 (invoke "sh" "./config.status"))))))))
1125 (define gcc-core-mesboot0
1126 ;; Gcc-2.95.3 is the most recent GCC that is supported by what the Mes C
1127 ;; Library v0.16 offers. Gcc-3.x (and 4.x) place higher demands on a C
1128 ;; library, such as dir.h/struct DIR/readdir, locales, signals... Also,
1129 ;; with gcc-2.95.3, binutils (2.14.0, 2.20.1a) and glibc-2.2.5 we found a
1130 ;; GNU toolchain triplet "that works".
1133 (name "gcc-core-mesboot0")
1137 (uri (string-append "mirror://gnu/gcc/gcc-2.95.3/gcc-core-"
1140 ;; `patches' needs XZ
1141 ;; (patches (search-patches "gcc-boot-2.95.3.patch"))
1144 "1xvfy4pqhrd5v2cv8lzf63iqg92k09g6z9n2ah6ndd4h17k1x0an"))))
1145 (supported-systems '("i686-linux" "x86_64-linux"))
1147 (propagated-inputs '())
1148 (native-inputs `(("boot-patch" ,(search-patch "gcc-boot-2.95.3.patch"))
1149 ("binutils" ,binutils-mesboot0)
1150 ,@(%boot-tcc-inputs)))
1153 `(#:implicit-inputs? #f
1154 #:guile ,%bootstrap-guile
1156 #:parallel-build? #f
1157 #:strip-binaries? #f
1159 (let ((out (assoc-ref %outputs "out")))
1163 "--build=i686-unknown-linux-gnu"
1164 "--host=i686-unknown-linux-gnu"
1165 ,(string-append "--prefix=" out)))
1167 `("CC=tcc -static -D __GLIBC_MINOR__=6"
1168 "OLDCC=tcc -static -D __GLIBC_MINOR__=6"
1169 "CC_FOR_BUILD=tcc -static -D __GLIBC_MINOR__=6"
1172 ,(string-append "LIBGCC2_INCLUDES=-I "
1173 (assoc-ref %build-inputs "tcc")
1176 ,(string-append "BOOT_LDFLAGS="
1177 " -B" (assoc-ref %build-inputs "tcc")
1179 #:modules ((guix build gnu-build-system)
1183 (modify-phases %standard-phases
1184 (add-after 'unpack 'apply-boot-patch
1185 (lambda* (#:key inputs #:allow-other-keys)
1186 (let ((patch-file (assoc-ref inputs "boot-patch")))
1187 (system* "patch" "--force" "-p1" "-i" patch-file)
1189 (add-before 'configure 'setenv
1190 (lambda* (#:key outputs #:allow-other-keys)
1191 (let* ((out (assoc-ref outputs "out"))
1192 (bash (assoc-ref %build-inputs "bash"))
1193 (shell (string-append bash "/bin/bash"))
1194 (tcc (assoc-ref %build-inputs "tcc"))
1195 (cppflags " -D __GLIBC_MINOR__=6"))
1196 (setenv "CONFIG_SHELL" shell)
1197 (setenv "CPPFLAGS" cppflags)
1198 (setenv "CC" (string-append "tcc" cppflags))
1199 (setenv "CC_FOR_BUILD" (string-append "tcc" cppflags))
1200 (setenv "CPP" (string-append "tcc -E" cppflags))
1201 (with-output-to-file "config.cache"
1204 ac_cv_c_float_format='IEEE (little-endian)'
1207 (replace 'configure ; needs classic invocation of configure
1208 (lambda* (#:key configure-flags #:allow-other-keys)
1209 (format (current-error-port)
1210 "running ./configure ~a\n" (string-join configure-flags))
1211 (apply invoke "./configure" configure-flags)))
1212 (add-after 'configure 'remove-info
1214 ;; no info at this stage
1215 (delete-file-recursively "texinfo")
1216 (invoke "touch" "gcc/cpp.info" "gcc/gcc.info")))
1217 (add-after 'install 'install2
1218 (lambda* (#:key outputs #:allow-other-keys)
1219 (let* ((tcc (assoc-ref %build-inputs "tcc"))
1220 (tcc-lib (string-append tcc "/lib/x86-mes-gcc"))
1221 (out (assoc-ref outputs "out"))
1222 (gcc-dir (string-append
1223 out "/lib/gcc-lib/i686-unknown-linux-gnu/2.95.3")))
1225 (with-directory-excursion "tmp"
1226 (invoke "ar" "x" (string-append "../gcc/libgcc2.a"))
1227 (invoke "ar" "x" (string-append tcc "/lib/libtcc1.a"))
1228 (apply invoke "ar" "r" (string-append gcc-dir "/libgcc.a")
1229 (find-files "." "\\.o")))
1230 (copy-file "gcc/libgcc2.a" (string-append out "/lib/libgcc2.a"))
1231 (copy-file (string-append tcc "/lib/libtcc1.a")
1232 (string-append out "/lib/libtcc1.a"))
1233 (invoke "ar" "x" (string-append tcc "/lib/libtcc1.a"))
1234 (invoke "ar" "x" (string-append tcc "/lib/libc.a"))
1235 (invoke "ar" "r" (string-append gcc-dir "/libc.a")
1236 "libc.o" "libtcc1.o")
1238 (native-search-paths
1239 (list (search-path-specification
1240 (variable "C_INCLUDE_PATH")
1243 ;; Needed to get things like GCC's <stddef.h>.
1244 "lib/gcc-lib/i686-unknown-linux-gnu/2.95.3/include")))
1245 (search-path-specification
1246 (variable "LIBRARY_PATH")
1247 (files '("lib")))))))
1249 (define (%boot-mesboot-core-inputs)
1250 `(("binutils" ,binutils-mesboot0)
1251 ("gawk" ,gawk-mesboot0)
1252 ("gcc" ,gcc-core-mesboot0)
1253 ,@(alist-delete "tcc" (%boot-tcc-inputs))))
1255 (define mesboot-headers
1258 (name "mesboot-headers")
1259 (supported-systems '("i686-linux" "x86_64-linux"))
1261 (propagated-inputs '())
1262 (native-inputs `(("kernel-headers" ,%bootstrap-linux-libre-headers)
1263 ,@(%boot-tcc-inputs)))
1265 `(#:implicit-inputs? #f
1266 #:guile ,%bootstrap-guile
1268 #:strip-binaries? #f
1270 (modify-phases %standard-phases
1274 (lambda* (#:key outputs #:allow-other-keys)
1275 (let* ((out (assoc-ref outputs "out"))
1276 (include (string-append out "/include"))
1277 (headers (assoc-ref %build-inputs "kernel-headers")))
1279 (copy-recursively "include" out)
1280 (copy-recursively headers out)
1283 (define gawk-mesboot0
1284 ;; The initial Gawk.
1287 (name "gawk-mesboot0")
1291 (uri (string-append "mirror://gnu/gawk/gawk-"
1295 "087s7vpc8zawn3l7bwv9f44bf59rc398hvaiid63klw6fkbvabr3"))))
1296 (supported-systems '("i686-linux" "x86_64-linux"))
1298 (propagated-inputs '())
1299 (native-inputs (%boot-tcc-inputs))
1301 `(#:implicit-inputs? #f
1302 #:guile ,%bootstrap-guile
1303 #:configure-flags '("--build=i686-unknown-linux-gnu"
1304 "--host=i686-unknown-linux-gnu"
1306 #:make-flags '("gawk")
1307 #:parallel-build? #f
1308 #:parallel-tests? #f
1309 #:strip-binaries? #f ; no strip yet
1311 (modify-phases %standard-phases
1312 (add-after 'unpack 'scripted-patch
1314 (substitute* "Makefile.in"
1315 (("date ") "echo today ")
1316 ((" autoheader") "true")
1318 (substitute* "test/Makefile.in"
1319 (("^bigtest:.*") "bigtest: basic\n")
1320 (("( |\t)(childin|convfmt|fflush|longwrds|math|negexp)" all sep) sep))))
1321 (add-before 'configure 'setenv
1323 (let* ((out (assoc-ref %outputs "out"))
1324 (bash (assoc-ref %build-inputs "bash"))
1325 (shell (string-append bash "/bin/bash")))
1326 (setenv "CONFIG_SHELL" shell)
1327 (setenv "SHELL" shell)
1329 (setenv "CPP" "tcc -E")
1331 (setenv "ac_cv_func_getpgrp_void" "yes")
1332 (setenv "ac_cv_func_tzset" "yes"))
1334 (replace 'configure ; needs classic invocation of configure
1335 (lambda* (#:key configure-flags #:allow-other-keys)
1336 (let* ((out (assoc-ref %outputs "out"))
1339 ,(string-append "--prefix=" out))))
1340 (format (current-error-port) "running ./configure ~a\n" (string-join configure-flags))
1341 (system* "touch" "configure") ; aclocal.m4 is newer than configure
1342 (apply invoke (cons "./configure" configure-flags)))))
1344 (lambda* (#:key outputs #:allow-other-keys)
1345 (let* ((out (assoc-ref outputs "out"))
1346 (bin (string-append out "/bin")))
1347 (install-file "gawk" bin)
1348 (symlink "gawk" (string-append bin "/awk"))
1351 (define glibc-mesboot0
1352 ;; GNU C Library 2.2.5 is the most recent glibc that we managed to build
1353 ;; using gcc-2.95.3. Newer versions (2.3.x, 2.6, 2.1x) seem to need a newer
1357 (name "glibc-mesboot0")
1361 (uri (string-append "mirror://gnu/glibc/glibc-"
1365 ;; (patches (search-patches "glibc-boot-2.2.5.patch"))
1368 "1vl48i16gx6h68whjyhgnn1s57vqq32f9ygfa2fls7pdkbsqvp2q"))))
1369 (supported-systems '("i686-linux" "x86_64-linux"))
1371 (propagated-inputs '())
1372 (native-inputs `(("boot-patch" ,(search-patch "glibc-boot-2.2.5.patch"))
1373 ("system-patch" ,(search-patch "glibc-bootstrap-system-2.2.5.patch"))
1374 ("headers" ,mesboot-headers)
1375 ,@(%boot-mesboot-core-inputs)))
1378 `(#:implicit-inputs? #f
1379 #:guile ,%bootstrap-guile
1381 #:strip-binaries? #f
1382 #:validate-runpath? #f ; no dynamic executables
1383 #:parallel-build? #f ; gcc-2.95.3 ICEs on massively parallel builds
1384 #:make-flags (list (string-append
1386 (assoc-ref %build-inputs "bash")
1389 (let ((out (assoc-ref %outputs "out"))
1390 (headers (assoc-ref %build-inputs "headers")))
1391 `("--disable-shared"
1393 "--disable-sanity-checks"
1394 "--build=i686-unknown-linux-gnu"
1395 "--host=i686-unknown-linux-gnu"
1396 ,(string-append "--with-headers=" headers "/include")
1397 "--enable-static-nss"
1398 "--without-__thread"
1402 ,(string-append "--prefix=" out)))
1404 (modify-phases %standard-phases
1405 (add-after 'unpack 'apply-boot-patch
1406 (lambda* (#:key inputs #:allow-other-keys)
1407 (and (let ((patch (assoc-ref inputs "boot-patch")))
1408 (invoke "patch" "--force" "-p1" "-i" patch))
1409 (let ((patch (assoc-ref inputs "system-patch")))
1410 (invoke "patch" "--force" "-p1" "-i" patch)))))
1411 (add-before 'configure 'setenv
1412 (lambda* (#:key outputs #:allow-other-keys)
1413 (let* ((out (assoc-ref outputs "out"))
1414 (bash (assoc-ref %build-inputs "bash"))
1415 (shell (string-append bash "/bin/bash"))
1416 (gcc (assoc-ref %build-inputs "gcc"))
1417 (headers (assoc-ref %build-inputs "headers"))
1418 (cppflags (string-append
1420 " -D MES_BOOTSTRAP=1"
1421 " -D BOOTSTRAP_GLIBC=1"))
1422 (cflags (string-append " -L " (getcwd))))
1423 (setenv "CONFIG_SHELL" shell)
1424 (setenv "SHELL" shell)
1425 (setenv "CPP" (string-append gcc "/bin/gcc -E " cppflags))
1426 (setenv "CC" (string-append gcc "/bin/gcc " cppflags cflags))
1428 (replace 'configure ; needs classic invocation of configure
1429 (lambda* (#:key configure-flags #:allow-other-keys)
1430 (format (current-error-port)
1431 "running ./configure ~a\n" (string-join configure-flags))
1432 (apply invoke "./configure" configure-flags)))
1433 (add-after 'configure 'fixup-configure
1435 (let* ((out (assoc-ref %outputs "out"))
1436 (bash (assoc-ref %build-inputs "bash"))
1437 (shell (string-append bash "/bin/bash")))
1438 (substitute* "config.make"
1439 (("INSTALL = scripts/") "INSTALL = $(..)./scripts/"))
1440 (substitute* "config.make"
1441 (("INSTALL = scripts/") "INSTALL = $(..)./scripts/")
1442 (("BASH = ") (string-append
1447 (define gcc-mesboot0
1449 (inherit gcc-core-mesboot0)
1450 (name "gcc-mesboot0")
1451 (native-inputs `(("boot-patch" ,(search-patch "gcc-boot-2.95.3.patch"))
1452 ;; Packages are given in an order that's relevant for
1453 ;; #include_next purposes.
1454 ("libc" ,glibc-mesboot0)
1455 ("kernel-headers" ,%bootstrap-linux-libre-headers)
1456 ,@(%boot-mesboot-core-inputs)))
1458 (substitute-keyword-arguments (package-arguments gcc-core-mesboot0)
1460 `(modify-phases ,phases
1463 (setenv "CONFIG_SHELL" (which "sh"))
1464 (with-output-to-file "config.cache"
1467 ac_cv_c_float_format='IEEE (little-endian)'
1471 (lambda* (#:key outputs #:allow-other-keys)
1472 (let* ((out (assoc-ref outputs "out"))
1473 (gcc-dir (string-append
1474 out "/lib/gcc-lib/i686-unknown-linux-gnu/2.95.3")))
1477 (zero? (system (string-append "set -x; cd tmp && ar x ../gcc/libgcc2.a")))
1478 (zero? (system (string-append "set -x; cd tmp && ar r " gcc-dir "/libgcc.a *.o")))
1479 (copy-file "gcc/libgcc2.a" (string-append out "/lib/libgcc2.a"))))))))
1480 ((#:configure-flags configure-flags)
1481 `(let ((out (assoc-ref %outputs "out")))
1482 `("--disable-shared"
1484 "--build=i686-unknown-linux-gnu"
1485 "--host=i686-unknown-linux-gnu"
1486 ,(string-append "--prefix=" out))))
1487 ((#:make-flags make-flags)
1488 `(let ((gcc (assoc-ref %build-inputs "gcc")))
1490 ,(string-append "LIBGCC2_INCLUDES=-I " gcc "/include")
1491 "LANGUAGES=c")))))))
1493 (define (%boot-mesboot0-inputs)
1494 `(("gcc" ,gcc-mesboot0)
1495 ("kernel-headers" ,%bootstrap-linux-libre-headers)
1496 ("libc" ,glibc-mesboot0)
1497 ,@(alist-delete "gcc" (%boot-mesboot-core-inputs))))
1500 ;; Initial tar with support for xz compression.
1503 (name "tar-mesboot")
1507 (uri (string-append "mirror://gnu/tar/tar-"
1511 "19nvix64y95n5v6rr5g9g3fn08zz85cb5anzd7csfv4a4sz9lw4y"))))
1512 (supported-systems '("i686-linux" "x86_64-linux"))
1514 (propagated-inputs '())
1515 (native-inputs (%boot-mesboot0-inputs))
1517 `(#:implicit-inputs? #f
1518 #:guile ,%bootstrap-guile
1519 #:parallel-build? #f
1520 #:tests? #f ; check is naive, also checks non-built PROGRAMS
1521 #:strip-binaries? #f ; no strip yet
1522 #:configure-flags '("--build=i686-unknown-linux-gnu"
1523 "--host=i686-unknown-linux-gnu"
1526 (modify-phases %standard-phases
1528 (lambda* (#:key configure-flags #:allow-other-keys)
1529 (let* ((out (assoc-ref %outputs "out"))
1530 (bash (assoc-ref %build-inputs "bash"))
1531 (shell (string-append bash "/bin/bash")))
1532 (setenv "CONFIG_SHELL" shell)
1533 (setenv "SHELL" shell)
1534 (setenv "LIBS" "-lc -lnss_files -lnss_dns -lresolv")
1535 (setenv "gl_cv_func_rename_dest_works" "yes")
1536 (format (current-error-port)
1537 "running ./configure ~a\n" (string-join configure-flags))
1538 (apply invoke (cons "./configure" configure-flags)))))
1539 (add-after 'unpack 'scripted-patch
1541 (let* ((bash (assoc-ref %build-inputs "bash"))
1542 (shell (string-append bash "/bin/bash")))
1543 (substitute* "configure"
1544 ((" /bin/sh") shell)))
1545 (substitute* "Makefile.in"
1546 (("^SUBDIRS = doc") "SUBDIRS ="))
1550 (let* ((out (assoc-ref %outputs "out"))
1551 (bin (string-append out "/bin")))
1552 (install-file "src/tar" bin)
1555 (define grep-mesboot
1556 ;; The initial grep.
1559 (name "grep-mesboot")
1563 (uri (string-append "mirror://gnu/grep/grep-"
1567 "1w862l80lgc5mxvpiy4cfwk761d6xxavn0m3xd2l7xs2kmzvp6lq"))))
1568 (supported-systems '("i686-linux" "x86_64-linux"))
1570 (propagated-inputs '())
1571 (native-inputs (%boot-mesboot0-inputs))
1573 `(#:implicit-inputs? #f
1574 #:guile ,%bootstrap-guile
1575 #:parallel-build? #f
1577 (modify-phases %standard-phases
1578 (add-before 'configure 'patch-configure
1580 (let* ((bash (assoc-ref %build-inputs "bash"))
1581 (shell (string-append bash "/bin/bash")))
1582 (substitute* "configure"
1583 ((" [|][|] ./config.status") " || sh ./config.status")))))
1586 (let* ((out (assoc-ref %outputs "out"))
1587 (bin (string-append out "/bin")))
1588 (install-file "grep" bin)
1589 (symlink "grep" (string-append bin "/egrep"))
1590 (symlink "grep" (string-append bin "/fgrep"))
1593 (define binutils-mesboot1
1595 (inherit binutils-mesboot0)
1596 (name "binutils-mesboot1")
1597 (native-inputs (%boot-mesboot0-inputs))
1599 (substitute-keyword-arguments (package-arguments binutils-mesboot0)
1600 ((#:configure-flags configure-flags)
1601 '(let ((out (assoc-ref %outputs "out")))
1605 "--build=i686-unknown-linux-gnu"
1606 "--host=i686-unknown-linux-gnu"
1608 ,(string-append "--prefix=" out))))
1610 `(modify-phases ,phases
1613 (let* ((out (assoc-ref %outputs "out"))
1614 (bash (assoc-ref %build-inputs "bash"))
1615 (shell (string-append bash "/bin/bash")))
1616 (setenv "CONFIG_SHELL" shell)
1619 (define coreutils-mesboot0
1622 (name "coreutils-mesboot0")
1623 ;; The latest .gz release of Coreutils is 8.13; which does not build with gcc-2.95.3:
1624 ;; randperm.c: In function `sparse_swap':
1625 ;; randperm.c:117: invalid lvalue in unary `&'
1626 (version "5.0") ; 2003-04
1629 (uri (string-append "mirror://gnu/coreutils/coreutils-"
1633 "10wq6k66i8adr4k08p0xmg87ff4ypiazvwzlmi7myib27xgffz62"))))
1634 (native-inputs (%boot-mesboot0-inputs))
1635 (supported-systems '("i686-linux" "x86_64-linux"))
1637 (propagated-inputs '())
1639 `(#:implicit-inputs? #f
1640 #:tests? #f ; WARNING: `perl' is needed, ...
1641 #:parallel-build? #f
1642 #:strip-binaries? #f ; strip: unrecognized option `--only-keep-debug'
1643 #:guile ,%bootstrap-guile
1646 "LIBS=-lc -lnss_files -lnss_dns -lresolv"
1647 "ac_cv_func_gethostbyname=no"
1648 "gl_cv_func_rename_dest_works=yes")))))
1650 (define gnu-make-mesboot
1653 (name "make-mesboot")
1657 (uri (string-append "mirror://gnu/make/make-"
1661 "1rs2f9hmvy3q6zkl15jnlmnpgffm0bhw5ax0h5c7q604wqrip69x"))))
1662 (native-inputs (%boot-mesboot0-inputs))
1663 (supported-systems '("i686-linux" "x86_64-linux"))
1665 (propagated-inputs '())
1667 `(#:implicit-inputs? #f
1668 #:parallel-build? #f
1669 #:guile ,%bootstrap-guile
1670 #:configure-flags '("LIBS=-lc -lnss_files -lnss_dns -lresolv")
1672 (modify-phases %standard-phases
1675 (invoke "./make" "--version")))
1677 (lambda* (#:key outputs #:allow-other-keys)
1678 (let* ((out (assoc-ref outputs "out"))
1679 (bin (string-append out "/bin")))
1680 (install-file "make" bin)
1683 (define gawk-mesboot
1686 (name "gawk-mesboot")
1690 (uri (string-append "mirror://gnu/gawk/gawk-"
1694 "03d5y7jabq7p2s7ys9alay9446mm7i5g2wvy8nlicardgb6b6ii1"))))
1695 (native-inputs `(,@(%boot-mesboot0-inputs)
1696 ("mesboot-headers" ,mesboot-headers)))
1697 (supported-systems '("i686-linux" "x86_64-linux"))
1699 (propagated-inputs '())
1701 `(#:implicit-inputs? #f
1702 #:parallel-build? #f
1703 #:guile ,%bootstrap-guile
1704 #:configure-flags '("ac_cv_func_connect=no")
1705 #:make-flags '("gawk")
1707 (modify-phases %standard-phases
1710 (invoke "./gawk" "--version")))
1712 (lambda* (#:key outputs #:allow-other-keys)
1713 (let* ((out (assoc-ref outputs "out"))
1714 (bin (string-append out "/bin")))
1715 (install-file "gawk" bin)
1716 (symlink "gawk" (string-append bin "/awk"))
1722 (name "sed-mesboot")
1723 (version "4.0.6") ; 2003-04
1726 (uri (string-append "mirror://gnu/sed/sed-"
1730 "0861ij94cqc4vaaki6r2wlapwcmhpx4ggp4r70f46mb21a8fkvf1"))))
1731 (native-inputs (%boot-mesboot0-inputs))
1732 (supported-systems '("i686-linux" "x86_64-linux"))
1734 (propagated-inputs '())
1736 `(#:implicit-inputs? #f
1737 #:parallel-build? #f
1738 #:guile ,%bootstrap-guile
1739 #:tests? #f ; 8to7 fails
1741 (modify-phases %standard-phases
1742 (add-after 'unpack '/bin/sh
1744 (let* ((bash (assoc-ref %build-inputs "bash"))
1745 (shell (string-append bash "/bin/bash")))
1746 (substitute* "testsuite/Makefile.tests"
1747 (("^SHELL = /bin/sh")
1748 (string-append "SHELL = " shell)))
1751 (define bash-mesboot
1753 (inherit bash-mesboot0)
1755 (name "bash-mesboot")
1758 (uri (string-append "mirror://gnu/bash/bash-"
1762 "1jyz6snd63xjn6skk7za6psgidsd53k05cr3lksqybi0q6936syq"))))
1764 (propagated-inputs '())
1765 (native-inputs (%boot-mesboot0-inputs))
1768 `(#:implicit-inputs? #f
1769 #:guile ,%bootstrap-guile
1770 #:parallel-build? #f
1772 '("--build=i686-unknown-linux-gnu"
1773 "--host=i686-unknown-linux-gnu"
1775 "--without-bash-malloc"
1776 "--disable-readline"
1778 "--disable-help-builtin"
1779 "--disable-progcomp"
1780 "--disable-net-redirections"
1783 ;; Pretend 'dlopen' is missing so we don't build loadable
1784 ;; modules and related code.
1785 "ac_cv_func_dlopen=no")
1786 #:make-flags '("bash")
1788 (modify-phases %standard-phases
1789 (add-after 'unpack 'scripted-patch
1791 (substitute* "shell.c"
1794 (add-before 'configure 'setenv
1796 (setenv "AWK" "gawk")
1797 (setenv "LIBS" "-lc -lnss_files -lnss_dns -lresolv")
1798 (setenv "gl_cv_func_rename_dest_works" "yes")
1800 (add-after 'configure 'configure-fixups
1802 (let ((config.h (open-file "config.h" "a")))
1803 (display (string-append "
1804 #define enable_hostname_completion(on_or_off) 0
1811 (invoke "./bash" "--version")))
1814 (let* ((out (assoc-ref %outputs "out"))
1815 (bin (string-append out "/bin")))
1817 (copy-file "bash" (string-append bin "/bash"))
1818 (copy-file "bash" (string-append bin "/sh"))
1821 (define (%boot-mesboot1-inputs)
1822 `(("bash" ,bash-mesboot)
1823 ("binutils" ,binutils-mesboot1)
1824 ("coreutils" ,coreutils-mesboot0)
1825 ("gawk" ,gawk-mesboot)
1826 ("grep" ,grep-mesboot)
1827 ("make" ,gnu-make-mesboot)
1828 ("sed" ,sed-mesboot)
1829 ("tar" ,tar-mesboot)
1830 ,@(fold alist-delete (%boot-mesboot0-inputs)
1831 '("bash" "binutils" "bootar" "coreutils" "gash"
1832 "gawk" "grep" "guile" "make" "sed" "tar"))))
1840 (uri (string-append "mirror://gnu/gmp/gmp-" version
1843 "15rwq54fi3s11izas6g985y9jklm3xprfsmym3v1g6xr84bavqvv"))))))
1851 (uri (string-append "mirror://gnu/mpfr/mpfr-" version
1854 "0dxn4904dra50xa22hi047lj8kkpr41d6vb9sd4grca880c7wv94"))))))
1863 "mirror://gnu/mpc/mpc-" version ".tar.gz"))
1866 "1hzci2zrrd7v3g1jk35qindq05hbl0bhjcyyisq9z209xb3fqzb1"))))))
1868 (define gcc-core-mesboot1
1869 ;; GCC 4.6.4 is the latest modular distribution. This package is not
1870 ;; stricly needed, but very helpful for development because it builds
1871 ;; relatively fast. If this configures and builds then gcc-mesboot1 also
1874 (inherit gcc-mesboot0)
1875 (name "gcc-core-mesboot1")
1879 (uri (string-append "mirror://gnu/gcc/gcc-"
1880 version "/gcc-core-" version ".tar.gz"))
1883 "173kdb188qg79pcz073cj9967rs2vzanyjdjyxy9v0xb0p5sad75"))
1885 ;; (patches (search-patches "gcc-boot-4.6.4.patch"))
1887 (inputs `(("gmp-source" ,(package-source gmp-boot))
1888 ("mpfr-source" ,(package-source mpfr-boot))
1889 ("mpc-source" ,(package-source mpc-boot))))
1890 (native-inputs `(("boot-patch" ,(search-patch "gcc-boot-4.6.4.patch"))
1891 ,@(%boot-mesboot1-inputs)))
1893 `(#:implicit-inputs? #f
1894 #:guile ,%bootstrap-guile
1896 #:modules ((guix build gnu-build-system)
1899 #:parallel-build? #f ; for debugging
1901 (let* ((libc (assoc-ref %build-inputs "libc"))
1902 (ldflags (string-append
1904 "-Wl,-dynamic-linker "
1906 ,(glibc-dynamic-linker "i686-linux"))))
1907 (list (string-append "LDFLAGS=" ldflags)
1908 (string-append "LDFLAGS_FOR_TARGET=" ldflags)))
1910 (let ((out (assoc-ref %outputs "out"))
1911 (glibc (assoc-ref %build-inputs "libc")))
1912 (list (string-append "--prefix=" out)
1913 "--build=i686-unknown-linux-gnu"
1914 "--host=i686-unknown-linux-gnu"
1915 (string-append "--with-native-system-header-dir=" glibc "/include")
1916 (string-append "--with-build-sysroot=" glibc "/include")
1917 "--disable-bootstrap"
1918 "--disable-decimal-float"
1919 "--disable-libatomic"
1920 "--disable-libcilkrts"
1923 "--disable-libmudflap"
1924 "--disable-libquadmath"
1925 "--disable-libsanitizer"
1929 "--disable-lto-plugin"
1930 "--disable-multilib"
1933 "--enable-languages=c"
1936 "--enable-threads=single"
1937 "--disable-libstdcxx-pch"
1938 "--disable-build-with-cxx"))
1940 (modify-phases %standard-phases
1941 (add-after 'unpack 'apply-boot-patch
1942 (lambda* (#:key inputs #:allow-other-keys)
1943 (let ((patch-file (assoc-ref inputs "boot-patch")))
1944 (format (current-error-port) "patch file=~s\n" patch-file)
1945 (system* "patch" "--force" "-p1" "-i" patch-file))
1947 ;; c&p from commencement.scm:gcc-boot0
1948 (add-after 'unpack 'unpack-gmp&co
1949 (lambda* (#:key inputs #:allow-other-keys)
1950 (let ((gmp (assoc-ref %build-inputs "gmp-source"))
1951 (mpfr (assoc-ref %build-inputs "mpfr-source"))
1952 (mpc (assoc-ref %build-inputs "mpc-source")))
1954 ;; To reduce the set of pre-built bootstrap inputs, build
1955 ;; GMP & co. from GCC.
1956 (for-each (lambda (source)
1957 (or (invoke "tar" "xvf" source)
1958 (error "failed to unpack tarball"
1960 (list gmp mpfr mpc))
1962 ;; Create symlinks like `gmp' -> `gmp-x.y.z'.
1963 ,@(map (lambda (lib)
1964 ;; Drop trailing letters, as gmp-6.0.0a unpacks
1966 `(symlink ,(string-trim-right
1967 (package-full-name lib "-")
1969 ,(package-name lib)))
1970 (list gmp-boot mpfr-boot mpc-boot))
1972 (add-before 'configure 'setenv
1973 (lambda* (#:key outputs #:allow-other-keys)
1974 (let* ((out (assoc-ref outputs "out"))
1975 (binutils (assoc-ref %build-inputs "binutils"))
1976 (bash (assoc-ref %build-inputs "bash"))
1977 (gcc (assoc-ref %build-inputs "gcc"))
1978 (glibc (assoc-ref %build-inputs "libc"))
1979 (kernel-headers (assoc-ref %build-inputs "kernel-headers")))
1980 (setenv "CONFIG_SHELL" (string-append bash "/bin/sh"))
1981 (setenv "C_INCLUDE_PATH" (string-append
1982 gcc "/lib/gcc-lib/i686-unknown-linux-gnu/2.95.3/include"
1983 ":" kernel-headers "/include"
1984 ":" glibc "/include"
1985 ":" (getcwd) "/mpfr/src"))
1986 (setenv "LIBRARY_PATH" (string-append glibc "/lib"
1988 (format (current-error-port) "C_INCLUDE_PATH=~a\n" (getenv "C_INCLUDE_PATH"))
1989 (format (current-error-port) "LIBRARY_PATH=~a\n" (getenv "LIBRARY_PATH"))
1992 (define gcc-mesboot1
1994 (inherit gcc-core-mesboot1)
1995 (name "gcc-mesboot1")
2001 (uri (string-append "mirror://gnu/gcc/gcc-"
2002 version "/gcc-g++-" version ".tar.gz"))
2005 "1fqqk5zkmdg4vmqzdmip9i42q6b82i3f6yc0n86n9021cr7ms2k9"))))
2006 ,@(package-native-inputs gcc-core-mesboot1)))
2008 (substitute-keyword-arguments (package-arguments gcc-core-mesboot1)
2009 ((#:configure-flags configure-flags)
2010 `(let ((out (assoc-ref %outputs "out")))
2011 `("--enable-languages=c,c++"
2013 (negate (lambda (x) (string-prefix? "--enable-languages=" x)))
2014 ,configure-flags))))
2016 `(modify-phases ,phases
2017 (add-before 'unpack 'unpack-g++
2019 (let ((source-g++ (assoc-ref %build-inputs "gcc-g++")))
2020 (invoke "tar" "xvf" source-g++))
2024 (setenv "CONFIG_SHELL" (which "sh"))
2026 ;; Allow MPFR headers to be found.
2027 (setenv "C_INCLUDE_PATH"
2028 (string-append (getcwd) "/mpfr/src:"
2029 (getenv "C_INCLUDE_PATH")))
2031 ;; Set the C++ search path so that C headers can be found as
2032 ;; libstdc++ is being compiled.
2033 (setenv "CPLUS_INCLUDE_PATH" (getenv "C_INCLUDE_PATH"))
2036 (define (%boot-mesboot2-inputs)
2037 `(("gcc" ,gcc-mesboot1)
2038 ,@(alist-delete "gcc" (%boot-mesboot1-inputs))))
2041 ;; Finally, we can build xz.
2046 (source (bootstrap-origin
2049 (uri (list (string-append "http://tukaani.org/xz/xz-" version
2051 (string-append "http://multiprecision.org/guix/xz-"
2052 version ".tar.gz")))
2055 "0kf40ggbs1vaaj5s9k4csycahzqcf65n20pa6lngqhm6j0cj3agb")))))
2056 (supported-systems '("i686-linux" "x86_64-linux"))
2059 (propagated-inputs '())
2060 (native-inputs (%boot-mesboot2-inputs))
2062 `(#:implicit-inputs? #f
2063 #:guile ,%bootstrap-guile
2064 #:parallel-build? #f
2066 `("--disable-assembler"
2072 "--disable-lzmainfo"
2073 "--disable-lzma-links"
2077 "--disable-symbol-versions"
2078 ;; configure disqualifies BASH, CPP, GCC and GREP
2079 ;; all of which seem fine for the build
2080 "ac_cv_prog_cc_c99=-std=gnu9x"
2081 "ac_cv_path_GREP=grep"
2082 "gl_cv_posix_shell=bash"
2083 "ac_cv_have_decl_optreset=no"
2084 "CPPFLAGS=-D__GNUC__=1")))))
2086 (define hello-mesboot
2087 ;; Check for Scheme-only bootstrap.
2090 (name "hello-mesboot")
2091 (supported-systems '("i686-linux" "x86_64-linux"))
2093 (propagated-inputs '())
2094 (native-inputs (%boot-mesboot2-inputs))
2096 `(#:implicit-inputs? #f
2097 #:guile ,%bootstrap-guile
2098 #:parallel-build? #f
2099 ;; checking for grep that handles long lines and -e...
2100 ;; configure: error: no acceptable grep could be found
2101 #:configure-flags '("ac_cv_path_GREP=grep")
2103 (modify-phases %standard-phases
2106 (invoke "./hello"))))))))
2108 (define binutils-mesboot
2111 (name "binutils-mesboot")
2113 (source (bootstrap-origin
2116 (uri (string-append "mirror://gnu/binutils/binutils-"
2117 version ".tar.bz2"))
2118 (patches (search-patches "binutils-boot-2.20.1a.patch"))
2121 "0r7dr0brfpchh5ic0z9r4yxqn4ybzmlh25sbp30cacqk8nb7rlvi")))))
2123 (propagated-inputs '())
2124 (native-inputs `(("xz" ,xz-mesboot)
2125 ,@(%boot-mesboot2-inputs)))
2126 (supported-systems '("i686-linux" "x86_64-linux"))
2128 `(#:implicit-inputs? #f
2129 #:guile ,%bootstrap-guile
2130 #:tests? #f ; runtest: command not found
2131 #:parallel-build? #f
2132 #:strip-binaries? #f ; no strip yet
2141 "--build=i686-unknown-linux-gnu"
2142 "--host=i686-unknown-linux-gnu"
2144 ;; checking for grep that handles long lines and -e
2145 "ac_cv_path_GREP=grep")
2146 ;; FIXME: ac_cv_path_GREP=grep doesn't seem to be forwarded to
2147 ;; cascading configure's?
2148 #:make-flags '("ac_cv_path_GREP=grep")
2150 (modify-phases %standard-phases
2151 (add-after 'unpack 'scripted-patch
2153 ;; sed-mesboot0 cannot build these
2154 (copy-file "binutils/Makefile.in" "binutils/Makefile.in.orig")
2155 (substitute* "binutils/Makefile.in"
2156 ;; binutils/binutils uses an amazingly complex install
2157 ;; command, using FOR, SED, READ, IF, ECHO, SED, SED, AWK,
2158 ;; READ, and then LIBTOOL (to do something like
2159 ;; `mkdir $DESTDIR$bindir; cp readline $DESTDIR$bindir ...')
2161 ;; Some tool [debugme!] cannot handle two escaped newlines
2162 ;; (bash?), and the install stops after $(am__EXEEXT_11)
2163 ;; ("objcopy"), so $(am__EXEEXT_13) ("readelf") and others do
2164 ;; not get installed. Remove the stray newline:
2165 (("^\t@BUILD_NLMCONV@ @BUILD_SRCONV@ @BUILD_DLLTOOL@ @BUILD_WINDRES@ .*") ""))
2166 (substitute* "opcodes/Makefile.in"
2167 (("^SUBDIRS = [.] po") "SUBDIRS = ."))
2168 (substitute* "binutils/Makefile.in"
2169 (("^SUBDIRS = doc po") "SUBDIRS ="))
2170 (substitute* "gas/Makefile.in"
2171 (("^SUBDIRS = doc po") "SUBDIRS ="))
2172 (substitute* "gprof/Makefile.in"
2173 (("^SUBDIRS = po") "SUBDIRS ="))
2174 (substitute* "ld/Makefile.in"
2175 (("^SUBDIRS = po") "SUBDIRS ="))
2178 (define (%boot-mesboot3-inputs)
2179 `(("binutils" ,binutils-mesboot)
2181 ,@(alist-delete "binutils" (%boot-mesboot2-inputs))))
2183 (define glibc-headers-mesboot
2185 (inherit glibc-mesboot0)
2186 (name "glibc-headers-mesboot")
2188 (source (bootstrap-origin
2191 (uri (string-append "mirror://gnu/glibc/glibc-"
2194 (patches (search-patches "glibc-boot-2.16.0.patch"
2195 "glibc-bootstrap-system-2.16.0.patch"))
2198 "0vlz4x6cgz7h54qq4528q526qlhnsjzbsvgc4iizn76cb0bfanx7")))))
2199 (native-inputs `(("headers" ,mesboot-headers)
2200 ,@(%boot-mesboot3-inputs)))
2202 (substitute-keyword-arguments (package-arguments glibc-mesboot0)
2203 ((#:configure-flags configure-flags)
2204 `(let ((out (assoc-ref %outputs "out"))
2205 (headers (assoc-ref %build-inputs "headers")))
2207 (string-append "--prefix=" out)
2208 "--disable-obsolete-rpc"
2209 "--host=i686-unknown-linux-gnu"
2210 (string-append "--with-headers=" headers "/include")
2211 "--enable-static-nss"
2215 "--enable-add-ons=nptl"
2216 ;; avoid: configure: error: confusing output from nm -u
2217 "libc_cv_predef_stack_protector=no")))
2218 ((#:make-flags make-flags)
2219 '(list "install-bootstrap-headers=yes" "install-headers"))
2221 `(modify-phases ,phases
2222 (delete 'apply-boot-patch)
2223 (delete 'fixup-configure)
2226 (lambda* (#:key source #:allow-other-keys)
2227 (invoke "tar" "xvf" source)
2228 (chdir (string-append "glibc-" ,version))
2231 (lambda* (#:key inputs #:allow-other-keys)
2232 (let* ((headers (assoc-ref inputs "headers"))
2233 (libc (assoc-ref inputs "libc"))
2234 (gcc (assoc-ref inputs "gcc"))
2235 (cppflags (string-append
2236 " -I " (getcwd) "/nptl/sysdeps/pthread/bits"
2237 " -D BOOTSTRAP_GLIBC=1"))
2238 (cflags (string-append " -L " (getcwd)
2239 " -L " libc "/lib")))
2240 (setenv "libc_cv_friendly_stddef" "yes")
2241 (setenv "CONFIG_SHELL" (which "sh"))
2242 (setenv "SHELL" (which "sh"))
2244 (setenv "CPP" (string-append gcc "/bin/gcc -E " cppflags))
2245 (setenv "CC" (string-append gcc "/bin/gcc " cppflags cflags))
2248 ;; avoid -fstack-protector
2249 (setenv "libc_cv_ssp" "false")
2250 (substitute* "configure"
2251 (("/bin/pwd") "pwd"))
2254 (lambda* (#:key outputs make-flags #:allow-other-keys)
2255 (let ((kernel-headers (assoc-ref %build-inputs "kernel-headers"))
2256 (out (assoc-ref outputs "out")))
2257 (and (apply invoke "make" make-flags)
2258 (copy-recursively kernel-headers out)
2261 (lambda* (#:key configure-flags #:allow-other-keys)
2262 (format (current-error-port) "running ../configure ~a\n" (string-join configure-flags))
2265 (apply invoke "../configure" configure-flags)))
2266 (add-after 'configure 'remove-sunrpc
2268 (let* ((out (assoc-ref %outputs "out"))
2269 (bash (assoc-ref %build-inputs "bash"))
2270 (shell (string-append bash "/bin/bash")))
2272 (let ((Makefile (open-file "Makefile" "a")))
2273 (display (string-append "
2279 (substitute* "../Makefile"
2280 (("^SHELL := /bin/sh") (string-append "SHELL := " shell)))
2281 (substitute* "../Makeconfig"
2282 (("^SHELL := /bin/sh") (string-append "SHELL := " shell)))
2283 (substitute* "../elf/Makefile"
2284 (("^SHELL := /bin/sh") (string-append "SHELL := " shell)))
2285 (invoke "make" (string-append (getcwd) "/sysd-sorted" ))
2286 (substitute* "sysd-sorted"
2291 (define glibc-mesboot
2293 (inherit glibc-headers-mesboot)
2294 (name "glibc-mesboot")
2295 (native-inputs `(("headers" ,glibc-headers-mesboot)
2296 ,@(%boot-mesboot3-inputs)))
2298 `(#:validate-runpath? #f ; fails when using --enable-shared
2299 ,@(substitute-keyword-arguments (package-arguments glibc-headers-mesboot)
2300 ((#:make-flags make-flags)
2301 `(let ((bash (assoc-ref %build-inputs "bash")))
2302 (list (string-append "SHELL=" bash "/bin/sh"))))
2304 `(modify-phases ,phases
2306 (lambda* (#:key outputs make-flags #:allow-other-keys)
2307 (let* ((kernel-headers (assoc-ref %build-inputs "kernel-headers"))
2308 (out (assoc-ref outputs "out"))
2309 (install-flags (cons "install" make-flags)))
2310 (and (apply invoke "make" install-flags)
2311 (copy-recursively kernel-headers out)
2314 (define (%boot-mesboot4-inputs)
2315 `(("libc" ,glibc-mesboot)
2316 ,@(alist-delete "libc" (%boot-mesboot3-inputs))))
2318 (define gcc-mesboot1-wrapper
2319 ;; We need this so gcc-mesboot1 can be used to create shared binaries that
2320 ;; have the correct interpreter, otherwise configuring gcc-mesboot using
2321 ;; --enable-shared will fail.
2323 (inherit gcc-mesboot1)
2324 (name "gcc-mesboot1-wrapper")
2327 (native-inputs `(("bash" ,bash-mesboot)
2328 ("coreutils" ,coreutils-mesboot0)
2329 ("libc" ,glibc-mesboot)
2330 ("gcc" ,gcc-mesboot1)))
2332 `(#:implicit-inputs? #f
2333 #:guile ,%bootstrap-guile
2335 (modify-phases %standard-phases
2340 (lambda* (#:key outputs #:allow-other-keys)
2341 (let* ((out (assoc-ref outputs "out"))
2342 (bash (assoc-ref %build-inputs "bash"))
2343 (libc (assoc-ref %build-inputs "libc"))
2344 (gcc (assoc-ref %build-inputs "gcc"))
2345 (bin (string-append out "/bin")))
2349 (let ((wrapper (string-append bin "/" program)))
2350 (with-output-to-file wrapper
2352 (display (string-append "#! " bash "/bin/bash
2353 exec " gcc "/bin/" program
2354 " -Wl,--dynamic-linker"
2355 ;; also for x86_64-linux, we are still on i686-linux
2356 " -Wl," libc ,(glibc-dynamic-linker "i686-linux")
2361 (chmod wrapper #o555)))))
2365 "i686-unknown-linux-gnu-cpp"
2366 "i686-unknown-linux-gnu-gcc"
2367 "i686-unknown-linux-gnu-g++"))
2370 (lambda* (#:key outputs #:allow-other-keys)
2371 (let* ((out (assoc-ref outputs "out"))
2372 (bin (string-append out "/bin"))
2373 (program (string-append bin "/gcc")))
2374 (invoke program "--help")))))))))
2378 (inherit gcc-mesboot1)
2379 (name "gcc-mesboot")
2380 (version (package-version gcc-4.9))
2381 (source (bootstrap-origin (package-source gcc-4.9)))
2382 (native-inputs `(("gcc-wrapper" ,gcc-mesboot1-wrapper)
2383 ("gcc" ,gcc-mesboot1)
2384 ("headers" ,glibc-headers-mesboot)
2385 ,@(%boot-mesboot4-inputs)))
2387 `(#:validate-runpath? #f
2388 ,@(substitute-keyword-arguments (package-arguments gcc-mesboot1)
2389 ((#:configure-flags configure-flags)
2390 `(let ((out (assoc-ref %outputs "out"))
2391 (glibc (assoc-ref %build-inputs "libc")))
2392 (list (string-append "--prefix=" out)
2393 "--build=i686-unknown-linux-gnu"
2394 "--host=i686-unknown-linux-gnu"
2396 "--with-host-libstdcxx=-lsupc++"
2398 (string-append "--with-native-system-header-dir=" glibc "/include")
2399 (string-append "--with-build-sysroot=" glibc "/include")
2401 "--disable-bootstrap"
2402 "--disable-decimal-float"
2403 "--disable-libatomic"
2404 "--disable-libcilkrts"
2407 "--disable-libmudflap"
2408 "--disable-libquadmath"
2409 "--disable-libsanitizer"
2413 "--disable-lto-plugin"
2414 "--disable-multilib"
2417 "--enable-languages=c,c++"
2421 "--enable-threads=single"
2423 ;; No pre-compiled libstdc++ headers, to save space.
2424 "--disable-libstdcxx-pch"
2427 "--disable-build-with-cxx")))
2429 `(modify-phases ,phases
2430 (delete 'apply-boot-patch)
2431 (delete 'unpack-g++) ; sadly, gcc-4.9.4 does not provide
2432 ; modular core/language downloads
2434 (lambda* (#:key outputs #:allow-other-keys)
2435 (let* ((out (assoc-ref outputs "out"))
2436 (binutils (assoc-ref %build-inputs "binutils"))
2437 (bash (assoc-ref %build-inputs "bash"))
2438 (gcc (assoc-ref %build-inputs "gcc"))
2439 (glibc (assoc-ref %build-inputs "libc"))
2440 (kernel-headers (assoc-ref %build-inputs "kernel-headers")))
2441 (setenv "CONFIG_SHELL" (string-append bash "/bin/sh"))
2442 (setenv "C_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 "CPLUS_INCLUDE_PATH" (string-append
2448 gcc "/lib/gcc-lib/i686-unknown-linux-gnu/4.6.4/include"
2449 ":" kernel-headers "/include"
2450 ":" glibc "/include"
2451 ":" (getcwd) "/mpfr/src"))
2452 (setenv "LIBRARY_PATH" (string-append glibc "/lib"
2454 (format (current-error-port) "C_INCLUDE_PATH=~a\n" (getenv "C_INCLUDE_PATH"))
2455 (format (current-error-port) "CPLUS_INCLUDE_PATH=~a\n" (getenv "CPLUS_INCLUDE_PATH"))
2456 (format (current-error-port) "LIBRARY_PATH=~a\n" (getenv "LIBRARY_PATH"))
2459 (define gcc-mesboot-wrapper
2460 ;; We need this so gcc-mesboot can be used to create shared binaries that
2461 ;; have the correct interpreter and runpath to libc.
2463 (inherit gcc-mesboot1-wrapper)
2464 (name "gcc-mesboot-wrapper")
2465 (version (package-version gcc-mesboot))
2468 (native-inputs `(("bash" ,bash-mesboot)
2469 ("coreutils" ,coreutils-mesboot0)
2470 ("libc" ,glibc-mesboot)
2471 ("gcc" ,gcc-mesboot)))))
2473 (define (%boot-mesboot5-inputs)
2474 `(("gcc-wrapper" ,gcc-mesboot-wrapper)
2475 ("gcc" ,gcc-mesboot)
2476 ,@(fold alist-delete (%boot-mesboot4-inputs) '("gcc" "gcc-wrapper"))))
2478 (define coreutils-mesboot
2481 (name "coreutils-mesboot")
2482 (source (bootstrap-origin (package-source coreutils)))
2483 (native-inputs (%boot-mesboot5-inputs))
2484 (supported-systems '("i686-linux" "x86_64-linux"))
2486 (propagated-inputs '())
2488 `(#:implicit-inputs? #f
2489 #:guile ,%bootstrap-guile
2492 (define (%boot-mesboot6-inputs)
2493 `(("coreutils" ,coreutils-mesboot)
2494 ,@(fold alist-delete (%boot-mesboot5-inputs)
2495 '("coreutils" "kernel-headers"))))
2497 (define (%bootstrap-inputs+toolchain)
2498 ;; The traditional bootstrap-inputs. For the i686-linux, x86_64-linux
2499 ;; Scheme-only bootstrap the actual reduced set with bootstrapped toolchain.
2500 (match (%current-system)
2501 ((or "i686-linux" "x86_64-linux")
2502 (%boot-mesboot6-inputs))
2504 (%bootstrap-inputs))))
2506 (define gnu-make-boot0
2509 (source (bootstrap-origin (package-source gnu-make)))
2512 `(#:guile ,%bootstrap-guile
2513 #:implicit-inputs? #f
2514 #:tests? #f ; cannot run "make check"
2515 ,@(substitute-keyword-arguments (package-arguments gnu-make)
2516 ((#:configure-flags flags ''())
2517 ;; The generated config.status has some problems due to the
2518 ;; bootstrap environment. Disable dependency tracking to work
2520 `(cons "--disable-dependency-tracking" ,flags))
2522 `(modify-phases ,phases
2525 (invoke "./build.sh")))
2527 (lambda* (#:key outputs #:allow-other-keys)
2528 (let* ((out (assoc-ref outputs "out"))
2529 (bin (string-append out "/bin")))
2530 (install-file "make" bin)
2532 (native-inputs '()) ; no need for 'pkg-config'
2533 (inputs (%bootstrap-inputs+toolchain))))
2538 (name "bzip2-boot0")
2541 `(("diffutils" ,diffutils-boot0)
2542 ("make" ,gnu-make-boot0)
2543 ,@(%bootstrap-inputs+toolchain)))
2545 `(#:guile ,%bootstrap-guile
2546 #:implicit-inputs? #f
2547 ,@(package-arguments bzip2)))))
2549 (define coreutils-boot0
2552 (source (bootstrap-origin (package-source coreutils)))
2553 (name "coreutils-boot0")
2556 `(("make" ,gnu-make-boot0)
2557 ,@(%bootstrap-inputs+toolchain)))
2560 #:implicit-inputs? #f
2561 #:guile ,%bootstrap-guile
2562 ,@(package-arguments coreutils)))))
2564 (define diffutils-boot0
2567 (name "diffutils-boot0")
2570 `(("make" ,gnu-make-boot0)
2571 ,@(%bootstrap-inputs+toolchain)))
2573 `(#:tests? #f ; the test suite needs diffutils
2574 #:guile ,%bootstrap-guile
2575 #:implicit-inputs? #f
2576 ,@(match (%current-system)
2577 ((or "arm-linux" "aarch64-linux")
2578 (substitute-keyword-arguments (package-arguments diffutils)
2579 ((#:configure-flags flags ''())
2580 ;; The generated config.status has some problems due to the
2581 ;; bootstrap environment. Disable dependency tracking to work
2583 `(cons "--disable-dependency-tracking" ,flags))))
2586 (define findutils-boot0
2589 (name "findutils-boot0")
2590 (source (bootstrap-origin (package-source findutils)))
2592 `(("make" ,gnu-make-boot0)
2593 ("diffutils" ,diffutils-boot0) ; for tests
2594 ,@(%bootstrap-inputs+toolchain)))
2596 `(#:implicit-inputs? #f
2597 #:guile ,%bootstrap-guile
2599 ;; The build system assumes we have done a mistake when time_t is 32-bit
2600 ;; on a 64-bit system. Ignore that for our bootstrap toolchain.
2601 ,@(substitute-keyword-arguments (package-arguments findutils)
2602 ((#:configure-flags flags ''())
2604 ,(if (target-64bit?)
2605 ''("TIME_T_32_BIT_OK=yes")
2607 ,(match (%current-system)
2608 ((or "arm-linux" "aarch64-linux")
2609 ''("--disable-dependency-tracking"))
2615 (inherit (@ (gnu packages file) file))
2619 ,,@(match (%current-system)
2620 ((or "arm-linux" "aarch64-linux")
2621 '("--disable-dependency-tracking"))
2627 (source (bootstrap-origin (package-source file)))
2630 `(("make" ,gnu-make-boot0)
2631 ,@(%bootstrap-inputs+toolchain)))
2633 `(#:tests? #f ; merge test fails
2634 #:implicit-inputs? #f
2635 #:guile ,%bootstrap-guile
2636 #:configure-flags '("--disable-bzlib")
2637 #:strip-binaries? #f
2638 #:validate-runpath? #f
2639 ,@(package-arguments file)))))
2644 (source (bootstrap-origin (package-source gawk)))
2648 `(("make" ,gnu-make-boot0)
2649 ,@(%bootstrap-inputs+toolchain)))
2652 #:implicit-inputs? #f
2653 #:guile ,%bootstrap-guile
2654 #:strip-binaries? #f
2655 #:validate-runpath? #f))))
2660 (source (bootstrap-origin (package-source patch)))
2661 (name "patch-boot0")
2664 `(("make" ,gnu-make-boot0)
2665 ,@(%bootstrap-inputs+toolchain)))
2667 `(#:tests? #f ; merge test fails
2668 #:implicit-inputs? #f
2669 #:guile ,%bootstrap-guile
2670 #:strip-binaries? #f
2671 #:validate-runpath? #f))))
2677 (source (bootstrap-origin (package-source sed)))
2680 `(("make" ,gnu-make-boot0)
2681 ,@(%bootstrap-inputs+toolchain)))
2683 `(#:implicit-inputs? #f
2685 #:guile ,%bootstrap-guile
2686 ,@(package-arguments sed)))))
2692 (source (bootstrap-origin (package-source tar)))
2695 `(("make" ,gnu-make-boot0)
2696 ,@(%bootstrap-inputs+toolchain)))
2698 `(#:implicit-inputs? #f
2700 #:guile ,%bootstrap-guile
2701 ,@(package-arguments tar)))))
2703 (define (%boot0-inputs)
2704 `(,@(match (%current-system)
2705 ((or "i686-linux" "x86_64-linux")
2706 `(("bzip2" ,bzip2-boot0)
2707 ("coreutils" ,coreutils-boot0)
2708 ("gawk" ,gawk-boot0)
2709 ("patch" ,patch-boot0)
2711 ("tar" ,tar-boot0)))
2713 ("make" ,gnu-make-boot0)
2714 ("diffutils" ,diffutils-boot0)
2715 ("findutils" ,findutils-boot0)
2716 ("file" ,file-boot0)
2717 ,@(%bootstrap-inputs+toolchain)))
2719 (define* (boot-triplet #:optional (system (%current-system)))
2720 ;; Return the triplet used to create the cross toolchain needed in the
2721 ;; first bootstrapping stage.
2722 (nix-system->gnu-triplet system "guix"))
2724 ;; Following Linux From Scratch, build a cross-toolchain in stage 0. That
2725 ;; toolchain actually targets the same OS and arch, but it has the advantage
2726 ;; of being independent of the libc and tools in
2727 ;; (%BOOTSTRAP-INPUTS+TOOLCHAIN), since GCC-BOOT0 (below) is built without any
2728 ;; reference to the target libc.
2730 (define binutils-boot0
2733 (source (bootstrap-origin (package-source binutils)))
2734 (name "binutils-cross-boot0")
2736 `(#:guile ,%bootstrap-guile
2737 #:implicit-inputs? #f
2739 #:modules ((guix build gnu-build-system)
2741 (ice-9 ftw)) ; for 'scandir'
2742 #:phases (modify-phases %standard-phases
2743 (add-after 'install 'add-symlinks
2744 (lambda* (#:key outputs #:allow-other-keys)
2745 ;; The cross-gcc invokes 'as', 'ld', etc, without the
2746 ;; triplet prefix, so add symlinks.
2747 (let ((out (assoc-ref outputs "out"))
2748 (triplet-prefix (string-append ,(boot-triplet) "-")))
2749 (define (has-triplet-prefix? name)
2750 (string-prefix? triplet-prefix name))
2751 (define (remove-triplet-prefix name)
2752 (substring name (string-length triplet-prefix)))
2753 (with-directory-excursion (string-append out "/bin")
2754 (for-each (lambda (name)
2755 (symlink name (remove-triplet-prefix name)))
2756 (scandir "." has-triplet-prefix?)))
2759 ,@(substitute-keyword-arguments (package-arguments binutils)
2760 ((#:configure-flags cf)
2761 `(cons ,(string-append "--target=" (boot-triplet))
2763 (inputs (%boot0-inputs))))
2765 (define libstdc++-boot0
2766 ;; GCC's libcc1 is always built as a shared library (the top-level
2767 ;; 'Makefile.def' forcefully adds --enable-shared) and thus needs to refer
2768 ;; to libstdc++.so. We cannot build libstdc++-5.3 because it relies on
2769 ;; C++14 features missing in some of our bootstrap compilers.
2770 (let ((lib (make-libstdc++ gcc-4.9)))
2773 (source (bootstrap-origin (package-source lib)))
2774 (name "libstdc++-boot0")
2776 `(#:guile ,%bootstrap-guile
2777 #:implicit-inputs? #f
2779 ;; XXX: libstdc++.so NEEDs ld.so for some reason.
2780 #:validate-runpath? #f
2782 ,@(match (%current-system)
2783 ((or "i686-linux" "x86_64-linux")
2784 (substitute-keyword-arguments (package-arguments lib)
2786 `(modify-phases ,phases
2787 (add-after 'unpack 'workaround-wrapper-bug
2788 ;; XXX: The crude gcc-cross-wrapper causes "g++ -v" to
2789 ;; fail, which in turn confuses the configure script.
2791 (substitute* "libstdc++-v3/configure"
2792 (("g\\+\\+ -v") "true"))
2794 (_ (package-arguments lib)))))
2795 (inputs (%boot0-inputs))
2796 (native-inputs '()))))
2801 (name "gcc-cross-boot0")
2802 (source (bootstrap-origin (package-source gcc)))
2804 `(#:guile ,%bootstrap-guile
2805 #:implicit-inputs? #f
2806 #:modules ((guix build gnu-build-system)
2811 ,@(substitute-keyword-arguments (package-arguments gcc)
2812 ((#:configure-flags flags)
2813 `(append (list ,(string-append "--target=" (boot-triplet))
2818 ;; Disable features not needed at this stage.
2820 "--enable-languages=c,c++"
2822 ;; boot-triplet inserts "guix" in the triplet.
2823 ,@(if (equal? "powerpc64le-guix-linux-gnu" (boot-triplet))
2824 ;; On POWER9 (little endian) glibc needs the
2825 ;; 128-bit long double type.
2826 '("--with-long-double-128")
2829 ;; libstdc++ cannot be built at this stage
2830 ;; ("Link tests are not allowed after
2831 ;; GCC_NO_EXECUTABLES.").
2832 "--disable-libstdc++-v3"
2835 "--disable-libmudflap"
2836 "--disable-libatomic"
2837 "--disable-libsanitizer"
2841 "--disable-libcilkrts"
2844 "--disable-libquadmath"
2845 "--disable-decimal-float")
2846 (remove (cut string-match
2847 "--(with-system-zlib|enable-languages.*)" <>)
2849 ((#:make-flags flags)
2850 `(let* ((libc (assoc-ref %build-inputs "libc"))
2851 (libc-native (or (assoc-ref %build-inputs "libc-native")
2853 `(,(string-append "LDFLAGS="
2854 "-Wl,-rpath=" libc-native "/lib "
2855 "-Wl,-dynamic-linker "
2856 "-Wl," libc-native ,(glibc-dynamic-linker
2857 (match (%current-system)
2858 ("x86_64-linux" "i686-linux")
2859 (_ (%current-system))))))))
2861 `(modify-phases ,phases
2862 (add-after 'unpack 'unpack-gmp&co
2863 (lambda* (#:key inputs #:allow-other-keys)
2864 (let ((gmp (assoc-ref %build-inputs "gmp-source"))
2865 (mpfr (assoc-ref %build-inputs "mpfr-source"))
2866 (mpc (assoc-ref %build-inputs "mpc-source")))
2868 ;; To reduce the set of pre-built bootstrap inputs, build
2869 ;; GMP & co. from GCC.
2870 (for-each (lambda (source)
2871 (invoke "tar" "xvf" source))
2872 (list gmp mpfr mpc))
2874 ;; Create symlinks like `gmp' -> `gmp-x.y.z'.
2875 ,@(map (lambda (lib)
2876 ;; Drop trailing letters, as gmp-6.0.0a unpacks
2878 `(symlink ,(string-trim-right
2879 (package-full-name lib "-")
2881 ,(package-name lib)))
2882 (list gmp-6.0 mpfr mpc))
2884 ,(match (%current-system)
2885 ((or "i686-linux" "x86_64-linux")
2886 '(add-before 'configure 'fix-libcc1
2887 (lambda* (#:key inputs #:allow-other-keys)
2888 ;; libcc1.so NEEDs libgcc_s.so, so provide one here
2889 ;; to placate the 'validate-runpath' phase.
2890 (substitute* "libcc1/Makefile.in"
2892 (string-append "la_LDFLAGS = -Wl,-rpath="
2893 (assoc-ref inputs "gcc") "/lib")))
2894 ;; XXX: "g++ -v" is broken (see also libstdc++ above).
2895 (substitute* "libcc1/configure"
2896 (("g\\+\\+ -v") "true"))
2898 (_ '(add-before 'configure 'return-true
2900 (add-after 'install 'symlink-libgcc_eh
2901 (lambda* (#:key outputs #:allow-other-keys)
2902 (let ((out (assoc-ref outputs "lib")))
2903 ;; Glibc wants to link against libgcc_eh, so provide
2905 (with-directory-excursion
2906 (string-append out "/lib/gcc/"
2908 "/" ,(package-version gcc))
2909 (symlink "libgcc.a" "libgcc_eh.a"))
2912 (inputs `(("gmp-source" ,(bootstrap-origin (package-source gmp-6.0)))
2913 ("mpfr-source" ,(bootstrap-origin (package-source mpfr)))
2914 ("mpc-source" ,(bootstrap-origin (package-source mpc)))
2915 ("binutils-cross" ,binutils-boot0)
2917 ;; The libstdc++ that libcc1 links against.
2918 ("libstdc++" ,libstdc++-boot0)
2920 ;; Call it differently so that the builder can check whether
2921 ;; the "libc" input is #f.
2922 ("libc-native" ,@(assoc-ref (%boot0-inputs) "libc"))
2923 ,@(alist-delete "libc" (%boot0-inputs))))
2925 ;; No need for the native-inputs to build the documentation at this stage.
2926 (native-inputs `())))
2932 (source (bootstrap-origin (package-source perl)))
2933 (inputs (%boot0-inputs))
2935 `(#:implicit-inputs? #f
2936 #:guile ,%bootstrap-guile
2937 #:validate-runpath? #f
2939 ;; At the very least, this must not depend on GCC & co.
2940 #:disallowed-references ,(list %bootstrap-binutils)
2942 ,@(substitute-keyword-arguments (package-arguments perl)
2944 `(modify-phases ,phases
2945 ;; Pthread support is missing in the bootstrap compiler
2946 ;; (broken spec file), so disable it.
2947 (add-before 'configure 'disable-pthreads
2949 (substitute* "Configure"
2950 (("^libswanted=(.*)pthread" _ before)
2951 (string-append "libswanted=" before)))
2953 ;; Do not configure with '-Dusethreads' since pthread
2954 ;; support is missing.
2955 ((#:configure-flags configure-flags)
2956 `(delete "-Dusethreads" ,configure-flags)))))))
2962 (source (bootstrap-origin (package-source m4)))
2963 (inputs (%boot0-inputs))
2965 `(#:guile ,%bootstrap-guile
2966 #:implicit-inputs? #f
2967 ,@(package-arguments m4)))))
2970 ;; This Bison is needed to build MiG so we need it early in the process.
2971 ;; Recent versions of Linux-Libre headers also depend on this.
2974 (name "bison-boot0")
2975 (propagated-inputs `(("m4" ,m4-boot0)))
2976 (native-inputs `(("perl" ,perl-boot0)))
2977 (inputs (%boot0-inputs)) ;remove Flex...
2979 `(#:tests? #f ;... and thus disable tests
2980 #:implicit-inputs? #f
2981 #:guile ,%bootstrap-guile
2983 ;; Zero timestamps in liby.a; this must be done
2984 ;; explicitly here because the bootstrap Binutils don't
2985 ;; do that (default is "cru".)
2986 #:make-flags `("ARFLAGS=crD"
2987 ,,(match (%current-system)
2988 ;; ranlib: '-D': No such file
2989 ((or "i686-linux" "x86_64-linux")
2992 "RANLIB=ranlib -D"))
2995 ,@(package-arguments bison)))))
2998 ;; This Flex is needed to build MiG as well as Linux-Libre headers.
3001 (native-inputs `(("bison" ,bison-boot0)))
3002 (propagated-inputs `(("m4" ,m4-boot0)))
3003 (inputs (%boot0-inputs))
3005 `(#:implicit-inputs? #f
3006 #:guile ,%bootstrap-guile
3012 (native-inputs `(("perl" ,perl-boot0)))
3013 (inputs (%boot0-inputs))
3015 `(#:implicit-inputs? #f
3016 #:guile ,%bootstrap-guile))))
3018 (define-syntax define/system-dependent
3020 "Bind IDENTIFIER to EXP, where the value of EXP is known to depend on
3021 '%current-system'. The definition ensures that (1) EXP is \"thunked\" so that
3022 it sees the right value of '%current-system', and (2) that its result is
3023 memoized as a function of '%current-system'."
3026 (with-syntax ((memoized (datum->syntax #'identifier
3028 (syntax->datum #'identifier)
3032 (mlambda (system) exp))
3033 (define-syntax identifier
3034 (identifier-syntax (memoized (%current-system))))))))))
3036 (define/system-dependent linux-libre-headers-boot0
3037 ;; Note: this is wrapped in a thunk to nicely handle circular dependencies
3038 ;; between (gnu packages linux) and this module. Additionally, memoize
3039 ;; the result to play well with further memoization and code that relies
3040 ;; on pointer identity; see <https://bugs.gnu.org/30155>.
3042 (inherit linux-libre-headers)
3044 `(#:guile ,%bootstrap-guile
3045 #:implicit-inputs? #f
3046 ,@(package-arguments linux-libre-headers)))
3048 `(("perl" ,perl-boot0)
3050 ;; Flex and Bison are required since version 4.16.
3051 ("flex" ,flex-boot0)
3052 ("bison" ,bison-boot0)
3054 ;; Rsync is required since version 5.3.
3055 ("rsync" ,rsync-boot0)
3056 ,@(%boot0-inputs)))))
3059 (package-with-explicit-inputs %boot0-inputs
3062 (define gnumach-headers-boot0
3064 (package-with-bootstrap-guile
3066 (inherit gnumach-headers)
3067 (version "1.8-116-g28b53508")
3068 (source (bootstrap-origin
3071 (uri (string-append "https://lilypond.org/janneke/hurd/"
3072 "gnumach-" version ".tar.gz"))
3075 "006i0zgwy81vxarpfm12vip4q6i5mgmi5mmy5ldvxp5hx9h3l0zg")))))
3076 (native-inputs '())))))
3079 (let* ((mig (package
3080 (inherit (package-with-bootstrap-guile mig))
3081 (native-inputs `(("bison" ,bison-boot0)
3082 ("flex" ,flex-boot0)))
3083 (inputs `(("flex" ,flex-boot0)))
3086 `(,(string-append "LDFLAGS=-Wl,-rpath="
3087 (assoc-ref %build-inputs "flex") "/lib/")))))))
3090 (define hurd-version-boot0 "0.9-229-ga1efcee8")
3091 (define hurd-source-boot0
3092 (let ((version hurd-version-boot0))
3096 (uri (string-append "https://lilypond.org/janneke/hurd/"
3097 "hurd-v" version ".tar.gz"))
3100 "0bq2q2jisxcy0kgcm6rz0z2fddwxxm7azsama7li28a2m08kdpzy"))))))
3102 (define hurd-headers-boot0
3103 (let ((hurd-headers (package (inherit hurd-headers)
3104 (version hurd-version-boot0)
3105 (source hurd-source-boot0)
3106 (native-inputs `(("mig" ,mig-boot0)))
3108 (with-boot0 (package-with-bootstrap-guile hurd-headers))))
3110 (define hurd-minimal-boot0
3111 (let ((hurd-minimal (package (inherit hurd-minimal)
3112 (version hurd-version-boot0)
3113 (source hurd-source-boot0)
3114 (native-inputs `(("mig" ,mig-boot0)))
3116 (with-boot0 (package-with-bootstrap-guile hurd-minimal))))
3118 (define/system-dependent hurd-core-headers-boot0
3119 ;; Return the Hurd and Mach headers as well as initial Hurd libraries for
3120 ;; the bootstrap environment.
3121 (package (inherit (package-with-bootstrap-guile hurd-core-headers))
3122 (arguments `(#:guile ,%bootstrap-guile
3123 ,@(package-arguments hurd-core-headers)))
3125 `(("gnumach-headers" ,gnumach-headers-boot0)
3126 ("hurd-headers" ,hurd-headers-boot0)
3127 ("hurd-minimal" ,hurd-minimal-boot0)
3128 ,@(%boot0-inputs)))))
3130 (define* (kernel-headers-boot0 #:optional (system (%current-system)))
3132 ("i586-gnu" hurd-core-headers-boot0)
3133 (_ linux-libre-headers-boot0)))
3135 (define texinfo-boot0
3136 ;; Texinfo used to build libc's manual.
3137 ;; We build without ncurses because it fails to build at this stage, and
3138 ;; because we don't need the stand-alone Info reader.
3139 ;; Also, use (%BOOT0-INPUTS) to avoid building Perl once more.
3143 (inputs `(,@(%boot0-inputs)
3144 ("perl" ,perl-boot0)))
3146 `(#:implicit-inputs? #f
3147 #:guile ,%bootstrap-guile
3149 ;; Some of Texinfo 6.1's tests would fail with "Couldn't set UTF-8
3150 ;; character type in locale" but we don't have a UTF-8 locale at this
3151 ;; stage, so skip them.
3154 (define expat-sans-tests
3157 (inputs (%boot0-inputs))
3159 ;; XXX: Linking 'runtestscpp' fails with things like:
3161 ;; ld: Dwarf Error: found dwarf version '3789', this reader only handles version 2 and 3 information.
3163 ;; Skip tests altogether.
3164 `(#:implicit-inputs? #f
3165 #:guile ,%bootstrap-guile
3167 ,@(substitute-keyword-arguments (package-arguments expat)
3168 ((#:configure-flags flags ''())
3169 ;; Since we're not passing the right -Wl,-rpath flags, build the
3170 ;; static library to avoid RUNPATH validation failure.
3171 `(cons "--disable-shared" ,flags))
3172 ((#:tests? _ #f) #f))))))
3174 (define python-boot0
3176 (inherit python-minimal)
3177 ;; We cannot use Python 3.7 and later here, because they require
3178 ;; pthreads, which is missing on non-x86 platforms at this stage.
3179 ;; Python 3.6 technically supports being built without threading
3180 ;; support, but requires additional patches.
3182 (source (bootstrap-origin
3185 (uri (string-append "https://www.python.org/ftp/python/"
3186 version "/Python-" version ".tar.xz"))
3189 "0jdh9pvx6m6lfz2liwvvhn7vks7qrysqgwn517fkpxb77b33fjn2"))
3190 (modules '((guix build utils)))
3193 ;; Delete the bundled copy of libexpat.
3194 (delete-file-recursively "Modules/expat")
3195 (substitute* "Modules/Setup.dist"
3196 ;; Link Expat instead of embedding the bundled one.
3197 (("^#pyexpat.*") "pyexpat pyexpat.c -lexpat\n"))
3201 ("expat" ,expat-sans-tests))) ;remove OpenSSL, zlib, etc.
3202 (native-inputs '()) ;and pkg-config
3204 `(#:implicit-inputs? #f
3205 #:guile ,%bootstrap-guile
3207 ,@(substitute-keyword-arguments (package-arguments python-minimal)
3208 ;; Disable features that cannot be built at this stage.
3209 ((#:configure-flags _ ''())
3210 `(list "--without-ensurepip"
3211 "--without-threads"))
3212 ;; Clear #:make-flags, such that changes to the regular
3213 ;; Python package won't interfere with this one.
3214 ((#:make-flags _ ''()) ''())
3216 ;; Remove the 'apply-alignment-patch' phase if present to avoid
3217 ;; rebuilding this package. TODO: for the next rebuild cycle,
3218 ;; consider inlining all the arguments instead of inheriting to
3219 ;; make it easier to patch Python without risking a full rebuild.
3220 ;; Or better yet, change to 'python-on-guile'.
3221 `(modify-phases ,@(list (match phases
3222 (('modify-phases original-phases
3224 ('add-after unpack apply-alignment-patch _))
3225 `(modify-phases ,original-phases ,@changes))
3227 (add-before 'configure 'disable-modules
3229 (substitute* "setup.py"
3230 ;; Disable ctypes, since it requires libffi.
3231 (("extensions\\.append\\(ctypes\\)") "")
3232 ;; Prevent the 'ossaudiodev' extension from being
3233 ;; built, since it requires Linux headers.
3237 ,@(if (hurd-system?)
3238 `((add-before 'build 'fix-regen
3239 (lambda* (#:key inputs #:allow-other-keys)
3240 (let ((libc (assoc-ref inputs "libc")))
3241 (substitute* "Lib/plat-generic/regen"
3242 (("/usr/include/") (string-append libc "/include/")))
3245 ((#:tests? _ #f) #f))))))
3247 (define/system-dependent ld-wrapper-boot0
3248 ;; The first 'ld' wrapper, defined with 'define/system-dependent' because
3249 ;; its calls '%boot0-inputs', whose result depends on (%current-system)
3251 ;; We need this so binaries on Hurd will have libmachuser and libhurduser
3252 ;; in their RUNPATH, otherwise validate-runpath will fail.
3253 (make-ld-wrapper "ld-wrapper-boot0"
3254 #:target boot-triplet
3255 #:binutils binutils-boot0
3256 #:guile %bootstrap-guile
3257 #:bash (car (assoc-ref (%boot0-inputs) "bash"))
3258 #:guile-for-build %bootstrap-guile))
3260 (define (%boot1-inputs)
3261 ;; 2nd stage inputs.
3262 `(("gcc" ,gcc-boot0)
3263 ("ld-wrapper-cross" ,ld-wrapper-boot0)
3264 ("binutils-cross" ,binutils-boot0)
3265 ,@(alist-delete "binutils" (%boot0-inputs))))
3267 (define glibc-final-with-bootstrap-bash
3268 ;; The final libc, "cross-built". If everything went well, the resulting
3269 ;; store path has no dependencies. Actually, the really-final libc is
3270 ;; built just below; the only difference is that this one uses the
3274 (name "glibc-intermediate")
3275 (source (bootstrap-origin (package-source glibc)))
3277 `(#:guile ,%bootstrap-guile
3278 #:implicit-inputs? #f
3280 ,@(substitute-keyword-arguments (package-arguments glibc)
3281 ((#:configure-flags flags)
3282 `(append (list ,(string-append "--host=" (boot-triplet))
3283 ,(string-append "--build="
3284 (nix-system->gnu-triplet))
3285 ,(if (hurd-system?) "--disable-werror"
3289 `(modify-phases ,phases
3290 (add-before 'configure 'pre-configure
3291 (lambda* (#:key inputs #:allow-other-keys)
3292 ;; Don't clobber CPATH with the bootstrap libc.
3293 (setenv "NATIVE_CPATH" (getenv "CPATH"))
3296 ;; Tell 'libpthread' where to find 'libihash' on Hurd systems.
3297 ,@(if (hurd-system?)
3298 '((substitute* '("sysdeps/mach/Makefile"
3299 "sysdeps/mach/hurd/Makefile")
3300 (("LDLIBS-pthread.so =.*")
3301 (string-append "LDLIBS-pthread.so = "
3302 (assoc-ref %build-inputs "kernel-headers")
3303 "/lib/libihash.a\n"))))
3306 ;; 'rpcgen' needs native libc headers to be built.
3307 (substitute* "sunrpc/Makefile"
3308 (("sunrpc-CPPFLAGS =.*" all)
3309 (string-append "CPATH = $(NATIVE_CPATH)\n"
3313 (propagated-inputs `(("kernel-headers" ,(kernel-headers-boot0))))
3315 `(("bison" ,bison-boot0)
3316 ("texinfo" ,texinfo-boot0)
3317 ("perl" ,perl-boot0)
3318 ("python" ,python-boot0)
3319 ,@(if (target-powerpc?)
3320 `(("powerpc64le-patch" ,@(search-patches
3321 "glibc-ldd-powerpc.patch")))
3324 `( ;; The boot inputs. That includes the bootstrap libc. We don't want
3325 ;; it in $CPATH, hence the 'pre-configure' phase above.
3328 ;; A native MiG is needed to build Glibc on Hurd.
3329 ,@(if (hurd-system?)
3330 `(("mig" ,mig-boot0))
3333 ;; A native GCC is needed to build `cross-rpcgen'.
3334 ("native-gcc" ,@(assoc-ref (%boot0-inputs) "gcc"))
3336 ;; Here, we use the bootstrap Bash, which is not satisfactory
3337 ;; because we don't want to depend on bootstrap tools.
3338 ("static-bash" ,@(assoc-ref (%boot0-inputs) "bash"))))))
3340 (define (cross-gcc-wrapper gcc binutils glibc bash)
3341 "Return a wrapper for the pseudo-cross toolchain GCC/BINUTILS/GLIBC
3342 that makes it available under the native tool names."
3343 (package (inherit gcc)
3344 (name (string-append (package-name gcc) "-wrapped"))
3346 (build-system trivial-build-system)
3349 `(#:guile ,%bootstrap-guile
3350 #:modules ((guix build utils))
3352 (use-modules (guix build utils))
3354 (let* ((binutils (assoc-ref %build-inputs "binutils"))
3355 (gcc (assoc-ref %build-inputs "gcc"))
3356 (libc (assoc-ref %build-inputs "libc"))
3357 (bash (assoc-ref %build-inputs "bash"))
3358 (out (assoc-ref %outputs "out"))
3359 (bindir (string-append out "/bin"))
3360 (triplet ,(boot-triplet)))
3361 (define (wrap-program program)
3362 ;; GCC-BOOT0 is a libc-less cross-compiler, so it
3363 ;; needs to be told where to find the crt files and
3364 ;; the dynamic linker.
3365 (call-with-output-file program
3367 (format p "#!~a/bin/bash
3368 exec ~a/bin/~a-~a -B~a/lib -Wl,-dynamic-linker -Wl,~a/~a \"$@\"~%"
3372 ,(glibc-dynamic-linker))))
3374 (chmod program #o555))
3377 (with-directory-excursion bindir
3378 (for-each (lambda (tool)
3379 (symlink (string-append binutils "/bin/"
3383 (for-each wrap-program '("gcc" "g++")))
3387 `(("binutils" ,binutils)
3393 (define/system-dependent gcc-boot0-intermediate-wrapped
3394 ;; Make the cross-tools GCC-BOOT0 and BINUTILS-BOOT0 available under the
3396 (cross-gcc-wrapper gcc-boot0 binutils-boot0
3397 glibc-final-with-bootstrap-bash
3398 (car (assoc-ref (%boot1-inputs) "bash"))))
3400 (define static-bash-for-glibc
3401 ;; A statically-linked Bash to be used by GLIBC-FINAL in system(3) & co.
3403 (inherit static-bash)
3404 (source (bootstrap-origin (package-source static-bash)))
3405 (inputs `(("gcc" ,gcc-boot0-intermediate-wrapped)
3406 ("libc" ,glibc-final-with-bootstrap-bash)
3407 ("libc:static" ,glibc-final-with-bootstrap-bash "static")
3408 ,@(fold alist-delete (%boot1-inputs)
3411 `(#:implicit-inputs? #f
3412 #:guile ,%bootstrap-guile
3414 ,@(substitute-keyword-arguments (package-arguments static-bash)
3415 ((#:configure-flags flags '())
3416 ;; Add a '-L' flag so that the pseudo-cross-ld of
3417 ;; BINUTILS-BOOT0 can find libc.a.
3419 (list (string-append "LDFLAGS=-static -L"
3420 (assoc-ref %build-inputs
3424 (define gettext-boot0
3425 ;; A minimal gettext used during bootstrap.
3427 (inherit gettext-minimal)
3428 (name "gettext-boot0")
3429 ;; Newer versions of GNU gettext depends on libxml2 and ncurses. To
3430 ;; simplify the dependency chain, we stick to this version here.
3431 (version "0.19.8.1")
3434 (uri (string-append "mirror://gnu/gettext/gettext-"
3438 "0hsw28f9q9xaggjlsdp2qmbp2rbd1mp0njzan2ld9kiqwkq2m57z"))))
3439 (inputs (%boot1-inputs)) ;zero dependencies
3441 `(#:implicit-inputs? #f
3442 #:guile ,%bootstrap-guile
3444 #:phases (modify-phases %standard-phases
3445 ;; Build only the tools.
3446 (add-after 'unpack 'chdir
3448 (chdir "gettext-tools")
3451 ;; Some test programs require pthreads, which we don't have.
3452 (add-before 'configure 'no-test-programs
3454 (substitute* "tests/Makefile.in"
3460 ;; The final glibc, which embeds the statically-linked Bash built above.
3461 ;; Use 'package/inherit' so we get the 'replacement' of 'glibc', if any.
3465 (source (bootstrap-origin (package-source glibc)))
3466 (inputs `(("static-bash" ,static-bash-for-glibc)
3469 (package-inputs glibc-final-with-bootstrap-bash))))
3471 ;; This time we need 'msgfmt' to install all the libc.mo files.
3472 (native-inputs `(,@(package-native-inputs glibc-final-with-bootstrap-bash)
3473 ,@(if (target-powerpc?)
3474 `(("powerpc64le-patch" ,@(search-patches
3475 "glibc-ldd-powerpc.patch")))
3477 ("gettext" ,gettext-boot0)))
3480 (package-propagated-inputs glibc-final-with-bootstrap-bash))
3482 ;; The final libc only refers to itself, but the 'debug' output contains
3483 ;; references to GCC-BOOT0 and to the Linux headers. XXX: Would be great
3484 ;; if 'allowed-references' were per-output.
3486 `(#:allowed-references
3488 ,(kernel-headers-boot0)
3489 ,static-bash-for-glibc
3490 ,@(if (hurd-system?)
3491 `(,gnumach-headers-boot0
3492 ,hurd-headers-boot0)
3494 ,@(package-outputs glibc-final-with-bootstrap-bash))
3495 ,@(package-arguments glibc-final-with-bootstrap-bash)))))
3497 (define/system-dependent gcc-boot0-wrapped
3498 ;; Make the cross-tools GCC-BOOT0 and BINUTILS-BOOT0 available under the
3500 (cross-gcc-wrapper gcc-boot0 binutils-boot0 glibc-final
3501 (car (assoc-ref (%boot1-inputs) "bash"))))
3503 (define (%boot2-inputs)
3504 ;; 3rd stage inputs.
3505 `(("libc" ,glibc-final)
3506 ("libc:static" ,glibc-final "static")
3507 ("gcc" ,gcc-boot0-wrapped)
3508 ,@(fold alist-delete (%boot1-inputs) '("libc" "gcc" "linux-libre-headers"))))
3510 (define binutils-final
3513 (source (bootstrap-origin (package-source binutils)))
3515 `(#:guile ,%bootstrap-guile
3516 #:implicit-inputs? #f
3517 #:allowed-references
3518 ,@(match (%current-system)
3519 ((? target-powerpc?)
3520 `(("out" ,glibc-final ,static-bash-for-glibc)))
3522 `(("out" ,glibc-final))))
3523 ,@(package-arguments binutils)))
3525 (match (%current-system)
3526 ((? target-powerpc?)
3527 `(("bash" ,static-bash-for-glibc)
3529 (_ (%boot2-inputs))))))
3532 ;; Intermediate libstdc++ that will allow us to build the final GCC
3533 ;; (remember that GCC-BOOT0 cannot build libstdc++.)
3534 (let ((lib (make-libstdc++ gcc)))
3537 (source (bootstrap-origin (package-source lib)))
3539 `(#:guile ,%bootstrap-guile
3540 #:implicit-inputs? #f
3541 #:allowed-references ("out")
3543 ;; XXX: libstdc++.so NEEDs ld.so for some reason.
3544 #:validate-runpath? #f
3546 ;; All of the package arguments from 'make-libstdc++
3547 ;; except for the configure-flags.
3548 ,@(package-arguments lib)
3549 #:configure-flags `("--disable-shared"
3550 "--disable-libstdcxx-dual-abi"
3551 "--disable-libstdcxx-threads"
3552 "--disable-libstdcxx-pch"
3553 ,(string-append "--with-gxx-include-dir="
3554 (assoc-ref %outputs "out")
3557 (inputs (%boot2-inputs))
3558 (synopsis "GNU C++ standard library (intermediate)"))))
3561 ;; Zlib used by GCC-FINAL.
3565 `(#:guile ,%bootstrap-guile
3566 #:implicit-inputs? #f
3567 #:allowed-references ("out" ,glibc-final)
3568 ,@(package-arguments zlib)))
3569 (inputs (%boot2-inputs))))
3571 (define/system-dependent ld-wrapper-boot3
3572 ;; A linker wrapper that uses the bootstrap Guile.
3573 (make-ld-wrapper "ld-wrapper-boot3"
3574 #:binutils binutils-final
3575 #:guile %bootstrap-guile
3576 #:bash (car (assoc-ref (%boot2-inputs) "bash"))
3577 #:guile-for-build %bootstrap-guile))
3581 (package (inherit gcc-boot0)
3584 ;; XXX: Currently #:allowed-references applies to all the outputs but the
3585 ;; "debug" output contains disallowed references, notably
3586 ;; linux-libre-headers. Disable the debugging output to work around that.
3587 (outputs (delete "debug" (package-outputs gcc-boot0)))
3590 `(#:guile ,%bootstrap-guile
3591 #:implicit-inputs? #f
3593 #:allowed-references ("out" "lib" ,zlib-final
3594 ,glibc-final ,static-bash-for-glibc)
3596 ;; Things like libasan.so and libstdc++.so NEED ld.so for some
3597 ;; reason, but it is not in their RUNPATH. This is a false
3598 ;; positive, so turn it off.
3599 #:validate-runpath? #f
3601 ,@(substitute-keyword-arguments (package-arguments gcc)
3602 ((#:make-flags flags)
3603 ;; Since $LIBRARY_PATH is not honored, add the relevant flags.
3604 `(let ((zlib (assoc-ref %build-inputs "zlib")))
3606 (if (string-prefix? "LDFLAGS=" flag)
3607 (string-append flag " -L"
3608 (assoc-ref %build-inputs "libstdc++")
3609 "/lib -L" zlib "/lib -Wl,-rpath="
3613 ;; Build again GMP & co. within GCC's build process, because it's hard
3614 ;; to do outside (because GCC-BOOT0 is a cross-compiler, and thus
3615 ;; doesn't honor $LIBRARY_PATH, which breaks `gnu-build-system'.)
3617 `(modify-phases ,phases
3618 (add-after 'unpack 'unpack-gmp&co
3619 (lambda* (#:key inputs #:allow-other-keys)
3620 (let ((gmp (assoc-ref %build-inputs "gmp-source"))
3621 (mpfr (assoc-ref %build-inputs "mpfr-source"))
3622 (mpc (assoc-ref %build-inputs "mpc-source")))
3624 ;; To reduce the set of pre-built bootstrap inputs, build
3625 ;; GMP & co. from GCC.
3626 (for-each (lambda (source)
3627 (invoke "tar" "xvf" source))
3628 (list gmp mpfr mpc))
3630 ;; Create symlinks like `gmp' -> `gmp-x.y.z'.
3631 ,@(map (lambda (lib)
3632 ;; Drop trailing letters, as gmp-6.0.0a unpacks
3634 `(symlink ,(string-trim-right
3635 (package-full-name lib "-")
3637 ,(package-name lib)))
3638 (list gmp-6.0 mpfr mpc))
3641 ;; This time we want Texinfo, so we get the manual. Add
3642 ;; STATIC-BASH-FOR-GLIBC so that it's used in the final shebangs of
3643 ;; scripts such as 'mkheaders' and 'fixinc.sh' (XXX: who cares about these
3645 (native-inputs `(("texinfo" ,texinfo-boot0)
3646 ("perl" ,perl-boot0) ;for manpages
3647 ("static-bash" ,static-bash-for-glibc)
3648 ,@(package-native-inputs gcc-boot0)))
3650 (inputs `(("gmp-source" ,(bootstrap-origin (package-source gmp-6.0)))
3651 ("mpfr-source" ,(package-source mpfr))
3652 ("mpc-source" ,(package-source mpc))
3653 ("ld-wrapper" ,ld-wrapper-boot3)
3654 ("binutils" ,binutils-final)
3655 ("libstdc++" ,libstdc++)
3656 ("zlib" ,zlib-final)
3657 ,@(%boot2-inputs)))))
3659 (define (%boot3-inputs)
3660 ;; 4th stage inputs.
3661 `(("gcc" ,gcc-final)
3662 ("ld-wrapper" ,ld-wrapper-boot3)
3663 ,@(alist-delete "gcc" (%boot2-inputs))))
3666 ;; Link with `-static-libgcc' to make sure we don't retain a reference
3667 ;; to the bootstrap GCC. Use "bash-minimal" to avoid an extra dependency
3668 ;; on Readline and ncurses.
3669 (let ((bash (static-libgcc-package bash-minimal)))
3672 (source (bootstrap-origin (package-source bash)))
3673 (inputs (%boot3-inputs))
3675 `(#:implicit-inputs? #f
3676 #:guile ,%bootstrap-guile
3678 #:disallowed-references ,(assoc-ref (%boot3-inputs) "coreutils&co")
3680 ,@(package-arguments bash))))))
3682 (define (%boot4-inputs)
3683 ;; Now use the final Bash.
3684 `(("bash" ,bash-final)
3685 ,@(alist-delete "bash" (%boot3-inputs))))
3688 (package-with-explicit-inputs %boot4-inputs %bootstrap-guile))
3690 (define-public guile-final
3691 ;; This package must be public because other modules refer to it. However,
3692 ;; mark it as hidden so that 'fold-packages' ignores it.
3693 (with-boot4 (hidden-package
3694 (package-with-bootstrap-guile guile-3.0/fixed))))
3696 (define glibc-utf8-locales-final
3697 ;; Now that we have GUILE-FINAL, build the UTF-8 locales. They are needed
3698 ;; by the build processes afterwards so their 'scm_to_locale_string' works
3699 ;; with the full range of Unicode codepoints (remember
3700 ;; 'scm_to_locale_string' is called every time a string is passed to a C
3703 (inherit glibc-utf8-locales)
3705 `(("glibc" ,glibc-final)
3706 ("gzip" ,(with-boot4 gzip))))))
3708 (define-public ld-wrapper
3709 ;; The final 'ld' wrapper, which uses the final Guile and Binutils.
3710 (make-ld-wrapper "ld-wrapper"
3711 #:binutils binutils-final
3715 (define (%boot5-inputs)
3716 ;; Now with UTF-8 locales. Remember that the bootstrap binaries were built
3717 ;; with an older libc, which cannot load the new locale format. See
3718 ;; <https://lists.gnu.org/archive/html/guix-devel/2015-08/msg00737.html>.
3719 `(("locales" ,glibc-utf8-locales-final)
3723 (package-with-explicit-inputs %boot5-inputs))
3725 (define gnu-make-final
3726 ;; The final GNU Make, which uses the final Guile.
3727 (let ((pkg-config (package
3728 (inherit %pkg-config) ;the native pkg-config
3729 (inputs `(("guile" ,guile-final)
3732 `(#:implicit-inputs? #f
3733 ,@(package-arguments pkg-config))))))
3735 (inherit (package-with-bootstrap-guile gnu-make))
3736 (inputs `(("guile" ,guile-final)
3738 (native-inputs `(("pkg-config" ,pkg-config)))
3740 `(#:implicit-inputs? #f
3741 ,@(package-arguments gnu-make))))))
3744 (define coreutils-final
3745 ;; The final Coreutils. Treat them specially because some packages, such as
3746 ;; Findutils, keep a reference to the Coreutils they were built with.
3747 (with-boot5 (package-with-bootstrap-guile
3749 (inherit coreutils-minimal)
3750 (name "coreutils")))
3751 ;; Use the final Guile, linked against the
3752 ;; final libc with working iconv, so that
3753 ;; 'substitute*' works well when touching
3754 ;; test files in Gettext.
3758 ;; The final grep. Gzip holds a reference to it (via zgrep), so it must be
3759 ;; built before gzip.
3760 (let ((grep (with-boot5 (package-with-bootstrap-guile grep))))
3761 (package/inherit grep
3762 (inputs (alist-delete "pcre" (package-inputs grep)))
3763 (native-inputs `(("perl" ,perl-boot0))))))
3765 (define (%boot6-inputs)
3766 ;; Now use the final Coreutils.
3767 `(("coreutils" ,coreutils-final)
3768 ("grep" ,grep-final)
3772 (package-with-explicit-inputs %boot6-inputs))
3776 (let ((sed (with-boot6 (package-with-bootstrap-guile sed))))
3777 (package/inherit sed (native-inputs `(("perl" ,perl-boot0))))))
3779 (define-public %final-inputs
3780 ;; Final derivations used as implicit inputs by 'gnu-build-system'. We
3781 ;; still use 'package-with-bootstrap-guile' so that the bootstrap tools are
3782 ;; used for origins that have patches, thereby avoiding circular
3784 (let ((finalize (compose with-boot6
3785 package-with-bootstrap-guile)))
3786 `(,@(map (match-lambda
3788 (list name (finalize package))))
3794 ("diffutils" ,diffutils)
3796 ("findutils" ,findutils)
3799 ("grep" ,grep-final)
3800 ("coreutils" ,coreutils-final)
3801 ("make" ,gnu-make-final)
3802 ("bash" ,bash-final)
3803 ("ld-wrapper" ,ld-wrapper)
3804 ("binutils" ,binutils-final)
3806 ("libc" ,glibc-final)
3807 ("libc:static" ,glibc-final "static")
3808 ("locales" ,glibc-utf8-locales-final))))
3810 (define-public canonical-package
3811 (let ((name->package (fold (lambda (input result)
3813 ((_ package . outputs)
3814 (vhash-cons (package-full-name package)
3817 `(("guile" ,guile-final)
3820 "Return the 'canonical' variant of PACKAGE---i.e., if PACKAGE is one of
3821 the implicit inputs of 'gnu-build-system', return that one, otherwise return
3824 The goal is to avoid duplication in cases like GUILE-FINAL vs. GUILE-2.2,
3825 COREUTILS-FINAL vs. COREUTILS, etc."
3826 ;; XXX: This doesn't handle dependencies of the final inputs, such as
3827 ;; libunistring, GMP, etc.
3828 (match (vhash-assoc (package-full-name package) name->package)
3830 ;; In general we want CANON, except if we're cross-compiling: CANON
3831 ;; uses explicit inputs, so it is "anchored" in the bootstrapped
3832 ;; process, with dependencies on things that cannot be
3834 (if (%current-target-system)
3844 ;; Using the following procedure, a gcc toolchain targeting glibc-2.27 can be
3845 ;; instantiated like this:
3847 ;; (define-public gcc-glibc-2.27-toolchain
3848 ;; (make-gcc-toolchain gcc glibc-2.27))
3850 (define* (make-gcc-toolchain gcc
3853 "Return a complete toolchain for GCC. If LIBC is specified, target that libc."
3854 (let ((gcc (if libc (make-gcc-libc gcc libc) gcc))
3855 (libc (if libc libc glibc-final)))
3857 (name (string-append (package-name gcc) "-toolchain"))
3858 (version (package-version gcc))
3860 (build-system trivial-build-system)
3862 '(#:modules ((guix build union))
3864 (use-modules (ice-9 match)
3869 (let ((out (assoc-ref %outputs "out")))
3871 (filter-map (match-lambda
3872 (("libc-debug" . _) #f)
3873 (("libc-static" . _) #f)
3874 ((_ . directory) directory))
3877 (union-build (assoc-ref %outputs "debug")
3878 (list (assoc-ref %build-inputs
3880 (union-build (assoc-ref %outputs "static")
3881 (list (assoc-ref %build-inputs
3885 (native-search-paths
3886 (append (package-native-search-paths gcc)
3887 (package-native-search-paths libc))) ;GUIX_LOCPATH
3889 (append (package-search-paths gcc)
3890 (package-search-paths libc)))
3892 (license (package-license gcc))
3893 (synopsis "Complete GCC tool chain for C/C++ development")
3895 "This package provides a complete GCC tool chain for C/C++ development to
3896 be installed in user profiles. This includes GCC, as well as libc (headers and
3897 binaries, plus debugging symbols in the @code{debug} output), and Binutils. GCC
3898 is the GNU Compiler Collection.")
3899 (home-page "https://gcc.gnu.org/")
3900 (outputs '("out" "debug" "static"))
3902 ;; The main raison d'être of this "meta-package" is (1) to conveniently
3903 ;; install everything that we need, and (2) to make sure ld-wrapper comes
3904 ;; before Binutils' ld in the user's profile.
3905 (inputs `(("gcc" ,gcc)
3906 ("ld-wrapper" ,(car (assoc-ref %final-inputs "ld-wrapper")))
3907 ("binutils" ,binutils-final)
3909 ("libc-debug" ,libc "debug")
3910 ("libc-static" ,libc "static"))))))
3912 (define-public gcc-toolchain
3913 (make-gcc-toolchain gcc-final))
3915 (define-public gcc-toolchain-4.8
3916 (make-gcc-toolchain gcc-4.8))
3918 (define-public gcc-toolchain-4.9
3919 (make-gcc-toolchain gcc-4.9))
3921 (define-public gcc-toolchain-5
3922 (make-gcc-toolchain gcc-5))
3924 (define-public gcc-toolchain-6
3925 (make-gcc-toolchain gcc-6))
3927 (define-public gcc-toolchain-7
3930 (define-public gcc-toolchain-8
3931 (make-gcc-toolchain gcc-8))
3933 (define-public gcc-toolchain-9
3934 (make-gcc-toolchain gcc-9))
3936 (define-public gcc-toolchain-10
3937 (make-gcc-toolchain gcc-10))
3939 (define-public gcc-toolchain-aka-gcc
3940 ;; It's natural for users to try "guix install gcc". This package
3941 ;; automatically "redirects" them to 'gcc-toolchain'.
3942 (deprecated-package "gcc" gcc-toolchain-10))
3945 (define-public gdc-toolchain-10
3946 (package (inherit (make-gcc-toolchain gdc-10))
3947 (synopsis "Complete GCC tool chain for D lang development")
3948 (description "This package provides a complete GCC tool chain for
3949 D lang development to be installed in user profiles. This includes
3950 gdc, as well as libc (headers and binaries, plus debugging symbols
3951 in the @code{debug} output), and binutils.")))
3953 ;; Provide the Fortran toolchain package only for the version of gfortran that
3954 ;; is used by Guix internally to build Fortran libraries, because combining
3955 ;; code compiled with different versions can cause problems.
3957 (define-public gfortran-toolchain
3958 (package (inherit (make-gcc-toolchain gfortran))
3959 (synopsis "Complete GCC tool chain for Fortran development")
3960 (description "This package provides a complete GCC tool chain for
3961 Fortran development to be installed in user profiles. This includes
3962 gfortran, as well as libc (headers and binaries, plus debugging symbols
3963 in the @code{debug} output), and binutils.")))
3966 ;;; commencement.scm ends here