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)))
398 (uri (string-append "mirror://gnu/mes/"
399 "mes-" version ".tar.gz"))
402 "15h4yhaywdc0djpjlin2jz1kzahpqxfki0r0aav1qm9nxxmnp1l0"))))
404 (propagated-inputs '())
406 `(("mescc-tools" ,%bootstrap-mescc-tools)
407 ("nyacc-source" ,(bootstrap-origin
408 (package-source nyacc-0.86)))
410 ("coreutils" , %bootstrap-coreutils&co)
411 ("bootstrap-mes" ,%bootstrap-mes)))
413 `(#:implicit-inputs? #f
414 #:guile ,%bootstrap-guile
415 #:strip-binaries? #f ; binutil's strip b0rkes MesCC/M1/hex2 binaries
417 (modify-phases %standard-phases
418 (add-after 'unpack 'unpack-seeds
420 (let ((nyacc-source (assoc-ref %build-inputs "nyacc-source"))
421 (bootstrap-mes (assoc-ref %build-inputs "bootstrap-mes")))
422 (with-directory-excursion ".."
423 (mkdir-p "nyacc-source")
424 (invoke "tar" "--strip=1" "-C" "nyacc-source" "-xvf" nyacc-source)
425 (symlink (string-append bootstrap-mes "/share/mes/lib") "mes-seed"))
428 (lambda* (#:key outputs #:allow-other-keys)
429 (let ((out (assoc-ref %outputs "out")))
430 (setenv "GUILE" "mes")
431 (setenv "GUILE_EFFECTIVE_VERSION" "2.2")
432 (setenv "GUILE_LOAD_PATH" "nyacc")
433 (symlink (string-append "../nyacc-source/module") "nyacc")
434 (invoke "bash" "configure.sh"
435 (string-append "--prefix=" out)))))
438 (let ((mes (assoc-ref %build-inputs "bootstrap-mes")))
439 (setenv "MES_PREFIX" (string-append mes "/share/mes"))
440 (setenv "MES_ARENA" "100000000")
441 (setenv "MES_MAX_ARENA" "100000000")
442 (setenv "MES_STACK" "10000000")
443 (invoke "sh" "bootstrap.sh"))))
446 (setenv "DIFF" "sh scripts/diff.scm")
448 ;; (invoke "sh" "-x" "build-aux/test.sh" "scaffold/tests/t")
449 ;; (invoke "sh" "-x" "build-aux/test.sh" "scaffold/tests/63-struct-cell")
450 (invoke "sh" "check.sh")))
453 (invoke "sh" "install.sh"))))))
455 (list (search-path-specification
456 (variable "C_INCLUDE_PATH")
457 (files '("share/mes/include")))
458 (search-path-specification
459 (variable "LIBRARY_PATH")
460 (files '("share/mes/lib")))))))
463 ;; Pristine tcc cannot be built by MesCC, we are keeping a delta of 11
464 ;; patches. In a very early and rough form they were presented to the
465 ;; TinyCC developers, who at the time showed no interest in supporting the
466 ;; bootstrappable effort; we will try again later. These patches have been
467 ;; ported to 0.9.27, alas the resulting tcc is buggy. Once MesCC is more
468 ;; mature, this package should use the 0.9.27 sources (or later).
469 (let ((version "0.9.26")
471 (commit "c004e9a34fb026bb44d211ab98bb768e79900eef"))
475 (version (string-append version "-" revision "." (string-take commit 7)))
478 (uri (list (string-append "mirror://gnu/guix/mirror"
479 "/tinycc-" commit ".tar.gz")
480 (string-append "https://gitlab.com/janneke/tinycc"
482 "/tinycc-" commit ".tar.gz")))
485 "1hmzn1pq0x22ppd80hyrn5qzqq94mxd0ychzj6vrr2vnj2frjv5b"))))
486 (build-system gnu-build-system)
487 (supported-systems '("i686-linux" "x86_64-linux"))
489 (propagated-inputs '())
492 ("mescc-tools" ,%bootstrap-mescc-tools)
493 ("nyacc-source" ,(bootstrap-origin
494 (package-source nyacc-0.86)))
496 ("coreutils" , %bootstrap-coreutils&co)
497 ("bootstrap-mes" ,%bootstrap-mes)))
499 `(#:implicit-inputs? #f
500 #:guile ,%bootstrap-guile
501 #:strip-binaries? #f ; binutil's strip b0rkes MesCC/M1/hex2 binaries
503 (modify-phases %standard-phases
504 (add-after 'unpack 'unpack-seeds
505 (lambda* (#:key outputs #:allow-other-keys)
506 (let* ((coreutils (assoc-ref %build-inputs "coreutils"))
507 (nyacc-source (assoc-ref %build-inputs "nyacc-source"))
508 (bootstrap-mes (assoc-ref %build-inputs "bootstrap-mes")))
509 (setenv "PATH" (string-append
511 (format (current-error-port) "PATH=~s\n" (getenv "PATH"))
512 (with-directory-excursion ".."
513 (mkdir-p "nyacc-source")
514 (invoke "tar" "--strip=1" "-C" "nyacc-source"
516 (symlink (string-append bootstrap-mes "/share/mes/lib") "mes-seed"))
519 (lambda* (#:key outputs #:allow-other-keys)
520 (let* ((out (assoc-ref %outputs "out"))
521 (dir (with-directory-excursion ".." (getcwd)))
522 (coreutils (assoc-ref %build-inputs "coreutils"))
523 (mes (assoc-ref %build-inputs "mes"))
524 (mescc-tools (assoc-ref %build-inputs "mescc-tools"))
525 (libc (assoc-ref %build-inputs "libc"))
526 (interpreter (if libc
527 ;; also for x86_64-linux, we are still on i686-linux
528 (string-append libc ,(glibc-dynamic-linker "i686-linux"))
529 (string-append mes "/lib/mes-loader"))))
530 (setenv "PATH" (string-append
533 ":" mescc-tools "/bin"))
534 (format (current-error-port) "PATH=~s\n" (getenv "PATH"))
536 (setenv "PREFIX" out)
537 (symlink (string-append mes "/share/mes") "mes")
538 (symlink (string-append "../nyacc-source/module") "nyacc")
539 (setenv "MES_PREFIX" "mes")
540 (setenv "MES_ARENA" "100000000")
541 (setenv "MES_MAX_ARENA" "100000000")
542 (setenv "MES_STACK" "10000000")
544 (setenv "GUILE_LOAD_PATH" "nyacc")
545 (invoke "sh" "configure"
547 (string-append "--elfinterp=" interpreter)
552 (substitute* "bootstrap.sh"
554 (invoke "sh" "bootstrap.sh")))
557 (setenv "DIFF" "diff.scm")
558 (setenv "OBJDUMP" "true")
560 ;; (invoke "sh" "test.sh" "mes/scaffold/tests/30-strlen")
561 ;; (invoke "sh" "-x" "test.sh" "mes/scaffold/tinycc/00_assignment")
562 (setenv "TCC" "./tcc")
563 (invoke "sh" "check.sh")))
566 (invoke "sh" "install.sh"))))))
568 (list (search-path-specification
569 (variable "C_INCLUDE_PATH")
570 (files '("include")))
571 (search-path-specification
572 (variable "LIBRARY_PATH")
573 (files '("lib"))))))))
580 (source (bootstrap-origin
582 (inherit (package-source tcc))
583 (patches (search-patches "tcc-boot-0.9.27.patch")))))
584 (build-system gnu-build-system)
586 (propagated-inputs '())
591 ("coreutils" , %bootstrap-coreutils&co)))
593 `(#:implicit-inputs? #f
594 #:guile ,%bootstrap-guile
596 ;; Binutils' 'strip' b0rkes MesCC/M1/hex2 binaries, tcc-boot also comes
597 ;; with MesCC/M1/hex2-built binaries.
601 (modify-phases %standard-phases
603 (lambda* (#:key outputs #:allow-other-keys)
604 (let* ((out (assoc-ref %outputs "out"))
605 (coreutils (assoc-ref %build-inputs "coreutils"))
606 (mes (assoc-ref %build-inputs "mes"))
607 (tcc (assoc-ref %build-inputs "tcc"))
608 (libc (assoc-ref %build-inputs "libc"))
609 (interpreter (if libc
610 ;; also for x86_64-linux, we are still on i686-linux
611 (string-append libc ,(glibc-dynamic-linker "i686-linux"))
612 (string-append mes "/lib/mes-loader"))))
614 (setenv "PATH" (string-append
617 (format (current-error-port) "PATH=~s\n" (getenv "PATH"))
618 (invoke "sh" "configure"
619 (string-append "--cc=tcc")
620 (string-append "--cpu=i386")
621 (string-append "--prefix=" out)
622 (string-append "--elfinterp=" interpreter)
623 (string-append "--crtprefix=" tcc "/lib")
624 (string-append "--sysincludepaths=" tcc "/include")
625 (string-append "--libpaths=" tcc "/lib")))))
627 (lambda* (#:key outputs #:allow-other-keys)
628 (let* ((out (assoc-ref %outputs "out"))
629 (mes (assoc-ref %build-inputs "mes"))
630 (tcc (assoc-ref %build-inputs "tcc"))
631 (libc (assoc-ref %build-inputs "libc"))
632 (interpreter (if libc
633 ;; also for x86_64-linux, we are still on i686-linux
634 (string-append libc ,(glibc-dynamic-linker "i686-linux"))
635 (string-append mes "/lib/mes-loader"))))
640 "-D" "TCC_TARGET_I386=1"
641 "-D" "CONFIG_TCC_STATIC=1"
642 "-D" "CONFIG_USE_LIBGCC=1"
643 "-D" (string-append "CONFIG_TCCDIR=\"" out "/lib/tcc\"")
644 "-D" (string-append "CONFIG_TCC_CRTPREFIX=\"" out "/lib:{B}/lib:.\"")
645 "-D" (string-append "CONFIG_TCC_CRTPREFIX=\"" out
647 "-D" (string-append "CONFIG_TCC_ELFINTERP=\"" interpreter "\"")
648 "-D" (string-append "CONFIG_TCC_LIBPATHS=\"" tcc "/lib:{B}/lib:.\"")
649 "-D" (string-append "CONFIG_TCC_SYSINCLUDEPATHS=\"" tcc "/include" ":/include:{B}/include\"")
650 "-D" (string-append "TCC_LIBGCC=\"" tcc "/lib/libc.a\"")
655 ;; FIXME: add sensible check target (without depending on make)
657 (= 1 (status:exit-val (system* "./tcc" "--help")))))
659 (lambda* (#:key outputs #:allow-other-keys)
660 (let ((out (assoc-ref %outputs "out"))
661 (tcc (assoc-ref %build-inputs "tcc")))
662 (mkdir-p (string-append out "/bin"))
663 (copy-file "tcc" (string-append out "/bin/tcc"))
664 (mkdir-p (string-append out "/lib/tcc"))
665 (copy-recursively (string-append tcc "/include")
666 (string-append out "/include"))
667 (copy-recursively (string-append tcc "/lib")
668 (string-append out "/lib"))
669 (invoke "tcc" "-D" "TCC_TARGET_I386=1" "-c" "-o" "libtcc1.o" "lib/libtcc1.c")
670 (invoke "tcc" "-ar" "rc" "libtcc1.a" "libtcc1.o")
671 (copy-file "libtcc1.a" (string-append out "/lib/libtcc1.a"))
672 (delete-file (string-append out "/lib/tcc/libtcc1.a"))
673 (copy-file "libtcc1.a" (string-append out "/lib/tcc/libtcc1.a"))
676 (define make-mesboot0
679 (name "make-mesboot0")
683 (uri (string-append "mirror://gnu/make/make-"
687 "1pb7fb7fqf9wz9najm85qdma1xhxzf1rhj5gwrlzdsz2zm0hpcv4"))))
688 (supported-systems '("i686-linux" "x86_64-linux"))
690 (propagated-inputs '())
691 (native-inputs `(("tcc" ,tcc-boot)
693 ("bash" ,%bootstrap-coreutils&co)
694 ("coreutils" ,%bootstrap-coreutils&co)))
696 `(#:implicit-inputs? #f
697 #:tests? #f ; check depends on perl
698 #:guile ,%bootstrap-guile
699 #:configure-flags `("CC=tcc -DO_RDONLY=0"
703 (modify-phases %standard-phases
704 (add-after 'configure 'configure-fixup
706 (substitute* "build.sh"
707 (("^REMOTE=.*") "REMOTE=stub\n")
708 (("^extras=.*") "extras=getloadavg.c\n"))
709 (substitute* "make.h"
710 (("^extern long int lseek.*" all) (string-append "// " all)))
712 (delete 'patch-generated-file-shebangs) ; no perl
715 (invoke "sh" "./build.sh")))
717 (lambda* (#:key outputs #:allow-other-keys)
718 (let* ((out (assoc-ref outputs "out"))
719 (bin (string-append out "/bin")))
720 (install-file "make" bin)
723 (define diffutils-mesboot
726 (name "diffutils-mesboot")
730 (uri (string-append "mirror://gnu/diffutils/diffutils-"
734 "1mirn5i825bn5w7rh6mgn0r8aj9xqanav95dwcl1b8sn82f4iwnm"))))
735 (supported-systems '("i686-linux" "x86_64-linux"))
737 (propagated-inputs '())
738 (native-inputs `(("mes" ,mes-boot)
741 ("bash" ,%bootstrap-coreutils&co)
742 ("coreutils" ,%bootstrap-coreutils&co)
743 ("make" ,make-mesboot0)))
745 `(#:implicit-inputs? #f
746 #:guile ,%bootstrap-guile
748 #:tests? #f ; check is naive, also checks non-built PROGRAMS
749 #:strip-binaries? #f ; no strip yet
751 (modify-phases %standard-phases
752 ;; diffutils-2.7 needs more traditional configure
754 (lambda* (#:key outputs #:allow-other-keys)
755 (let ((out (assoc-ref outputs "out"))
756 (bash (assoc-ref %build-inputs "bash")))
757 (setenv "CONFIG_SHELL" (string-append bash "/bin/sh"))
760 (invoke "./configure" (string-append "--prefix=" out)))))
761 (add-before 'configure 'remove-diff3-sdiff
762 (lambda* (#:key outputs #:allow-other-keys)
763 (substitute* "Makefile.in"
764 (("PROGRAMS = .*" all) "PROGRAMS = cmp diff"))
767 (define binutils-mesboot0
770 (name "binutils-mesboot0")
772 (source (bootstrap-origin
775 (uri (string-append "mirror://gnu/binutils/binutils-"
777 (patches (search-patches "binutils-boot-2.20.1a.patch"))
780 "0r7dr0brfpchh5ic0z9r4yxqn4ybzmlh25sbp30cacqk8nb7rlvi")))))
782 (propagated-inputs '())
783 (native-inputs `(("tcc" ,tcc-boot)
785 ("bash" ,%bootstrap-coreutils&co)
786 ("coreutils" ,%bootstrap-coreutils&co)
787 ("diffutils" ,diffutils-mesboot)
788 ("make" ,make-mesboot0)))
789 (supported-systems '("i686-linux" "x86_64-linux"))
791 `(#:implicit-inputs? #f
792 #:guile ,%bootstrap-guile
793 #:tests? #f ; runtest: command not found
795 #:strip-binaries? #f ; no strip yet
797 (let ((cppflags (string-append " -D __GLIBC_MINOR__=6"
798 " -D MES_BOOTSTRAP=1"))
799 (bash (assoc-ref %build-inputs "bash")))
800 `(,(string-append "CONFIG_SHELL=" bash "/bin/sh")
801 ,(string-append "CPPFLAGS=" cppflags)
805 ,(string-append "CC=tcc" cppflags)
809 "--build=i686-unknown-linux-gnu"
810 "--host=i686-unknown-linux-gnu"
811 "--with-sysroot=/"))))))
813 (define gcc-core-mesboot
814 ;; Gcc-2.95.3 is the most recent GCC that is supported by what the Mes C
815 ;; Library v0.16 offers. Gcc-3.x (and 4.x) place higher demands on a C
816 ;; library, such as dir.h/struct DIR/readdir, locales, signals... Also,
817 ;; with gcc-2.95.3, binutils-boot-2.20.1a and glibc-2.2.5 we found a GNU
818 ;; toolchain triplet "that works".
821 (name "gcc-core-mesboot")
823 (source (bootstrap-origin
826 (uri (string-append "mirror://gnu/gcc/gcc-2.95.3/gcc-core-"
829 (patches (search-patches "gcc-boot-2.95.3.patch"))
832 "1xvfy4pqhrd5v2cv8lzf63iqg92k09g6z9n2ah6ndd4h17k1x0an")))))
833 (supported-systems '("i686-linux" "x86_64-linux"))
835 (propagated-inputs '())
836 (native-inputs `(("binutils" ,binutils-mesboot0)
839 ("bash" ,%bootstrap-coreutils&co)
840 ("coreutils" ,%bootstrap-coreutils&co)
841 ("diffutils" ,diffutils-mesboot)
842 ("make" ,make-mesboot0)))
845 `(#:implicit-inputs? #f
846 #:guile ,%bootstrap-guile
851 (let ((out (assoc-ref %outputs "out")))
855 "--build=i686-unknown-linux-gnu"
856 "--host=i686-unknown-linux-gnu"
857 ,(string-append "--prefix=" out)))
859 "CC=tcc -static -D __GLIBC_MINOR__=6"
860 "OLDCC=tcc -static -D __GLIBC_MINOR__=6"
861 "CC_FOR_BUILD=tcc -static -D __GLIBC_MINOR__=6"
864 (string-append "LIBGCC2_INCLUDES=-I "
865 (assoc-ref %build-inputs "tcc")
868 (string-append "BOOT_LDFLAGS="
869 " -B" (assoc-ref %build-inputs "tcc")
871 #:modules ((guix build gnu-build-system)
875 (modify-phases %standard-phases
876 ;; gcc-2.95.3 needs more traditional configure
877 (add-before 'configure 'setenv
878 (lambda* (#:key outputs #:allow-other-keys)
879 (let ((out (assoc-ref outputs "out"))
880 (bash (assoc-ref %build-inputs "bash"))
881 (tcc (assoc-ref %build-inputs "tcc"))
882 (cppflags " -D __GLIBC_MINOR__=6"))
883 (setenv "CONFIG_SHELL" (string-append bash "/bin/sh"))
884 (setenv "CPPFLAGS" cppflags)
885 (setenv "CC" (string-append "tcc" cppflags))
886 (setenv "CC_FOR_BUILD" (string-append "tcc" cppflags))
887 (setenv "CPP" (string-append "tcc -E" cppflags))
888 (with-output-to-file "config.cache"
891 ac_cv_c_float_format='IEEE (little-endian)'
895 (lambda* (#:key configure-flags #:allow-other-keys)
896 (format (current-error-port)
897 "running ./configure ~a\n" (string-join configure-flags))
898 (apply invoke "./configure" configure-flags)))
899 (add-after 'configure 'remove-info
901 ;; no info at this stage
902 (delete-file-recursively "texinfo")
903 (invoke "touch" "gcc/cpp.info" "gcc/gcc.info")))
904 (add-after 'install 'install2
905 (lambda* (#:key outputs #:allow-other-keys)
906 (let* ((tcc (assoc-ref %build-inputs "tcc"))
907 (tcc-lib (string-append tcc "/lib/x86-mes-gcc"))
908 (out (assoc-ref outputs "out"))
909 (gcc-dir (string-append
910 out "/lib/gcc-lib/i686-unknown-linux-gnu/2.95.3")))
912 (zero? (system (string-append "set -x; cd tmp && ar x ../gcc/libgcc2.a")))
913 (zero? (system (string-append "set -x; cd tmp && ar r " gcc-dir "/libgcc.a *.o")))
914 (copy-file "gcc/libgcc2.a" (string-append out "/lib/libgcc2.a"))
915 (copy-file (string-append tcc "/lib/libtcc1.a")
916 (string-append out "/lib/libtcc1.a"))
917 (invoke "ar" "r" (string-append gcc-dir "/libc.a")
918 (string-append tcc-lib "/libc+gnu.o")
919 (string-append tcc-lib "/libtcc1.o"))
920 (invoke "ar" "r" (string-append out "/lib/libc.a")
921 (string-append tcc-lib "/libc+gnu.o")
922 (string-append tcc-lib "/libtcc1.o"))
923 (invoke "ls" "-ltrF" gcc-dir)
926 (list (search-path-specification
927 (variable "C_INCLUDE_PATH")
930 ;; Needed to get things like GCC's <stddef.h>.
931 "lib/gcc-lib/i686-unknown-linux-gnu/2.95.3/include")))
932 (search-path-specification
933 (variable "LIBRARY_PATH")
934 (files '("lib")))))))
936 (define mesboot-headers
939 (name "mesboot-headers")
940 (supported-systems '("i686-linux" "x86_64-linux"))
942 (propagated-inputs '())
943 (native-inputs `(("coreutils" ,%bootstrap-coreutils&co)
944 ("headers" ,%bootstrap-linux-libre-headers)))
946 `(#:implicit-inputs? #f
947 #:guile ,%bootstrap-guile
951 (modify-phases %standard-phases
955 (lambda* (#:key outputs #:allow-other-keys)
956 (let* ((out (assoc-ref outputs "out"))
957 (include (string-append out "/include"))
958 (headers (assoc-ref %build-inputs "headers" )))
960 (copy-recursively "include" out)
961 (copy-recursively headers out)
964 (define glibc-mesboot0
965 ;; GNU C Library 2.2.5 is the most recent glibc that we managed to build
966 ;; using gcc-2.95.3. Newer versions (2.3.x, 2.6, 2.1x) seem to need a newer
970 (name "glibc-mesboot0")
972 (source (bootstrap-origin
975 (uri (string-append "mirror://gnu/glibc/glibc-"
978 (patches (search-patches "glibc-boot-2.2.5.patch"))
981 "1vl48i16gx6h68whjyhgnn1s57vqq32f9ygfa2fls7pdkbsqvp2q")))))
982 (supported-systems '("i686-linux" "x86_64-linux"))
984 (propagated-inputs '())
985 (native-inputs `(("binutils" ,binutils-mesboot0)
986 ("gcc" ,gcc-core-mesboot)
988 ("bash" ,%bootstrap-coreutils&co)
989 ("coreutils" ,%bootstrap-coreutils&co)
990 ("diffutils" ,diffutils-mesboot)
991 ("headers" ,mesboot-headers)
992 ("make" ,make-mesboot0)))
995 `(#:implicit-inputs? #f
996 #:guile ,%bootstrap-guile
999 #:parallel-build? #f ; gcc-2.95.3 ICEs on massively parallel builds
1000 #:make-flags (list (string-append
1002 (assoc-ref %build-inputs "bash")
1005 (let ((out (assoc-ref %outputs "out"))
1006 (headers (assoc-ref %build-inputs "headers")))
1010 "--disable-sanity-checks"
1011 "--build=i686-unknown-linux-gnu"
1012 "--host=i686-unknown-linux-gnu"
1013 (string-append "--with-headers=" headers "/include")
1014 "--enable-static-nss"
1015 "--without-__thread"
1019 (string-append "--prefix=" out)))
1021 (modify-phases %standard-phases
1022 (add-before 'configure 'setenv
1023 (lambda* (#:key outputs #:allow-other-keys)
1024 (let* ((out (assoc-ref outputs "out"))
1025 (bash (assoc-ref %build-inputs "bash"))
1026 (gcc (assoc-ref %build-inputs "gcc"))
1027 (headers (assoc-ref %build-inputs "headers"))
1028 (cppflags (string-append
1030 " -D MES_BOOTSTRAP=1"
1031 " -D BOOTSTRAP_GLIBC=1"))
1032 (cflags (string-append " -L " (getcwd))))
1033 (setenv "CONFIG_SHELL" (string-append bash "/bin/sh"))
1034 (setenv "SHELL" (getenv "CONFIG_SHELL"))
1035 (setenv "CPP" (string-append gcc "/bin/gcc -E " cppflags))
1036 (setenv "CC" (string-append gcc "/bin/gcc " cppflags cflags))
1038 ;; glibc-2.2.5 needs a more classic invocation of configure
1039 ;; configure: warning: CONFIG_SHELL=/gnu/store/…-bash-minimal-4.4.12/bin/bash: invalid host type
1041 (lambda* (#:key configure-flags #:allow-other-keys)
1042 (format (current-error-port)
1043 "running ./configure ~a\n" (string-join configure-flags))
1044 (apply invoke "./configure" configure-flags))))))))
1046 (define gcc-mesboot0
1048 (inherit gcc-core-mesboot)
1049 (name "gcc-mesboot0")
1050 (native-inputs `(("binutils" ,binutils-mesboot0)
1052 ;; Packages are given in an order that's relevant for
1053 ;; #include_next purposes.
1054 ("libc" ,glibc-mesboot0)
1055 ("kernel-headers" ,%bootstrap-linux-libre-headers)
1056 ("gcc" ,gcc-core-mesboot)
1058 ("bash" ,%bootstrap-coreutils&co)
1059 ("coreutils" ,%bootstrap-coreutils&co)
1060 ("diffutils" ,diffutils-mesboot)
1061 ("make" ,make-mesboot0)))
1063 (substitute-keyword-arguments (package-arguments gcc-core-mesboot)
1065 `(modify-phases ,phases
1068 (setenv "CONFIG_SHELL" (which "sh"))
1069 (with-output-to-file "config.cache"
1072 ac_cv_c_float_format='IEEE (little-endian)'
1076 (lambda* (#:key outputs #:allow-other-keys)
1077 (let* ((out (assoc-ref outputs "out"))
1078 (gcc-dir (string-append
1079 out "/lib/gcc-lib/i686-unknown-linux-gnu/2.95.3")))
1081 (zero? (system (string-append "set -x; cd tmp && ar x ../gcc/libgcc2.a")))
1082 (zero? (system (string-append "set -x; cd tmp && ar r " gcc-dir "/libgcc.a *.o")))
1083 (copy-file "gcc/libgcc2.a" (string-append out "/lib/libgcc2.a"))
1085 ((#:configure-flags configure-flags)
1086 `(let ((out (assoc-ref %outputs "out")))
1087 `("--disable-shared"
1089 "--build=i686-unknown-linux-gnu"
1090 "--host=i686-unknown-linux-gnu"
1091 ,(string-append "--prefix=" out))))
1092 ((#:make-flags make-flags)
1093 `(let ((gcc (assoc-ref %build-inputs "gcc")))
1095 ,(string-append "LIBGCC2_INCLUDES=-I " gcc "/include")
1096 "LANGUAGES=c")))))))
1098 (define binutils-mesboot
1100 (inherit binutils-mesboot0)
1101 (name "binutils-mesboot")
1102 (native-inputs `(("binutils" ,binutils-mesboot0)
1103 ("libc" ,glibc-mesboot0)
1104 ("gcc" ,gcc-mesboot0)
1106 ("bash" ,%bootstrap-coreutils&co)
1107 ("coreutils" ,%bootstrap-coreutils&co)
1108 ("diffutils" ,diffutils-mesboot)
1109 ("kernel-headers" ,%bootstrap-linux-libre-headers)
1110 ("make" ,make-mesboot0)))
1112 (substitute-keyword-arguments (package-arguments binutils-mesboot0)
1113 ((#:configure-flags configure-flags)
1114 '(list "--disable-nls"
1117 "--build=i686-unknown-linux-gnu"
1118 "--host=i686-unknown-linux-gnu"
1119 "--with-sysroot=/"))))))
1121 (define make-mesboot
1123 (inherit make-mesboot0)
1124 (name "make-mesboot")
1128 (uri (string-append "mirror://gnu/make/make-"
1132 "1rs2f9hmvy3q6zkl15jnlmnpgffm0bhw5ax0h5c7q604wqrip69x"))))
1133 (native-inputs `(("binutils" ,binutils-mesboot0)
1134 ("libc" ,glibc-mesboot0)
1135 ("gcc" ,gcc-mesboot0)
1136 ("make" ,make-mesboot0)
1138 ("bash" ,%bootstrap-coreutils&co)
1139 ("coreutils" ,%bootstrap-coreutils&co)
1140 ("kernel-headers" ,%bootstrap-linux-libre-headers)))
1142 (substitute-keyword-arguments (package-arguments make-mesboot0)
1143 ((#:configure-flags configure-flags)
1144 `(let ((out (assoc-ref %outputs "out")))
1145 `(,(string-append "--prefix=" out))))
1147 `(modify-phases ,phases
1148 (delete 'configure-fixup)
1149 (add-before 'configure 'setenv
1151 (setenv "LIBS" "-lc -lnss_files -lnss_dns -lresolv")
1160 (uri (string-append "mirror://gnu/gmp/gmp-" version
1163 "15rwq54fi3s11izas6g985y9jklm3xprfsmym3v1g6xr84bavqvv"))))))
1171 (uri (string-append "mirror://gnu/mpfr/mpfr-" version
1174 "0dxn4904dra50xa22hi047lj8kkpr41d6vb9sd4grca880c7wv94"))))))
1183 "mirror://gnu/mpc/mpc-" version ".tar.gz"))
1186 "1hzci2zrrd7v3g1jk35qindq05hbl0bhjcyyisq9z209xb3fqzb1"))))))
1188 (define gcc-mesboot1
1190 (inherit gcc-mesboot0)
1191 (name "gcc-mesboot1")
1192 (version (package-version gcc-4.7))
1193 (source (bootstrap-origin
1194 (origin (inherit (package-source gcc-4.7))
1195 (patches (search-patches "gcc-boot-4.7.4.patch")))))
1196 (inputs `(("gmp-source" ,(package-source gmp-boot))
1197 ("mpfr-source" ,(package-source mpfr-boot))
1198 ("mpc-source" ,(package-source mpc-boot))))
1199 (native-inputs `(("binutils" ,binutils-mesboot)
1201 ("libc" ,glibc-mesboot0)
1202 ("kernel-headers" ,%bootstrap-linux-libre-headers)
1203 ("gcc" ,gcc-mesboot0)
1205 ("bash" ,%bootstrap-coreutils&co)
1206 ("coreutils" ,%bootstrap-coreutils&co)
1207 ("diffutils" ,diffutils-mesboot)
1208 ("make" ,make-mesboot)))
1210 (substitute-keyword-arguments (package-arguments gcc-core-mesboot)
1211 ((#:make-flags make-flags)
1212 `(let* ((libc (assoc-ref %build-inputs "libc"))
1213 (ldflags (string-append
1215 "-Wl,-dynamic-linker "
1217 ,(glibc-dynamic-linker "i686-linux"))))
1218 (list (string-append "LDFLAGS=" ldflags)
1219 (string-append "LDFLAGS_FOR_TARGET=" ldflags))))
1221 `(modify-phases ,phases
1222 ;; c&p from commencement.scm:gcc-boot0
1223 (add-after 'unpack 'unpack-gmp&co
1224 (lambda* (#:key inputs #:allow-other-keys)
1225 (let ((gmp (assoc-ref %build-inputs "gmp-source"))
1226 (mpfr (assoc-ref %build-inputs "mpfr-source"))
1227 (mpc (assoc-ref %build-inputs "mpc-source")))
1229 ;; To reduce the set of pre-built bootstrap inputs, build
1230 ;; GMP & co. from GCC.
1231 (for-each (lambda (source)
1232 (or (invoke "tar" "xvf" source)
1233 (error "failed to unpack tarball"
1235 (list gmp mpfr mpc))
1237 ;; Create symlinks like `gmp' -> `gmp-x.y.z'.
1238 ,@(map (lambda (lib)
1239 ;; Drop trailing letters, as gmp-6.0.0a unpacks
1241 `(symlink ,(string-trim-right
1242 (package-full-name lib "-")
1244 ,(package-name lib)))
1245 (list gmp-boot mpfr-boot mpc-boot))
1247 (delete 'remove-info)
1250 (setenv "CONFIG_SHELL" (which "sh"))
1252 ;; Allow MPFR headers to be found.
1253 (setenv "C_INCLUDE_PATH"
1254 (string-append (getcwd) "/mpfr/src:"
1255 (getenv "C_INCLUDE_PATH")))
1257 ;; Set the C++ search path so that C headers can be found as
1258 ;; libstdc++ is being compiled.
1259 (setenv "CPLUS_INCLUDE_PATH" (getenv "C_INCLUDE_PATH"))
1261 (delete 'install2)))
1262 ((#:configure-flags configure-flags)
1263 `(let ((out (assoc-ref %outputs "out"))
1264 (glibc (assoc-ref %build-inputs "libc")))
1265 (list (string-append "--prefix=" out)
1266 "--build=i686-unknown-linux-gnu"
1267 "--host=i686-unknown-linux-gnu"
1269 (string-append "--with-native-system-header-dir=" glibc "/include")
1270 (string-append "--with-build-sysroot=" glibc "/include")
1272 "--disable-bootstrap"
1273 "--disable-decimal-float"
1274 "--disable-libatomic"
1275 "--disable-libcilkrts"
1278 "--disable-libmudflap"
1279 "--disable-libquadmath"
1280 "--disable-libsanitizer"
1284 "--disable-lto-plugin"
1285 "--disable-multilib"
1288 "--enable-languages=c,c++"
1291 ;; libstdc++.so: error: depends on 'libgcc_s.so.1', which cannot be found in RUNPATH ()
1293 "--enable-threads=single"
1295 ;; No pre-compiled libstdc++ headers, to save space.
1296 "--disable-libstdcxx-pch"
1299 "--disable-build-with-cxx")))))))
1301 (define gcc-mesboot1-wrapper
1302 ;; We need this so gcc-mesboot1 can be used to create shared binaries that
1303 ;; have the correct interpreter, otherwise configuring gcc-mesboot using
1304 ;; --enable-shared will fail.
1306 (inherit gcc-mesboot1)
1307 (name "gcc-mesboot1-wrapper")
1310 (native-inputs `(("bash" ,%bootstrap-coreutils&co)
1311 ("libc" ,glibc-mesboot)
1312 ("gcc" ,gcc-mesboot1)))
1314 `(#:implicit-inputs? #f
1315 #:guile ,%bootstrap-guile
1317 (modify-phases %standard-phases
1322 (lambda* (#:key outputs #:allow-other-keys)
1323 (let* ((out (assoc-ref outputs "out"))
1324 (bash (assoc-ref %build-inputs "bash"))
1325 (libc (assoc-ref %build-inputs "libc"))
1326 (gcc (assoc-ref %build-inputs "gcc"))
1327 (bin (string-append out "/bin")))
1331 (let ((wrapper (string-append bin "/" program)))
1332 (with-output-to-file wrapper
1334 (display (string-append "#! " bash "/bin/bash
1335 exec " gcc "/bin/" program
1336 " -Wl,--dynamic-linker"
1337 ;; also for x86_64-linux, we are still on i686-linux
1338 " -Wl," libc ,(glibc-dynamic-linker "i686-linux")
1343 (chmod wrapper #o555)))))
1347 "i686-unknown-linux-gnu-gcc"
1348 "i686-unknown-linux-gnu-g++"
1352 (lambda* (#:key outputs #:allow-other-keys)
1353 (let* ((out (assoc-ref outputs "out"))
1354 (bin (string-append out "/bin"))
1355 (program (string-append bin "/gcc")))
1356 (invoke program "--help")))))))))
1358 (define glibc-headers-mesboot
1360 (inherit glibc-mesboot0)
1361 (name "glibc-headers-mesboot")
1363 (source (bootstrap-origin
1366 (uri (string-append "mirror://gnu/glibc/glibc-"
1369 (patches (search-patches "glibc-boot-2.16.0.patch"
1370 "glibc-bootstrap-system-2.16.0.patch"))
1373 "0vlz4x6cgz7h54qq4528q526qlhnsjzbsvgc4iizn76cb0bfanx7")))))
1374 (native-inputs `(("binutils" ,binutils-mesboot)
1375 ("libc" ,glibc-mesboot0)
1376 ("gcc" ,gcc-mesboot1)
1377 ("headers" ,mesboot-headers)
1379 ("bash" ,%bootstrap-coreutils&co)
1380 ("coreutils" ,%bootstrap-coreutils&co)
1381 ("diffutils" ,diffutils-mesboot)
1382 ("kernel-headers" ,%bootstrap-linux-libre-headers)
1383 ("make" ,make-mesboot)))
1386 (substitute-keyword-arguments (package-arguments glibc-mesboot0)
1387 ((#:configure-flags configure-flags)
1388 `(let ((out (assoc-ref %outputs "out"))
1389 (headers (assoc-ref %build-inputs "headers")))
1391 (string-append "--prefix=" out)
1392 "--disable-obsolete-rpc"
1393 "--host=i686-unknown-linux-gnu"
1394 (string-append "--with-headers=" headers "/include")
1395 "--enable-static-nss"
1399 "--enable-add-ons=nptl")))
1400 ((#:make-flags make-flags)
1401 `(let ((bash (assoc-ref %build-inputs "bash")))
1402 (list (string-append "SHELL=" bash "/bin/sh")
1403 "install-bootstrap-headers=yes" "install-headers")))
1405 `(modify-phases ,phases
1407 (lambda* (#:key inputs #:allow-other-keys)
1408 (let* ((headers (assoc-ref inputs "headers"))
1409 (libc (assoc-ref inputs "libc"))
1410 (gcc (assoc-ref inputs "gcc"))
1411 (cppflags (string-append
1412 " -I " (getcwd) "/nptl/sysdeps/pthread/bits"
1413 " -D BOOTSTRAP_GLIBC=1"))
1414 (cflags (string-append " -L " (getcwd)
1415 " -L " libc "/lib")))
1416 (setenv "libc_cv_friendly_stddef" "yes")
1417 (setenv "CONFIG_SHELL" (which "sh"))
1418 (setenv "SHELL" (which "sh"))
1420 (setenv "CPP" (string-append gcc "/bin/gcc -E " cppflags))
1421 (setenv "CC" (string-append gcc "/bin/gcc " cppflags cflags))
1423 ;; avoid -fstack-protector
1424 (setenv "libc_cv_ssp" "false")
1425 (substitute* "configure"
1426 (("/bin/pwd") "pwd"))
1429 (lambda* (#:key outputs make-flags #:allow-other-keys)
1430 (let ((kernel-headers (assoc-ref %build-inputs "kernel-headers"))
1431 (out (assoc-ref outputs "out")))
1432 (apply invoke "make" make-flags)
1433 (copy-recursively kernel-headers out)
1436 (lambda* (#:key configure-flags #:allow-other-keys)
1437 (format (current-error-port) "running ../configure ~a\n" (string-join configure-flags))
1440 (apply invoke "../configure" configure-flags)))
1441 (add-after 'configure 'remove-sunrpc
1443 (invoke "make" (string-append (getcwd) "/sysd-sorted" )
1444 (string-append "SHELL=" (getenv "CONFIG_SHELL")))
1445 (substitute* "sysd-sorted"
1448 ;; 'rpcgen' needs native libc headers to be built.
1449 (substitute* "../Makefile"
1450 (("^SHELL := /bin/sh") (string-append "SHELL := " (getenv "CONFIG_SHELL"))))
1451 (substitute* "../Makeconfig"
1452 (("^SHELL := /bin/sh") (string-append "SHELL := " (getenv "CONFIG_SHELL"))))
1453 (substitute* "../elf/Makefile"
1454 (("^SHELL := /bin/sh") (string-append "SHELL := " (getenv "CONFIG_SHELL"))))))))))))
1456 (define glibc-mesboot
1458 (inherit glibc-headers-mesboot)
1459 (name "glibc-mesboot")
1460 (native-inputs `(("binutils" ,binutils-mesboot)
1461 ("libc" ,glibc-mesboot0)
1462 ("headers" ,glibc-headers-mesboot)
1463 ("gcc" ,gcc-mesboot1)
1465 ("bash" ,%bootstrap-coreutils&co)
1466 ("coreutils" ,%bootstrap-coreutils&co)
1467 ("diffutils" ,diffutils-mesboot)
1468 ("kernel-headers" ,%bootstrap-linux-libre-headers)
1469 ("make" ,make-mesboot)))
1472 `(#:validate-runpath? #f ; fails when using --enable-shared
1473 ,@(substitute-keyword-arguments (package-arguments glibc-headers-mesboot)
1474 ((#:make-flags make-flags)
1475 `(let ((bash (assoc-ref %build-inputs "bash")))
1476 (list (string-append "SHELL=" bash "/bin/sh"))))
1478 `(modify-phases ,phases
1480 (lambda* (#:key outputs make-flags #:allow-other-keys)
1481 (let* ((kernel-headers (assoc-ref %build-inputs "kernel-headers"))
1482 (out (assoc-ref outputs "out"))
1483 (install-flags (cons "install" make-flags)))
1484 (apply invoke "make" install-flags)
1485 (copy-recursively kernel-headers out)
1490 (inherit gcc-mesboot1)
1491 (name "gcc-mesboot")
1492 (version (package-version gcc-4.9))
1493 (source (bootstrap-origin (package-source gcc-4.9)))
1494 (native-inputs `(("binutils" ,binutils-mesboot)
1496 ("libc" ,glibc-mesboot)
1497 ("kernel-headers" ,%bootstrap-linux-libre-headers)
1498 ("gcc-wrapper" ,gcc-mesboot1-wrapper)
1499 ("gcc" ,gcc-mesboot1)
1501 ("bash" ,%bootstrap-coreutils&co)
1502 ("coreutils" ,%bootstrap-coreutils&co)
1503 ("diffutils" ,diffutils-mesboot)
1504 ("make" ,make-mesboot)))
1506 `(#:validate-runpath? #f
1507 ,@(substitute-keyword-arguments (package-arguments gcc-mesboot1)
1508 ((#:configure-flags configure-flags)
1509 `(let ((out (assoc-ref %outputs "out"))
1510 (glibc (assoc-ref %build-inputs "libc")))
1511 (list (string-append "--prefix=" out)
1512 "--build=i686-unknown-linux-gnu"
1513 "--host=i686-unknown-linux-gnu"
1515 "--with-host-libstdcxx=-lsupc++"
1517 (string-append "--with-native-system-header-dir=" glibc "/include")
1518 (string-append "--with-build-sysroot=" glibc "/include")
1520 "--disable-bootstrap"
1521 "--disable-decimal-float"
1522 "--disable-libatomic"
1523 "--disable-libcilkrts"
1526 "--disable-libmudflap"
1527 "--disable-libquadmath"
1528 "--disable-libsanitizer"
1532 "--disable-lto-plugin"
1533 "--disable-multilib"
1536 "--enable-languages=c,c++"
1540 "--enable-threads=single"
1542 ;; No pre-compiled libstdc++ headers, to save space.
1543 "--disable-libstdcxx-pch"
1546 "--disable-build-with-cxx"))))))))
1548 (define gcc-mesboot-wrapper
1549 ;; We need this so gcc-mesboot can be used to create shared binaries that
1550 ;; have the correct interpreter and runpath to libc.
1552 (inherit gcc-mesboot1-wrapper)
1553 (name "gcc-mesboot-wrapper")
1554 (version (package-version gcc-mesboot))
1557 (native-inputs `(("bash" ,%bootstrap-coreutils&co)
1558 ("libc" ,glibc-mesboot)
1559 ("gcc" ,gcc-mesboot)))))
1568 (uri (string-append "mirror://gnu/m4/m4-"
1572 "1f9bxj176kf3pvs350w2dfs8jgwhminywri5pyn01b11yc4yhsjw"))))
1573 (supported-systems '("i686-linux" "x86_64-linux"))
1574 (native-inputs `(("mes" ,mes-boot)
1578 (modify-phases %standard-phases
1580 (lambda* (#:key outputs #:allow-other-keys)
1581 (let ((out (assoc-ref outputs "out")))
1582 (setenv "CONFIG_SHELL" (string-append
1583 (assoc-ref %build-inputs "bash")
1585 (setenv "CC" "tcc -static")
1586 (setenv "CPP" "tcc -E")
1587 (invoke "./configure" (string-append "--prefix=" out))))))))))
1589 (define (%bootstrap-inputs+toolchain)
1590 ;; The traditional bootstrap-inputs. For the i686-linux Reduced Binary Seed
1591 ;; the actual reduced set with bootstrapped toolchain.
1592 (match (%current-system)
1593 ((or "i686-linux" "x86_64-linux")
1594 `(("libc" ,glibc-mesboot)
1595 ("binutils" ,binutils-mesboot)
1596 ("gcc-wrapper" ,gcc-mesboot-wrapper)
1597 ("gcc" ,gcc-mesboot)
1598 ,@(fold alist-delete (%bootstrap-inputs)
1599 '("bootstrap-mescc-tools" "mes"))))
1601 (%bootstrap-inputs))))
1603 (define gnu-make-boot0
1606 (source (bootstrap-origin (package-source gnu-make)))
1609 `(#:guile ,%bootstrap-guile
1610 #:implicit-inputs? #f
1611 #:tests? #f ; cannot run "make check"
1612 ,@(substitute-keyword-arguments (package-arguments gnu-make)
1613 ((#:configure-flags flags ''())
1614 ;; The generated config.status has some problems due to the
1615 ;; bootstrap environment. Disable dependency tracking to work
1617 `(cons "--disable-dependency-tracking" ,flags))
1619 `(modify-phases ,phases
1622 (invoke "./build.sh")))
1624 (lambda* (#:key outputs #:allow-other-keys)
1625 (let* ((out (assoc-ref outputs "out"))
1626 (bin (string-append out "/bin")))
1627 (install-file "make" bin)
1629 (native-inputs '()) ; no need for 'pkg-config'
1630 (inputs (%bootstrap-inputs+toolchain))))
1632 (define diffutils-boot0
1635 (name "diffutils-boot0")
1638 `(("make" ,gnu-make-boot0)
1639 ,@(%bootstrap-inputs+toolchain)))
1641 `(#:tests? #f ; the test suite needs diffutils
1642 #:guile ,%bootstrap-guile
1643 #:implicit-inputs? #f
1644 ,@(package-arguments diffutils)))))
1646 (define findutils-boot0
1649 (name "findutils-boot0")
1650 (source (bootstrap-origin (package-source findutils)))
1652 `(("make" ,gnu-make-boot0)
1653 ("diffutils" ,diffutils-boot0) ; for tests
1654 ,@(%bootstrap-inputs+toolchain)))
1656 `(#:implicit-inputs? #f
1657 #:guile ,%bootstrap-guile
1659 ;; The build system assumes we have done a mistake when time_t is 32-bit
1660 ;; on a 64-bit system. Ignore that for our bootstrap toolchain.
1661 ,@(if (target-64bit?)
1662 (substitute-keyword-arguments (package-arguments findutils)
1663 ((#:configure-flags flags ''())
1664 `(cons "TIME_T_32_BIT_OK=yes"
1666 (package-arguments findutils))))))
1671 (source (bootstrap-origin (package-source file)))
1674 `(("make" ,gnu-make-boot0)
1675 ,@(%bootstrap-inputs+toolchain)))
1677 `(#:implicit-inputs? #f
1678 #:guile ,%bootstrap-guile
1679 #:strip-binaries? #f
1680 #:validate-runpath? #f))))
1682 (define (%boot0-inputs)
1683 `(("make" ,gnu-make-boot0)
1684 ("diffutils" ,diffutils-boot0)
1685 ("findutils" ,findutils-boot0)
1686 ("file" ,file-boot0)
1687 ,@(%bootstrap-inputs+toolchain)))
1689 (define* (boot-triplet #:optional (system (%current-system)))
1690 ;; Return the triplet used to create the cross toolchain needed in the
1691 ;; first bootstrapping stage.
1692 (nix-system->gnu-triplet system "guix"))
1694 ;; Following Linux From Scratch, build a cross-toolchain in stage 0. That
1695 ;; toolchain actually targets the same OS and arch, but it has the advantage
1696 ;; of being independent of the libc and tools in
1697 ;; (%BOOTSTRAP-INPUTS+TOOLCHAIN), since GCC-BOOT0 (below) is built without any
1698 ;; reference to the target libc.
1700 (define binutils-boot0
1703 (source (bootstrap-origin (package-source binutils)))
1704 (name "binutils-cross-boot0")
1706 `(#:guile ,%bootstrap-guile
1707 #:implicit-inputs? #f
1709 #:modules ((guix build gnu-build-system)
1711 (ice-9 ftw)) ; for 'scandir'
1712 #:phases (modify-phases %standard-phases
1713 (add-after 'install 'add-symlinks
1714 (lambda* (#:key outputs #:allow-other-keys)
1715 ;; The cross-gcc invokes 'as', 'ld', etc, without the
1716 ;; triplet prefix, so add symlinks.
1717 (let ((out (assoc-ref outputs "out"))
1718 (triplet-prefix (string-append ,(boot-triplet) "-")))
1719 (define (has-triplet-prefix? name)
1720 (string-prefix? triplet-prefix name))
1721 (define (remove-triplet-prefix name)
1722 (substring name (string-length triplet-prefix)))
1723 (with-directory-excursion (string-append out "/bin")
1724 (for-each (lambda (name)
1725 (symlink name (remove-triplet-prefix name)))
1726 (scandir "." has-triplet-prefix?)))
1729 ,@(substitute-keyword-arguments (package-arguments binutils)
1730 ((#:configure-flags cf)
1731 `(cons ,(string-append "--target=" (boot-triplet))
1733 (inputs (%boot0-inputs))))
1735 (define libstdc++-boot0
1736 ;; GCC's libcc1 is always built as a shared library (the top-level
1737 ;; 'Makefile.def' forcefully adds --enable-shared) and thus needs to refer
1738 ;; to libstdc++.so. We cannot build libstdc++-5.3 because it relies on
1739 ;; C++14 features missing in some of our bootstrap compilers.
1740 (let ((lib (make-libstdc++ gcc-4.9)))
1743 (source (bootstrap-origin (package-source lib)))
1744 (name "libstdc++-boot0")
1746 `(#:guile ,%bootstrap-guile
1747 #:implicit-inputs? #f
1749 ;; XXX: libstdc++.so NEEDs ld.so for some reason.
1750 #:validate-runpath? #f
1752 ,@(match (%current-system)
1753 ((or "i686-linux" "x86_64-linux")
1754 (substitute-keyword-arguments (package-arguments lib)
1756 `(modify-phases ,phases
1757 (add-after 'unpack 'workaround-wrapper-bug
1758 ;; XXX: The crude gcc-cross-wrapper causes "g++ -v" to
1759 ;; fail, which in turn confuses the configure script.
1761 (substitute* "libstdc++-v3/configure"
1762 (("g\\+\\+ -v") "true"))
1764 (_ (package-arguments lib)))))
1765 (inputs (%boot0-inputs))
1766 (native-inputs '()))))
1771 (name "gcc-cross-boot0")
1772 (source (bootstrap-origin (package-source gcc)))
1774 `(#:guile ,%bootstrap-guile
1775 #:implicit-inputs? #f
1776 #:modules ((guix build gnu-build-system)
1781 ,@(substitute-keyword-arguments (package-arguments gcc)
1782 ((#:configure-flags flags)
1783 `(append (list ,(string-append "--target=" (boot-triplet))
1788 ;; Disable features not needed at this stage.
1790 "--enable-languages=c,c++"
1792 ;; libstdc++ cannot be built at this stage
1793 ;; ("Link tests are not allowed after
1794 ;; GCC_NO_EXECUTABLES.").
1795 "--disable-libstdc++-v3"
1798 "--disable-libmudflap"
1799 "--disable-libatomic"
1800 "--disable-libsanitizer"
1804 "--disable-libcilkrts"
1807 "--disable-libquadmath"
1808 "--disable-decimal-float")
1809 (remove (cut string-match
1810 "--(with-system-zlib|enable-languages.*)" <>)
1812 ((#:make-flags flags)
1813 `(let* ((libc (assoc-ref %build-inputs "libc"))
1814 (libc-native (or (assoc-ref %build-inputs "libc-native")
1816 `(,(string-append "LDFLAGS="
1817 "-Wl,-rpath=" libc-native "/lib "
1818 "-Wl,-dynamic-linker "
1819 "-Wl," libc-native ,(glibc-dynamic-linker
1820 (match (%current-system)
1821 ("x86_64-linux" "i686-linux")
1822 (_ (%current-system))))))))
1824 `(modify-phases ,phases
1825 (add-after 'unpack 'unpack-gmp&co
1826 (lambda* (#:key inputs #:allow-other-keys)
1827 (let ((gmp (assoc-ref %build-inputs "gmp-source"))
1828 (mpfr (assoc-ref %build-inputs "mpfr-source"))
1829 (mpc (assoc-ref %build-inputs "mpc-source")))
1831 ;; To reduce the set of pre-built bootstrap inputs, build
1832 ;; GMP & co. from GCC.
1833 (for-each (lambda (source)
1834 (invoke "tar" "xvf" source))
1835 (list gmp mpfr mpc))
1837 ;; Create symlinks like `gmp' -> `gmp-x.y.z'.
1838 ,@(map (lambda (lib)
1839 ;; Drop trailing letters, as gmp-6.0.0a unpacks
1841 `(symlink ,(string-trim-right
1842 (package-full-name lib "-")
1844 ,(package-name lib)))
1845 (list gmp-6.0 mpfr mpc))
1847 ,(match (%current-system)
1848 ((or "i686-linux" "x86_64-linux")
1849 '(add-before 'configure 'fix-libcc1
1850 (lambda* (#:key inputs #:allow-other-keys)
1851 ;; libcc1.so NEEDs libgcc_s.so, so provide one here
1852 ;; to placate the 'validate-runpath' phase.
1853 (substitute* "libcc1/Makefile.in"
1855 (string-append "la_LDFLAGS = -Wl,-rpath="
1856 (assoc-ref inputs "gcc") "/lib")))
1857 ;; XXX: "g++ -v" is broken (see also libstdc++ above).
1858 (substitute* "libcc1/configure"
1859 (("g\\+\\+ -v") "true"))
1861 (_ '(add-before 'configure 'return-true
1863 (add-after 'install 'symlink-libgcc_eh
1864 (lambda* (#:key outputs #:allow-other-keys)
1865 (let ((out (assoc-ref outputs "lib")))
1866 ;; Glibc wants to link against libgcc_eh, so provide
1868 (with-directory-excursion
1869 (string-append out "/lib/gcc/"
1871 "/" ,(package-version gcc))
1872 (symlink "libgcc.a" "libgcc_eh.a"))
1875 (inputs `(("gmp-source" ,(bootstrap-origin (package-source gmp-6.0)))
1876 ("mpfr-source" ,(bootstrap-origin (package-source mpfr)))
1877 ("mpc-source" ,(bootstrap-origin (package-source mpc)))
1878 ("binutils-cross" ,binutils-boot0)
1880 ;; The libstdc++ that libcc1 links against.
1881 ("libstdc++" ,libstdc++-boot0)
1883 ;; Call it differently so that the builder can check whether
1884 ;; the "libc" input is #f.
1885 ("libc-native" ,@(assoc-ref (%boot0-inputs) "libc"))
1886 ,@(alist-delete "libc" (%boot0-inputs))))
1888 ;; No need for the native-inputs to build the documentation at this stage.
1889 (native-inputs `())))
1895 (source (bootstrap-origin (package-source perl)))
1896 (inputs (%boot0-inputs))
1898 `(#:implicit-inputs? #f
1899 #:guile ,%bootstrap-guile
1900 #:validate-runpath? #f
1902 ;; At the very least, this must not depend on GCC & co.
1903 #:disallowed-references ,(list %bootstrap-binutils)
1905 ,@(substitute-keyword-arguments (package-arguments perl)
1907 `(modify-phases ,phases
1908 ;; Pthread support is missing in the bootstrap compiler
1909 ;; (broken spec file), so disable it.
1910 (add-before 'configure 'disable-pthreads
1912 (substitute* "Configure"
1913 (("^libswanted=(.*)pthread" _ before)
1914 (string-append "libswanted=" before)))
1916 ;; Do not configure with '-Dusethreads' since pthread
1917 ;; support is missing.
1918 ((#:configure-flags configure-flags)
1919 `(delete "-Dusethreads" ,configure-flags)))))))
1925 (source (bootstrap-origin (package-source m4)))
1926 (inputs (%boot0-inputs))
1928 `(#:guile ,%bootstrap-guile
1929 #:implicit-inputs? #f
1930 ,@(package-arguments m4)))))
1933 ;; This Bison is needed to build MiG so we need it early in the process.
1934 ;; Recent versions of Linux-Libre headers also depend on this.
1937 (name "bison-boot0")
1938 (propagated-inputs `(("m4" ,m4-boot0)))
1939 (native-inputs `(("perl" ,perl-boot0)))
1940 (inputs (%boot0-inputs)) ;remove Flex...
1942 `(#:tests? #f ;... and thus disable tests
1943 #:implicit-inputs? #f
1944 #:guile ,%bootstrap-guile
1946 ;; Zero timestamps in liby.a; this must be done
1947 ;; explicitly here because the bootstrap Binutils don't
1948 ;; do that (default is "cru".)
1949 #:make-flags `("ARFLAGS=crD"
1950 ,,(match (%current-system)
1951 ;; ranlib: '-D': No such file
1952 ((or "i686-linux" "x86_64-linux")
1955 "RANLIB=ranlib -D"))
1958 ,@(package-arguments bison)))))
1961 ;; This Flex is needed to build MiG as well as Linux-Libre headers.
1964 (native-inputs `(("bison" ,bison-boot0)))
1965 (propagated-inputs `(("m4" ,m4-boot0)))
1966 (inputs (%boot0-inputs))
1968 `(#:implicit-inputs? #f
1969 #:guile ,%bootstrap-guile
1975 (native-inputs `(("perl" ,perl-boot0)))
1976 (inputs (%boot0-inputs))
1978 `(#:implicit-inputs? #f
1979 #:guile ,%bootstrap-guile))))
1981 (define linux-libre-headers-boot0
1983 "Return Linux-Libre header files for the bootstrap environment."
1984 ;; Note: this is wrapped in a thunk to nicely handle circular dependencies
1985 ;; between (gnu packages linux) and this module. Additionally, memoize
1986 ;; the result to play well with further memoization and code that relies
1987 ;; on pointer identity; see <https://bugs.gnu.org/30155>.
1989 (inherit linux-libre-headers)
1991 `(#:guile ,%bootstrap-guile
1992 #:implicit-inputs? #f
1993 ,@(package-arguments linux-libre-headers)))
1995 `(("perl" ,perl-boot0)
1997 ;; Flex and Bison are required since version 4.16.
1998 ("flex" ,flex-boot0)
1999 ("bison" ,bison-boot0)
2001 ;; Rsync is required since version 5.3.
2002 ("rsync" ,rsync-boot0)
2003 ,@(%boot0-inputs))))))
2006 (package-with-explicit-inputs %boot0-inputs
2009 (define gnumach-headers-boot0
2010 (with-boot0 (package-with-bootstrap-guile gnumach-headers)))
2013 (let* ((mig (package
2014 (inherit (package-with-bootstrap-guile mig))
2015 (native-inputs `(("bison" ,bison-boot0)
2016 ("flex" ,flex-boot0)))
2017 (inputs `(("flex" ,flex-boot0)))
2020 `(,(string-append "LDFLAGS=-Wl,-rpath="
2021 (assoc-ref %build-inputs "flex") "/lib/")))))))
2024 (define hurd-headers-boot0
2025 (let ((hurd-headers (package (inherit hurd-headers)
2026 (native-inputs `(("mig" ,mig-boot0)))
2028 (with-boot0 (package-with-bootstrap-guile hurd-headers))))
2030 (define hurd-minimal-boot0
2031 (let ((hurd-minimal (package (inherit hurd-minimal)
2032 (native-inputs `(("mig" ,mig-boot0)))
2034 (with-boot0 (package-with-bootstrap-guile hurd-minimal))))
2036 (define hurd-core-headers-boot0
2038 "Return the Hurd and Mach headers as well as initial Hurd libraries for
2039 the bootstrap environment."
2040 (package (inherit (package-with-bootstrap-guile hurd-core-headers))
2041 (arguments `(#:guile ,%bootstrap-guile
2042 ,@(package-arguments hurd-core-headers)))
2044 `(("gnumach-headers" ,gnumach-headers-boot0)
2045 ("hurd-headers" ,hurd-headers-boot0)
2046 ("hurd-minimal" ,hurd-minimal-boot0)
2047 ,@(%boot0-inputs))))))
2049 (define* (kernel-headers-boot0 #:optional (system (%current-system)))
2051 ("i586-gnu" (hurd-core-headers-boot0))
2052 (_ (linux-libre-headers-boot0))))
2054 (define texinfo-boot0
2055 ;; Texinfo used to build libc's manual.
2056 ;; We build without ncurses because it fails to build at this stage, and
2057 ;; because we don't need the stand-alone Info reader.
2058 ;; Also, use (%BOOT0-INPUTS) to avoid building Perl once more.
2062 (inputs `(,@(%boot0-inputs)
2063 ("perl" ,perl-boot0)))
2065 `(#:implicit-inputs? #f
2066 #:guile ,%bootstrap-guile
2068 ;; Some of Texinfo 6.1's tests would fail with "Couldn't set UTF-8
2069 ;; character type in locale" but we don't have a UTF-8 locale at this
2070 ;; stage, so skip them.
2073 (define expat-sans-tests
2076 (inputs (%boot0-inputs))
2078 ;; XXX: Linking 'runtestscpp' fails with things like:
2080 ;; ld: Dwarf Error: found dwarf version '3789', this reader only handles version 2 and 3 information.
2082 ;; Skip tests altogether.
2083 `(#:implicit-inputs? #f
2084 #:guile ,%bootstrap-guile
2086 ,@(substitute-keyword-arguments (package-arguments expat)
2087 ((#:configure-flags flags ''())
2088 ;; Since we're not passing the right -Wl,-rpath flags, build the
2089 ;; static library to avoid RUNPATH validation failure.
2090 `(cons "--disable-shared" ,flags))
2091 ((#:tests? _ #f) #f))))))
2093 (define python-boot0
2095 (inherit python-minimal)
2096 ;; We cannot use Python 3.7 and later here, because they require
2097 ;; pthreads, which is missing on non-x86 platforms at this stage.
2098 ;; Python 3.6 technically supports being built without threading
2099 ;; support, but requires additional patches.
2101 (source (bootstrap-origin
2104 (uri (string-append "https://www.python.org/ftp/python/"
2105 version "/Python-" version ".tar.xz"))
2108 "0jdh9pvx6m6lfz2liwvvhn7vks7qrysqgwn517fkpxb77b33fjn2"))
2109 (modules '((guix build utils)))
2112 ;; Delete the bundled copy of libexpat.
2113 (delete-file-recursively "Modules/expat")
2114 (substitute* "Modules/Setup.dist"
2115 ;; Link Expat instead of embedding the bundled one.
2116 (("^#pyexpat.*") "pyexpat pyexpat.c -lexpat\n"))
2120 ("expat" ,expat-sans-tests))) ;remove OpenSSL, zlib, etc.
2121 (native-inputs '()) ;and pkg-config
2123 `(#:implicit-inputs? #f
2124 #:guile ,%bootstrap-guile
2126 ,@(substitute-keyword-arguments (package-arguments python-minimal)
2127 ;; Disable features that cannot be built at this stage.
2128 ((#:configure-flags _ ''())
2129 `(list "--without-ensurepip"
2130 "--without-threads"))
2131 ;; Clear #:make-flags, such that changes to the regular
2132 ;; Python package won't interfere with this one.
2133 ((#:make-flags _ ''()) ''())
2135 `(modify-phases ,phases
2136 (add-before 'configure 'disable-modules
2138 (substitute* "setup.py"
2139 ;; Disable ctypes, since it requires libffi.
2140 (("extensions\\.append\\(ctypes\\)") "")
2141 ;; Prevent the 'ossaudiodev' extension from being
2142 ;; built, since it requires Linux headers.
2145 (delete 'set-TZDIR)))
2146 ((#:tests? _ #f) #f))))))
2148 (define ld-wrapper-boot0
2150 ;; We need this so binaries on Hurd will have libmachuser and libhurduser
2151 ;; in their RUNPATH, otherwise validate-runpath will fail.
2152 (make-ld-wrapper "ld-wrapper-boot0"
2153 #:target boot-triplet
2154 #:binutils binutils-boot0
2155 #:guile %bootstrap-guile
2156 #:bash (car (assoc-ref (%boot0-inputs) "bash"))
2157 #:guile-for-build %bootstrap-guile)))
2159 (define (%boot1-inputs)
2160 ;; 2nd stage inputs.
2161 `(("gcc" ,gcc-boot0)
2162 ("ld-wrapper-cross" ,(ld-wrapper-boot0))
2163 ("binutils-cross" ,binutils-boot0)
2164 ,@(alist-delete "binutils" (%boot0-inputs))))
2166 (define glibc-final-with-bootstrap-bash
2167 ;; The final libc, "cross-built". If everything went well, the resulting
2168 ;; store path has no dependencies. Actually, the really-final libc is
2169 ;; built just below; the only difference is that this one uses the
2173 (name "glibc-intermediate")
2174 (source (bootstrap-origin (package-source glibc)))
2176 `(#:guile ,%bootstrap-guile
2177 #:implicit-inputs? #f
2179 ,@(substitute-keyword-arguments (package-arguments glibc)
2180 ((#:configure-flags flags)
2181 `(append (list ,(string-append "--host=" (boot-triplet))
2182 ,(string-append "--build="
2183 (nix-system->gnu-triplet)))
2186 `(modify-phases ,phases
2187 (add-before 'configure 'pre-configure
2188 (lambda* (#:key inputs #:allow-other-keys)
2189 ;; Don't clobber CPATH with the bootstrap libc.
2190 (setenv "NATIVE_CPATH" (getenv "CPATH"))
2193 ;; Tell 'libpthread' where to find 'libihash' on Hurd systems.
2194 ,@(if (hurd-triplet? (%current-system))
2195 `((substitute* "libpthread/Makefile"
2196 (("LDLIBS-pthread.so =.*")
2197 (string-append "LDLIBS-pthread.so = "
2198 (assoc-ref %build-inputs "kernel-headers")
2199 "/lib/libihash.a\n"))))
2202 ;; 'rpcgen' needs native libc headers to be built.
2203 (substitute* "sunrpc/Makefile"
2204 (("sunrpc-CPPFLAGS =.*" all)
2205 (string-append "CPATH = $(NATIVE_CPATH)\n"
2209 (propagated-inputs `(("kernel-headers" ,(kernel-headers-boot0))))
2211 `(("bison" ,bison-boot0)
2212 ("texinfo" ,texinfo-boot0)
2213 ("perl" ,perl-boot0)
2214 ("python" ,python-boot0)))
2216 `( ;; The boot inputs. That includes the bootstrap libc. We don't want
2217 ;; it in $CPATH, hence the 'pre-configure' phase above.
2220 ;; A native MiG is needed to build Glibc on Hurd.
2221 ,@(if (hurd-triplet? (%current-system))
2222 `(("mig" ,mig-boot0))
2225 ;; A native GCC is needed to build `cross-rpcgen'.
2226 ("native-gcc" ,@(assoc-ref (%boot0-inputs) "gcc"))
2228 ;; Here, we use the bootstrap Bash, which is not satisfactory
2229 ;; because we don't want to depend on bootstrap tools.
2230 ("static-bash" ,@(assoc-ref (%boot0-inputs) "bash"))))))
2232 (define (cross-gcc-wrapper gcc binutils glibc bash)
2233 "Return a wrapper for the pseudo-cross toolchain GCC/BINUTILS/GLIBC
2234 that makes it available under the native tool names."
2235 (package (inherit gcc)
2236 (name (string-append (package-name gcc) "-wrapped"))
2238 (build-system trivial-build-system)
2241 `(#:guile ,%bootstrap-guile
2242 #:modules ((guix build utils))
2244 (use-modules (guix build utils))
2246 (let* ((binutils (assoc-ref %build-inputs "binutils"))
2247 (gcc (assoc-ref %build-inputs "gcc"))
2248 (libc (assoc-ref %build-inputs "libc"))
2249 (bash (assoc-ref %build-inputs "bash"))
2250 (out (assoc-ref %outputs "out"))
2251 (bindir (string-append out "/bin"))
2252 (triplet ,(boot-triplet)))
2253 (define (wrap-program program)
2254 ;; GCC-BOOT0 is a libc-less cross-compiler, so it
2255 ;; needs to be told where to find the crt files and
2256 ;; the dynamic linker.
2257 (call-with-output-file program
2259 (format p "#!~a/bin/bash
2260 exec ~a/bin/~a-~a -B~a/lib -Wl,-dynamic-linker -Wl,~a/~a \"$@\"~%"
2264 ,(glibc-dynamic-linker))))
2266 (chmod program #o555))
2269 (with-directory-excursion bindir
2270 (for-each (lambda (tool)
2271 (symlink (string-append binutils "/bin/"
2275 (for-each wrap-program '("gcc" "g++")))
2279 `(("binutils" ,binutils)
2285 (define gcc-boot0-intermediate-wrapped
2287 ;; Make the cross-tools GCC-BOOT0 and BINUTILS-BOOT0 available under the
2289 (cross-gcc-wrapper gcc-boot0 binutils-boot0
2290 glibc-final-with-bootstrap-bash
2291 (car (assoc-ref (%boot1-inputs) "bash")))))
2293 (define static-bash-for-glibc
2294 ;; A statically-linked Bash to be used by GLIBC-FINAL in system(3) & co.
2296 (inherit static-bash)
2297 (source (bootstrap-origin (package-source static-bash)))
2298 (inputs `(("gcc" ,(gcc-boot0-intermediate-wrapped))
2299 ("libc" ,glibc-final-with-bootstrap-bash)
2300 ("libc:static" ,glibc-final-with-bootstrap-bash "static")
2301 ,@(fold alist-delete (%boot1-inputs)
2304 `(#:implicit-inputs? #f
2305 #:guile ,%bootstrap-guile
2307 ,@(substitute-keyword-arguments (package-arguments static-bash)
2308 ((#:configure-flags flags '())
2309 ;; Add a '-L' flag so that the pseudo-cross-ld of
2310 ;; BINUTILS-BOOT0 can find libc.a.
2312 (list (string-append "LDFLAGS=-static -L"
2313 (assoc-ref %build-inputs
2317 (define gettext-boot0
2318 ;; A minimal gettext used during bootstrap.
2320 (inherit gettext-minimal)
2321 (name "gettext-boot0")
2322 ;; Newer versions of GNU gettext depends on libxml2 and ncurses. To
2323 ;; simplify the dependency chain, we stick to this version here.
2324 (version "0.19.8.1")
2327 (uri (string-append "mirror://gnu/gettext/gettext-"
2331 "0hsw28f9q9xaggjlsdp2qmbp2rbd1mp0njzan2ld9kiqwkq2m57z"))))
2332 (inputs (%boot1-inputs)) ;zero dependencies
2334 `(#:implicit-inputs? #f
2335 #:guile ,%bootstrap-guile
2337 #:phases (modify-phases %standard-phases
2338 ;; Build only the tools.
2339 (add-after 'unpack 'chdir
2341 (chdir "gettext-tools")
2344 ;; Some test programs require pthreads, which we don't have.
2345 (add-before 'configure 'no-test-programs
2347 (substitute* "tests/Makefile.in"
2353 ;; The final glibc, which embeds the statically-linked Bash built above.
2354 ;; Use 'package/inherit' so we get the 'replacement' of 'glibc', if any.
2358 (source (bootstrap-origin (package-source glibc)))
2359 (inputs `(("static-bash" ,static-bash-for-glibc)
2362 (package-inputs glibc-final-with-bootstrap-bash))))
2364 ;; This time we need 'msgfmt' to install all the libc.mo files.
2365 (native-inputs `(,@(package-native-inputs glibc-final-with-bootstrap-bash)
2366 ("gettext" ,gettext-boot0)))
2369 (package-propagated-inputs glibc-final-with-bootstrap-bash))
2371 ;; The final libc only refers to itself, but the 'debug' output contains
2372 ;; references to GCC-BOOT0 and to the Linux headers. XXX: Would be great
2373 ;; if 'allowed-references' were per-output.
2375 `(#:allowed-references
2376 ,(cons* `(,gcc-boot0 "lib") (kernel-headers-boot0)
2377 static-bash-for-glibc
2378 (package-outputs glibc-final-with-bootstrap-bash))
2380 ,@(package-arguments glibc-final-with-bootstrap-bash)))))
2382 (define gcc-boot0-wrapped
2384 ;; Make the cross-tools GCC-BOOT0 and BINUTILS-BOOT0 available under the
2386 (cross-gcc-wrapper gcc-boot0 binutils-boot0 glibc-final
2387 (car (assoc-ref (%boot1-inputs) "bash")))))
2389 (define (%boot2-inputs)
2390 ;; 3rd stage inputs.
2391 `(("libc" ,glibc-final)
2392 ("libc:static" ,glibc-final "static")
2393 ("gcc" ,(gcc-boot0-wrapped))
2394 ,@(fold alist-delete (%boot1-inputs) '("libc" "gcc" "linux-libre-headers"))))
2396 (define binutils-final
2399 (source (bootstrap-origin (package-source binutils)))
2401 `(#:guile ,%bootstrap-guile
2402 #:implicit-inputs? #f
2403 #:allowed-references ("out" ,glibc-final)
2404 ,@(package-arguments binutils)))
2405 (inputs (%boot2-inputs))))
2408 ;; Intermediate libstdc++ that will allow us to build the final GCC
2409 ;; (remember that GCC-BOOT0 cannot build libstdc++.)
2410 (let ((lib (make-libstdc++ gcc)))
2413 (source (bootstrap-origin (package-source lib)))
2415 `(#:guile ,%bootstrap-guile
2416 #:implicit-inputs? #f
2417 #:allowed-references ("out")
2419 ;; XXX: libstdc++.so NEEDs ld.so for some reason.
2420 #:validate-runpath? #f
2422 ;; All of the package arguments from 'make-libstdc++
2423 ;; except for the configure-flags.
2424 ,@(package-arguments lib)
2425 #:configure-flags `("--disable-shared"
2426 "--disable-libstdcxx-dual-abi"
2427 "--disable-libstdcxx-threads"
2428 "--disable-libstdcxx-pch"
2429 ,(string-append "--with-gxx-include-dir="
2430 (assoc-ref %outputs "out")
2433 (inputs (%boot2-inputs))
2434 (synopsis "GNU C++ standard library (intermediate)"))))
2437 ;; Zlib used by GCC-FINAL.
2441 `(#:guile ,%bootstrap-guile
2442 #:implicit-inputs? #f
2443 #:allowed-references ("out" ,glibc-final)
2444 ,@(package-arguments zlib)))
2445 (inputs (%boot2-inputs))))
2447 (define ld-wrapper-boot3
2449 ;; A linker wrapper that uses the bootstrap Guile.
2450 (make-ld-wrapper "ld-wrapper-boot3"
2451 #:binutils binutils-final
2452 #:guile %bootstrap-guile
2453 #:bash (car (assoc-ref (%boot2-inputs) "bash"))
2454 #:guile-for-build %bootstrap-guile)))
2458 (package (inherit gcc-boot0)
2461 ;; XXX: Currently #:allowed-references applies to all the outputs but the
2462 ;; "debug" output contains disallowed references, notably
2463 ;; linux-libre-headers. Disable the debugging output to work around that.
2464 (outputs (delete "debug" (package-outputs gcc-boot0)))
2467 `(#:guile ,%bootstrap-guile
2468 #:implicit-inputs? #f
2470 #:allowed-references ("out" "lib" ,zlib-final
2471 ,glibc-final ,static-bash-for-glibc)
2473 ;; Things like libasan.so and libstdc++.so NEED ld.so for some
2474 ;; reason, but it is not in their RUNPATH. This is a false
2475 ;; positive, so turn it off.
2476 #:validate-runpath? #f
2478 ,@(substitute-keyword-arguments (package-arguments gcc)
2479 ((#:make-flags flags)
2480 ;; Since $LIBRARY_PATH is not honored, add the relevant flags.
2481 `(let ((zlib (assoc-ref %build-inputs "zlib")))
2483 (if (string-prefix? "LDFLAGS=" flag)
2484 (string-append flag " -L"
2485 (assoc-ref %build-inputs "libstdc++")
2486 "/lib -L" zlib "/lib -Wl,-rpath="
2490 ;; Build again GMP & co. within GCC's build process, because it's hard
2491 ;; to do outside (because GCC-BOOT0 is a cross-compiler, and thus
2492 ;; doesn't honor $LIBRARY_PATH, which breaks `gnu-build-system'.)
2494 `(modify-phases ,phases
2495 (add-after 'unpack 'unpack-gmp&co
2496 (lambda* (#:key inputs #:allow-other-keys)
2497 (let ((gmp (assoc-ref %build-inputs "gmp-source"))
2498 (mpfr (assoc-ref %build-inputs "mpfr-source"))
2499 (mpc (assoc-ref %build-inputs "mpc-source")))
2501 ;; To reduce the set of pre-built bootstrap inputs, build
2502 ;; GMP & co. from GCC.
2503 (for-each (lambda (source)
2504 (invoke "tar" "xvf" source))
2505 (list gmp mpfr mpc))
2507 ;; Create symlinks like `gmp' -> `gmp-x.y.z'.
2508 ,@(map (lambda (lib)
2509 ;; Drop trailing letters, as gmp-6.0.0a unpacks
2511 `(symlink ,(string-trim-right
2512 (package-full-name lib "-")
2514 ,(package-name lib)))
2515 (list gmp-6.0 mpfr mpc))
2518 ;; This time we want Texinfo, so we get the manual. Add
2519 ;; STATIC-BASH-FOR-GLIBC so that it's used in the final shebangs of
2520 ;; scripts such as 'mkheaders' and 'fixinc.sh' (XXX: who cares about these
2522 (native-inputs `(("texinfo" ,texinfo-boot0)
2523 ("perl" ,perl-boot0) ;for manpages
2524 ("static-bash" ,static-bash-for-glibc)
2525 ,@(package-native-inputs gcc-boot0)))
2527 (inputs `(("gmp-source" ,(bootstrap-origin (package-source gmp-6.0)))
2528 ("mpfr-source" ,(package-source mpfr))
2529 ("mpc-source" ,(package-source mpc))
2530 ("ld-wrapper" ,(ld-wrapper-boot3))
2531 ("binutils" ,binutils-final)
2532 ("libstdc++" ,libstdc++)
2533 ("zlib" ,zlib-final)
2534 ,@(%boot2-inputs)))))
2536 (define (%boot3-inputs)
2537 ;; 4th stage inputs.
2538 `(("gcc" ,gcc-final)
2539 ("ld-wrapper" ,(ld-wrapper-boot3))
2540 ,@(alist-delete "gcc" (%boot2-inputs))))
2543 ;; Link with `-static-libgcc' to make sure we don't retain a reference
2544 ;; to the bootstrap GCC. Use "bash-minimal" to avoid an extra dependency
2545 ;; on Readline and ncurses.
2546 (let ((bash (static-libgcc-package bash-minimal)))
2549 (source (bootstrap-origin (package-source bash)))
2550 (inputs (%boot3-inputs))
2552 `(#:implicit-inputs? #f
2553 #:guile ,%bootstrap-guile
2555 #:disallowed-references ,(assoc-ref (%boot3-inputs) "coreutils&co")
2557 ,@(package-arguments bash))))))
2559 (define (%boot4-inputs)
2560 ;; Now use the final Bash.
2561 `(("bash" ,bash-final)
2562 ,@(alist-delete "bash" (%boot3-inputs))))
2565 (package-with-explicit-inputs %boot4-inputs %bootstrap-guile))
2567 (define-public guile-final
2568 ;; This package must be public because other modules refer to it. However,
2569 ;; mark it as hidden so that 'fold-packages' ignores it.
2570 (with-boot4 (hidden-package
2571 (package-with-bootstrap-guile guile-2.2/fixed))))
2573 (define glibc-utf8-locales-final
2574 ;; Now that we have GUILE-FINAL, build the UTF-8 locales. They are needed
2575 ;; by the build processes afterwards so their 'scm_to_locale_string' works
2576 ;; with the full range of Unicode codepoints (remember
2577 ;; 'scm_to_locale_string' is called every time a string is passed to a C
2580 (inherit glibc-utf8-locales)
2582 `(("glibc" ,glibc-final)
2583 ("gzip" ,(with-boot4 gzip))))))
2585 (define-public ld-wrapper
2586 ;; The final 'ld' wrapper, which uses the final Guile and Binutils.
2587 (make-ld-wrapper "ld-wrapper"
2588 #:binutils binutils-final
2592 (define (%boot5-inputs)
2593 ;; Now with UTF-8 locales. Remember that the bootstrap binaries were built
2594 ;; with an older libc, which cannot load the new locale format. See
2595 ;; <https://lists.gnu.org/archive/html/guix-devel/2015-08/msg00737.html>.
2596 `(("locales" ,glibc-utf8-locales-final)
2600 (package-with-explicit-inputs %boot5-inputs))
2602 (define gnu-make-final
2603 ;; The final GNU Make, which uses the final Guile.
2604 (let ((pkg-config (package
2605 (inherit %pkg-config) ;the native pkg-config
2606 (inputs `(("guile" ,guile-final)
2609 `(#:implicit-inputs? #f
2610 ,@(package-arguments pkg-config))))))
2612 (inherit (package-with-bootstrap-guile gnu-make))
2613 (inputs `(("guile" ,guile-final)
2615 (native-inputs `(("pkg-config" ,pkg-config)))
2617 `(#:implicit-inputs? #f
2618 ,@(package-arguments gnu-make))))))
2621 (define coreutils-final
2622 ;; The final Coreutils. Treat them specially because some packages, such as
2623 ;; Findutils, keep a reference to the Coreutils they were built with.
2624 (with-boot5 (package-with-bootstrap-guile coreutils)
2625 ;; Use the final Guile, linked against the
2626 ;; final libc with working iconv, so that
2627 ;; 'substitute*' works well when touching
2628 ;; test files in Gettext.
2632 ;; The final grep. Gzip holds a reference to it (via zgrep), so it must be
2633 ;; built before gzip.
2634 (let ((grep (with-boot5 (package-with-bootstrap-guile grep))))
2635 (package/inherit grep
2636 (inputs (alist-delete "pcre" (package-inputs grep)))
2637 (native-inputs `(("perl" ,perl-boot0))))))
2639 (define (%boot6-inputs)
2640 ;; Now use the final Coreutils.
2641 `(("coreutils" ,coreutils-final)
2642 ("grep" ,grep-final)
2646 (package-with-explicit-inputs %boot6-inputs))
2650 (let ((sed (with-boot6 (package-with-bootstrap-guile sed))))
2651 (package/inherit sed (native-inputs `(("perl" ,perl-boot0))))))
2653 (define-public %final-inputs
2654 ;; Final derivations used as implicit inputs by 'gnu-build-system'. We
2655 ;; still use 'package-with-bootstrap-guile' so that the bootstrap tools are
2656 ;; used for origins that have patches, thereby avoiding circular
2658 (let ((finalize (compose with-boot6
2659 package-with-bootstrap-guile)))
2660 `(,@(map (match-lambda
2662 (list name (finalize package))))
2668 ("diffutils" ,diffutils)
2670 ("findutils" ,findutils)
2673 ("grep" ,grep-final)
2674 ("coreutils" ,coreutils-final)
2675 ("make" ,gnu-make-final)
2676 ("bash" ,bash-final)
2677 ("ld-wrapper" ,ld-wrapper)
2678 ("binutils" ,binutils-final)
2680 ("libc" ,glibc-final)
2681 ("libc:static" ,glibc-final "static")
2682 ("locales" ,glibc-utf8-locales-final))))
2684 (define-public canonical-package
2685 (let ((name->package (fold (lambda (input result)
2687 ((_ package . outputs)
2688 (vhash-cons (package-full-name package)
2691 `(("guile" ,guile-final)
2694 "Return the 'canonical' variant of PACKAGE---i.e., if PACKAGE is one of
2695 the implicit inputs of 'gnu-build-system', return that one, otherwise return
2698 The goal is to avoid duplication in cases like GUILE-FINAL vs. GUILE-2.2,
2699 COREUTILS-FINAL vs. COREUTILS, etc."
2700 ;; XXX: This doesn't handle dependencies of the final inputs, such as
2701 ;; libunistring, GMP, etc.
2702 (match (vhash-assoc (package-full-name package) name->package)
2704 ;; In general we want CANON, except if we're cross-compiling: CANON
2705 ;; uses explicit inputs, so it is "anchored" in the bootstrapped
2706 ;; process, with dependencies on things that cannot be
2708 (if (%current-target-system)
2718 ;; Using the following procedure, a gcc toolchain targeting glibc-2.27 can be
2719 ;; instantiated like this:
2721 ;; (define-public gcc-glibc-2.27-toolchain
2722 ;; (make-gcc-toolchain gcc glibc-2.27))
2724 (define* (make-gcc-toolchain gcc
2727 "Return a complete toolchain for GCC. If LIBC is specified, target that libc."
2728 (let ((gcc (if libc (make-gcc-libc gcc libc) gcc))
2729 (libc (if libc libc glibc-final)))
2731 (name (string-append (package-name gcc) "-toolchain"))
2732 (version (package-version gcc))
2734 (build-system trivial-build-system)
2736 '(#:modules ((guix build union))
2738 (use-modules (ice-9 match)
2742 (let ((out (assoc-ref %outputs "out")))
2744 (match %build-inputs
2745 (((names . directories) ...)
2746 (union-build out directories)))
2748 (union-build (assoc-ref %outputs "debug")
2749 (list (assoc-ref %build-inputs
2751 (union-build (assoc-ref %outputs "static")
2752 (list (assoc-ref %build-inputs
2756 (native-search-paths (package-native-search-paths gcc))
2757 (search-paths (package-search-paths gcc))
2759 (license (package-license gcc))
2760 (synopsis "Complete GCC tool chain for C/C++ development")
2762 "This package provides a complete GCC tool chain for C/C++ development to
2763 be installed in user profiles. This includes GCC, as well as libc (headers and
2764 binaries, plus debugging symbols in the @code{debug} output), and Binutils.")
2765 (home-page "https://gcc.gnu.org/")
2766 (outputs '("out" "debug" "static"))
2768 ;; The main raison d'être of this "meta-package" is (1) to conveniently
2769 ;; install everything that we need, and (2) to make sure ld-wrapper comes
2770 ;; before Binutils' ld in the user's profile.
2771 (inputs `(("gcc" ,gcc)
2772 ("ld-wrapper" ,(car (assoc-ref %final-inputs "ld-wrapper")))
2773 ("binutils" ,binutils-final)
2775 ("libc-debug" ,libc "debug")
2776 ("libc-static" ,libc "static"))))))
2778 (define-public gcc-toolchain
2779 (make-gcc-toolchain gcc-final))
2781 (define-public gcc-toolchain-4.8
2782 (make-gcc-toolchain gcc-4.8))
2784 (define-public gcc-toolchain-4.9
2785 (make-gcc-toolchain gcc-4.9))
2787 (define-public gcc-toolchain-5
2788 (make-gcc-toolchain gcc-5))
2790 (define-public gcc-toolchain-6
2791 (make-gcc-toolchain gcc-6))
2793 (define-public gcc-toolchain-7
2796 (define-public gcc-toolchain-8
2797 (make-gcc-toolchain gcc-8))
2799 (define-public gcc-toolchain-9
2800 (make-gcc-toolchain gcc-9))
2802 ;; Provide the Fortran toolchain package only for the version of gfortran that
2803 ;; is used by Guix internally to build Fortran libraries, because combining
2804 ;; code compiled with different versions can cause problems.
2806 (define-public gfortran-toolchain
2807 (package (inherit (make-gcc-toolchain gfortran))
2808 (synopsis "Complete GCC tool chain for Fortran development")
2809 (description "This package provides a complete GCC tool chain for
2810 Fortran development to be installed in user profiles. This includes
2811 gfortran, as well as libc (headers and binaries, plus debugging symbols
2812 in the @code{debug} output), and binutils.")))
2815 ;;; commencement.scm ends here