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 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
9 ;;; Copyright © 2019, 2020 Marius Bakke <mbakke@fastmail.com>
11 ;;; This file is part of GNU Guix.
13 ;;; GNU Guix is free software; you can redistribute it and/or modify it
14 ;;; under the terms of the GNU General Public License as published by
15 ;;; the Free Software Foundation; either version 3 of the License, or (at
16 ;;; your option) any later version.
18 ;;; GNU Guix is distributed in the hope that it will be useful, but
19 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ;;; GNU General Public License for more details.
23 ;;; You should have received a copy of the GNU General Public License
24 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
26 (define-module (gnu packages commencement)
27 #:use-module (gnu packages)
28 #:use-module (gnu packages bootstrap)
29 #:use-module (gnu packages base)
30 #:use-module (gnu packages bash)
31 #:use-module (gnu packages c)
32 #:use-module (gnu packages gcc)
33 #:use-module (gnu packages m4)
34 #:use-module (gnu packages file)
35 #:use-module (gnu packages gawk)
36 #:use-module (gnu packages bison)
37 #:use-module (gnu packages flex)
38 #:use-module (gnu packages guile)
39 #:use-module (gnu packages gettext)
40 #:use-module (gnu packages multiprecision)
41 #:use-module (gnu packages compression)
42 #:use-module (gnu packages mes)
43 #:use-module (gnu packages perl)
44 #:use-module (gnu packages python)
45 #:use-module (gnu packages linux)
46 #:use-module (gnu packages hurd)
47 #:use-module (gnu packages shells)
48 #:use-module (gnu packages texinfo)
49 #:use-module (gnu packages pkg-config)
50 #:use-module (gnu packages rsync)
51 #:use-module (gnu packages xml)
52 #:use-module (guix packages)
53 #:use-module (guix download)
54 #:use-module (guix build-system gnu)
55 #:use-module (guix build-system guile)
56 #:use-module (guix build-system trivial)
57 #:use-module (guix memoization)
58 #:use-module (guix utils)
59 #:use-module (srfi srfi-1)
60 #:use-module (ice-9 vlist)
61 #:use-module (ice-9 match)
62 #:export (make-gcc-toolchain))
66 ;;; This is the commencement, this is where things start. Before the
67 ;;; commencement, of course, there's the 'bootstrap' module, which provides us
68 ;;; with the initial binaries. This module uses those bootstrap binaries to
69 ;;; actually build up the whole tool chain that make up the implicit inputs of
70 ;;; 'gnu-build-system'.
72 ;;; To avoid circular dependencies, this module should not be imported
73 ;;; directly from anywhere.
75 ;;; Below, we frequently use "inherit" to create modified packages. The
76 ;;; reason why we use "inherit" instead of "package/inherit" is because we do
77 ;;; not want these commencement packages to inherit grafts. By definition,
78 ;;; these packages are not depended on at run time by any of the packages we
79 ;;; use. Thus it does not make sense to inherit grafts. Furthermore, those
80 ;;; grafts would often lead to extra overhead for users who would end up
81 ;;; downloading those "-boot0" packages just to build package replacements
82 ;;; that are in fact not going to be used.
86 (define %bootstrap-guile+guild
87 ;; This package combines %bootstrap-guile with guild, which is not included
88 ;; in %bootstrap-guile. Guild is needed to build gash-boot and
89 ;; gash-core-utils-boot because it is dependency of the Guile build system.
91 (name "guile-bootstrap+guild")
93 (source (bootstrap-origin (package-source guile-2.0)))
94 (native-inputs `(("bash" ,(bootstrap-executable "bash" (%current-system)))
95 ("tar" ,(bootstrap-executable "tar" (%current-system)))
96 ("xz" ,(bootstrap-executable "xz" (%current-system)))
97 ("guile" ,%bootstrap-guile)))
98 (build-system trivial-build-system)
100 `(#:guile ,%bootstrap-guile
101 #:modules ((guix build utils))
103 (use-modules (guix build utils))
104 (let ((guile-source (assoc-ref %build-inputs "source"))
105 (bin (string-append (getcwd) "/bin"))
106 (tar (assoc-ref %build-inputs "tar"))
107 (xz (assoc-ref %build-inputs "xz")))
110 (with-directory-excursion bin
111 (copy-file tar "tar")
114 (let* ((out (assoc-ref %outputs "out"))
115 (out-bin (string-append out "/bin"))
116 (guile (assoc-ref %build-inputs "guile"))
117 (bash (assoc-ref %build-inputs "bash")))
119 (with-directory-excursion out-bin
120 (symlink (string-append guile "/bin/guile")
122 (invoke "tar" "--strip-components=2"
124 (string-append "guile-"
125 ,(package-version guile-2.0)
127 (copy-file "guild.in" "guild")
129 (("#!/bin/sh") (string-append "#! " bash))
130 (("@installed_guile@") (string-append out-bin "/guile")))
131 (chmod "guild" #o555)))))))
132 (synopsis "Bootstrap Guile plus Guild")
133 (description "Bootstrap Guile with added Guild")
135 (license (package-license guile-2.0))
137 (list (search-path-specification
138 (variable "GUILE_LOAD_PATH")
139 (files '("share/guile/site/2.0")))
140 (search-path-specification
141 (variable "GUILE_LOAD_COMPILED_PATH")
142 (files '("lib/guile/2.0/site-ccache")))))))
149 (source (bootstrap-origin
150 (origin (inherit (package-source gash))
151 (modules '((guix build utils)
155 ;; Remove Guix'y files that we cannot compile.
156 (delete-file "guix.scm")
157 (delete-file-recursively "tests")
159 (build-system guile-build-system)
160 (native-inputs `(("bash" ,(bootstrap-executable "bash" (%current-system)))
161 ("tar" ,(bootstrap-executable "tar" (%current-system)))
162 ("xz" ,(bootstrap-executable "xz" (%current-system)))
163 ("guile-source" ,(bootstrap-origin
164 (package-source guile-2.0)))))
165 (inputs `(("guile" ,%bootstrap-guile+guild)))
167 `(#:implicit-inputs? #f
168 #:guile ,%bootstrap-guile+guild
170 (modify-phases %standard-phases
171 (add-after 'unpack 'unpack-guile-source
173 (let ((guile-source (assoc-ref %build-inputs "guile-source"))
174 (bin (string-append (getcwd) "/zee-bin")))
176 (with-directory-excursion bin
177 (invoke "tar" "--strip-components=2"
180 (string-append "guile-"
181 ,(package-version guile-2.0)
183 (copy-file "guild.in" "guild")
184 (chmod "guild" #o555))
186 (add-before 'unpack 'set-path
188 (let ((bash (assoc-ref %build-inputs "bash"))
189 (tar (assoc-ref %build-inputs "tar"))
190 (xz (assoc-ref %build-inputs "xz"))
191 (bin (string-append (getcwd) "/zee-bin")))
193 (setenv "PATH" (string-append bin ":" (getenv "PATH")))
194 (copy-file bash (string-append bin "/bash"))
195 (copy-file bash (string-append bin "/sh"))
196 (copy-file tar (string-append bin "/tar"))
197 (copy-file xz (string-append bin "/xz"))
199 (add-after 'build 'build-scripts
201 (let* ((guile (assoc-ref %build-inputs "guile"))
202 (guile (string-append guile "/bin/guile"))
203 (out (assoc-ref %outputs "out"))
205 (moddir (string-append out "/share/guile/site/" effective "/"))
206 (godir (string-append out "/lib/guile/" effective "/site-ccache/")))
207 (copy-file "scripts/gash.in" "scripts/gash")
208 (chmod "scripts/gash" #o555)
209 (substitute* "scripts/gash"
211 (("@MODDIR@") moddir)
214 (add-after 'install 'install-scripts
216 (let* ((out (assoc-ref %outputs "out"))
217 (bin (string-append out "/bin")))
218 (install-file "scripts/gash" bin)
219 (copy-file "scripts/gash" "scripts/sh")
220 (install-file "scripts/sh" bin)
221 (copy-file "scripts/gash" "scripts/bash")
222 (install-file "scripts/bash" bin)
225 (define gash-core-utils-boot
227 (inherit gash-core-utils)
228 (name "gash-core-utils-boot")
229 (version "0.0.213-3f6eb")
230 (source (bootstrap-origin
233 (uri (string-append "http://lilypond.org/janneke/"
234 "/gash-core-utils-" version ".tar.gz"))
235 (modules '((guix build utils)))
238 ;; The Guile build system compiles *.scm; avoid
239 ;; compiling included lalr.
240 (delete-file "guix.scm")
241 (delete-file-recursively "tests")
242 (substitute* "system/base/lalr.scm"
243 (("system/base/lalr.upstream.scm") "lalr.upstream.scm"))
247 "0601c9hqbjrjjsllr2m3zmkglkd53d97in7a5c22ikd8islddp76")))))
248 (build-system guile-build-system)
249 (native-inputs `(("bash" ,(bootstrap-executable "bash" (%current-system)))
250 ("tar" ,(bootstrap-executable "tar" (%current-system)))
251 ("xz" ,(bootstrap-executable "xz" (%current-system)))
252 ("guile-source" ,(bootstrap-origin
253 (package-source guile-2.0)))
254 ;; We need the 2.0.9 lalr for %bootstrap-guile
258 (uri (string-append "http://git.savannah.gnu.org/cgit/guile.git/plain/module/system/base/lalr.upstream.scm?h=v2.0.9"))
259 (file-name "lalr.upstream.scm")
262 "0h7gyjj8nr2qrgzwma146s7l22scp8bbcqzdy9wqf12bgyhbw7d5"))))))
263 (inputs `(("guile" ,%bootstrap-guile+guild)
264 ("gash" ,gash-boot)))
266 `(#:implicit-inputs? #f
267 #:guile ,%bootstrap-guile+guild
268 #:not-compiled-file-regexp "upstream\\.scm$"
270 (modify-phases %standard-phases
271 (add-after 'unpack 'unpack-guile-source
273 (let ((guile-source (assoc-ref %build-inputs "guile-source"))
274 (bin (string-append (getcwd) "/zee-bin")))
276 (with-directory-excursion bin
277 (invoke "tar" "--strip-components=2"
280 (string-append "guile-"
281 ,(package-version guile-2.0)
283 (copy-file "guild.in" "guild")
284 (chmod "guild" #o555))
286 (add-before 'unpack 'set-path
288 (let ((bash (assoc-ref %build-inputs "bash"))
289 (tar (assoc-ref %build-inputs "tar"))
290 (xz (assoc-ref %build-inputs "xz"))
291 (bin (string-append (getcwd) "/zee-bin")))
293 (setenv "PATH" (string-append bin ":" (getenv "PATH")))
294 (copy-file bash (string-append bin "/bash"))
295 (copy-file bash (string-append bin "/sh"))
296 (copy-file tar (string-append bin "/tar"))
297 (copy-file xz (string-append bin "/xz"))
299 (add-before 'build 'set-env
301 (let ((gash (assoc-ref %build-inputs "gash")))
303 (setenv "LC_ALL" "C")
304 (setenv "GUILE_LOAD_PATH"
305 (string-append (getcwd)
306 ":" (getcwd) "/system/base"
307 ":" gash "/share/guile/2.0"))
308 (setenv "GUILE_LOAD_COMPILED_PATH"
309 (string-append ".:" gash "/lib/guile/2.0/site-ccache/"))
310 (format (current-error-port)
311 "GUILE_LOAD_PATH=~s\n" (getenv "GUILE_LOAD_PATH"))
313 (add-before 'build 'replace-lalr.upstream
315 (let ((lalr.upstream (assoc-ref %build-inputs "lalr.upstream")))
316 (copy-file lalr.upstream "system/base/lalr.upstream.scm")
318 (add-after 'build 'build-scripts
320 (let* ((guile (assoc-ref %build-inputs "guile"))
321 (guile (string-append guile "/bin/guile"))
322 (gash (string-append guile "gash"))
323 (out (assoc-ref %outputs "out"))
325 (guilemoduledir (string-append gash "/share/guile/site/" effective "/"))
326 (guileobjectdir (string-append gash "/lib/guile/" effective "/site-ccache/"))
327 (gashmoduledir (string-append out "/share/guile/site/" effective "/"))
328 (gashobjectdir (string-append out "/lib/guile/" effective "/site-ccache/"))
329 (bin (string-append out "/bin")))
331 (copy-file "command.in" name)
335 (("@guilemoduledir@") guilemoduledir)
336 (("@guileobjectdir") guileobjectdir)
337 (("@gashmoduledir@") gashmoduledir)
338 (("@gashobjectdir") gashobjectdir)
339 (("@command@") name))
340 (install-file name bin))
342 (with-directory-excursion "bin"
343 (for-each wrap '("awk"
379 (with-directory-excursion bin
380 (copy-file "grep" "fgrep")
381 (copy-file "grep" "egrep")
382 (copy-file "test" "["))
385 (define (%boot-gash-inputs)
386 `(("bash" , gash-boot) ; gnu-build-system wants "bash"
387 ("coreutils" , gash-core-utils-boot)
388 ("guile" ,%bootstrap-guile)
389 ("guile+guild" ,%bootstrap-guile+guild)))
391 (define %bootstrap-mes-rewired
394 (name "bootstrap-mes-rewired")
397 (native-inputs `(("mes" ,(@ (gnu packages bootstrap) %bootstrap-mes))
398 ("gash" ,gash-boot)))
400 (propagated-inputs '())
402 (build-system trivial-build-system)
404 `(#:guile ,%bootstrap-guile
405 #:modules ((guix build utils)
408 (use-modules (guix build utils)
410 (let* ((mes (assoc-ref %build-inputs "mes"))
411 (gash (assoc-ref %build-inputs "gash"))
412 (mes-bin (string-append mes "/bin"))
413 (guile (string-append mes-bin "/mes"))
414 (mes-module (string-append mes "/share/mes/module"))
415 (out (assoc-ref %outputs "out"))
416 (bin (string-append out "/bin"))
417 (mescc (string-append bin "/mescc"))
418 (module (string-append out "/share/mes/module")))
419 (define (rewire file)
422 (("/gnu/store[^ ]+mes-minimal-[^/)}\"]*") out)
423 (("/gnu/store[^ ]+guile-[^/]*/bin/guile") guile)
424 (("/gnu/store[^ ]+bash-[^/)}\"]*") gash)))
427 (for-each (lambda (file) (install-file file bin))
428 (find-files mes-bin))
430 (copy-recursively (string-append mes-module "/mes")
431 (string-append module "/mes"))
432 (copy-recursively (string-append mes-module "/srfi")
433 (string-append module "/srfi"))
435 ;; Cannot easily rewire "mes" because it
436 ;; contains NUL characters; would require
437 ;; remove-store-references alike trick
438 (filter (negate (cut string-suffix? "/mes" <>))
440 (rewire (string-append module "/mes/boot-0.scm"))
443 (with-output-to-file mescc
445 (display (string-append
452 MES_PREFIX=${MES_REWIRED_PREFIX-" out "/share/mes}
454 export MES MES_PREFIX
456 MES_ARENA=${MES_REWIRED_ARENA-10000000}
457 MES_MAX_ARENA=${MES_REWIRED_ARENA-10000000}
458 MES_STACK=${MES_REWIRED_STACK-1000000}
459 export MES_ARENA MES_MAX_ARENA MES_STACK
461 $MES -e '(mescc)' module/mescc.scm -- \"$@\"
465 (with-directory-excursion module
466 (chmod "mes/base.mes" #o644)
467 (copy-file "mes/base.mes" "mes/base.mes.orig")
468 (let ((base.mes (open-file "mes/base.mes" "a")))
470 ;; A fixed map, from Mes 0.21, required to bootstrap Mes 0.21
471 (define (map f h . t)
473 (and (pair? t) (null? (car t)))
474 (and (pair? t) (pair? (cdr t)) (null? (cadr t)))) '()
475 (if (null? t) (cons (f (car h)) (map f (cdr h)))
477 (cons (f (car h) (caar t)) (map f (cdr h) (cdar t)))
479 (cons (f (car h) (caar t) (caadr t)) (map f (cdr h) (cdar t) (cdadr t)))
480 (error 'unsupported (cons* 'map-4: f h t))b )))))
484 (chmod "mes/guile.mes" #o644)
485 (copy-file "mes/guile.mes" "mes/guile.mes.orig")
486 (let ((guile.mes (open-file "mes/guile.mes" "a")))
488 ;; After booting guile.scm; use Mes 0.21; especially: MesCC 0.21
489 (let* ((self (car (command-line)))
490 (prefix (dirname (dirname self))))
491 (set! %moduledir (string-append prefix \"/mes/module/\"))
492 (setenv \"%numbered_arch\" \"true\"))
502 (version "0.21-33-g6d493b90d")
505 (uri (string-append "http://lilypond.org/janneke/mes/"
506 "mes-" version ".tar.gz"))
509 "0nr74zyam5n82svjwfbcz2mycj88vvsqab12x0mxv1lm6yqxqmmj"))))
511 (propagated-inputs '())
513 `(("nyacc-source" ,(origin (inherit (package-source nyacc))
515 ("mes" ,%bootstrap-mes-rewired)
516 ("mescc-tools" ,%bootstrap-mescc-tools)
517 ,@(%boot-gash-inputs)))
519 `(#:implicit-inputs? #f
521 #:guile ,%bootstrap-guile
522 #:strip-binaries? #f ; binutil's strip b0rkes MesCC/M1/hex2 binaries
524 (modify-phases %standard-phases
525 (add-after 'unpack 'unpack-seeds
527 (let ((nyacc-source (assoc-ref %build-inputs "nyacc-source")))
528 (with-directory-excursion ".."
529 (invoke "tar" "-xvf" nyacc-source)))))
531 (lambda* (#:key outputs #:allow-other-keys)
532 (let ((out (assoc-ref %outputs "out"))
533 (gash (assoc-ref %build-inputs "bash"))
534 (mes (assoc-ref %build-inputs "mes"))
535 (dir (with-directory-excursion ".." (getcwd))))
536 (setenv "AR" (string-append "gash " (getcwd) "/scripts/mesar"))
537 (setenv "BASH" (string-append gash "/bin/bash"))
538 (setenv "CC" (string-append mes "/bin/mescc"))
539 (setenv "GUILE_LOAD_PATH"
541 mes "/share/mes/module"
542 ":" dir "/nyacc-0.99.0/module"
543 ":" (getenv "GUILE_LOAD_PATH")))
544 (invoke "gash" "configure.sh"
545 (string-append "--prefix=" out)
546 (string-append "--host=i686-linux-gnu")))))
549 (invoke "sh" "bootstrap.sh")))
553 (substitute* "install.sh" ; show some progress
555 (("^( *)((cp|mkdir|tar) [^']*[^\\])\n" all space cmd)
556 (string-append space "echo '" cmd "'\n"
558 (invoke "sh" "install.sh")
559 ;; Keep ASCII output, for friendlier comparison and bisection
560 (let* ((out (assoc-ref %outputs "out"))
561 (cache (string-append out "/lib/cache")))
562 (define (objects-in-dir dir)
565 (and (equal? (dirname name) dir)
566 (or (string-suffix? ".o" name)
567 (string-suffix? ".s" name))))))
568 (for-each (lambda (x) (install-file x cache))
569 (append (objects-in-dir ".")
570 (objects-in-dir "mescc-lib"))))
573 (list (search-path-specification
574 (variable "C_INCLUDE_PATH")
575 (files '("include")))
576 (search-path-specification
577 (variable "LIBRARY_PATH")
579 (search-path-specification
580 (variable "MES_PREFIX")
586 ;; Pristine tcc cannot be built by MesCC, we are keeping a delta of 11
587 ;; patches. In a very early and rough form they were presented to the
588 ;; TinyCC developers, who at the time showed no interest in supporting the
589 ;; bootstrappable effort; we will try again later. These patches have been
590 ;; ported to 0.9.27, alas the resulting tcc is buggy. Once MesCC is more
591 ;; mature, this package should use the 0.9.27 sources (or later).
592 (let ((version "0.9.26")
594 (commit "c004e9a34fb026bb44d211ab98bb768e79900eef"))
598 (version (string-append version "-" revision "." (string-take commit 7)))
601 (uri (list (string-append "mirror://gnu/guix/mirror"
602 "/tinycc-" commit ".tar.gz")
603 (string-append "https://gitlab.com/janneke/tinycc"
605 "/tinycc-" commit ".tar.gz")))
608 "1hmzn1pq0x22ppd80hyrn5qzqq94mxd0ychzj6vrr2vnj2frjv5b"))))
609 (build-system gnu-build-system)
610 (supported-systems '("i686-linux" "x86_64-linux"))
612 (propagated-inputs '())
615 ("mescc-tools" ,%bootstrap-mescc-tools)
616 ("nyacc-source" ,(bootstrap-origin
617 (package-source nyacc-0.86)))
619 ("coreutils" , %bootstrap-coreutils&co)
620 ("bootstrap-mes" ,%bootstrap-mes)))
622 `(#:implicit-inputs? #f
623 #:guile ,%bootstrap-guile
624 #:strip-binaries? #f ; binutil's strip b0rkes MesCC/M1/hex2 binaries
626 (modify-phases %standard-phases
627 (add-after 'unpack 'unpack-seeds
628 (lambda* (#:key outputs #:allow-other-keys)
629 (let* ((coreutils (assoc-ref %build-inputs "coreutils"))
630 (nyacc-source (assoc-ref %build-inputs "nyacc-source"))
631 (bootstrap-mes (assoc-ref %build-inputs "bootstrap-mes")))
632 (setenv "PATH" (string-append
634 (format (current-error-port) "PATH=~s\n" (getenv "PATH"))
635 (with-directory-excursion ".."
636 (mkdir-p "nyacc-source")
637 (invoke "tar" "--strip=1" "-C" "nyacc-source"
639 (symlink (string-append bootstrap-mes "/share/mes/lib") "mes-seed"))
642 (lambda* (#:key outputs #:allow-other-keys)
643 (let* ((out (assoc-ref %outputs "out"))
644 (dir (with-directory-excursion ".." (getcwd)))
645 (coreutils (assoc-ref %build-inputs "coreutils"))
646 (mes (assoc-ref %build-inputs "mes"))
647 (mescc-tools (assoc-ref %build-inputs "mescc-tools"))
648 (libc (assoc-ref %build-inputs "libc"))
649 (interpreter (if libc
650 ;; also for x86_64-linux, we are still on i686-linux
651 (string-append libc ,(glibc-dynamic-linker "i686-linux"))
652 (string-append mes "/lib/mes-loader"))))
653 (setenv "PATH" (string-append
656 ":" mescc-tools "/bin"))
657 (format (current-error-port) "PATH=~s\n" (getenv "PATH"))
659 (setenv "PREFIX" out)
660 (symlink (string-append mes "/share/mes") "mes")
661 (symlink (string-append "../nyacc-source/module") "nyacc")
662 (setenv "MES_PREFIX" "mes")
663 (setenv "MES_ARENA" "100000000")
664 (setenv "MES_MAX_ARENA" "100000000")
665 (setenv "MES_STACK" "10000000")
667 (setenv "GUILE_LOAD_PATH" "nyacc")
668 (invoke "sh" "configure"
670 (string-append "--elfinterp=" interpreter)
675 (substitute* "bootstrap.sh"
677 (invoke "sh" "bootstrap.sh")))
680 (setenv "DIFF" "diff.scm")
681 (setenv "OBJDUMP" "true")
683 ;; (invoke "sh" "test.sh" "mes/scaffold/tests/30-strlen")
684 ;; (invoke "sh" "-x" "test.sh" "mes/scaffold/tinycc/00_assignment")
685 (setenv "TCC" "./tcc")
686 (invoke "sh" "check.sh")))
689 (invoke "sh" "install.sh"))))))
691 (list (search-path-specification
692 (variable "C_INCLUDE_PATH")
693 (files '("include")))
694 (search-path-specification
695 (variable "LIBRARY_PATH")
696 (files '("lib"))))))))
703 (source (bootstrap-origin
705 (inherit (package-source tcc))
706 (patches (search-patches "tcc-boot-0.9.27.patch")))))
707 (build-system gnu-build-system)
709 (propagated-inputs '())
714 ("coreutils" , %bootstrap-coreutils&co)))
716 `(#:implicit-inputs? #f
717 #:guile ,%bootstrap-guile
719 ;; Binutils' 'strip' b0rkes MesCC/M1/hex2 binaries, tcc-boot also comes
720 ;; with MesCC/M1/hex2-built binaries.
724 (modify-phases %standard-phases
726 (lambda* (#:key outputs #:allow-other-keys)
727 (let* ((out (assoc-ref %outputs "out"))
728 (coreutils (assoc-ref %build-inputs "coreutils"))
729 (mes (assoc-ref %build-inputs "mes"))
730 (tcc (assoc-ref %build-inputs "tcc"))
731 (libc (assoc-ref %build-inputs "libc"))
732 (interpreter (if libc
733 ;; also for x86_64-linux, we are still on i686-linux
734 (string-append libc ,(glibc-dynamic-linker "i686-linux"))
735 (string-append mes "/lib/mes-loader"))))
737 (setenv "PATH" (string-append
740 (format (current-error-port) "PATH=~s\n" (getenv "PATH"))
741 (invoke "sh" "configure"
742 (string-append "--cc=tcc")
743 (string-append "--cpu=i386")
744 (string-append "--prefix=" out)
745 (string-append "--elfinterp=" interpreter)
746 (string-append "--crtprefix=" tcc "/lib")
747 (string-append "--sysincludepaths=" tcc "/include")
748 (string-append "--libpaths=" tcc "/lib")))))
750 (lambda* (#:key outputs #:allow-other-keys)
751 (let* ((out (assoc-ref %outputs "out"))
752 (mes (assoc-ref %build-inputs "mes"))
753 (tcc (assoc-ref %build-inputs "tcc"))
754 (libc (assoc-ref %build-inputs "libc"))
755 (interpreter (if libc
756 ;; also for x86_64-linux, we are still on i686-linux
757 (string-append libc ,(glibc-dynamic-linker "i686-linux"))
758 (string-append mes "/lib/mes-loader"))))
763 "-D" "TCC_TARGET_I386=1"
764 "-D" "CONFIG_TCC_STATIC=1"
765 "-D" "CONFIG_USE_LIBGCC=1"
766 "-D" (string-append "CONFIG_TCCDIR=\"" out "/lib/tcc\"")
767 "-D" (string-append "CONFIG_TCC_CRTPREFIX=\"" out "/lib:{B}/lib:.\"")
768 "-D" (string-append "CONFIG_TCC_CRTPREFIX=\"" out
770 "-D" (string-append "CONFIG_TCC_ELFINTERP=\"" interpreter "\"")
771 "-D" (string-append "CONFIG_TCC_LIBPATHS=\"" tcc "/lib:{B}/lib:.\"")
772 "-D" (string-append "CONFIG_TCC_SYSINCLUDEPATHS=\"" tcc "/include" ":/include:{B}/include\"")
773 "-D" (string-append "TCC_LIBGCC=\"" tcc "/lib/libc.a\"")
778 ;; FIXME: add sensible check target (without depending on make)
780 (= 1 (status:exit-val (system* "./tcc" "--help")))))
782 (lambda* (#:key outputs #:allow-other-keys)
783 (let ((out (assoc-ref %outputs "out"))
784 (tcc (assoc-ref %build-inputs "tcc")))
785 (mkdir-p (string-append out "/bin"))
786 (copy-file "tcc" (string-append out "/bin/tcc"))
787 (mkdir-p (string-append out "/lib/tcc"))
788 (copy-recursively (string-append tcc "/include")
789 (string-append out "/include"))
790 (copy-recursively (string-append tcc "/lib")
791 (string-append out "/lib"))
792 (invoke "tcc" "-D" "TCC_TARGET_I386=1" "-c" "-o" "libtcc1.o" "lib/libtcc1.c")
793 (invoke "tcc" "-ar" "rc" "libtcc1.a" "libtcc1.o")
794 (copy-file "libtcc1.a" (string-append out "/lib/libtcc1.a"))
795 (delete-file (string-append out "/lib/tcc/libtcc1.a"))
796 (copy-file "libtcc1.a" (string-append out "/lib/tcc/libtcc1.a"))
799 (define make-mesboot0
802 (name "make-mesboot0")
806 (uri (string-append "mirror://gnu/make/make-"
810 "1pb7fb7fqf9wz9najm85qdma1xhxzf1rhj5gwrlzdsz2zm0hpcv4"))))
811 (supported-systems '("i686-linux" "x86_64-linux"))
813 (propagated-inputs '())
814 (native-inputs `(("tcc" ,tcc-boot)
816 ("bash" ,%bootstrap-coreutils&co)
817 ("coreutils" ,%bootstrap-coreutils&co)))
819 `(#:implicit-inputs? #f
820 #:tests? #f ; check depends on perl
821 #:guile ,%bootstrap-guile
822 #:configure-flags `("CC=tcc -DO_RDONLY=0"
826 (modify-phases %standard-phases
827 (add-after 'configure 'configure-fixup
829 (substitute* "build.sh"
830 (("^REMOTE=.*") "REMOTE=stub\n")
831 (("^extras=.*") "extras=getloadavg.c\n"))
832 (substitute* "make.h"
833 (("^extern long int lseek.*" all) (string-append "// " all)))
835 (delete 'patch-generated-file-shebangs) ; no perl
838 (invoke "sh" "./build.sh")))
840 (lambda* (#:key outputs #:allow-other-keys)
841 (let* ((out (assoc-ref outputs "out"))
842 (bin (string-append out "/bin")))
843 (install-file "make" bin)
846 (define diffutils-mesboot
849 (name "diffutils-mesboot")
853 (uri (string-append "mirror://gnu/diffutils/diffutils-"
857 "1mirn5i825bn5w7rh6mgn0r8aj9xqanav95dwcl1b8sn82f4iwnm"))))
858 (supported-systems '("i686-linux" "x86_64-linux"))
860 (propagated-inputs '())
861 (native-inputs `(("mes" ,mes-boot)
864 ("bash" ,%bootstrap-coreutils&co)
865 ("coreutils" ,%bootstrap-coreutils&co)
866 ("make" ,make-mesboot0)))
868 `(#:implicit-inputs? #f
869 #:guile ,%bootstrap-guile
871 #:tests? #f ; check is naive, also checks non-built PROGRAMS
872 #:strip-binaries? #f ; no strip yet
874 (modify-phases %standard-phases
875 ;; diffutils-2.7 needs more traditional configure
877 (lambda* (#:key outputs #:allow-other-keys)
878 (let ((out (assoc-ref outputs "out"))
879 (bash (assoc-ref %build-inputs "bash")))
880 (setenv "CONFIG_SHELL" (string-append bash "/bin/sh"))
883 (invoke "./configure" (string-append "--prefix=" out)))))
884 (add-before 'configure 'remove-diff3-sdiff
885 (lambda* (#:key outputs #:allow-other-keys)
886 (substitute* "Makefile.in"
887 (("PROGRAMS = .*" all) "PROGRAMS = cmp diff"))
890 (define binutils-mesboot0
893 (name "binutils-mesboot0")
895 (source (bootstrap-origin
898 (uri (string-append "mirror://gnu/binutils/binutils-"
900 (patches (search-patches "binutils-boot-2.20.1a.patch"))
903 "0r7dr0brfpchh5ic0z9r4yxqn4ybzmlh25sbp30cacqk8nb7rlvi")))))
905 (propagated-inputs '())
906 (native-inputs `(("tcc" ,tcc-boot)
908 ("bash" ,%bootstrap-coreutils&co)
909 ("coreutils" ,%bootstrap-coreutils&co)
910 ("diffutils" ,diffutils-mesboot)
911 ("make" ,make-mesboot0)))
912 (supported-systems '("i686-linux" "x86_64-linux"))
914 `(#:implicit-inputs? #f
915 #:guile ,%bootstrap-guile
916 #:tests? #f ; runtest: command not found
918 #:strip-binaries? #f ; no strip yet
920 (let ((cppflags (string-append " -D __GLIBC_MINOR__=6"
921 " -D MES_BOOTSTRAP=1"))
922 (bash (assoc-ref %build-inputs "bash")))
923 `(,(string-append "CONFIG_SHELL=" bash "/bin/sh")
924 ,(string-append "CPPFLAGS=" cppflags)
928 ,(string-append "CC=tcc" cppflags)
932 "--build=i686-unknown-linux-gnu"
933 "--host=i686-unknown-linux-gnu"
934 "--with-sysroot=/"))))))
936 (define gcc-core-mesboot
937 ;; Gcc-2.95.3 is the most recent GCC that is supported by what the Mes C
938 ;; Library v0.16 offers. Gcc-3.x (and 4.x) place higher demands on a C
939 ;; library, such as dir.h/struct DIR/readdir, locales, signals... Also,
940 ;; with gcc-2.95.3, binutils-boot-2.20.1a and glibc-2.2.5 we found a GNU
941 ;; toolchain triplet "that works".
944 (name "gcc-core-mesboot")
946 (source (bootstrap-origin
949 (uri (string-append "mirror://gnu/gcc/gcc-2.95.3/gcc-core-"
952 (patches (search-patches "gcc-boot-2.95.3.patch"))
955 "1xvfy4pqhrd5v2cv8lzf63iqg92k09g6z9n2ah6ndd4h17k1x0an")))))
956 (supported-systems '("i686-linux" "x86_64-linux"))
958 (propagated-inputs '())
959 (native-inputs `(("binutils" ,binutils-mesboot0)
962 ("bash" ,%bootstrap-coreutils&co)
963 ("coreutils" ,%bootstrap-coreutils&co)
964 ("diffutils" ,diffutils-mesboot)
965 ("make" ,make-mesboot0)))
968 `(#:implicit-inputs? #f
969 #:guile ,%bootstrap-guile
974 (let ((out (assoc-ref %outputs "out")))
978 "--build=i686-unknown-linux-gnu"
979 "--host=i686-unknown-linux-gnu"
980 ,(string-append "--prefix=" out)))
982 "CC=tcc -static -D __GLIBC_MINOR__=6"
983 "OLDCC=tcc -static -D __GLIBC_MINOR__=6"
984 "CC_FOR_BUILD=tcc -static -D __GLIBC_MINOR__=6"
987 (string-append "LIBGCC2_INCLUDES=-I "
988 (assoc-ref %build-inputs "tcc")
991 (string-append "BOOT_LDFLAGS="
992 " -B" (assoc-ref %build-inputs "tcc")
994 #:modules ((guix build gnu-build-system)
998 (modify-phases %standard-phases
999 ;; gcc-2.95.3 needs more traditional configure
1000 (add-before 'configure 'setenv
1001 (lambda* (#:key outputs #:allow-other-keys)
1002 (let ((out (assoc-ref outputs "out"))
1003 (bash (assoc-ref %build-inputs "bash"))
1004 (tcc (assoc-ref %build-inputs "tcc"))
1005 (cppflags " -D __GLIBC_MINOR__=6"))
1006 (setenv "CONFIG_SHELL" (string-append bash "/bin/sh"))
1007 (setenv "CPPFLAGS" cppflags)
1008 (setenv "CC" (string-append "tcc" cppflags))
1009 (setenv "CC_FOR_BUILD" (string-append "tcc" cppflags))
1010 (setenv "CPP" (string-append "tcc -E" cppflags))
1011 (with-output-to-file "config.cache"
1014 ac_cv_c_float_format='IEEE (little-endian)'
1018 (lambda* (#:key configure-flags #:allow-other-keys)
1019 (format (current-error-port)
1020 "running ./configure ~a\n" (string-join configure-flags))
1021 (apply invoke "./configure" configure-flags)))
1022 (add-after 'configure 'remove-info
1024 ;; no info at this stage
1025 (delete-file-recursively "texinfo")
1026 (invoke "touch" "gcc/cpp.info" "gcc/gcc.info")))
1027 (add-after 'install 'install2
1028 (lambda* (#:key outputs #:allow-other-keys)
1029 (let* ((tcc (assoc-ref %build-inputs "tcc"))
1030 (tcc-lib (string-append tcc "/lib/x86-mes-gcc"))
1031 (out (assoc-ref outputs "out"))
1032 (gcc-dir (string-append
1033 out "/lib/gcc-lib/i686-unknown-linux-gnu/2.95.3")))
1035 (zero? (system (string-append "set -x; cd tmp && ar x ../gcc/libgcc2.a")))
1036 (zero? (system (string-append "set -x; cd tmp && ar r " gcc-dir "/libgcc.a *.o")))
1037 (copy-file "gcc/libgcc2.a" (string-append out "/lib/libgcc2.a"))
1038 (copy-file (string-append tcc "/lib/libtcc1.a")
1039 (string-append out "/lib/libtcc1.a"))
1040 (invoke "ar" "r" (string-append gcc-dir "/libc.a")
1041 (string-append tcc-lib "/libc+gnu.o")
1042 (string-append tcc-lib "/libtcc1.o"))
1043 (invoke "ar" "r" (string-append out "/lib/libc.a")
1044 (string-append tcc-lib "/libc+gnu.o")
1045 (string-append tcc-lib "/libtcc1.o"))
1046 (invoke "ls" "-ltrF" gcc-dir)
1048 (native-search-paths
1049 (list (search-path-specification
1050 (variable "C_INCLUDE_PATH")
1053 ;; Needed to get things like GCC's <stddef.h>.
1054 "lib/gcc-lib/i686-unknown-linux-gnu/2.95.3/include")))
1055 (search-path-specification
1056 (variable "LIBRARY_PATH")
1057 (files '("lib")))))))
1059 (define mesboot-headers
1062 (name "mesboot-headers")
1063 (supported-systems '("i686-linux" "x86_64-linux"))
1065 (propagated-inputs '())
1066 (native-inputs `(("coreutils" ,%bootstrap-coreutils&co)
1067 ("headers" ,%bootstrap-linux-libre-headers)))
1069 `(#:implicit-inputs? #f
1070 #:guile ,%bootstrap-guile
1072 #:strip-binaries? #f
1074 (modify-phases %standard-phases
1078 (lambda* (#:key outputs #:allow-other-keys)
1079 (let* ((out (assoc-ref outputs "out"))
1080 (include (string-append out "/include"))
1081 (headers (assoc-ref %build-inputs "headers" )))
1083 (copy-recursively "include" out)
1084 (copy-recursively headers out)
1087 (define glibc-mesboot0
1088 ;; GNU C Library 2.2.5 is the most recent glibc that we managed to build
1089 ;; using gcc-2.95.3. Newer versions (2.3.x, 2.6, 2.1x) seem to need a newer
1093 (name "glibc-mesboot0")
1095 (source (bootstrap-origin
1098 (uri (string-append "mirror://gnu/glibc/glibc-"
1101 (patches (search-patches "glibc-boot-2.2.5.patch"))
1104 "1vl48i16gx6h68whjyhgnn1s57vqq32f9ygfa2fls7pdkbsqvp2q")))))
1105 (supported-systems '("i686-linux" "x86_64-linux"))
1107 (propagated-inputs '())
1108 (native-inputs `(("binutils" ,binutils-mesboot0)
1109 ("gcc" ,gcc-core-mesboot)
1111 ("bash" ,%bootstrap-coreutils&co)
1112 ("coreutils" ,%bootstrap-coreutils&co)
1113 ("diffutils" ,diffutils-mesboot)
1114 ("headers" ,mesboot-headers)
1115 ("make" ,make-mesboot0)))
1118 `(#:implicit-inputs? #f
1119 #:guile ,%bootstrap-guile
1121 #:strip-binaries? #f
1122 #:parallel-build? #f ; gcc-2.95.3 ICEs on massively parallel builds
1123 #:make-flags (list (string-append
1125 (assoc-ref %build-inputs "bash")
1128 (let ((out (assoc-ref %outputs "out"))
1129 (headers (assoc-ref %build-inputs "headers")))
1133 "--disable-sanity-checks"
1134 "--build=i686-unknown-linux-gnu"
1135 "--host=i686-unknown-linux-gnu"
1136 (string-append "--with-headers=" headers "/include")
1137 "--enable-static-nss"
1138 "--without-__thread"
1142 (string-append "--prefix=" out)))
1144 (modify-phases %standard-phases
1145 (add-before 'configure 'setenv
1146 (lambda* (#:key outputs #:allow-other-keys)
1147 (let* ((out (assoc-ref outputs "out"))
1148 (bash (assoc-ref %build-inputs "bash"))
1149 (gcc (assoc-ref %build-inputs "gcc"))
1150 (headers (assoc-ref %build-inputs "headers"))
1151 (cppflags (string-append
1153 " -D MES_BOOTSTRAP=1"
1154 " -D BOOTSTRAP_GLIBC=1"))
1155 (cflags (string-append " -L " (getcwd))))
1156 (setenv "CONFIG_SHELL" (string-append bash "/bin/sh"))
1157 (setenv "SHELL" (getenv "CONFIG_SHELL"))
1158 (setenv "CPP" (string-append gcc "/bin/gcc -E " cppflags))
1159 (setenv "CC" (string-append gcc "/bin/gcc " cppflags cflags))
1161 ;; glibc-2.2.5 needs a more classic invocation of configure
1162 ;; configure: warning: CONFIG_SHELL=/gnu/store/…-bash-minimal-4.4.12/bin/bash: invalid host type
1164 (lambda* (#:key configure-flags #:allow-other-keys)
1165 (format (current-error-port)
1166 "running ./configure ~a\n" (string-join configure-flags))
1167 (apply invoke "./configure" configure-flags))))))))
1169 (define gcc-mesboot0
1171 (inherit gcc-core-mesboot)
1172 (name "gcc-mesboot0")
1173 (native-inputs `(("binutils" ,binutils-mesboot0)
1175 ;; Packages are given in an order that's relevant for
1176 ;; #include_next purposes.
1177 ("libc" ,glibc-mesboot0)
1178 ("kernel-headers" ,%bootstrap-linux-libre-headers)
1179 ("gcc" ,gcc-core-mesboot)
1181 ("bash" ,%bootstrap-coreutils&co)
1182 ("coreutils" ,%bootstrap-coreutils&co)
1183 ("diffutils" ,diffutils-mesboot)
1184 ("make" ,make-mesboot0)))
1186 (substitute-keyword-arguments (package-arguments gcc-core-mesboot)
1188 `(modify-phases ,phases
1191 (setenv "CONFIG_SHELL" (which "sh"))
1192 (with-output-to-file "config.cache"
1195 ac_cv_c_float_format='IEEE (little-endian)'
1199 (lambda* (#:key outputs #:allow-other-keys)
1200 (let* ((out (assoc-ref outputs "out"))
1201 (gcc-dir (string-append
1202 out "/lib/gcc-lib/i686-unknown-linux-gnu/2.95.3")))
1204 (zero? (system (string-append "set -x; cd tmp && ar x ../gcc/libgcc2.a")))
1205 (zero? (system (string-append "set -x; cd tmp && ar r " gcc-dir "/libgcc.a *.o")))
1206 (copy-file "gcc/libgcc2.a" (string-append out "/lib/libgcc2.a"))
1208 ((#:configure-flags configure-flags)
1209 `(let ((out (assoc-ref %outputs "out")))
1210 `("--disable-shared"
1212 "--build=i686-unknown-linux-gnu"
1213 "--host=i686-unknown-linux-gnu"
1214 ,(string-append "--prefix=" out))))
1215 ((#:make-flags make-flags)
1216 `(let ((gcc (assoc-ref %build-inputs "gcc")))
1218 ,(string-append "LIBGCC2_INCLUDES=-I " gcc "/include")
1219 "LANGUAGES=c")))))))
1221 (define binutils-mesboot
1223 (inherit binutils-mesboot0)
1224 (name "binutils-mesboot")
1225 (native-inputs `(("binutils" ,binutils-mesboot0)
1226 ("libc" ,glibc-mesboot0)
1227 ("gcc" ,gcc-mesboot0)
1229 ("bash" ,%bootstrap-coreutils&co)
1230 ("coreutils" ,%bootstrap-coreutils&co)
1231 ("diffutils" ,diffutils-mesboot)
1232 ("kernel-headers" ,%bootstrap-linux-libre-headers)
1233 ("make" ,make-mesboot0)))
1235 (substitute-keyword-arguments (package-arguments binutils-mesboot0)
1236 ((#:configure-flags configure-flags)
1237 '(list "--disable-nls"
1240 "--build=i686-unknown-linux-gnu"
1241 "--host=i686-unknown-linux-gnu"
1242 "--with-sysroot=/"))))))
1244 (define make-mesboot
1246 (inherit make-mesboot0)
1247 (name "make-mesboot")
1251 (uri (string-append "mirror://gnu/make/make-"
1255 "1rs2f9hmvy3q6zkl15jnlmnpgffm0bhw5ax0h5c7q604wqrip69x"))))
1256 (native-inputs `(("binutils" ,binutils-mesboot0)
1257 ("libc" ,glibc-mesboot0)
1258 ("gcc" ,gcc-mesboot0)
1259 ("make" ,make-mesboot0)
1261 ("bash" ,%bootstrap-coreutils&co)
1262 ("coreutils" ,%bootstrap-coreutils&co)
1263 ("kernel-headers" ,%bootstrap-linux-libre-headers)))
1265 (substitute-keyword-arguments (package-arguments make-mesboot0)
1266 ((#:configure-flags configure-flags)
1267 `(let ((out (assoc-ref %outputs "out")))
1268 `(,(string-append "--prefix=" out))))
1270 `(modify-phases ,phases
1271 (delete 'configure-fixup)
1272 (add-before 'configure 'setenv
1274 (setenv "LIBS" "-lc -lnss_files -lnss_dns -lresolv")
1283 (uri (string-append "mirror://gnu/gmp/gmp-" version
1286 "15rwq54fi3s11izas6g985y9jklm3xprfsmym3v1g6xr84bavqvv"))))))
1294 (uri (string-append "mirror://gnu/mpfr/mpfr-" version
1297 "0dxn4904dra50xa22hi047lj8kkpr41d6vb9sd4grca880c7wv94"))))))
1306 "mirror://gnu/mpc/mpc-" version ".tar.gz"))
1309 "1hzci2zrrd7v3g1jk35qindq05hbl0bhjcyyisq9z209xb3fqzb1"))))))
1311 (define gcc-mesboot1
1313 (inherit gcc-mesboot0)
1314 (name "gcc-mesboot1")
1315 (version (package-version gcc-4.7))
1316 (source (bootstrap-origin
1317 (origin (inherit (package-source gcc-4.7))
1318 (patches (search-patches "gcc-boot-4.7.4.patch")))))
1319 (inputs `(("gmp-source" ,(package-source gmp-boot))
1320 ("mpfr-source" ,(package-source mpfr-boot))
1321 ("mpc-source" ,(package-source mpc-boot))))
1322 (native-inputs `(("binutils" ,binutils-mesboot)
1324 ("libc" ,glibc-mesboot0)
1325 ("kernel-headers" ,%bootstrap-linux-libre-headers)
1326 ("gcc" ,gcc-mesboot0)
1328 ("bash" ,%bootstrap-coreutils&co)
1329 ("coreutils" ,%bootstrap-coreutils&co)
1330 ("diffutils" ,diffutils-mesboot)
1331 ("make" ,make-mesboot)))
1333 (substitute-keyword-arguments (package-arguments gcc-core-mesboot)
1334 ((#:make-flags make-flags)
1335 `(let* ((libc (assoc-ref %build-inputs "libc"))
1336 (ldflags (string-append
1338 "-Wl,-dynamic-linker "
1340 ,(glibc-dynamic-linker "i686-linux"))))
1341 (list (string-append "LDFLAGS=" ldflags)
1342 (string-append "LDFLAGS_FOR_TARGET=" ldflags))))
1344 `(modify-phases ,phases
1345 ;; c&p from commencement.scm:gcc-boot0
1346 (add-after 'unpack 'unpack-gmp&co
1347 (lambda* (#:key inputs #:allow-other-keys)
1348 (let ((gmp (assoc-ref %build-inputs "gmp-source"))
1349 (mpfr (assoc-ref %build-inputs "mpfr-source"))
1350 (mpc (assoc-ref %build-inputs "mpc-source")))
1352 ;; To reduce the set of pre-built bootstrap inputs, build
1353 ;; GMP & co. from GCC.
1354 (for-each (lambda (source)
1355 (or (invoke "tar" "xvf" source)
1356 (error "failed to unpack tarball"
1358 (list gmp mpfr mpc))
1360 ;; Create symlinks like `gmp' -> `gmp-x.y.z'.
1361 ,@(map (lambda (lib)
1362 ;; Drop trailing letters, as gmp-6.0.0a unpacks
1364 `(symlink ,(string-trim-right
1365 (package-full-name lib "-")
1367 ,(package-name lib)))
1368 (list gmp-boot mpfr-boot mpc-boot))
1370 (delete 'remove-info)
1373 (setenv "CONFIG_SHELL" (which "sh"))
1375 ;; Allow MPFR headers to be found.
1376 (setenv "C_INCLUDE_PATH"
1377 (string-append (getcwd) "/mpfr/src:"
1378 (getenv "C_INCLUDE_PATH")))
1380 ;; Set the C++ search path so that C headers can be found as
1381 ;; libstdc++ is being compiled.
1382 (setenv "CPLUS_INCLUDE_PATH" (getenv "C_INCLUDE_PATH"))
1384 (delete 'install2)))
1385 ((#:configure-flags configure-flags)
1386 `(let ((out (assoc-ref %outputs "out"))
1387 (glibc (assoc-ref %build-inputs "libc")))
1388 (list (string-append "--prefix=" out)
1389 "--build=i686-unknown-linux-gnu"
1390 "--host=i686-unknown-linux-gnu"
1392 (string-append "--with-native-system-header-dir=" glibc "/include")
1393 (string-append "--with-build-sysroot=" glibc "/include")
1395 "--disable-bootstrap"
1396 "--disable-decimal-float"
1397 "--disable-libatomic"
1398 "--disable-libcilkrts"
1401 "--disable-libmudflap"
1402 "--disable-libquadmath"
1403 "--disable-libsanitizer"
1407 "--disable-lto-plugin"
1408 "--disable-multilib"
1411 "--enable-languages=c,c++"
1414 ;; libstdc++.so: error: depends on 'libgcc_s.so.1', which cannot be found in RUNPATH ()
1416 "--enable-threads=single"
1418 ;; No pre-compiled libstdc++ headers, to save space.
1419 "--disable-libstdcxx-pch"
1422 "--disable-build-with-cxx")))))))
1424 (define gcc-mesboot1-wrapper
1425 ;; We need this so gcc-mesboot1 can be used to create shared binaries that
1426 ;; have the correct interpreter, otherwise configuring gcc-mesboot using
1427 ;; --enable-shared will fail.
1429 (inherit gcc-mesboot1)
1430 (name "gcc-mesboot1-wrapper")
1433 (native-inputs `(("bash" ,%bootstrap-coreutils&co)
1434 ("libc" ,glibc-mesboot)
1435 ("gcc" ,gcc-mesboot1)))
1437 `(#:implicit-inputs? #f
1438 #:guile ,%bootstrap-guile
1440 (modify-phases %standard-phases
1445 (lambda* (#:key outputs #:allow-other-keys)
1446 (let* ((out (assoc-ref outputs "out"))
1447 (bash (assoc-ref %build-inputs "bash"))
1448 (libc (assoc-ref %build-inputs "libc"))
1449 (gcc (assoc-ref %build-inputs "gcc"))
1450 (bin (string-append out "/bin")))
1454 (let ((wrapper (string-append bin "/" program)))
1455 (with-output-to-file wrapper
1457 (display (string-append "#! " bash "/bin/bash
1458 exec " gcc "/bin/" program
1459 " -Wl,--dynamic-linker"
1460 ;; also for x86_64-linux, we are still on i686-linux
1461 " -Wl," libc ,(glibc-dynamic-linker "i686-linux")
1466 (chmod wrapper #o555)))))
1470 "i686-unknown-linux-gnu-gcc"
1471 "i686-unknown-linux-gnu-g++"
1475 (lambda* (#:key outputs #:allow-other-keys)
1476 (let* ((out (assoc-ref outputs "out"))
1477 (bin (string-append out "/bin"))
1478 (program (string-append bin "/gcc")))
1479 (invoke program "--help")))))))))
1481 (define glibc-headers-mesboot
1483 (inherit glibc-mesboot0)
1484 (name "glibc-headers-mesboot")
1486 (source (bootstrap-origin
1489 (uri (string-append "mirror://gnu/glibc/glibc-"
1492 (patches (search-patches "glibc-boot-2.16.0.patch"
1493 "glibc-bootstrap-system-2.16.0.patch"))
1496 "0vlz4x6cgz7h54qq4528q526qlhnsjzbsvgc4iizn76cb0bfanx7")))))
1497 (native-inputs `(("binutils" ,binutils-mesboot)
1498 ("libc" ,glibc-mesboot0)
1499 ("gcc" ,gcc-mesboot1)
1500 ("headers" ,mesboot-headers)
1502 ("bash" ,%bootstrap-coreutils&co)
1503 ("coreutils" ,%bootstrap-coreutils&co)
1504 ("diffutils" ,diffutils-mesboot)
1505 ("kernel-headers" ,%bootstrap-linux-libre-headers)
1506 ("make" ,make-mesboot)))
1509 (substitute-keyword-arguments (package-arguments glibc-mesboot0)
1510 ((#:configure-flags configure-flags)
1511 `(let ((out (assoc-ref %outputs "out"))
1512 (headers (assoc-ref %build-inputs "headers")))
1514 (string-append "--prefix=" out)
1515 "--disable-obsolete-rpc"
1516 "--host=i686-unknown-linux-gnu"
1517 (string-append "--with-headers=" headers "/include")
1518 "--enable-static-nss"
1522 "--enable-add-ons=nptl")))
1523 ((#:make-flags make-flags)
1524 `(let ((bash (assoc-ref %build-inputs "bash")))
1525 (list (string-append "SHELL=" bash "/bin/sh")
1526 "install-bootstrap-headers=yes" "install-headers")))
1528 `(modify-phases ,phases
1530 (lambda* (#:key inputs #:allow-other-keys)
1531 (let* ((headers (assoc-ref inputs "headers"))
1532 (libc (assoc-ref inputs "libc"))
1533 (gcc (assoc-ref inputs "gcc"))
1534 (cppflags (string-append
1535 " -I " (getcwd) "/nptl/sysdeps/pthread/bits"
1536 " -D BOOTSTRAP_GLIBC=1"))
1537 (cflags (string-append " -L " (getcwd)
1538 " -L " libc "/lib")))
1539 (setenv "libc_cv_friendly_stddef" "yes")
1540 (setenv "CONFIG_SHELL" (which "sh"))
1541 (setenv "SHELL" (which "sh"))
1543 (setenv "CPP" (string-append gcc "/bin/gcc -E " cppflags))
1544 (setenv "CC" (string-append gcc "/bin/gcc " cppflags cflags))
1546 ;; avoid -fstack-protector
1547 (setenv "libc_cv_ssp" "false")
1548 (substitute* "configure"
1549 (("/bin/pwd") "pwd"))
1552 (lambda* (#:key outputs make-flags #:allow-other-keys)
1553 (let ((kernel-headers (assoc-ref %build-inputs "kernel-headers"))
1554 (out (assoc-ref outputs "out")))
1555 (apply invoke "make" make-flags)
1556 (copy-recursively kernel-headers out)
1559 (lambda* (#:key configure-flags #:allow-other-keys)
1560 (format (current-error-port) "running ../configure ~a\n" (string-join configure-flags))
1563 (apply invoke "../configure" configure-flags)))
1564 (add-after 'configure 'remove-sunrpc
1566 (invoke "make" (string-append (getcwd) "/sysd-sorted" )
1567 (string-append "SHELL=" (getenv "CONFIG_SHELL")))
1568 (substitute* "sysd-sorted"
1571 ;; 'rpcgen' needs native libc headers to be built.
1572 (substitute* "../Makefile"
1573 (("^SHELL := /bin/sh") (string-append "SHELL := " (getenv "CONFIG_SHELL"))))
1574 (substitute* "../Makeconfig"
1575 (("^SHELL := /bin/sh") (string-append "SHELL := " (getenv "CONFIG_SHELL"))))
1576 (substitute* "../elf/Makefile"
1577 (("^SHELL := /bin/sh") (string-append "SHELL := " (getenv "CONFIG_SHELL"))))))))))))
1579 (define glibc-mesboot
1581 (inherit glibc-headers-mesboot)
1582 (name "glibc-mesboot")
1583 (native-inputs `(("binutils" ,binutils-mesboot)
1584 ("libc" ,glibc-mesboot0)
1585 ("headers" ,glibc-headers-mesboot)
1586 ("gcc" ,gcc-mesboot1)
1588 ("bash" ,%bootstrap-coreutils&co)
1589 ("coreutils" ,%bootstrap-coreutils&co)
1590 ("diffutils" ,diffutils-mesboot)
1591 ("kernel-headers" ,%bootstrap-linux-libre-headers)
1592 ("make" ,make-mesboot)))
1595 `(#:validate-runpath? #f ; fails when using --enable-shared
1596 ,@(substitute-keyword-arguments (package-arguments glibc-headers-mesboot)
1597 ((#:make-flags make-flags)
1598 `(let ((bash (assoc-ref %build-inputs "bash")))
1599 (list (string-append "SHELL=" bash "/bin/sh"))))
1601 `(modify-phases ,phases
1603 (lambda* (#:key outputs make-flags #:allow-other-keys)
1604 (let* ((kernel-headers (assoc-ref %build-inputs "kernel-headers"))
1605 (out (assoc-ref outputs "out"))
1606 (install-flags (cons "install" make-flags)))
1607 (apply invoke "make" install-flags)
1608 (copy-recursively kernel-headers out)
1613 (inherit gcc-mesboot1)
1614 (name "gcc-mesboot")
1615 (version (package-version gcc-4.9))
1616 (source (bootstrap-origin (package-source gcc-4.9)))
1617 (native-inputs `(("binutils" ,binutils-mesboot)
1619 ("libc" ,glibc-mesboot)
1620 ("kernel-headers" ,%bootstrap-linux-libre-headers)
1621 ("gcc-wrapper" ,gcc-mesboot1-wrapper)
1622 ("gcc" ,gcc-mesboot1)
1624 ("bash" ,%bootstrap-coreutils&co)
1625 ("coreutils" ,%bootstrap-coreutils&co)
1626 ("diffutils" ,diffutils-mesboot)
1627 ("make" ,make-mesboot)))
1629 `(#:validate-runpath? #f
1630 ,@(substitute-keyword-arguments (package-arguments gcc-mesboot1)
1631 ((#:configure-flags configure-flags)
1632 `(let ((out (assoc-ref %outputs "out"))
1633 (glibc (assoc-ref %build-inputs "libc")))
1634 (list (string-append "--prefix=" out)
1635 "--build=i686-unknown-linux-gnu"
1636 "--host=i686-unknown-linux-gnu"
1638 "--with-host-libstdcxx=-lsupc++"
1640 (string-append "--with-native-system-header-dir=" glibc "/include")
1641 (string-append "--with-build-sysroot=" glibc "/include")
1643 "--disable-bootstrap"
1644 "--disable-decimal-float"
1645 "--disable-libatomic"
1646 "--disable-libcilkrts"
1649 "--disable-libmudflap"
1650 "--disable-libquadmath"
1651 "--disable-libsanitizer"
1655 "--disable-lto-plugin"
1656 "--disable-multilib"
1659 "--enable-languages=c,c++"
1663 "--enable-threads=single"
1665 ;; No pre-compiled libstdc++ headers, to save space.
1666 "--disable-libstdcxx-pch"
1669 "--disable-build-with-cxx"))))))))
1671 (define gcc-mesboot-wrapper
1672 ;; We need this so gcc-mesboot can be used to create shared binaries that
1673 ;; have the correct interpreter and runpath to libc.
1675 (inherit gcc-mesboot1-wrapper)
1676 (name "gcc-mesboot-wrapper")
1677 (version (package-version gcc-mesboot))
1680 (native-inputs `(("bash" ,%bootstrap-coreutils&co)
1681 ("libc" ,glibc-mesboot)
1682 ("gcc" ,gcc-mesboot)))))
1691 (uri (string-append "mirror://gnu/m4/m4-"
1695 "1f9bxj176kf3pvs350w2dfs8jgwhminywri5pyn01b11yc4yhsjw"))))
1696 (supported-systems '("i686-linux" "x86_64-linux"))
1697 (native-inputs `(("mes" ,mes-boot)
1701 (modify-phases %standard-phases
1703 (lambda* (#:key outputs #:allow-other-keys)
1704 (let ((out (assoc-ref outputs "out")))
1705 (setenv "CONFIG_SHELL" (string-append
1706 (assoc-ref %build-inputs "bash")
1708 (setenv "CC" "tcc -static")
1709 (setenv "CPP" "tcc -E")
1710 (invoke "./configure" (string-append "--prefix=" out))))))))))
1712 (define (%bootstrap-inputs+toolchain)
1713 ;; The traditional bootstrap-inputs. For the i686-linux Reduced Binary Seed
1714 ;; the actual reduced set with bootstrapped toolchain.
1715 (match (%current-system)
1716 ((or "i686-linux" "x86_64-linux")
1717 `(("libc" ,glibc-mesboot)
1718 ("binutils" ,binutils-mesboot)
1719 ("gcc-wrapper" ,gcc-mesboot-wrapper)
1720 ("gcc" ,gcc-mesboot)
1721 ,@(fold alist-delete (%bootstrap-inputs)
1722 '("bootstrap-mescc-tools" "mes"))))
1724 (%bootstrap-inputs))))
1726 (define gnu-make-boot0
1729 (source (bootstrap-origin (package-source gnu-make)))
1732 `(#:guile ,%bootstrap-guile
1733 #:implicit-inputs? #f
1734 #:tests? #f ; cannot run "make check"
1735 ,@(substitute-keyword-arguments (package-arguments gnu-make)
1736 ((#:configure-flags flags ''())
1737 ;; The generated config.status has some problems due to the
1738 ;; bootstrap environment. Disable dependency tracking to work
1740 `(cons "--disable-dependency-tracking" ,flags))
1742 `(modify-phases ,phases
1745 (invoke "./build.sh")))
1747 (lambda* (#:key outputs #:allow-other-keys)
1748 (let* ((out (assoc-ref outputs "out"))
1749 (bin (string-append out "/bin")))
1750 (install-file "make" bin)
1752 (native-inputs '()) ; no need for 'pkg-config'
1753 (inputs (%bootstrap-inputs+toolchain))))
1755 (define diffutils-boot0
1758 (name "diffutils-boot0")
1761 `(("make" ,gnu-make-boot0)
1762 ,@(%bootstrap-inputs+toolchain)))
1764 `(#:tests? #f ; the test suite needs diffutils
1765 #:guile ,%bootstrap-guile
1766 #:implicit-inputs? #f
1767 ,@(package-arguments diffutils)))))
1769 (define findutils-boot0
1772 (name "findutils-boot0")
1773 (source (bootstrap-origin (package-source findutils)))
1775 `(("make" ,gnu-make-boot0)
1776 ("diffutils" ,diffutils-boot0) ; for tests
1777 ,@(%bootstrap-inputs+toolchain)))
1779 `(#:implicit-inputs? #f
1780 #:guile ,%bootstrap-guile
1782 ;; The build system assumes we have done a mistake when time_t is 32-bit
1783 ;; on a 64-bit system. Ignore that for our bootstrap toolchain.
1784 ,@(if (target-64bit?)
1785 (substitute-keyword-arguments (package-arguments findutils)
1786 ((#:configure-flags flags ''())
1787 `(cons "TIME_T_32_BIT_OK=yes"
1789 (package-arguments findutils))))))
1794 (source (bootstrap-origin (package-source file)))
1797 `(("make" ,gnu-make-boot0)
1798 ,@(%bootstrap-inputs+toolchain)))
1800 `(#:implicit-inputs? #f
1801 #:guile ,%bootstrap-guile
1802 #:strip-binaries? #f
1803 #:validate-runpath? #f))))
1805 (define (%boot0-inputs)
1806 `(("make" ,gnu-make-boot0)
1807 ("diffutils" ,diffutils-boot0)
1808 ("findutils" ,findutils-boot0)
1809 ("file" ,file-boot0)
1810 ,@(%bootstrap-inputs+toolchain)))
1812 (define* (boot-triplet #:optional (system (%current-system)))
1813 ;; Return the triplet used to create the cross toolchain needed in the
1814 ;; first bootstrapping stage.
1815 (nix-system->gnu-triplet system "guix"))
1817 ;; Following Linux From Scratch, build a cross-toolchain in stage 0. That
1818 ;; toolchain actually targets the same OS and arch, but it has the advantage
1819 ;; of being independent of the libc and tools in
1820 ;; (%BOOTSTRAP-INPUTS+TOOLCHAIN), since GCC-BOOT0 (below) is built without any
1821 ;; reference to the target libc.
1823 (define binutils-boot0
1826 (source (bootstrap-origin (package-source binutils)))
1827 (name "binutils-cross-boot0")
1829 `(#:guile ,%bootstrap-guile
1830 #:implicit-inputs? #f
1832 #:modules ((guix build gnu-build-system)
1834 (ice-9 ftw)) ; for 'scandir'
1835 #:phases (modify-phases %standard-phases
1836 (add-after 'install 'add-symlinks
1837 (lambda* (#:key outputs #:allow-other-keys)
1838 ;; The cross-gcc invokes 'as', 'ld', etc, without the
1839 ;; triplet prefix, so add symlinks.
1840 (let ((out (assoc-ref outputs "out"))
1841 (triplet-prefix (string-append ,(boot-triplet) "-")))
1842 (define (has-triplet-prefix? name)
1843 (string-prefix? triplet-prefix name))
1844 (define (remove-triplet-prefix name)
1845 (substring name (string-length triplet-prefix)))
1846 (with-directory-excursion (string-append out "/bin")
1847 (for-each (lambda (name)
1848 (symlink name (remove-triplet-prefix name)))
1849 (scandir "." has-triplet-prefix?)))
1852 ,@(substitute-keyword-arguments (package-arguments binutils)
1853 ((#:configure-flags cf)
1854 `(cons ,(string-append "--target=" (boot-triplet))
1856 (inputs (%boot0-inputs))))
1858 (define libstdc++-boot0
1859 ;; GCC's libcc1 is always built as a shared library (the top-level
1860 ;; 'Makefile.def' forcefully adds --enable-shared) and thus needs to refer
1861 ;; to libstdc++.so. We cannot build libstdc++-5.3 because it relies on
1862 ;; C++14 features missing in some of our bootstrap compilers.
1863 (let ((lib (make-libstdc++ gcc-4.9)))
1866 (source (bootstrap-origin (package-source lib)))
1867 (name "libstdc++-boot0")
1869 `(#:guile ,%bootstrap-guile
1870 #:implicit-inputs? #f
1872 ;; XXX: libstdc++.so NEEDs ld.so for some reason.
1873 #:validate-runpath? #f
1875 ,@(match (%current-system)
1876 ((or "i686-linux" "x86_64-linux")
1877 (substitute-keyword-arguments (package-arguments lib)
1879 `(modify-phases ,phases
1880 (add-after 'unpack 'workaround-wrapper-bug
1881 ;; XXX: The crude gcc-cross-wrapper causes "g++ -v" to
1882 ;; fail, which in turn confuses the configure script.
1884 (substitute* "libstdc++-v3/configure"
1885 (("g\\+\\+ -v") "true"))
1887 (_ (package-arguments lib)))))
1888 (inputs (%boot0-inputs))
1889 (native-inputs '()))))
1894 (name "gcc-cross-boot0")
1895 (source (bootstrap-origin (package-source gcc)))
1897 `(#:guile ,%bootstrap-guile
1898 #:implicit-inputs? #f
1899 #:modules ((guix build gnu-build-system)
1904 ,@(substitute-keyword-arguments (package-arguments gcc)
1905 ((#:configure-flags flags)
1906 `(append (list ,(string-append "--target=" (boot-triplet))
1911 ;; Disable features not needed at this stage.
1913 "--enable-languages=c,c++"
1915 ;; libstdc++ cannot be built at this stage
1916 ;; ("Link tests are not allowed after
1917 ;; GCC_NO_EXECUTABLES.").
1918 "--disable-libstdc++-v3"
1921 "--disable-libmudflap"
1922 "--disable-libatomic"
1923 "--disable-libsanitizer"
1927 "--disable-libcilkrts"
1930 "--disable-libquadmath"
1931 "--disable-decimal-float")
1932 (remove (cut string-match
1933 "--(with-system-zlib|enable-languages.*)" <>)
1935 ((#:make-flags flags)
1936 `(let* ((libc (assoc-ref %build-inputs "libc"))
1937 (libc-native (or (assoc-ref %build-inputs "libc-native")
1939 `(,(string-append "LDFLAGS="
1940 "-Wl,-rpath=" libc-native "/lib "
1941 "-Wl,-dynamic-linker "
1942 "-Wl," libc-native ,(glibc-dynamic-linker
1943 (match (%current-system)
1944 ("x86_64-linux" "i686-linux")
1945 (_ (%current-system))))))))
1947 `(modify-phases ,phases
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 (invoke "tar" "xvf" source))
1958 (list gmp mpfr mpc))
1960 ;; Create symlinks like `gmp' -> `gmp-x.y.z'.
1961 ,@(map (lambda (lib)
1962 ;; Drop trailing letters, as gmp-6.0.0a unpacks
1964 `(symlink ,(string-trim-right
1965 (package-full-name lib "-")
1967 ,(package-name lib)))
1968 (list gmp-6.0 mpfr mpc))
1970 ,(match (%current-system)
1971 ((or "i686-linux" "x86_64-linux")
1972 '(add-before 'configure 'fix-libcc1
1973 (lambda* (#:key inputs #:allow-other-keys)
1974 ;; libcc1.so NEEDs libgcc_s.so, so provide one here
1975 ;; to placate the 'validate-runpath' phase.
1976 (substitute* "libcc1/Makefile.in"
1978 (string-append "la_LDFLAGS = -Wl,-rpath="
1979 (assoc-ref inputs "gcc") "/lib")))
1980 ;; XXX: "g++ -v" is broken (see also libstdc++ above).
1981 (substitute* "libcc1/configure"
1982 (("g\\+\\+ -v") "true"))
1984 (_ '(add-before 'configure 'return-true
1986 (add-after 'install 'symlink-libgcc_eh
1987 (lambda* (#:key outputs #:allow-other-keys)
1988 (let ((out (assoc-ref outputs "lib")))
1989 ;; Glibc wants to link against libgcc_eh, so provide
1991 (with-directory-excursion
1992 (string-append out "/lib/gcc/"
1994 "/" ,(package-version gcc))
1995 (symlink "libgcc.a" "libgcc_eh.a"))
1998 (inputs `(("gmp-source" ,(bootstrap-origin (package-source gmp-6.0)))
1999 ("mpfr-source" ,(bootstrap-origin (package-source mpfr)))
2000 ("mpc-source" ,(bootstrap-origin (package-source mpc)))
2001 ("binutils-cross" ,binutils-boot0)
2003 ;; The libstdc++ that libcc1 links against.
2004 ("libstdc++" ,libstdc++-boot0)
2006 ;; Call it differently so that the builder can check whether
2007 ;; the "libc" input is #f.
2008 ("libc-native" ,@(assoc-ref (%boot0-inputs) "libc"))
2009 ,@(alist-delete "libc" (%boot0-inputs))))
2011 ;; No need for the native-inputs to build the documentation at this stage.
2012 (native-inputs `())))
2018 (source (bootstrap-origin (package-source perl)))
2019 (inputs (%boot0-inputs))
2021 `(#:implicit-inputs? #f
2022 #:guile ,%bootstrap-guile
2023 #:validate-runpath? #f
2025 ;; At the very least, this must not depend on GCC & co.
2026 #:disallowed-references ,(list %bootstrap-binutils)
2028 ,@(substitute-keyword-arguments (package-arguments perl)
2030 `(modify-phases ,phases
2031 ;; Pthread support is missing in the bootstrap compiler
2032 ;; (broken spec file), so disable it.
2033 (add-before 'configure 'disable-pthreads
2035 (substitute* "Configure"
2036 (("^libswanted=(.*)pthread" _ before)
2037 (string-append "libswanted=" before)))
2039 ;; Do not configure with '-Dusethreads' since pthread
2040 ;; support is missing.
2041 ((#:configure-flags configure-flags)
2042 `(delete "-Dusethreads" ,configure-flags)))))))
2048 (source (bootstrap-origin (package-source m4)))
2049 (inputs (%boot0-inputs))
2051 `(#:guile ,%bootstrap-guile
2052 #:implicit-inputs? #f
2053 ,@(package-arguments m4)))))
2056 ;; This Bison is needed to build MiG so we need it early in the process.
2057 ;; Recent versions of Linux-Libre headers also depend on this.
2060 (name "bison-boot0")
2061 (propagated-inputs `(("m4" ,m4-boot0)))
2062 (native-inputs `(("perl" ,perl-boot0)))
2063 (inputs (%boot0-inputs)) ;remove Flex...
2065 `(#:tests? #f ;... and thus disable tests
2066 #:implicit-inputs? #f
2067 #:guile ,%bootstrap-guile
2069 ;; Zero timestamps in liby.a; this must be done
2070 ;; explicitly here because the bootstrap Binutils don't
2071 ;; do that (default is "cru".)
2072 #:make-flags `("ARFLAGS=crD"
2073 ,,(match (%current-system)
2074 ;; ranlib: '-D': No such file
2075 ((or "i686-linux" "x86_64-linux")
2078 "RANLIB=ranlib -D"))
2081 ,@(package-arguments bison)))))
2084 ;; This Flex is needed to build MiG as well as Linux-Libre headers.
2087 (native-inputs `(("bison" ,bison-boot0)))
2088 (propagated-inputs `(("m4" ,m4-boot0)))
2089 (inputs (%boot0-inputs))
2091 `(#:implicit-inputs? #f
2092 #:guile ,%bootstrap-guile
2098 (native-inputs `(("perl" ,perl-boot0)))
2099 (inputs (%boot0-inputs))
2101 `(#:implicit-inputs? #f
2102 #:guile ,%bootstrap-guile))))
2104 (define linux-libre-headers-boot0
2106 "Return Linux-Libre header files for the bootstrap environment."
2107 ;; Note: this is wrapped in a thunk to nicely handle circular dependencies
2108 ;; between (gnu packages linux) and this module. Additionally, memoize
2109 ;; the result to play well with further memoization and code that relies
2110 ;; on pointer identity; see <https://bugs.gnu.org/30155>.
2112 (inherit linux-libre-headers)
2114 `(#:guile ,%bootstrap-guile
2115 #:implicit-inputs? #f
2116 ,@(package-arguments linux-libre-headers)))
2118 `(("perl" ,perl-boot0)
2120 ;; Flex and Bison are required since version 4.16.
2121 ("flex" ,flex-boot0)
2122 ("bison" ,bison-boot0)
2124 ;; Rsync is required since version 5.3.
2125 ("rsync" ,rsync-boot0)
2126 ,@(%boot0-inputs))))))
2129 (package-with-explicit-inputs %boot0-inputs
2132 (define gnumach-headers-boot0
2133 (with-boot0 (package-with-bootstrap-guile gnumach-headers)))
2136 (let* ((mig (package
2137 (inherit (package-with-bootstrap-guile mig))
2138 (native-inputs `(("bison" ,bison-boot0)
2139 ("flex" ,flex-boot0)))
2140 (inputs `(("flex" ,flex-boot0)))
2143 `(,(string-append "LDFLAGS=-Wl,-rpath="
2144 (assoc-ref %build-inputs "flex") "/lib/")))))))
2147 (define hurd-headers-boot0
2148 (let ((hurd-headers (package (inherit hurd-headers)
2149 (native-inputs `(("mig" ,mig-boot0)))
2151 (with-boot0 (package-with-bootstrap-guile hurd-headers))))
2153 (define hurd-minimal-boot0
2154 (let ((hurd-minimal (package (inherit hurd-minimal)
2155 (native-inputs `(("mig" ,mig-boot0)))
2157 (with-boot0 (package-with-bootstrap-guile hurd-minimal))))
2159 (define hurd-core-headers-boot0
2161 "Return the Hurd and Mach headers as well as initial Hurd libraries for
2162 the bootstrap environment."
2163 (package (inherit (package-with-bootstrap-guile hurd-core-headers))
2164 (arguments `(#:guile ,%bootstrap-guile
2165 ,@(package-arguments hurd-core-headers)))
2167 `(("gnumach-headers" ,gnumach-headers-boot0)
2168 ("hurd-headers" ,hurd-headers-boot0)
2169 ("hurd-minimal" ,hurd-minimal-boot0)
2170 ,@(%boot0-inputs))))))
2172 (define* (kernel-headers-boot0 #:optional (system (%current-system)))
2174 ("i586-gnu" (hurd-core-headers-boot0))
2175 (_ (linux-libre-headers-boot0))))
2177 (define texinfo-boot0
2178 ;; Texinfo used to build libc's manual.
2179 ;; We build without ncurses because it fails to build at this stage, and
2180 ;; because we don't need the stand-alone Info reader.
2181 ;; Also, use (%BOOT0-INPUTS) to avoid building Perl once more.
2185 (inputs `(,@(%boot0-inputs)
2186 ("perl" ,perl-boot0)))
2188 `(#:implicit-inputs? #f
2189 #:guile ,%bootstrap-guile
2191 ;; Some of Texinfo 6.1's tests would fail with "Couldn't set UTF-8
2192 ;; character type in locale" but we don't have a UTF-8 locale at this
2193 ;; stage, so skip them.
2196 (define expat-sans-tests
2199 (inputs (%boot0-inputs))
2201 ;; XXX: Linking 'runtestscpp' fails with things like:
2203 ;; ld: Dwarf Error: found dwarf version '3789', this reader only handles version 2 and 3 information.
2205 ;; Skip tests altogether.
2206 `(#:implicit-inputs? #f
2207 #:guile ,%bootstrap-guile
2209 ,@(substitute-keyword-arguments (package-arguments expat)
2210 ((#:configure-flags flags ''())
2211 ;; Since we're not passing the right -Wl,-rpath flags, build the
2212 ;; static library to avoid RUNPATH validation failure.
2213 `(cons "--disable-shared" ,flags))
2214 ((#:tests? _ #f) #f))))))
2216 (define python-boot0
2218 (inherit python-minimal)
2219 ;; We cannot use Python 3.7 and later here, because they require
2220 ;; pthreads, which is missing on non-x86 platforms at this stage.
2221 ;; Python 3.6 technically supports being built without threading
2222 ;; support, but requires additional patches.
2224 (source (bootstrap-origin
2227 (uri (string-append "https://www.python.org/ftp/python/"
2228 version "/Python-" version ".tar.xz"))
2231 "0jdh9pvx6m6lfz2liwvvhn7vks7qrysqgwn517fkpxb77b33fjn2"))
2232 (modules '((guix build utils)))
2235 ;; Delete the bundled copy of libexpat.
2236 (delete-file-recursively "Modules/expat")
2237 (substitute* "Modules/Setup.dist"
2238 ;; Link Expat instead of embedding the bundled one.
2239 (("^#pyexpat.*") "pyexpat pyexpat.c -lexpat\n"))
2243 ("expat" ,expat-sans-tests))) ;remove OpenSSL, zlib, etc.
2244 (native-inputs '()) ;and pkg-config
2246 `(#:implicit-inputs? #f
2247 #:guile ,%bootstrap-guile
2249 ,@(substitute-keyword-arguments (package-arguments python-minimal)
2250 ;; Disable features that cannot be built at this stage.
2251 ((#:configure-flags _ ''())
2252 `(list "--without-ensurepip"
2253 "--without-threads"))
2254 ;; Clear #:make-flags, such that changes to the regular
2255 ;; Python package won't interfere with this one.
2256 ((#:make-flags _ ''()) ''())
2258 `(modify-phases ,phases
2259 (add-before 'configure 'disable-modules
2261 (substitute* "setup.py"
2262 ;; Disable ctypes, since it requires libffi.
2263 (("extensions\\.append\\(ctypes\\)") "")
2264 ;; Prevent the 'ossaudiodev' extension from being
2265 ;; built, since it requires Linux headers.
2268 (delete 'set-TZDIR)))
2269 ((#:tests? _ #f) #f))))))
2271 (define ld-wrapper-boot0
2273 ;; We need this so binaries on Hurd will have libmachuser and libhurduser
2274 ;; in their RUNPATH, otherwise validate-runpath will fail.
2275 (make-ld-wrapper "ld-wrapper-boot0"
2276 #:target boot-triplet
2277 #:binutils binutils-boot0
2278 #:guile %bootstrap-guile
2279 #:bash (car (assoc-ref (%boot0-inputs) "bash"))
2280 #:guile-for-build %bootstrap-guile)))
2282 (define (%boot1-inputs)
2283 ;; 2nd stage inputs.
2284 `(("gcc" ,gcc-boot0)
2285 ("ld-wrapper-cross" ,(ld-wrapper-boot0))
2286 ("binutils-cross" ,binutils-boot0)
2287 ,@(alist-delete "binutils" (%boot0-inputs))))
2289 (define glibc-final-with-bootstrap-bash
2290 ;; The final libc, "cross-built". If everything went well, the resulting
2291 ;; store path has no dependencies. Actually, the really-final libc is
2292 ;; built just below; the only difference is that this one uses the
2296 (name "glibc-intermediate")
2297 (source (bootstrap-origin (package-source glibc)))
2299 `(#:guile ,%bootstrap-guile
2300 #:implicit-inputs? #f
2302 ,@(substitute-keyword-arguments (package-arguments glibc)
2303 ((#:configure-flags flags)
2304 `(append (list ,(string-append "--host=" (boot-triplet))
2305 ,(string-append "--build="
2306 (nix-system->gnu-triplet)))
2309 `(modify-phases ,phases
2310 (add-before 'configure 'pre-configure
2311 (lambda* (#:key inputs #:allow-other-keys)
2312 ;; Don't clobber CPATH with the bootstrap libc.
2313 (setenv "NATIVE_CPATH" (getenv "CPATH"))
2316 ;; Tell 'libpthread' where to find 'libihash' on Hurd systems.
2317 ,@(if (hurd-triplet? (%current-system))
2318 `((substitute* "libpthread/Makefile"
2319 (("LDLIBS-pthread.so =.*")
2320 (string-append "LDLIBS-pthread.so = "
2321 (assoc-ref %build-inputs "kernel-headers")
2322 "/lib/libihash.a\n"))))
2325 ;; 'rpcgen' needs native libc headers to be built.
2326 (substitute* "sunrpc/Makefile"
2327 (("sunrpc-CPPFLAGS =.*" all)
2328 (string-append "CPATH = $(NATIVE_CPATH)\n"
2332 (propagated-inputs `(("kernel-headers" ,(kernel-headers-boot0))))
2334 `(("bison" ,bison-boot0)
2335 ("texinfo" ,texinfo-boot0)
2336 ("perl" ,perl-boot0)
2337 ("python" ,python-boot0)))
2339 `( ;; The boot inputs. That includes the bootstrap libc. We don't want
2340 ;; it in $CPATH, hence the 'pre-configure' phase above.
2343 ;; A native MiG is needed to build Glibc on Hurd.
2344 ,@(if (hurd-triplet? (%current-system))
2345 `(("mig" ,mig-boot0))
2348 ;; A native GCC is needed to build `cross-rpcgen'.
2349 ("native-gcc" ,@(assoc-ref (%boot0-inputs) "gcc"))
2351 ;; Here, we use the bootstrap Bash, which is not satisfactory
2352 ;; because we don't want to depend on bootstrap tools.
2353 ("static-bash" ,@(assoc-ref (%boot0-inputs) "bash"))))))
2355 (define (cross-gcc-wrapper gcc binutils glibc bash)
2356 "Return a wrapper for the pseudo-cross toolchain GCC/BINUTILS/GLIBC
2357 that makes it available under the native tool names."
2358 (package (inherit gcc)
2359 (name (string-append (package-name gcc) "-wrapped"))
2361 (build-system trivial-build-system)
2364 `(#:guile ,%bootstrap-guile
2365 #:modules ((guix build utils))
2367 (use-modules (guix build utils))
2369 (let* ((binutils (assoc-ref %build-inputs "binutils"))
2370 (gcc (assoc-ref %build-inputs "gcc"))
2371 (libc (assoc-ref %build-inputs "libc"))
2372 (bash (assoc-ref %build-inputs "bash"))
2373 (out (assoc-ref %outputs "out"))
2374 (bindir (string-append out "/bin"))
2375 (triplet ,(boot-triplet)))
2376 (define (wrap-program program)
2377 ;; GCC-BOOT0 is a libc-less cross-compiler, so it
2378 ;; needs to be told where to find the crt files and
2379 ;; the dynamic linker.
2380 (call-with-output-file program
2382 (format p "#!~a/bin/bash
2383 exec ~a/bin/~a-~a -B~a/lib -Wl,-dynamic-linker -Wl,~a/~a \"$@\"~%"
2387 ,(glibc-dynamic-linker))))
2389 (chmod program #o555))
2392 (with-directory-excursion bindir
2393 (for-each (lambda (tool)
2394 (symlink (string-append binutils "/bin/"
2398 (for-each wrap-program '("gcc" "g++")))
2402 `(("binutils" ,binutils)
2408 (define gcc-boot0-intermediate-wrapped
2410 ;; Make the cross-tools GCC-BOOT0 and BINUTILS-BOOT0 available under the
2412 (cross-gcc-wrapper gcc-boot0 binutils-boot0
2413 glibc-final-with-bootstrap-bash
2414 (car (assoc-ref (%boot1-inputs) "bash")))))
2416 (define static-bash-for-glibc
2417 ;; A statically-linked Bash to be used by GLIBC-FINAL in system(3) & co.
2419 (inherit static-bash)
2420 (source (bootstrap-origin (package-source static-bash)))
2421 (inputs `(("gcc" ,(gcc-boot0-intermediate-wrapped))
2422 ("libc" ,glibc-final-with-bootstrap-bash)
2423 ("libc:static" ,glibc-final-with-bootstrap-bash "static")
2424 ,@(fold alist-delete (%boot1-inputs)
2427 `(#:implicit-inputs? #f
2428 #:guile ,%bootstrap-guile
2430 ,@(substitute-keyword-arguments (package-arguments static-bash)
2431 ((#:configure-flags flags '())
2432 ;; Add a '-L' flag so that the pseudo-cross-ld of
2433 ;; BINUTILS-BOOT0 can find libc.a.
2435 (list (string-append "LDFLAGS=-static -L"
2436 (assoc-ref %build-inputs
2440 (define gettext-boot0
2441 ;; A minimal gettext used during bootstrap.
2443 (inherit gettext-minimal)
2444 (name "gettext-boot0")
2445 ;; Newer versions of GNU gettext depends on libxml2 and ncurses. To
2446 ;; simplify the dependency chain, we stick to this version here.
2447 (version "0.19.8.1")
2450 (uri (string-append "mirror://gnu/gettext/gettext-"
2454 "0hsw28f9q9xaggjlsdp2qmbp2rbd1mp0njzan2ld9kiqwkq2m57z"))))
2455 (inputs (%boot1-inputs)) ;zero dependencies
2457 `(#:implicit-inputs? #f
2458 #:guile ,%bootstrap-guile
2460 #:phases (modify-phases %standard-phases
2461 ;; Build only the tools.
2462 (add-after 'unpack 'chdir
2464 (chdir "gettext-tools")
2467 ;; Some test programs require pthreads, which we don't have.
2468 (add-before 'configure 'no-test-programs
2470 (substitute* "tests/Makefile.in"
2476 ;; The final glibc, which embeds the statically-linked Bash built above.
2477 ;; Use 'package/inherit' so we get the 'replacement' of 'glibc', if any.
2481 (source (bootstrap-origin (package-source glibc)))
2482 (inputs `(("static-bash" ,static-bash-for-glibc)
2485 (package-inputs glibc-final-with-bootstrap-bash))))
2487 ;; This time we need 'msgfmt' to install all the libc.mo files.
2488 (native-inputs `(,@(package-native-inputs glibc-final-with-bootstrap-bash)
2489 ("gettext" ,gettext-boot0)))
2492 (package-propagated-inputs glibc-final-with-bootstrap-bash))
2494 ;; The final libc only refers to itself, but the 'debug' output contains
2495 ;; references to GCC-BOOT0 and to the Linux headers. XXX: Would be great
2496 ;; if 'allowed-references' were per-output.
2498 `(#:allowed-references
2499 ,(cons* `(,gcc-boot0 "lib") (kernel-headers-boot0)
2500 static-bash-for-glibc
2501 (package-outputs glibc-final-with-bootstrap-bash))
2503 ,@(package-arguments glibc-final-with-bootstrap-bash)))))
2505 (define gcc-boot0-wrapped
2507 ;; Make the cross-tools GCC-BOOT0 and BINUTILS-BOOT0 available under the
2509 (cross-gcc-wrapper gcc-boot0 binutils-boot0 glibc-final
2510 (car (assoc-ref (%boot1-inputs) "bash")))))
2512 (define (%boot2-inputs)
2513 ;; 3rd stage inputs.
2514 `(("libc" ,glibc-final)
2515 ("libc:static" ,glibc-final "static")
2516 ("gcc" ,(gcc-boot0-wrapped))
2517 ,@(fold alist-delete (%boot1-inputs) '("libc" "gcc" "linux-libre-headers"))))
2519 (define binutils-final
2522 (source (bootstrap-origin (package-source binutils)))
2524 `(#:guile ,%bootstrap-guile
2525 #:implicit-inputs? #f
2526 #:allowed-references ("out" ,glibc-final)
2527 ,@(package-arguments binutils)))
2528 (inputs (%boot2-inputs))))
2531 ;; Intermediate libstdc++ that will allow us to build the final GCC
2532 ;; (remember that GCC-BOOT0 cannot build libstdc++.)
2533 (let ((lib (make-libstdc++ gcc)))
2536 (source (bootstrap-origin (package-source lib)))
2538 `(#:guile ,%bootstrap-guile
2539 #:implicit-inputs? #f
2540 #:allowed-references ("out")
2542 ;; XXX: libstdc++.so NEEDs ld.so for some reason.
2543 #:validate-runpath? #f
2545 ;; All of the package arguments from 'make-libstdc++
2546 ;; except for the configure-flags.
2547 ,@(package-arguments lib)
2548 #:configure-flags `("--disable-shared"
2549 "--disable-libstdcxx-dual-abi"
2550 "--disable-libstdcxx-threads"
2551 "--disable-libstdcxx-pch"
2552 ,(string-append "--with-gxx-include-dir="
2553 (assoc-ref %outputs "out")
2556 (inputs (%boot2-inputs))
2557 (synopsis "GNU C++ standard library (intermediate)"))))
2560 ;; Zlib used by GCC-FINAL.
2564 `(#:guile ,%bootstrap-guile
2565 #:implicit-inputs? #f
2566 #:allowed-references ("out" ,glibc-final)
2567 ,@(package-arguments zlib)))
2568 (inputs (%boot2-inputs))))
2570 (define ld-wrapper-boot3
2572 ;; A linker wrapper that uses the bootstrap Guile.
2573 (make-ld-wrapper "ld-wrapper-boot3"
2574 #:binutils binutils-final
2575 #:guile %bootstrap-guile
2576 #:bash (car (assoc-ref (%boot2-inputs) "bash"))
2577 #:guile-for-build %bootstrap-guile)))
2581 (package (inherit gcc-boot0)
2584 ;; XXX: Currently #:allowed-references applies to all the outputs but the
2585 ;; "debug" output contains disallowed references, notably
2586 ;; linux-libre-headers. Disable the debugging output to work around that.
2587 (outputs (delete "debug" (package-outputs gcc-boot0)))
2590 `(#:guile ,%bootstrap-guile
2591 #:implicit-inputs? #f
2593 #:allowed-references ("out" "lib" ,zlib-final
2594 ,glibc-final ,static-bash-for-glibc)
2596 ;; Things like libasan.so and libstdc++.so NEED ld.so for some
2597 ;; reason, but it is not in their RUNPATH. This is a false
2598 ;; positive, so turn it off.
2599 #:validate-runpath? #f
2601 ,@(substitute-keyword-arguments (package-arguments gcc)
2602 ((#:make-flags flags)
2603 ;; Since $LIBRARY_PATH is not honored, add the relevant flags.
2604 `(let ((zlib (assoc-ref %build-inputs "zlib")))
2606 (if (string-prefix? "LDFLAGS=" flag)
2607 (string-append flag " -L"
2608 (assoc-ref %build-inputs "libstdc++")
2609 "/lib -L" zlib "/lib -Wl,-rpath="
2613 ;; Build again GMP & co. within GCC's build process, because it's hard
2614 ;; to do outside (because GCC-BOOT0 is a cross-compiler, and thus
2615 ;; doesn't honor $LIBRARY_PATH, which breaks `gnu-build-system'.)
2617 `(modify-phases ,phases
2618 (add-after 'unpack 'unpack-gmp&co
2619 (lambda* (#:key inputs #:allow-other-keys)
2620 (let ((gmp (assoc-ref %build-inputs "gmp-source"))
2621 (mpfr (assoc-ref %build-inputs "mpfr-source"))
2622 (mpc (assoc-ref %build-inputs "mpc-source")))
2624 ;; To reduce the set of pre-built bootstrap inputs, build
2625 ;; GMP & co. from GCC.
2626 (for-each (lambda (source)
2627 (invoke "tar" "xvf" source))
2628 (list gmp mpfr mpc))
2630 ;; Create symlinks like `gmp' -> `gmp-x.y.z'.
2631 ,@(map (lambda (lib)
2632 ;; Drop trailing letters, as gmp-6.0.0a unpacks
2634 `(symlink ,(string-trim-right
2635 (package-full-name lib "-")
2637 ,(package-name lib)))
2638 (list gmp-6.0 mpfr mpc))
2641 ;; This time we want Texinfo, so we get the manual. Add
2642 ;; STATIC-BASH-FOR-GLIBC so that it's used in the final shebangs of
2643 ;; scripts such as 'mkheaders' and 'fixinc.sh' (XXX: who cares about these
2645 (native-inputs `(("texinfo" ,texinfo-boot0)
2646 ("perl" ,perl-boot0) ;for manpages
2647 ("static-bash" ,static-bash-for-glibc)
2648 ,@(package-native-inputs gcc-boot0)))
2650 (inputs `(("gmp-source" ,(bootstrap-origin (package-source gmp-6.0)))
2651 ("mpfr-source" ,(package-source mpfr))
2652 ("mpc-source" ,(package-source mpc))
2653 ("ld-wrapper" ,(ld-wrapper-boot3))
2654 ("binutils" ,binutils-final)
2655 ("libstdc++" ,libstdc++)
2656 ("zlib" ,zlib-final)
2657 ,@(%boot2-inputs)))))
2659 (define (%boot3-inputs)
2660 ;; 4th stage inputs.
2661 `(("gcc" ,gcc-final)
2662 ("ld-wrapper" ,(ld-wrapper-boot3))
2663 ,@(alist-delete "gcc" (%boot2-inputs))))
2666 ;; Link with `-static-libgcc' to make sure we don't retain a reference
2667 ;; to the bootstrap GCC. Use "bash-minimal" to avoid an extra dependency
2668 ;; on Readline and ncurses.
2669 (let ((bash (static-libgcc-package bash-minimal)))
2672 (source (bootstrap-origin (package-source bash)))
2673 (inputs (%boot3-inputs))
2675 `(#:implicit-inputs? #f
2676 #:guile ,%bootstrap-guile
2678 #:disallowed-references ,(assoc-ref (%boot3-inputs) "coreutils&co")
2680 ,@(package-arguments bash))))))
2682 (define (%boot4-inputs)
2683 ;; Now use the final Bash.
2684 `(("bash" ,bash-final)
2685 ,@(alist-delete "bash" (%boot3-inputs))))
2688 (package-with-explicit-inputs %boot4-inputs %bootstrap-guile))
2690 (define-public guile-final
2691 ;; This package must be public because other modules refer to it. However,
2692 ;; mark it as hidden so that 'fold-packages' ignores it.
2693 (with-boot4 (hidden-package
2694 (package-with-bootstrap-guile guile-2.2/fixed))))
2696 (define glibc-utf8-locales-final
2697 ;; Now that we have GUILE-FINAL, build the UTF-8 locales. They are needed
2698 ;; by the build processes afterwards so their 'scm_to_locale_string' works
2699 ;; with the full range of Unicode codepoints (remember
2700 ;; 'scm_to_locale_string' is called every time a string is passed to a C
2703 (inherit glibc-utf8-locales)
2705 `(("glibc" ,glibc-final)
2706 ("gzip" ,(with-boot4 gzip))))))
2708 (define-public ld-wrapper
2709 ;; The final 'ld' wrapper, which uses the final Guile and Binutils.
2710 (make-ld-wrapper "ld-wrapper"
2711 #:binutils binutils-final
2715 (define (%boot5-inputs)
2716 ;; Now with UTF-8 locales. Remember that the bootstrap binaries were built
2717 ;; with an older libc, which cannot load the new locale format. See
2718 ;; <https://lists.gnu.org/archive/html/guix-devel/2015-08/msg00737.html>.
2719 `(("locales" ,glibc-utf8-locales-final)
2723 (package-with-explicit-inputs %boot5-inputs))
2725 (define gnu-make-final
2726 ;; The final GNU Make, which uses the final Guile.
2727 (let ((pkg-config (package
2728 (inherit %pkg-config) ;the native pkg-config
2729 (inputs `(("guile" ,guile-final)
2732 `(#:implicit-inputs? #f
2733 ,@(package-arguments pkg-config))))))
2735 (inherit (package-with-bootstrap-guile gnu-make))
2736 (inputs `(("guile" ,guile-final)
2738 (native-inputs `(("pkg-config" ,pkg-config)))
2740 `(#:implicit-inputs? #f
2741 ,@(package-arguments gnu-make))))))
2744 (define coreutils-final
2745 ;; The final Coreutils. Treat them specially because some packages, such as
2746 ;; Findutils, keep a reference to the Coreutils they were built with.
2747 (with-boot5 (package-with-bootstrap-guile coreutils)
2748 ;; Use the final Guile, linked against the
2749 ;; final libc with working iconv, so that
2750 ;; 'substitute*' works well when touching
2751 ;; test files in Gettext.
2755 ;; The final grep. Gzip holds a reference to it (via zgrep), so it must be
2756 ;; built before gzip.
2757 (let ((grep (with-boot5 (package-with-bootstrap-guile grep))))
2758 (package/inherit grep
2759 (inputs (alist-delete "pcre" (package-inputs grep)))
2760 (native-inputs `(("perl" ,perl-boot0))))))
2762 (define (%boot6-inputs)
2763 ;; Now use the final Coreutils.
2764 `(("coreutils" ,coreutils-final)
2765 ("grep" ,grep-final)
2769 (package-with-explicit-inputs %boot6-inputs))
2773 (let ((sed (with-boot6 (package-with-bootstrap-guile sed))))
2774 (package/inherit sed (native-inputs `(("perl" ,perl-boot0))))))
2776 (define-public %final-inputs
2777 ;; Final derivations used as implicit inputs by 'gnu-build-system'. We
2778 ;; still use 'package-with-bootstrap-guile' so that the bootstrap tools are
2779 ;; used for origins that have patches, thereby avoiding circular
2781 (let ((finalize (compose with-boot6
2782 package-with-bootstrap-guile)))
2783 `(,@(map (match-lambda
2785 (list name (finalize package))))
2791 ("diffutils" ,diffutils)
2793 ("findutils" ,findutils)
2796 ("grep" ,grep-final)
2797 ("coreutils" ,coreutils-final)
2798 ("make" ,gnu-make-final)
2799 ("bash" ,bash-final)
2800 ("ld-wrapper" ,ld-wrapper)
2801 ("binutils" ,binutils-final)
2803 ("libc" ,glibc-final)
2804 ("libc:static" ,glibc-final "static")
2805 ("locales" ,glibc-utf8-locales-final))))
2807 (define-public canonical-package
2808 (let ((name->package (fold (lambda (input result)
2810 ((_ package . outputs)
2811 (vhash-cons (package-full-name package)
2814 `(("guile" ,guile-final)
2817 "Return the 'canonical' variant of PACKAGE---i.e., if PACKAGE is one of
2818 the implicit inputs of 'gnu-build-system', return that one, otherwise return
2821 The goal is to avoid duplication in cases like GUILE-FINAL vs. GUILE-2.2,
2822 COREUTILS-FINAL vs. COREUTILS, etc."
2823 ;; XXX: This doesn't handle dependencies of the final inputs, such as
2824 ;; libunistring, GMP, etc.
2825 (match (vhash-assoc (package-full-name package) name->package)
2827 ;; In general we want CANON, except if we're cross-compiling: CANON
2828 ;; uses explicit inputs, so it is "anchored" in the bootstrapped
2829 ;; process, with dependencies on things that cannot be
2831 (if (%current-target-system)
2841 ;; Using the following procedure, a gcc toolchain targeting glibc-2.27 can be
2842 ;; instantiated like this:
2844 ;; (define-public gcc-glibc-2.27-toolchain
2845 ;; (make-gcc-toolchain gcc glibc-2.27))
2847 (define* (make-gcc-toolchain gcc
2850 "Return a complete toolchain for GCC. If LIBC is specified, target that libc."
2851 (let ((gcc (if libc (make-gcc-libc gcc libc) gcc))
2852 (libc (if libc libc glibc-final)))
2854 (name (string-append (package-name gcc) "-toolchain"))
2855 (version (package-version gcc))
2857 (build-system trivial-build-system)
2859 '(#:modules ((guix build union))
2861 (use-modules (ice-9 match)
2865 (let ((out (assoc-ref %outputs "out")))
2867 (match %build-inputs
2868 (((names . directories) ...)
2869 (union-build out directories)))
2871 (union-build (assoc-ref %outputs "debug")
2872 (list (assoc-ref %build-inputs
2874 (union-build (assoc-ref %outputs "static")
2875 (list (assoc-ref %build-inputs
2879 (native-search-paths (package-native-search-paths gcc))
2880 (search-paths (package-search-paths gcc))
2882 (license (package-license gcc))
2883 (synopsis "Complete GCC tool chain for C/C++ development")
2885 "This package provides a complete GCC tool chain for C/C++ development to
2886 be installed in user profiles. This includes GCC, as well as libc (headers and
2887 binaries, plus debugging symbols in the @code{debug} output), and Binutils.")
2888 (home-page "https://gcc.gnu.org/")
2889 (outputs '("out" "debug" "static"))
2891 ;; The main raison d'être of this "meta-package" is (1) to conveniently
2892 ;; install everything that we need, and (2) to make sure ld-wrapper comes
2893 ;; before Binutils' ld in the user's profile.
2894 (inputs `(("gcc" ,gcc)
2895 ("ld-wrapper" ,(car (assoc-ref %final-inputs "ld-wrapper")))
2896 ("binutils" ,binutils-final)
2898 ("libc-debug" ,libc "debug")
2899 ("libc-static" ,libc "static"))))))
2901 (define-public gcc-toolchain
2902 (make-gcc-toolchain gcc-final))
2904 (define-public gcc-toolchain-4.8
2905 (make-gcc-toolchain gcc-4.8))
2907 (define-public gcc-toolchain-4.9
2908 (make-gcc-toolchain gcc-4.9))
2910 (define-public gcc-toolchain-5
2911 (make-gcc-toolchain gcc-5))
2913 (define-public gcc-toolchain-6
2914 (make-gcc-toolchain gcc-6))
2916 (define-public gcc-toolchain-7
2919 (define-public gcc-toolchain-8
2920 (make-gcc-toolchain gcc-8))
2922 (define-public gcc-toolchain-9
2923 (make-gcc-toolchain gcc-9))
2925 ;; Provide the Fortran toolchain package only for the version of gfortran that
2926 ;; is used by Guix internally to build Fortran libraries, because combining
2927 ;; code compiled with different versions can cause problems.
2929 (define-public gfortran-toolchain
2930 (package (inherit (make-gcc-toolchain gfortran))
2931 (synopsis "Complete GCC tool chain for Fortran development")
2932 (description "This package provides a complete GCC tool chain for
2933 Fortran development to be installed in user profiles. This includes
2934 gfortran, as well as libc (headers and binaries, plus debugging symbols
2935 in the @code{debug} output), and binutils.")))
2938 ;;; commencement.scm ends here