gnu: commencement: Remove %bootstrap-guile+guild.
[jackhill/guix/guix.git] / gnu / packages / commencement.scm
CommitLineData
bdb36958 1;;; GNU Guix --- Functional package management for GNU
558b0bbe 2;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
bdb36958
LC
3;;; Copyright © 2014 Andreas Enge <andreas@enge.fr>
4;;; Copyright © 2012 Nikita Karetnikov <nikita@karetnikov.org>
13f7f2fd 5;;; Copyright © 2014, 2015, 2017 Mark H Weaver <mhw@netris.org>
5fe2c549 6;;; Copyright © 2017, 2018, 2019 Efraim Flashner <efraim@flashner.co.il>
53bfec7b 7;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
f8d1a95e 8;;; Copyright © 2018, 2019, 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
429243a4 9;;; Copyright © 2019, 2020 Marius Bakke <mbakke@fastmail.com>
2ca7af43 10;;; Copyright © 2020 Timothy Sample <samplet@ngyro.com>
bdb36958
LC
11;;;
12;;; This file is part of GNU Guix.
13;;;
14;;; GNU Guix is free software; you can redistribute it and/or modify it
15;;; under the terms of the GNU General Public License as published by
16;;; the Free Software Foundation; either version 3 of the License, or (at
17;;; your option) any later version.
18;;;
19;;; GNU Guix is distributed in the hope that it will be useful, but
20;;; WITHOUT ANY WARRANTY; without even the implied warranty of
21;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22;;; GNU General Public License for more details.
23;;;
24;;; You should have received a copy of the GNU General Public License
25;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
26
27(define-module (gnu packages commencement)
b2fd8f63 28 #:use-module (gnu packages)
bdb36958
LC
29 #:use-module (gnu packages bootstrap)
30 #:use-module (gnu packages base)
31 #:use-module (gnu packages bash)
0b652851 32 #:use-module (gnu packages c)
bdb36958 33 #:use-module (gnu packages gcc)
2d5d63d7 34 #:use-module (gnu packages m4)
bdb36958 35 #:use-module (gnu packages gawk)
2d5d63d7 36 #:use-module (gnu packages bison)
d75acc29 37 #:use-module (gnu packages flex)
bdb36958 38 #:use-module (gnu packages guile)
6162b95d 39 #:use-module (gnu packages gettext)
bdb36958
LC
40 #:use-module (gnu packages multiprecision)
41 #:use-module (gnu packages compression)
0b652851 42 #:use-module (gnu packages mes)
bdb36958 43 #:use-module (gnu packages perl)
5f3f7039 44 #:use-module (gnu packages python)
bdb36958 45 #:use-module (gnu packages linux)
d75acc29 46 #:use-module (gnu packages hurd)
d3aec6bd 47 #:use-module (gnu packages shells)
bdb36958
LC
48 #:use-module (gnu packages texinfo)
49 #:use-module (gnu packages pkg-config)
429243a4 50 #:use-module (gnu packages rsync)
5f3f7039 51 #:use-module (gnu packages xml)
bdb36958
LC
52 #:use-module (guix packages)
53 #:use-module (guix download)
54 #:use-module (guix build-system gnu)
55 #:use-module (guix build-system trivial)
2ca7af43 56 #:use-module ((guix licenses) #:prefix license:)
8102cf0b 57 #:use-module (guix memoization)
bdb36958
LC
58 #:use-module (guix utils)
59 #:use-module (srfi srfi-1)
bdb36958 60 #:use-module (ice-9 vlist)
d75acc29 61 #:use-module (ice-9 match)
6869b663 62 #:export (make-gcc-toolchain))
bdb36958
LC
63
64;;; Commentary:
65;;;
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'.
71;;;
72;;; To avoid circular dependencies, this module should not be imported
73;;; directly from anywhere.
74;;;
a1df45e9
CM
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.
83;;;
bdb36958
LC
84;;; Code:
85
2ca7af43
TS
86(define bootar
87 (package
88 (name "bootar")
89 (version "1")
90 (source (origin
91 (method url-fetch)
92 (uri "https://files.ngyro.com/bootar/bootar-1.ses")
93 (sha256
94 (base32
95 "011p0nky2qp0vmyhvdx220qywxxp7a0m6pvy0lzzg4qxbpyqpf0r"))))
96 (build-system gnu-build-system)
97 (arguments
98 `(#:implicit-inputs? #f
99 #:tests? #f
100 #:guile ,%bootstrap-guile
101 #:imported-modules ((guix build gnu-bootstrap)
102 ,@%gnu-build-system-modules)
103 #:phases
104 (begin
105 (use-modules (guix build gnu-bootstrap))
106 (modify-phases %standard-phases
107 (replace 'unpack
108 (lambda* (#:key inputs #:allow-other-keys)
109 (let* ((source (assoc-ref inputs "source"))
110 (guile-dir (assoc-ref inputs "guile"))
111 (guile (string-append guile-dir "/bin/guile")))
112 (invoke guile "--no-auto-compile" source)
113 (chdir "bootar")
114 #t)))
115 (replace 'configure (bootstrap-configure ,version "." "scripts"))
116 (replace 'build (bootstrap-build "."))
117 (replace 'install (bootstrap-install "." "scripts"))))))
118 (inputs `(("guile" ,%bootstrap-guile)))
119 (home-page "https://git.ngyro.com/bootar")
120 (synopsis "Tar decompression and extraction in Guile Scheme")
121 (description "Bootar is a simple Tar extractor written in Guile
122Scheme. It supports running 'tar xvf' on uncompressed tarballs or
123tarballs that are compressed with BZip2, GZip, or XZ. It also provides
124standalone scripts for 'bzip2', 'gzip', and 'xz' that each support
125decompression to standard output.
126
127What makes this special is that Bootar is distributed as a
128self-extracting Scheme (SES) program. That is, a little script that
129outputs the source code of Bootar. This makes it possible to go from
130pure Scheme to Tar and decompression in one easy step.")
131 (license license:gpl3+)))
132
d3aec6bd
JN
133(define gash-boot
134 (package
135 (inherit gash)
136 (name "gash-boot")
2ca7af43
TS
137 (source (origin
138 (inherit (package-source gash))
139 (modules '())))
d3aec6bd
JN
140 (arguments
141 `(#:implicit-inputs? #f
2ca7af43
TS
142 #:tests? #f
143 #:guile ,%bootstrap-guile
144 #:imported-modules ((guix build gnu-bootstrap)
145 ,@%gnu-build-system-modules)
d3aec6bd 146 #:phases
2ca7af43
TS
147 (begin
148 (use-modules (guix build gnu-bootstrap))
149 (modify-phases %standard-phases
150 (replace 'configure
151 (bootstrap-configure ,(version) "gash" "scripts"))
152 (replace 'build (bootstrap-build "gash"))
153 (replace 'install (bootstrap-install "gash" "scripts"))
154 (add-after 'install 'install-symlinks
155 (lambda* (#:key outputs #:allow-other-keys)
156 (let ((out (assoc-ref outputs "out")))
157 (symlink (string-append out "/bin/gash")
158 (string-append out "/bin/sh"))
159 (symlink (string-append out "/bin/gash")
160 (string-append out "/bin/bash"))
161 #t)))))))
162 (inputs `(("guile" ,%bootstrap-guile)))
163 (native-inputs `(("bootar" ,bootar)))))
899c8f3a 164
1681d3f1 165(define gash-utils-boot
9f5a22b9 166 (package
1681d3f1
TS
167 (inherit gash-utils)
168 (name "gash-utils-boot")
9f5a22b9
JN
169 (arguments
170 `(#:implicit-inputs? #f
2ca7af43
TS
171 #:tests? #f
172 #:guile ,%bootstrap-guile
173 #:imported-modules ((guix build gnu-bootstrap)
174 ,@%gnu-build-system-modules)
9f5a22b9 175 #:phases
2ca7af43
TS
176 (begin
177 (use-modules (guix build gnu-bootstrap))
178 (modify-phases %standard-phases
179 (add-after 'unpack 'set-load-path
180 (lambda* (#:key inputs #:allow-other-keys)
181 (let ((gash (assoc-ref inputs "gash")))
182 (add-to-load-path (string-append gash "/share/guile/site/"
183 (effective-version))))
184 #t))
185 (add-before 'configure 'pre-configure
186 (lambda _
187 (format #t "Creating gash/commands/testb.scm~%")
188 (copy-file "gash/commands/test.scm"
189 "gash/commands/testb.scm")
190 (substitute* "gash/commands/testb.scm"
191 (("gash commands test") "gash commands testb")
192 (("apply test [(]cdr") "apply test/bracket (cdr"))
193 (for-each (lambda (script)
194 (let ((target (string-append "scripts/"
195 script ".in")))
196 (format #t "Creating scripts/~a~%" target)
197 (copy-file "scripts/template.in" target)
198 (substitute* target
199 (("@UTILITY@") script))))
200 '("awk" "basename" "cat" "chmod" "cmp" "command"
201 "compress" "cp" "cut" "diff" "dirname" "expr"
202 "false" "find" "grep" "head" "ln" "ls" "mkdir"
203 "mv" "printf" "pwd" "reboot" "rm" "rmdir"
204 "sed" "sleep" "sort" "tar" "test" "touch" "tr"
205 "true" "uname" "uniq" "wc" "which"))
206 (format #t "Creating scripts/[.in~%")
207 (copy-file "scripts/template.in" "scripts/[.in")
208 (substitute* "scripts/[.in"
209 (("@UTILITY@") "testb"))
210 (delete-file "scripts/template.in")
211 #t))
212 (replace 'configure
213 (bootstrap-configure ,(version) "gash" "scripts"))
214 (replace 'build (bootstrap-build "gash"))
215 (replace 'install (bootstrap-install "gash" "scripts"))
216 ;; XXX: The scripts should add Gash to their load paths and
217 ;; this phase should not exist.
218 (add-after 'install 'copy-gash
219 (lambda* (#:key inputs outputs #:allow-other-keys)
220 (let* ((out (assoc-ref outputs "out"))
221 (moddir (string-append out "/share/guile/site/"
222 (effective-version)))
223 (godir (string-append out "/lib/guile/"
224 (effective-version)
225 "/site-ccache"))
226 (gash (assoc-ref inputs "gash"))
227 (gash-moddir (string-append gash "/share/guile/site/"
228 (effective-version)))
229 (gash-godir (string-append gash "/lib/guile/"
230 (effective-version)
231 "/site-ccache")))
232 (copy-file (string-append gash-moddir "/gash/compat.scm")
233 (string-append moddir "/gash/compat.scm"))
234 (copy-recursively (string-append gash-moddir "/gash/compat")
235 (string-append moddir "/gash/compat"))
236 (copy-file (string-append gash-godir "/gash/compat.go")
237 (string-append godir "/gash/compat.go"))
238 (copy-recursively (string-append gash-godir "/gash/compat")
239 (string-append godir "/gash/compat"))
240 #t)))))))
241 (inputs `(("gash" ,gash-boot)
242 ("guile" ,%bootstrap-guile)))
243 (native-inputs `(("bootar" ,bootar)))))
9f5a22b9
JN
244
245(define (%boot-gash-inputs)
246 `(("bash" , gash-boot) ; gnu-build-system wants "bash"
1681d3f1 247 ("coreutils" , gash-utils-boot)
2ca7af43
TS
248 ("bootar" ,bootar)
249 ("guile" ,%bootstrap-guile)))
9f5a22b9 250
da2ae09b
JN
251(define %bootstrap-mes-rewired
252 (package
253 (inherit mes)
254 (name "bootstrap-mes-rewired")
255 (version "0.19")
256 (source #f)
257 (native-inputs `(("mes" ,(@ (gnu packages bootstrap) %bootstrap-mes))
258 ("gash" ,gash-boot)))
259 (inputs '())
260 (propagated-inputs '())
261 (outputs '("out"))
262 (build-system trivial-build-system)
263 (arguments
264 `(#:guile ,%bootstrap-guile
265 #:modules ((guix build utils)
266 (srfi srfi-26))
267 #:builder (begin
268 (use-modules (guix build utils)
269 (srfi srfi-26))
270 (let* ((mes (assoc-ref %build-inputs "mes"))
271 (gash (assoc-ref %build-inputs "gash"))
272 (mes-bin (string-append mes "/bin"))
273 (guile (string-append mes-bin "/mes"))
274 (mes-module (string-append mes "/share/mes/module"))
275 (out (assoc-ref %outputs "out"))
276 (bin (string-append out "/bin"))
277 (mescc (string-append bin "/mescc"))
278 (module (string-append out "/share/mes/module")))
279 (define (rewire file)
280 (substitute* file
281 ((mes) out)
282 (("/gnu/store[^ ]+mes-minimal-[^/)}\"]*") out)
283 (("/gnu/store[^ ]+guile-[^/]*/bin/guile") guile)
284 (("/gnu/store[^ ]+bash-[^/)}\"]*") gash)))
285
286 (mkdir-p bin)
287 (for-each (lambda (file) (install-file file bin))
288 (find-files mes-bin))
289 (mkdir-p module)
290 (copy-recursively (string-append mes-module "/mes")
291 (string-append module "/mes"))
292 (copy-recursively (string-append mes-module "/srfi")
293 (string-append module "/srfi"))
294 (for-each rewire
295 ;; Cannot easily rewire "mes" because it
296 ;; contains NUL characters; would require
297 ;; remove-store-references alike trick
298 (filter (negate (cut string-suffix? "/mes" <>))
299 (find-files bin)))
300 (rewire (string-append module "/mes/boot-0.scm"))
301
302 (delete-file mescc)
303 (with-output-to-file mescc
304 (lambda _
305 (display (string-append
306 "\
307#! " gash "/bin/sh
308LANG=C
309LC_ALL=C
310export LANG LC_ALL
311
312MES_PREFIX=${MES_REWIRED_PREFIX-" out "/share/mes}
313MES=" bin "/mes
314export MES MES_PREFIX
315
316MES_ARENA=${MES_REWIRED_ARENA-10000000}
317MES_MAX_ARENA=${MES_REWIRED_ARENA-10000000}
318MES_STACK=${MES_REWIRED_STACK-1000000}
319export MES_ARENA MES_MAX_ARENA MES_STACK
320
321$MES -e '(mescc)' module/mescc.scm -- \"$@\"
322"))))
323 (chmod mescc #o555)
324
325 (with-directory-excursion module
326 (chmod "mes/base.mes" #o644)
327 (copy-file "mes/base.mes" "mes/base.mes.orig")
328 (let ((base.mes (open-file "mes/base.mes" "a")))
329 (display "
330;; A fixed map, from Mes 0.21, required to bootstrap Mes 0.21
331(define (map f h . t)
332 (if (or (null? h)
333 (and (pair? t) (null? (car t)))
334 (and (pair? t) (pair? (cdr t)) (null? (cadr t)))) '()
335 (if (null? t) (cons (f (car h)) (map f (cdr h)))
336 (if (null? (cdr t))
337 (cons (f (car h) (caar t)) (map f (cdr h) (cdar t)))
338 (if (null? (cddr t))
339 (cons (f (car h) (caar t) (caadr t)) (map f (cdr h) (cdar t) (cdadr t)))
c9c1cbf6 340 (error 'unsupported (cons* 'map-4: f h t))b )))))
da2ae09b
JN
341" base.mes)
342 (close base.mes))
343
344 (chmod "mes/guile.mes" #o644)
345 (copy-file "mes/guile.mes" "mes/guile.mes.orig")
346 (let ((guile.mes (open-file "mes/guile.mes" "a")))
347 (display "
348;; After booting guile.scm; use Mes 0.21; especially: MesCC 0.21
349(let* ((self (car (command-line)))
350 (prefix (dirname (dirname self))))
351 (set! %moduledir (string-append prefix \"/mes/module/\"))
352 (setenv \"%numbered_arch\" \"true\"))
353
354" guile.mes)
355 (close guile.mes)))
356 #t))))))
357
0b652851 358(define mes-boot
9a45a24f
LC
359 (package
360 (inherit mes)
361 (name "mes-boot")
1fdc6a38 362 (version "0.22")
9a45a24f
LC
363 (source (origin
364 (method url-fetch)
1fdc6a38 365 (uri (string-append "mirror://gnu/mes/"
9a45a24f
LC
366 "mes-" version ".tar.gz"))
367 (sha256
368 (base32
1fdc6a38 369 "0p1jsrrmcbc0zrvbvnjbb6iyxr0in71km293q8qj6gnar6bw09av"))))
9a45a24f
LC
370 (inputs '())
371 (propagated-inputs '())
372 (native-inputs
c9c1cbf6
JN
373 `(("nyacc-source" ,(origin (inherit (package-source nyacc))
374 (snippet #f)))
375 ("mes" ,%bootstrap-mes-rewired)
376 ("mescc-tools" ,%bootstrap-mescc-tools)
377 ,@(%boot-gash-inputs)))
9a45a24f
LC
378 (arguments
379 `(#:implicit-inputs? #f
c9c1cbf6 380 #:tests? #f
9a45a24f
LC
381 #:guile ,%bootstrap-guile
382 #:strip-binaries? #f ; binutil's strip b0rkes MesCC/M1/hex2 binaries
383 #:phases
384 (modify-phases %standard-phases
385 (add-after 'unpack 'unpack-seeds
386 (lambda _
c9c1cbf6 387 (let ((nyacc-source (assoc-ref %build-inputs "nyacc-source")))
9a45a24f 388 (with-directory-excursion ".."
c9c1cbf6 389 (invoke "tar" "-xvf" nyacc-source)))))
9a45a24f
LC
390 (replace 'configure
391 (lambda* (#:key outputs #:allow-other-keys)
c9c1cbf6
JN
392 (let ((out (assoc-ref %outputs "out"))
393 (gash (assoc-ref %build-inputs "bash"))
394 (mes (assoc-ref %build-inputs "mes"))
395 (dir (with-directory-excursion ".." (getcwd))))
396 (setenv "AR" (string-append "gash " (getcwd) "/scripts/mesar"))
397 (setenv "BASH" (string-append gash "/bin/bash"))
398 (setenv "CC" (string-append mes "/bin/mescc"))
399 (setenv "GUILE_LOAD_PATH"
400 (string-append
401 mes "/share/mes/module"
2ca7af43 402 ":" dir "/nyacc-0.99.0/module"))
c9c1cbf6
JN
403 (invoke "gash" "configure.sh"
404 (string-append "--prefix=" out)
405 (string-append "--host=i686-linux-gnu")))))
9a45a24f
LC
406 (replace 'build
407 (lambda _
c9c1cbf6
JN
408 (invoke "sh" "bootstrap.sh")))
409 (delete 'check)
9a45a24f
LC
410 (replace 'install
411 (lambda _
c9c1cbf6
JN
412 (substitute* "install.sh" ; show some progress
413 ((" -xf") " -xvf")
414 (("^( *)((cp|mkdir|tar) [^']*[^\\])\n" all space cmd)
415 (string-append space "echo '" cmd "'\n"
416 space cmd "\n")))
417 (invoke "sh" "install.sh")
418 ;; Keep ASCII output, for friendlier comparison and bisection
419 (let* ((out (assoc-ref %outputs "out"))
420 (cache (string-append out "/lib/cache")))
421 (define (objects-in-dir dir)
422 (find-files dir
423 (lambda (name stat)
424 (and (equal? (dirname name) dir)
425 (or (string-suffix? ".o" name)
426 (string-suffix? ".s" name))))))
427 (for-each (lambda (x) (install-file x cache))
428 (append (objects-in-dir ".")
429 (objects-in-dir "mescc-lib"))))
430 #t)))))
9a45a24f 431 (native-search-paths
9a45a24f
LC
432 (list (search-path-specification
433 (variable "C_INCLUDE_PATH")
c9c1cbf6 434 (files '("include")))
9a45a24f
LC
435 (search-path-specification
436 (variable "LIBRARY_PATH")
c9c1cbf6
JN
437 (files '("lib")))
438 (search-path-specification
439 (variable "MES_PREFIX")
440 (separator #f)
441 (files '("")))))))
442
0b652851
JN
443
444(define tcc-boot0
445 ;; Pristine tcc cannot be built by MesCC, we are keeping a delta of 11
446 ;; patches. In a very early and rough form they were presented to the
447 ;; TinyCC developers, who at the time showed no interest in supporting the
448 ;; bootstrappable effort; we will try again later. These patches have been
449 ;; ported to 0.9.27, alas the resulting tcc is buggy. Once MesCC is more
450 ;; mature, this package should use the 0.9.27 sources (or later).
5dedce04
JN
451 (package
452 (inherit tcc)
453 (name "tcc-boot0")
454 (version "0.9.26-1103-g6e62e0e")
455 (source (origin
456 (method url-fetch)
457 (uri (string-append
458 "http://lilypond.org/janneke/mes/20191117/"
459 "/tcc-" version ".tar.gz"))
460 (sha256
461 (base32
462 "1qbybw7mxbgkv3sazvz1v7c8byq998vk8f1h25ik8w3d2l63lxng"))))
463 (build-system gnu-build-system)
464 (supported-systems '("i686-linux" "x86_64-linux"))
465 (inputs '())
466 (propagated-inputs '())
467 (native-inputs
468 `(("mes" ,mes-boot)
469 ("nyacc-source" ,(origin (inherit (package-source nyacc))
470 (snippet #f)))
471 ("mescc-tools" ,%bootstrap-mescc-tools)
472 ,@(%boot-gash-inputs)))
473 (arguments
474 `(#:implicit-inputs? #f
475 #:guile ,%bootstrap-guile
476 #:validate-runpath? #f ; no dynamic executables
477 #:strip-binaries? #f ; no strip yet
478 #:phases
479 (modify-phases %standard-phases
480 (add-after 'unpack 'unpack-seeds
481 (lambda* (#:key outputs #:allow-other-keys)
482 (let ((nyacc-source (assoc-ref %build-inputs "nyacc-source")))
483 (with-directory-excursion ".."
484 (invoke "tar" "-xvf" nyacc-source)))))
485 (replace 'configure
486 (lambda* (#:key outputs #:allow-other-keys)
487 (let* ((out (assoc-ref %outputs "out"))
488 (dir (with-directory-excursion ".." (getcwd)))
489 (interpreter "/lib/mes-loader"))
490
491 (setenv "prefix" out)
492 (setenv "GUILE_LOAD_PATH"
493 (string-append dir "/nyacc-0.99.0/module"))
0b652851 494
5dedce04
JN
495 (substitute* "conftest.c"
496 (("volatile") ""))
497
498 (invoke "sh" "configure"
499 "--cc=mescc"
500 (string-append "--prefix=" out)
501 (string-append "--elfinterp=" interpreter)
502 "--crtprefix=."
503 "--tccdir=."))))
504 (replace 'build
505 (lambda _
506 (substitute* "bootstrap.sh" ; Show some progress
507 (("^( *)((cp|ls|mkdir|rm|[.]/tcc|[.]/[$][{PROGRAM_PREFIX[}]tcc) [^\"]*[^\\])\n" all space cmd)
508 (string-append space "echo \"" cmd "\"\n"
509 space cmd "\n")))
510 (invoke "sh" "bootstrap.sh")))
511 (replace 'check
512 (lambda _
513 ;; fail fast tests
514 (system* "./tcc" "--help") ; --help exits 1
515 ;; (invoke "sh" "test.sh" "mes/scaffold/tests/30-strlen")
516 ;; (invoke "sh" "-x" "test.sh" "mes/scaffold/tinycc/00_assignment")
517 ;; TODO: add sensible check target (without depending on make)
518 ;; (invoke "sh" "check.sh")
519 #t))
520 (replace 'install
521 (lambda _
522 (substitute* "install.sh" ; Show some progress
523 (("^( *)((cp|ls|mkdir|rm|tar|./[$][{PROGRAM_PREFIX[}]tcc) [^\"]*[^\\])\n" all space cmd)
524 (string-append space "echo \"" cmd "\"\n"
525 space cmd "\n")))
0b652851 526
5dedce04
JN
527 (invoke "sh" "install.sh"))))))
528 (native-search-paths
529 (list (search-path-specification
530 (variable "C_INCLUDE_PATH")
531 (files '("include")))
532 (search-path-specification
533 (variable "LIBRARY_PATH")
534 (files '("lib")))))))
0b652851 535
b022827d
JN
536(define gzip-mesboot
537 ;; The initial gzip. We keep this scripted gzip build before building make
538 ;; to soften the dependency on Gash Core Utils gzip.
539 (package
540 (inherit gzip)
541 (version "1.2.4")
542 (name "gzip-mesboot")
543 (source (origin
544 (method url-fetch)
545 (uri (string-append "mirror://gnu/gzip/gzip-" version ".tar"))
546 (sha256
547 (base32
548 "1rhgk2vvmdvnn6vygf0dja92ryyng00knl0kz5srb77k2kryjb2d"))))
549 (supported-systems '("i686-linux" "x86_64-linux"))
550 (inputs '())
551 (propagated-inputs '())
552 (native-inputs `(("tcc" ,tcc-boot0)
553 ,@(%boot-gash-inputs)))
554 (arguments
555 `(#:implicit-inputs? #f
556 #:guile ,%bootstrap-guile
557 #:strip-binaries? #f ; no strip yet
558 #:phases
559 (modify-phases %standard-phases
560 (delete 'configure)
561 (add-after 'unpack 'scripted-patch
562 (lambda _
563 (substitute* "util.c"
564 (("^char [*]strlwr" all) (string-append all "_tcc_cannot_handle_dupe")))
565 #t))
566 (replace 'build
567 (lambda _
568 (let ((files '("bits" "crypt" "deflate" "getopt" "gzip"
569 "inflate" "lzw" "trees" "unlzh" "unlzw"
570 "unpack" "unzip" "util" "zip")))
571 (define (compile x)
572 (invoke "tcc" "-c" "-D NO_UTIME=1" "-D HAVE_UNISTD_H=1"
573 (string-append x ".c")))
574 (for-each compile files)
575 (apply invoke
576 (cons* "tcc" "-o" "gzip"
577 (map (lambda (x) (string-append x ".o")) files)))
578 (link "gzip" "gunzip"))))
579 (replace 'install
580 (lambda _
581 (let* ((out (assoc-ref %outputs "out"))
582 (bin (string-append out "/bin")))
583 (install-file "gzip" bin)
584 (install-file "gunzip" bin))))
585 (replace 'check
586 (lambda _
587 (invoke "./gzip" "--version")))
588 ;; no gzip yet
589 (delete 'compress-documentation))))))
590
2bb7deff 591(define gnu-make-mesboot0
19be1dc6
JN
592 ;; The initial make
593 (package
594 (inherit gnu-make)
595 (name "make-mesboot0")
596 (version "3.80")
597 (source (origin
598 (method url-fetch)
599 (uri (string-append "mirror://gnu/make/make-" version ".tar.gz"))
600 (sha256
601 (base32
602 "1pb7fb7fqf9wz9najm85qdma1xhxzf1rhj5gwrlzdsz2zm0hpcv4"))))
603 (supported-systems '("i686-linux" "x86_64-linux"))
604 (inputs '())
605 (propagated-inputs '())
606 (native-inputs `(("tcc" ,tcc-boot0)
607 ,@(%boot-gash-inputs)))
608 (arguments
609 `(#:implicit-inputs? #f
610 #:guile ,%bootstrap-guile
611 #:configure-flags '("CC=tcc"
612 "CPP=tcc -E"
613 "LD=tcc"
614 "--build=i686-unknown-linux-gnu"
615 "--host=i686-unknown-linux-gnu"
616 "--disable-nls")
617 #:modules ((guix build gnu-build-system)
618 (guix build utils)
619 (srfi srfi-1))
620 #:strip-binaries? #f ; no strip yet
621 #:phases
622 (modify-phases %standard-phases
623 (add-after 'unpack 'scripted-patch
624 (lambda _
625 (substitute* "build.sh.in"
626 (("@LIBOBJS@") "getloadavg.o")
627 (("@REMOTE@") "stub"))
628 #t))
629 (add-after 'configure 'configure-fixup
630 (lambda _
631 (substitute* "make.h"
632 (("^extern long int lseek.*" all) (string-append "// " all)))
633 #t))
634 (replace 'build
635 (lambda _
636 (invoke "sh" "./build.sh")))
637 (replace 'check ; proper check needs awk
638 (lambda _
639 (invoke "./make" "--version")))
640 (replace 'install
641 (lambda _
642 (let* ((out (assoc-ref %outputs "out"))
643 (bin (string-append out "/bin")))
644 (install-file "make" bin)))))))))
645
646(define (%boot-tcc0-inputs)
2bb7deff 647 `(("make" ,gnu-make-mesboot0)
19be1dc6
JN
648 ("tcc" ,tcc-boot0)
649 ,@(%boot-gash-inputs)))
650
0bf34663
JN
651(define bzip2-mesboot
652 ;; The initial bzip2
653 (package
654 (inherit bzip2)
655 (name "bzip2-mesboot")
656 (version (package-version bzip2))
657 (source (bootstrap-origin (package-source bzip2)))
658 (supported-systems '("i686-linux" "x86_64-linux"))
659 (inputs '())
660 (propagated-inputs '())
661 (native-inputs (%boot-tcc0-inputs))
662 (outputs '("out"))
663 (arguments
664 `(#:implicit-inputs? #f
665 #:guile ,%bootstrap-guile
666 #:parallel-build? #f
667 #:tests? #f ; check is naive, also checks non-built PROGRAMS
668 #:strip-binaries? #f ; no strip yet
669 #:make-flags (list "CC=tcc -I ." "AR=tcc -ar" "bzip2"
670 (string-append "PREFIX="
671 (assoc-ref %outputs "out")))
672 #:phases
673 (modify-phases %standard-phases
674 (add-after 'unpack 'scripted-patch
675 (lambda _
676 (substitute* "Makefile"
677 (("\tln " all)
678 (string-append "\t#" all)))
679 (substitute* "bzip2.c"
680 (("struct utimbuf uTimBuf;" all)
681 (string-append "// " all))
682 (("uTimBuf[.]" all)
683 (string-append "// " all))
684 (("retVal = utime [(] dstName, &uTimBuf [)];" all)
685 (string-append "retVal = 0; // " all)))
686 #t))
687 (replace 'configure
688 (lambda _
689 (with-output-to-file "utime.h"
690 (lambda _ (display "
691#define fchown(filedes, owner, group) 0
692#define fchmod(filedes, mode) 0
693")))
694 #t))
695 (replace 'check
696 (lambda _
697 (invoke "./bzip2" "--help")))
698 ;; FIXME: no compressing gzip yet
699 (delete 'compress-documentation))))))
700
d9484fba
JN
701(define bash-mesboot0
702 ;; The initial Bash
703 (package
704 (inherit static-bash)
705 (name "bash-mesboot0")
706 (version "2.05b")
707 (source (origin
708 (method url-fetch)
709 (uri (string-append "mirror://gnu/bash/bash-"
710 version ".tar.gz"))
711 (sha256
712 (base32
713 "1r1z2qdw3rz668nxrzwa14vk2zcn00hw7mpjn384picck49d80xs"))))
714 (inputs '())
715 (propagated-inputs '())
716 (native-inputs (%boot-tcc0-inputs))
717 (outputs '("out"))
718 (arguments
719 `(#:implicit-inputs? #f
720 #:guile ,%bootstrap-guile
721 #:parallel-build? #f
722 #:strip-binaries? #f ; no strip yet
723 #:configure-flags
724 (list "--build=i686-unknown-linux-gnu"
725 "--host=i686-unknown-linux-gnu"
726
727 "--without-bash-malloc"
728 "--disable-readline"
729 "--disable-history"
730 "--disable-help-builtin"
731 "--disable-progcomp"
732 "--disable-net-redirections"
733 "--disable-nls"
734
735 ;; Pretend 'dlopen' is missing so we don't build loadable
736 ;; modules and related code.
737 "ac_cv_func_dlopen=no")
738 #:make-flags '("bash")
739 #:phases
740 (modify-phases %standard-phases
741 (add-before 'configure 'setenv
742 (lambda _
743 (let* ((gash (assoc-ref %build-inputs "bash"))
744 (shell (string-append gash "/bin/gash")))
745 (setenv "CONFIG_SHELL" shell)
746 (setenv "SHELL" shell)
747 (setenv "CC" "tcc")
748 (setenv "LD" "tcc")
749 (setenv "AR" "tcc -ar")
750 (setenv "CFLAGS" "-D _POSIX_VERSION=1")
751 #t)))
752 (add-after 'unpack 'scripted-patch
753 (lambda _
754 (substitute* "Makefile.in"
755 (("mksyntax\\.c\n") "mksyntax.c -lgetopt\n")
756 (("buildversion[.]o\n") "buildversion.o -lgetopt\n")
757 ;; No size in Gash
758 (("\tsize ") "#\tsize"))
759 (substitute* "lib/sh/oslib.c"
760 (("int name, namelen;") "char *name; int namelen;"))
761 (substitute* "lib/sh/snprintf.c"
762 (("^#if (defined [(]HAVE_LOCALE_H[)])" all define) (string-append "#if 0 //" define)))
763 (substitute* "configure"
764 ((" egrep") " grep"))
765 #t))
766 (replace 'configure
767 (lambda* (#:key configure-flags #:allow-other-keys)
768 (let ((configure-flags (filter (lambda (x)
769 (and (not (string-prefix? "CONFIG_SHELL=" x))
770 (not (string-prefix? "SHELL=" x))))
771 configure-flags)))
772 (format (current-error-port)
773 "running ./configure ~a\n" (string-join configure-flags)))
774 (apply invoke (cons "./configure" configure-flags))))
775 (add-after 'configure 'configure-fixups
776 (lambda _
777 (substitute* "config.h"
778 (("#define GETCWD_BROKEN 1") "#undef GETCWD_BROKEN"))
779 (let ((config.h (open-file "config.h" "a")))
780 (display (string-append "
781// tcc: error: undefined symbol 'enable_hostname_completion'
782#define enable_hostname_completion(on_or_off) 0
783
784// /gnu/store/cq0cmv35s9dhilx14zaghlc08gpc0hwr-tcc-boot0-0.9.26-6.c004e9a/lib/libc.a: error: 'sigprocmask' defined twice
785#define HAVE_POSIX_SIGNALS 1
786#define endpwent(x) 0
787")
788 config.h)
789 (close config.h))
790 #t))
791 (replace 'check
792 (lambda _
793 (invoke "./bash" "--version")))
794 (replace 'install
795 (lambda _
796 (let* ((out (assoc-ref %outputs "out"))
797 (bin (string-append out "/bin")))
798 (mkdir-p bin)
799 (copy-file "bash" (string-append bin "/bash"))
800 (copy-file "bash" (string-append bin "/sh"))
801 #t))))))))
802
1be3efb3
JN
803(define tcc-boot
804 ;; The final tcc.
805 (package
806 (inherit tcc-boot0)
807 (name "tcc-boot")
808 (version "0.9.27")
809 (source (origin
810 (inherit (package-source tcc))
811 ;; `patches' needs XZ
812 ;; (patches (search-patches "tcc-boot-0.9.27.patch"))
813 ))
814 (build-system gnu-build-system)
815 (inputs '())
816 (propagated-inputs '())
817 (native-inputs `(;;("boot-patch" ,(search-patch "tcc-boot-0.9.27.patch"))
818 ("bzip2" ,bzip2-mesboot)
819 ,@(%boot-tcc0-inputs)))
820 (arguments
821 `(#:implicit-inputs? #f
822 #:guile ,%bootstrap-guile
823 #:validate-runpath? #f ; no dynamic executables
824 #:strip-binaries? #f ; no strip yet
825 #:phases
826 (modify-phases %standard-phases
827 ;; tar xvf ..bz2 gives
828 ;; bzip2: PANIC -- internal consistency error
829 (replace 'unpack
830 (lambda* (#:key source #:allow-other-keys)
831 (copy-file source "tarball.tar.bz2")
832 (invoke "bzip2" "-d" "tarball.tar.bz2")
833 (invoke "tar" "xvf" "tarball.tar")
834 (chdir (string-append "tcc-" ,version))
835 #t))
836 ;; no patch yet
837 ;; (add-after 'unpack 'apply-boot-patch
838 ;; (lambda* (#:key inputs #:allow-other-keys)
839 ;; (let ((patch-file (assoc-ref inputs "boot-patch")))
840 ;; (invoke "patch" "-p1" "-i" patch-file))))
841 (add-after 'unpack 'scripted-patch
842 (lambda* (#:key inputs #:allow-other-keys)
843 (substitute* "libtcc.c"
844 (("s->alacarte_link = 1;" all)
845 (string-append all "
846 s->static_link = 1;")))
847 #t))
848 (replace 'configure
849 (lambda* (#:key outputs #:allow-other-keys)
850 (let* ((out (assoc-ref %outputs "out"))
851 (tcc (assoc-ref %build-inputs "tcc"))
852 (libc (assoc-ref %build-inputs "libc"))
853 (interpreter "/mes/loader"))
854 (invoke "sh" "configure"
855 (string-append "--cc=tcc")
856 (string-append "--cpu=i386")
857 (string-append "--prefix=" out)
858 (string-append "--elfinterp=" interpreter)
859 (string-append "--crtprefix=" tcc "/lib")
860 (string-append "--sysincludepaths=" tcc "/include")
861 (string-append "--libpaths=" tcc "/lib")))))
862 (replace 'build
863 (lambda* (#:key outputs #:allow-other-keys)
864 (let* ((out (assoc-ref %outputs "out"))
865 (tcc (assoc-ref %build-inputs "tcc"))
866 (libc (assoc-ref %build-inputs "libc"))
867 (interpreter "/mes/loader"))
868 (invoke
869 "tcc"
870 "-vvv"
871 "-D" "BOOTSTRAP=1"
872 "-D" "ONE_SOURCE=1"
873 "-D" "TCC_TARGET_I386=1"
874 "-D" "CONFIG_TCC_STATIC=1"
875 "-D" "CONFIG_USE_LIBGCC=1"
876 "-D" (string-append "CONFIG_TCCDIR=\"" out "/lib/tcc\"")
877 "-D" (string-append "CONFIG_TCC_CRTPREFIX=\"" out "/lib:{B}/lib:.\"")
878 "-D" (string-append "CONFIG_TCC_CRTPREFIX=\"" out "/lib:{B}/lib:.\"")
879 "-D" (string-append "CONFIG_TCC_ELFINTERP=\"" interpreter "\"")
880 "-D" (string-append "CONFIG_TCC_LIBPATHS=\"" tcc "/lib:{B}/lib:.\"")
881 "-D" (string-append "CONFIG_TCC_SYSINCLUDEPATHS=\""
882 tcc "/include" ":/include:{B}/include\"")
883 "-D" (string-append "TCC_LIBGCC=\"" tcc "/lib/libc.a\"")
884 "-o" "tcc"
885 "tcc.c"))))
886 (replace 'check
887 (lambda _
888 ;; FIXME: add sensible check target (without depending on make)
889 ;; ./check.sh ?
890 (= 1 (status:exit-val (system* "./tcc" "--help")))))
891 (replace 'install
892 (lambda* (#:key outputs #:allow-other-keys)
893 (let ((out (assoc-ref %outputs "out"))
894 (tcc (assoc-ref %build-inputs "tcc")))
895 (and
896 (mkdir-p (string-append out "/bin"))
897 (copy-file "tcc" (string-append out "/bin/tcc"))
898 (mkdir-p (string-append out "/lib/tcc"))
899 (copy-recursively (string-append tcc "/include")
900 (string-append out "/include"))
901 (copy-recursively (string-append tcc "/lib")
902 (string-append out "/lib"))
903 (invoke "tcc" "-D" "TCC_TARGET_I386=1" "-c" "-o" "libtcc1.o" "lib/libtcc1.c")
904 (invoke "tcc" "-ar" "rc" "libtcc1.a" "libtcc1.o")
905 (copy-file "libtcc1.a" (string-append out "/lib/libtcc1.a"))
906 (delete-file (string-append out "/lib/tcc/libtcc1.a"))
907 (copy-file "libtcc1.a" (string-append out "/lib/tcc/libtcc1.a"))
908 #t)))))))))
909
0b652851 910(define diffutils-mesboot
aa196f1f 911 ;; The initial diffutils.
9a45a24f
LC
912 (package
913 (inherit diffutils)
914 (name "diffutils-mesboot")
915 (version "2.7")
916 (source (origin
917 (method url-fetch)
918 (uri (string-append "mirror://gnu/diffutils/diffutils-"
919 version ".tar.gz"))
920 (sha256
921 (base32
922 "1mirn5i825bn5w7rh6mgn0r8aj9xqanav95dwcl1b8sn82f4iwnm"))))
923 (supported-systems '("i686-linux" "x86_64-linux"))
924 (inputs '())
925 (propagated-inputs '())
aa196f1f 926 (native-inputs (%boot-tcc0-inputs))
9a45a24f
LC
927 (arguments
928 `(#:implicit-inputs? #f
929 #:guile ,%bootstrap-guile
930 #:parallel-build? #f
931 #:tests? #f ; check is naive, also checks non-built PROGRAMS
932 #:strip-binaries? #f ; no strip yet
933 #:phases
934 (modify-phases %standard-phases
9a45a24f
LC
935 (add-before 'configure 'remove-diff3-sdiff
936 (lambda* (#:key outputs #:allow-other-keys)
937 (substitute* "Makefile.in"
aa196f1f
JN
938 (("PROGRAMS = .*" all) "PROGRAMS = cmp diff"))))
939 (replace 'configure ; needs classic invocation of configure
940 (lambda* (#:key configure-flags #:allow-other-keys)
941 (let* ((out (assoc-ref %outputs "out"))
942 (bash (assoc-ref %build-inputs "bash"))
943 (shell (string-append bash "/bin/bash")))
944 (setenv "CONFIG_SHELL" shell)
945 (setenv "CC" "tcc")
946 (setenv "LD" "tcc")
947 (format (current-error-port)
948 "running ./configure ~a\n" (string-join configure-flags))
949 (apply invoke (cons "./configure" configure-flags)))))
950 (replace 'install
951 (lambda _
952 (let* ((out (assoc-ref %outputs "out"))
953 (bin (string-append out "/bin")))
954 (mkdir-p bin)
955 (install-file "cmp" bin)
956 (install-file "diff" bin)
957 #t))))))))
0b652851 958
1a433d39
JN
959(define patch-mesboot
960 ;; The initial patch.
961 (package
962 (inherit patch)
963 (name "patch-mesboot")
964 (version "2.5.9")
965 (source (origin
966 (method url-fetch)
967 (uri (string-append "mirror://gnu/patch/patch-"
968 version ".tar.gz"))
969 (sha256
970 (base32
971 "12nv7jx3gxfp50y11nxzlnmqqrpicjggw6pcsq0wyavkkm3cddgc"))))
972 (supported-systems '("i686-linux" "x86_64-linux"))
973 (inputs '())
974 (propagated-inputs '())
975 (native-inputs (%boot-tcc0-inputs))
976 (arguments
977 `(#:implicit-inputs? #f
978 #:guile ,%bootstrap-guile
979 #:parallel-build? #f
980 #:tests? #f ; check is naive, also checks non-built PROGRAMS
981 #:strip-binaries? #f ; no strip yet
982 #:configure-flags '("AR=tcc -ar" "CC=tcc" "LD-tcc")
983 #:phases
984 (modify-phases %standard-phases
985 (add-after 'unpack 'scripted-patch
986 (lambda _
987 ;; avoid another segfault
988 (substitute* "pch.c"
989 (("while [(]p_end >= 0[)]" all)
990 "p_end = -1;\nwhile (0)"))
991 #t))
992 ;; FIXME: no compressing gzip yet
993 (delete 'compress-documentation))))))
994
b755ffef
JN
995(define sed-mesboot0
996 ;; The initial sed.
997 (package
998 (inherit sed)
999 (name "sed-mesboot0")
1000 (version "1.18")
1001 (source (origin
1002 (method url-fetch)
1003 (uri (string-append "mirror://gnu/sed/sed-"
1004 version ".tar.gz"))
1005 (sha256
1006 (base32
1007 "1hyv7i82jd0q18xcql51ylc8jwadp3gb3irgcqlis3v61p35jsv2"))))
1008 (supported-systems '("i686-linux" "x86_64-linux"))
1009 (inputs '())
1010 (propagated-inputs '())
1011 (native-inputs (%boot-tcc0-inputs))
1012 (arguments
1013 `(#:implicit-inputs? #f
1014 #:guile ,%bootstrap-guile
1015 #:parallel-build? #f
1016 #:configure-flags '("CC=tcc")
1017 #:make-flags '("CC=tcc" "extra_objs=" "DEFS=-D HAVE_BCOPY")
1018 #:strip-binaries? #f ; no strip yet
1019 #:phases
1020 (modify-phases %standard-phases
1021 (add-after 'unpack 'scripted-patch
1022 (lambda _
1023 (let* ((out (assoc-ref %outputs "out"))
1024 (bash (assoc-ref %build-inputs "bash"))
1025 (shell (string-append bash "/bin/bash")))
1026 (substitute* "configure"
1027 (("/bin/sh") shell))
1028 #t)))
1029 (replace 'check
1030 (lambda _
1031 (invoke "./sed" "--version")))
1032 (replace 'install
1033 (lambda _
1034 (let* ((out (assoc-ref %outputs "out"))
1035 (bin (string-append out "/bin")))
1036 (install-file "sed" bin)
1037 #t))))))))
1038
1039(define (%boot-tcc-inputs)
1040 `(("bash" ,bash-mesboot0)
1041 ("bzip2" ,bzip2-mesboot)
1042 ("diffutils" ,diffutils-mesboot)
1043 ("gzip" ,gzip-mesboot)
1044 ("patch" ,patch-mesboot)
1045 ("sed" ,sed-mesboot0)
1046 ("tcc" ,tcc-boot)
1047 ,@(alist-delete "tcc" (%boot-tcc0-inputs))))
1048
0b652851 1049(define binutils-mesboot0
cb167958 1050 ;; The initial Binutils
9a45a24f
LC
1051 (package
1052 (inherit binutils)
1053 (name "binutils-mesboot0")
cb167958
JN
1054 (version "2.14")
1055 (source (origin
1056 (method url-fetch)
1057 (uri (string-append "mirror://gnu/binutils/binutils-"
1058 version ".tar.gz"))
1059 (sha256
1060 (base32
1061 "1w8xp7k44bkijr974x9918i4p1sw4g2fcd5mxvspkjpg38m214ds"))))
9a45a24f
LC
1062 (inputs '())
1063 (propagated-inputs '())
cb167958 1064 (native-inputs (%boot-tcc-inputs))
9a45a24f
LC
1065 (supported-systems '("i686-linux" "x86_64-linux"))
1066 (arguments
1067 `(#:implicit-inputs? #f
1068 #:guile ,%bootstrap-guile
cb167958 1069 #:tests? #f ; runtest: command not found
9a45a24f 1070 #:parallel-build? #f
cb167958 1071 #:strip-binaries? #f ; no strip yet
9a45a24f 1072 #:configure-flags
cb167958
JN
1073 (let ((out (assoc-ref %outputs "out")))
1074 `("--disable-nls"
9a45a24f
LC
1075 "--disable-shared"
1076 "--disable-werror"
cb167958
JN
1077 "--build=i386-unknown-linux"
1078 "--host=i386-unknown-linux"
1079 "--target=i386-unknown-linux"
1080 "--with-sysroot=/"
1081 ,(string-append "--prefix=" out)))
1082 #:phases
1083 (modify-phases %standard-phases
1084 (add-before 'configure 'setenv
1085 (lambda _
1086 (let* ((out (assoc-ref %outputs "out"))
1087 (bash (assoc-ref %build-inputs "bash"))
1088 (shell (string-append bash "/bin/bash")))
1089 (setenv "CONFIG_SHELL" shell)
1090 (setenv "SHELL" shell)
1091 (setenv "AR" "tcc -ar")
1092 (setenv "RANLIB" "true")
1093 (setenv "CC" "tcc -D __GLIBC_MINOR__=6")
1094 #t)))
1095 (add-after 'unpack 'scripted-patch
1096 (lambda* (#:key inputs #:allow-other-keys)
1097 (substitute* "bfd/configure"
1098 (("^sed -e '/SRC-POTFILES.*" all)
1099 "echo -e 'all:\\n\\ttrue\\n\\ninstall:\\n\\ttrue\\n' > po/Makefile\n"))
1100 #t))
1101 (replace 'configure ; needs classic invocation of configure
1102 (lambda* (#:key configure-flags #:allow-other-keys)
1103 (format (current-error-port)
1104 "running ./configure ~a\n" (string-join configure-flags))
1105 (apply system* "./configure" configure-flags)
1106 (substitute* "config.status"
1107 (("[.]//dev/null") "/dev/null"))
1108 (invoke "sh" "./config.status"))))))))
0b652851 1109
06616960 1110(define gcc-core-mesboot0
0b652851
JN
1111 ;; Gcc-2.95.3 is the most recent GCC that is supported by what the Mes C
1112 ;; Library v0.16 offers. Gcc-3.x (and 4.x) place higher demands on a C
1113 ;; library, such as dir.h/struct DIR/readdir, locales, signals... Also,
06616960
JN
1114 ;; with gcc-2.95.3, binutils (2.14.0, 2.20.1a) and glibc-2.2.5 we found a
1115 ;; GNU toolchain triplet "that works".
9a45a24f
LC
1116 (package
1117 (inherit gcc)
06616960 1118 (name "gcc-core-mesboot0")
9a45a24f 1119 (version "2.95.3")
06616960
JN
1120 (source (origin
1121 (method url-fetch)
1122 (uri (string-append "mirror://gnu/gcc/gcc-2.95.3/gcc-core-"
1123 version
1124 ".tar.gz"))
1125 ;; `patches' needs XZ
1126 ;; (patches (search-patches "gcc-boot-2.95.3.patch"))
1127 (sha256
1128 (base32
1129 "1xvfy4pqhrd5v2cv8lzf63iqg92k09g6z9n2ah6ndd4h17k1x0an"))))
9a45a24f
LC
1130 (supported-systems '("i686-linux" "x86_64-linux"))
1131 (inputs '())
1132 (propagated-inputs '())
06616960
JN
1133 (native-inputs `(("boot-patch" ,(search-patch "gcc-boot-2.95.3.patch"))
1134 ("binutils" ,binutils-mesboot0)
1135 ,@(%boot-tcc-inputs)))
9a45a24f
LC
1136 (outputs '("out"))
1137 (arguments
1138 `(#:implicit-inputs? #f
1139 #:guile ,%bootstrap-guile
1140 #:tests? #f
1141 #:parallel-build? #f
1142 #:strip-binaries? #f
1143 #:configure-flags
1144 (let ((out (assoc-ref %outputs "out")))
1145 `("--enable-static"
1146 "--disable-shared"
1147 "--disable-werror"
1148 "--build=i686-unknown-linux-gnu"
1149 "--host=i686-unknown-linux-gnu"
1150 ,(string-append "--prefix=" out)))
06616960
JN
1151 #:make-flags
1152 `("CC=tcc -static -D __GLIBC_MINOR__=6"
1153 "OLDCC=tcc -static -D __GLIBC_MINOR__=6"
1154 "CC_FOR_BUILD=tcc -static -D __GLIBC_MINOR__=6"
1155 "AR=ar"
1156 "RANLIB=ranlib"
1157 ,(string-append "LIBGCC2_INCLUDES=-I "
1158 (assoc-ref %build-inputs "tcc")
1159 "/include")
1160 "LANGUAGES=c"
1161 ,(string-append "BOOT_LDFLAGS="
1162 " -B" (assoc-ref %build-inputs "tcc")
1163 "/lib/"))
9a45a24f
LC
1164 #:modules ((guix build gnu-build-system)
1165 (guix build utils)
1166 (srfi srfi-1))
1167 #:phases
1168 (modify-phases %standard-phases
06616960
JN
1169 (add-after 'unpack 'apply-boot-patch
1170 (lambda* (#:key inputs #:allow-other-keys)
1171 (let ((patch-file (assoc-ref inputs "boot-patch")))
1172 (system* "patch" "--force" "-p1" "-i" patch-file)
1173 #t)))
9a45a24f
LC
1174 (add-before 'configure 'setenv
1175 (lambda* (#:key outputs #:allow-other-keys)
06616960
JN
1176 (let* ((out (assoc-ref outputs "out"))
1177 (bash (assoc-ref %build-inputs "bash"))
1178 (shell (string-append bash "/bin/bash"))
1179 (tcc (assoc-ref %build-inputs "tcc"))
1180 (cppflags " -D __GLIBC_MINOR__=6"))
1181 (setenv "CONFIG_SHELL" shell)
9a45a24f
LC
1182 (setenv "CPPFLAGS" cppflags)
1183 (setenv "CC" (string-append "tcc" cppflags))
1184 (setenv "CC_FOR_BUILD" (string-append "tcc" cppflags))
1185 (setenv "CPP" (string-append "tcc -E" cppflags))
1186 (with-output-to-file "config.cache"
1187 (lambda _
1188 (display "
0b652851 1189ac_cv_c_float_format='IEEE (little-endian)'
06616960
JN
1190"))))))
1191 ;; gcc-2.95.3
1192 (replace 'configure ; needs classic invocation of configure
9a45a24f
LC
1193 (lambda* (#:key configure-flags #:allow-other-keys)
1194 (format (current-error-port)
1195 "running ./configure ~a\n" (string-join configure-flags))
1196 (apply invoke "./configure" configure-flags)))
1197 (add-after 'configure 'remove-info
1198 (lambda _
1199 ;; no info at this stage
1200 (delete-file-recursively "texinfo")
1201 (invoke "touch" "gcc/cpp.info" "gcc/gcc.info")))
1202 (add-after 'install 'install2
1203 (lambda* (#:key outputs #:allow-other-keys)
1204 (let* ((tcc (assoc-ref %build-inputs "tcc"))
1205 (tcc-lib (string-append tcc "/lib/x86-mes-gcc"))
1206 (out (assoc-ref outputs "out"))
1207 (gcc-dir (string-append
1208 out "/lib/gcc-lib/i686-unknown-linux-gnu/2.95.3")))
1209 (mkdir-p "tmp")
06616960
JN
1210 (with-directory-excursion "tmp"
1211 (invoke "ar" "x" (string-append "../gcc/libgcc2.a"))
1212 (invoke "ar" "x" (string-append tcc "/lib/libtcc1.a"))
1213 (apply invoke "ar" "r" (string-append gcc-dir "/libgcc.a")
1214 (find-files "." "\\.o")))
9a45a24f
LC
1215 (copy-file "gcc/libgcc2.a" (string-append out "/lib/libgcc2.a"))
1216 (copy-file (string-append tcc "/lib/libtcc1.a")
1217 (string-append out "/lib/libtcc1.a"))
06616960
JN
1218 (invoke "ar" "x" (string-append tcc "/lib/libtcc1.a"))
1219 (invoke "ar" "x" (string-append tcc "/lib/libc.a"))
9a45a24f 1220 (invoke "ar" "r" (string-append gcc-dir "/libc.a")
06616960 1221 "libc.o" "libtcc1.o")
9a45a24f
LC
1222 #t))))))
1223 (native-search-paths
9a45a24f
LC
1224 (list (search-path-specification
1225 (variable "C_INCLUDE_PATH")
558b0bbe
LC
1226 (files '("include"
1227
1228 ;; Needed to get things like GCC's <stddef.h>.
1229 "lib/gcc-lib/i686-unknown-linux-gnu/2.95.3/include")))
9a45a24f
LC
1230 (search-path-specification
1231 (variable "LIBRARY_PATH")
1232 (files '("lib")))))))
0b652851 1233
06616960
JN
1234(define (%boot-mesboot-core-inputs)
1235 `(("binutils" ,binutils-mesboot0)
1236 ("gawk" ,gawk-mesboot0)
1237 ("gcc" ,gcc-core-mesboot0)
1238 ,@(alist-delete "tcc" (%boot-tcc-inputs))))
1239
0b652851 1240(define mesboot-headers
9a45a24f
LC
1241 (package
1242 (inherit mes-boot)
1243 (name "mesboot-headers")
1244 (supported-systems '("i686-linux" "x86_64-linux"))
1245 (inputs '())
1246 (propagated-inputs '())
562c6e3c
JN
1247 (native-inputs `(("kernel-headers" ,%bootstrap-linux-libre-headers)
1248 ,@(%boot-tcc-inputs)))
9a45a24f
LC
1249 (arguments
1250 `(#:implicit-inputs? #f
1251 #:guile ,%bootstrap-guile
1252 #:tests? #f
1253 #:strip-binaries? #f
1254 #:phases
1255 (modify-phases %standard-phases
1256 (delete 'configure)
1257 (delete 'build)
1258 (replace 'install
1259 (lambda* (#:key outputs #:allow-other-keys)
1260 (let* ((out (assoc-ref outputs "out"))
1261 (include (string-append out "/include"))
562c6e3c 1262 (headers (assoc-ref %build-inputs "kernel-headers")))
9a45a24f
LC
1263 (mkdir-p include)
1264 (copy-recursively "include" out)
1265 (copy-recursively headers out)
558b0bbe 1266 #t))))))))
0b652851 1267
2c672814
JN
1268(define gawk-mesboot0
1269 ;; The initial Gawk.
1270 (package
1271 (inherit gawk)
1272 (name "gawk-mesboot0")
1273 (version "3.0.0")
1274 (source (origin
1275 (method url-fetch)
1276 (uri (string-append "mirror://gnu/gawk/gawk-"
1277 version ".tar.gz"))
1278 (sha256
1279 (base32
1280 "087s7vpc8zawn3l7bwv9f44bf59rc398hvaiid63klw6fkbvabr3"))))
1281 (supported-systems '("i686-linux" "x86_64-linux"))
1282 (inputs '())
1283 (propagated-inputs '())
1284 (native-inputs (%boot-tcc-inputs))
1285 (arguments
1286 `(#:implicit-inputs? #f
1287 #:guile ,%bootstrap-guile
1288 #:configure-flags '("--build=i686-unknown-linux-gnu"
1289 "--host=i686-unknown-linux-gnu"
1290 "--disable-nls")
1291 #:make-flags '("gawk")
1292 #:parallel-build? #f
1293 #:parallel-tests? #f
1294 #:strip-binaries? #f ; no strip yet
1295 #:phases
1296 (modify-phases %standard-phases
1297 (add-after 'unpack 'scripted-patch
1298 (lambda _
1299 (substitute* "Makefile.in"
1300 (("date ") "echo today ")
1301 ((" autoheader") "true")
1302 ((" -lm ") " "))
1303 (substitute* "test/Makefile.in"
1304 (("^bigtest:.*") "bigtest: basic\n")
1305 (("( |\t)(childin|convfmt|fflush|longwrds|math|negexp)" all sep) sep))))
1306 (add-before 'configure 'setenv
1307 (lambda _
1308 (let* ((out (assoc-ref %outputs "out"))
1309 (bash (assoc-ref %build-inputs "bash"))
1310 (shell (string-append bash "/bin/bash")))
1311 (setenv "CONFIG_SHELL" shell)
1312 (setenv "SHELL" shell)
1313 (setenv "CC" "tcc")
1314 (setenv "CPP" "tcc -E")
1315 (setenv "LD" "tcc")
1316 (setenv "ac_cv_func_getpgrp_void" "yes")
1317 (setenv "ac_cv_func_tzset" "yes"))
1318 #t))
1319 (replace 'configure ; needs classic invocation of configure
1320 (lambda* (#:key configure-flags #:allow-other-keys)
1321 (let* ((out (assoc-ref %outputs "out"))
1322 (configure-flags
1323 `(,@configure-flags
1324 ,(string-append "--prefix=" out))))
1325 (format (current-error-port) "running ./configure ~a\n" (string-join configure-flags))
1326 (system* "touch" "configure") ; aclocal.m4 is newer than configure
1327 (apply invoke (cons "./configure" configure-flags)))))
1328 (replace 'install
1329 (lambda* (#:key outputs #:allow-other-keys)
1330 (let* ((out (assoc-ref outputs "out"))
1331 (bin (string-append out "/bin")))
1332 (install-file "gawk" bin)
1333 (symlink "gawk" (string-append bin "/awk"))
1334 #t))))))))
1335
0b652851
JN
1336(define glibc-mesboot0
1337 ;; GNU C Library 2.2.5 is the most recent glibc that we managed to build
1338 ;; using gcc-2.95.3. Newer versions (2.3.x, 2.6, 2.1x) seem to need a newer
1339 ;; gcc.
9a45a24f
LC
1340 (package
1341 (inherit glibc)
1342 (name "glibc-mesboot0")
1343 (version "2.2.5")
f6b911fb
JN
1344 (source (origin
1345 (method url-fetch)
1346 (uri (string-append "mirror://gnu/glibc/glibc-"
1347 version
1348 ".tar.gz"))
1349 ;; Patch needs XZ
1350 ;; (patches (search-patches "glibc-boot-2.2.5.patch"))
1351 (sha256
1352 (base32
1353 "1vl48i16gx6h68whjyhgnn1s57vqq32f9ygfa2fls7pdkbsqvp2q"))))
9a45a24f
LC
1354 (supported-systems '("i686-linux" "x86_64-linux"))
1355 (inputs '())
1356 (propagated-inputs '())
f6b911fb
JN
1357 (native-inputs `(("boot-patch" ,(search-patch "glibc-boot-2.2.5.patch"))
1358 ("system-patch" ,(search-patch "glibc-bootstrap-system-2.2.5.patch"))
9a45a24f 1359 ("headers" ,mesboot-headers)
062bc721 1360 ,@(%boot-mesboot-core-inputs)))
9a45a24f
LC
1361 (outputs '("out"))
1362 (arguments
1363 `(#:implicit-inputs? #f
1364 #:guile ,%bootstrap-guile
1365 #:tests? #f
1366 #:strip-binaries? #f
f6b911fb 1367 #:validate-runpath? #f ; no dynamic executables
9a45a24f
LC
1368 #:parallel-build? #f ; gcc-2.95.3 ICEs on massively parallel builds
1369 #:make-flags (list (string-append
1370 "SHELL="
1371 (assoc-ref %build-inputs "bash")
1372 "/bin/sh"))
1373 #:configure-flags
1374 (let ((out (assoc-ref %outputs "out"))
1375 (headers (assoc-ref %build-inputs "headers")))
f6b911fb
JN
1376 `("--disable-shared"
1377 "--enable-static"
1378 "--disable-sanity-checks"
1379 "--build=i686-unknown-linux-gnu"
1380 "--host=i686-unknown-linux-gnu"
1381 ,(string-append "--with-headers=" headers "/include")
1382 "--enable-static-nss"
1383 "--without-__thread"
1384 "--without-cvs"
1385 "--without-gd"
1386 "--without-tls"
1387 ,(string-append "--prefix=" out)))
9a45a24f
LC
1388 #:phases
1389 (modify-phases %standard-phases
f6b911fb
JN
1390 (add-after 'unpack 'apply-boot-patch
1391 (lambda* (#:key inputs #:allow-other-keys)
1392 (and (let ((patch (assoc-ref inputs "boot-patch")))
1393 (invoke "patch" "--force" "-p1" "-i" patch))
1394 (let ((patch (assoc-ref inputs "system-patch")))
1395 (invoke "patch" "--force" "-p1" "-i" patch)))))
9a45a24f
LC
1396 (add-before 'configure 'setenv
1397 (lambda* (#:key outputs #:allow-other-keys)
1398 (let* ((out (assoc-ref outputs "out"))
1399 (bash (assoc-ref %build-inputs "bash"))
f6b911fb 1400 (shell (string-append bash "/bin/bash"))
9a45a24f
LC
1401 (gcc (assoc-ref %build-inputs "gcc"))
1402 (headers (assoc-ref %build-inputs "headers"))
1403 (cppflags (string-append
1404 ;;" -D __STDC__=1"
1405 " -D MES_BOOTSTRAP=1"
1406 " -D BOOTSTRAP_GLIBC=1"))
1407 (cflags (string-append " -L " (getcwd))))
f6b911fb
JN
1408 (setenv "CONFIG_SHELL" shell)
1409 (setenv "SHELL" shell)
9a45a24f
LC
1410 (setenv "CPP" (string-append gcc "/bin/gcc -E " cppflags))
1411 (setenv "CC" (string-append gcc "/bin/gcc " cppflags cflags))
1412 #t)))
f6b911fb 1413 (replace 'configure ; needs classic invocation of configure
9a45a24f
LC
1414 (lambda* (#:key configure-flags #:allow-other-keys)
1415 (format (current-error-port)
1416 "running ./configure ~a\n" (string-join configure-flags))
f6b911fb 1417 (apply invoke "./configure" configure-flags)))
062bc721
JN
1418 (add-after 'configure 'fixup-configure
1419 (lambda _
1420 (let* ((out (assoc-ref %outputs "out"))
1421 (bash (assoc-ref %build-inputs "bash"))
1422 (shell (string-append bash "/bin/bash")))
1423 (substitute* "config.make"
1424 (("INSTALL = scripts/") "INSTALL = $(..)./scripts/"))
1425 (substitute* "config.make"
1426 (("INSTALL = scripts/") "INSTALL = $(..)./scripts/")
1427 (("BASH = ") (string-append
1428 "SHELL = " shell "
1429 BASH = ")))
1430 #t))))))))
0b652851
JN
1431
1432(define gcc-mesboot0
9a45a24f 1433 (package
06616960 1434 (inherit gcc-core-mesboot0)
9a45a24f 1435 (name "gcc-mesboot0")
71fb04a5 1436 (native-inputs `(("boot-patch" ,(search-patch "gcc-boot-2.95.3.patch"))
558b0bbe
LC
1437 ;; Packages are given in an order that's relevant for
1438 ;; #include_next purposes.
9a45a24f 1439 ("libc" ,glibc-mesboot0)
558b0bbe 1440 ("kernel-headers" ,%bootstrap-linux-libre-headers)
71fb04a5 1441 ,@(%boot-mesboot-core-inputs)))
9a45a24f 1442 (arguments
06616960 1443 (substitute-keyword-arguments (package-arguments gcc-core-mesboot0)
9a45a24f
LC
1444 ((#:phases phases)
1445 `(modify-phases ,phases
1446 (replace 'setenv
558b0bbe
LC
1447 (lambda _
1448 (setenv "CONFIG_SHELL" (which "sh"))
1449 (with-output-to-file "config.cache"
1450 (lambda _
1451 (display "
0b652851
JN
1452ac_cv_c_float_format='IEEE (little-endian)'
1453")))
558b0bbe 1454 #t))
9a45a24f
LC
1455 (replace 'install2
1456 (lambda* (#:key outputs #:allow-other-keys)
1457 (let* ((out (assoc-ref outputs "out"))
1458 (gcc-dir (string-append
1459 out "/lib/gcc-lib/i686-unknown-linux-gnu/2.95.3")))
71fb04a5
JN
1460 (and
1461 (mkdir-p "tmp")
1462 (zero? (system (string-append "set -x; cd tmp && ar x ../gcc/libgcc2.a")))
1463 (zero? (system (string-append "set -x; cd tmp && ar r " gcc-dir "/libgcc.a *.o")))
1464 (copy-file "gcc/libgcc2.a" (string-append out "/lib/libgcc2.a"))))))))
9a45a24f
LC
1465 ((#:configure-flags configure-flags)
1466 `(let ((out (assoc-ref %outputs "out")))
1467 `("--disable-shared"
1468 "--disable-werror"
1469 "--build=i686-unknown-linux-gnu"
1470 "--host=i686-unknown-linux-gnu"
1471 ,(string-append "--prefix=" out))))
1472 ((#:make-flags make-flags)
1473 `(let ((gcc (assoc-ref %build-inputs "gcc")))
1474 `("RANLIB=true"
1475 ,(string-append "LIBGCC2_INCLUDES=-I " gcc "/include")
1476 "LANGUAGES=c")))))))
0b652851 1477
71fb04a5
JN
1478(define (%boot-mesboot0-inputs)
1479 `(("gcc" ,gcc-mesboot0)
1480 ("kernel-headers" ,%bootstrap-linux-libre-headers)
1481 ("libc" ,glibc-mesboot0)
1482 ,@(alist-delete "gcc" (%boot-mesboot-core-inputs))))
1483
125d7c58
JN
1484(define tar-mesboot
1485 ;; Initial tar with support for xz compression.
1486 (package
1487 (inherit tar)
1488 (name "tar-mesboot")
1489 (version "1.22")
1490 (source (origin
1491 (method url-fetch)
1492 (uri (string-append "mirror://gnu/tar/tar-"
1493 version ".tar.gz"))
1494 (sha256
1495 (base32
1496 "19nvix64y95n5v6rr5g9g3fn08zz85cb5anzd7csfv4a4sz9lw4y"))))
1497 (supported-systems '("i686-linux" "x86_64-linux"))
1498 (inputs '())
1499 (propagated-inputs '())
1500 (native-inputs (%boot-mesboot0-inputs))
1501 (arguments
1502 `(#:implicit-inputs? #f
1503 #:guile ,%bootstrap-guile
1504 #:parallel-build? #f
1505 #:tests? #f ; check is naive, also checks non-built PROGRAMS
1506 #:strip-binaries? #f ; no strip yet
1507 #:configure-flags '("--build=i686-unknown-linux-gnu"
1508 "--host=i686-unknown-linux-gnu"
1509 "--disable-nls")
1510 #:phases
1511 (modify-phases %standard-phases
1512 (replace 'configure
1513 (lambda* (#:key configure-flags #:allow-other-keys)
1514 (let* ((out (assoc-ref %outputs "out"))
1515 (bash (assoc-ref %build-inputs "bash"))
1516 (shell (string-append bash "/bin/bash")))
1517 (setenv "CONFIG_SHELL" shell)
1518 (setenv "SHELL" shell)
1519 (setenv "LIBS" "-lc -lnss_files -lnss_dns -lresolv")
1520 (setenv "gl_cv_func_rename_dest_works" "yes")
1521 (format (current-error-port)
1522 "running ./configure ~a\n" (string-join configure-flags))
1523 (apply invoke (cons "./configure" configure-flags)))))
1524 (add-after 'unpack 'scripted-patch
1525 (lambda _
1526 (let* ((bash (assoc-ref %build-inputs "bash"))
1527 (shell (string-append bash "/bin/bash")))
1528 (substitute* "configure"
1529 ((" /bin/sh") shell)))
1530 (substitute* "Makefile.in"
1531 (("^SUBDIRS = doc") "SUBDIRS ="))
1532 #t))
1533 (replace 'install
1534 (lambda _
1535 (let* ((out (assoc-ref %outputs "out"))
1536 (bin (string-append out "/bin")))
1537 (install-file "src/tar" bin)
1538 #t))))))))
1539
fa638c18
JN
1540(define grep-mesboot
1541 ;; The initial grep.
1542 (package
1543 (inherit grep)
1544 (name "grep-mesboot")
1545 (version "2.0")
1546 (source (origin
1547 (method url-fetch)
1548 (uri (string-append "mirror://gnu/grep/grep-"
1549 version ".tar.gz"))
1550 (sha256
1551 (base32
1552 "1w862l80lgc5mxvpiy4cfwk761d6xxavn0m3xd2l7xs2kmzvp6lq"))))
1553 (supported-systems '("i686-linux" "x86_64-linux"))
1554 (inputs '())
1555 (propagated-inputs '())
1556 (native-inputs (%boot-mesboot0-inputs))
1557 (arguments
1558 `(#:implicit-inputs? #f
1559 #:guile ,%bootstrap-guile
1560 #:parallel-build? #f
1561 #:phases
1562 (modify-phases %standard-phases
1563 (add-before 'configure 'patch-configure
1564 (lambda _
1565 (let* ((bash (assoc-ref %build-inputs "bash"))
1566 (shell (string-append bash "/bin/bash")))
1567 (substitute* "configure"
1568 ((" [|][|] ./config.status") " || sh ./config.status")))))
1569 (replace 'install
1570 (lambda _
1571 (let* ((out (assoc-ref %outputs "out"))
1572 (bin (string-append out "/bin")))
1573 (install-file "grep" bin)
1574 (symlink "grep" (string-append bin "/egrep"))
1575 (symlink "grep" (string-append bin "/fgrep"))
1576 #t))))))))
1577
e7c73268
JN
1578(define binutils-mesboot1
1579 (package
1580 (inherit binutils-mesboot0)
1581 (name "binutils-mesboot1")
1582 (native-inputs (%boot-mesboot0-inputs))
1583 (arguments
1584 (substitute-keyword-arguments (package-arguments binutils-mesboot0)
1585 ((#:configure-flags configure-flags)
1586 '(let ((out (assoc-ref %outputs "out")))
1587 `("--disable-nls"
1588 "--disable-shared"
1589 "--disable-werror"
1590 "--build=i686-unknown-linux-gnu"
1591 "--host=i686-unknown-linux-gnu"
1592 "--with-sysroot=/"
1593 ,(string-append "--prefix=" out))))
1594 ((#:phases phases)
1595 `(modify-phases ,phases
1596 (replace 'setenv
1597 (lambda _
1598 (let* ((out (assoc-ref %outputs "out"))
1599 (bash (assoc-ref %build-inputs "bash"))
1600 (shell (string-append bash "/bin/bash")))
1601 (setenv "CONFIG_SHELL" shell)
1602 #t)))))))))
1603
e6c7d14a
JN
1604(define coreutils-mesboot0
1605 (package
1606 (inherit coreutils)
1607 (name "coreutils-mesboot0")
1608 ;; The latest .gz release of Coreutils is 8.13; which does not build with gcc-2.95.3:
1609 ;; randperm.c: In function `sparse_swap':
1610 ;; randperm.c:117: invalid lvalue in unary `&'
1611 (version "5.0") ; 2003-04
1612 (source (origin
1613 (method url-fetch)
1614 (uri (string-append "mirror://gnu/coreutils/coreutils-"
1615 version ".tar.gz"))
1616 (sha256
1617 (base32
1618 "10wq6k66i8adr4k08p0xmg87ff4ypiazvwzlmi7myib27xgffz62"))))
1619 (native-inputs (%boot-mesboot0-inputs))
1620 (supported-systems '("i686-linux" "x86_64-linux"))
1621 (inputs '())
1622 (propagated-inputs '())
1623 (arguments
1624 `(#:implicit-inputs? #f
1625 #:tests? #f ; WARNING: `perl' is needed, ...
1626 #:parallel-build? #f
1627 #:strip-binaries? #f ; strip: unrecognized option `--only-keep-debug'
1628 #:guile ,%bootstrap-guile
1629 #:configure-flags
1630 '("--disable-doc"
1631 "LIBS=-lc -lnss_files -lnss_dns -lresolv"
1632 "ac_cv_func_gethostbyname=no"
1633 "gl_cv_func_rename_dest_works=yes")))))
1634
476614f7 1635(define gnu-make-mesboot
635ec0f4
JN
1636 (package
1637 (inherit gnu-make)
1638 (name "make-mesboot")
1639 (version "3.82")
1640 (source (origin
1641 (method url-fetch)
1642 (uri (string-append "mirror://gnu/make/make-"
1643 version ".tar.gz"))
1644 (sha256
1645 (base32
1646 "1rs2f9hmvy3q6zkl15jnlmnpgffm0bhw5ax0h5c7q604wqrip69x"))))
1647 (native-inputs (%boot-mesboot0-inputs))
1648 (supported-systems '("i686-linux" "x86_64-linux"))
1649 (inputs '())
1650 (propagated-inputs '())
1651 (arguments
1652 `(#:implicit-inputs? #f
1653 #:parallel-build? #f
1654 #:guile ,%bootstrap-guile
1655 #:configure-flags '("LIBS=-lc -lnss_files -lnss_dns -lresolv")
1656 #:phases
1657 (modify-phases %standard-phases
1658 (replace 'check
1659 (lambda _
1660 (invoke "./make" "--version")))
1661 (replace 'install
1662 (lambda* (#:key outputs #:allow-other-keys)
1663 (let* ((out (assoc-ref outputs "out"))
1664 (bin (string-append out "/bin")))
1665 (install-file "make" bin)
1666 #t))))))))
1667
53d5cb25
JN
1668(define gawk-mesboot
1669 (package
1670 (inherit gawk)
1671 (name "gawk-mesboot")
1672 (version "3.1.8")
1673 (source (origin
1674 (method url-fetch)
1675 (uri (string-append "mirror://gnu/gawk/gawk-"
1676 version ".tar.gz"))
1677 (sha256
1678 (base32
1679 "03d5y7jabq7p2s7ys9alay9446mm7i5g2wvy8nlicardgb6b6ii1"))))
1680 (native-inputs `(,@(%boot-mesboot0-inputs)
1681 ("mesboot-headers" ,mesboot-headers)))
1682 (supported-systems '("i686-linux" "x86_64-linux"))
1683 (inputs '())
1684 (propagated-inputs '())
1685 (arguments
1686 `(#:implicit-inputs? #f
1687 #:parallel-build? #f
1688 #:guile ,%bootstrap-guile
1689 #:configure-flags '("ac_cv_func_connect=no")
1690 #:make-flags '("gawk")
1691 #:phases
1692 (modify-phases %standard-phases
1693 (replace 'check
1694 (lambda _
1695 (invoke "./gawk" "--version")))
1696 (replace 'install
1697 (lambda* (#:key outputs #:allow-other-keys)
1698 (let* ((out (assoc-ref outputs "out"))
1699 (bin (string-append out "/bin")))
1700 (install-file "gawk" bin)
1701 (symlink "gawk" (string-append bin "/awk"))
1702 #t))))))))
1703
aad146a0
JN
1704(define sed-mesboot
1705 (package
1706 (inherit sed)
1707 (name "sed-mesboot")
1708 (version "4.0.6") ; 2003-04
1709 (source (origin
1710 (method url-fetch)
1711 (uri (string-append "mirror://gnu/sed/sed-"
1712 version ".tar.gz"))
1713 (sha256
1714 (base32
1715 "0861ij94cqc4vaaki6r2wlapwcmhpx4ggp4r70f46mb21a8fkvf1"))))
1716 (native-inputs (%boot-mesboot0-inputs))
1717 (supported-systems '("i686-linux" "x86_64-linux"))
1718 (inputs '())
1719 (propagated-inputs '())
1720 (arguments
1721 `(#:implicit-inputs? #f
1722 #:parallel-build? #f
1723 #:guile ,%bootstrap-guile
1724 #:tests? #f ; 8to7 fails
1725 #:phases
1726 (modify-phases %standard-phases
1727 (add-after 'unpack '/bin/sh
1728 (lambda _
1729 (let* ((bash (assoc-ref %build-inputs "bash"))
1730 (shell (string-append bash "/bin/bash")))
1731 (substitute* "testsuite/Makefile.tests"
1732 (("^SHELL = /bin/sh")
1733 (string-append "SHELL = " shell)))
1734 #t))))))))
1735
c1deb838
JN
1736(define bash-mesboot
1737 (package
1738 (inherit bash-mesboot0)
1739 (version "4.4")
1740 (name "bash-mesboot")
1741 (source (origin
1742 (method url-fetch)
1743 (uri (string-append "mirror://gnu/bash/bash-"
1744 version ".tar.gz"))
1745 (sha256
1746 (base32
1747 "1jyz6snd63xjn6skk7za6psgidsd53k05cr3lksqybi0q6936syq"))))
1748 (inputs '())
1749 (propagated-inputs '())
1750 (native-inputs (%boot-mesboot0-inputs))
1751 (outputs '("out"))
1752 (arguments
1753 `(#:implicit-inputs? #f
1754 #:guile ,%bootstrap-guile
1755 #:parallel-build? #f
1756 #:configure-flags
1757 '("--build=i686-unknown-linux-gnu"
1758 "--host=i686-unknown-linux-gnu"
1759
1760 "--without-bash-malloc"
1761 "--disable-readline"
1762 "--disable-history"
1763 "--disable-help-builtin"
1764 "--disable-progcomp"
1765 "--disable-net-redirections"
1766 "--disable-nls"
1767
1768 ;; Pretend 'dlopen' is missing so we don't build loadable
1769 ;; modules and related code.
1770 "ac_cv_func_dlopen=no")
1771 #:make-flags '("bash")
1772 #:phases
1773 (modify-phases %standard-phases
1774 (add-after 'unpack 'scripted-patch
1775 (lambda _
1776 (substitute* "shell.c"
1777 ((";;") ";"))
1778 #t))
1779 (add-before 'configure 'setenv
1780 (lambda _
1781 (setenv "AWK" "gawk")
1782 (setenv "LIBS" "-lc -lnss_files -lnss_dns -lresolv")
1783 (setenv "gl_cv_func_rename_dest_works" "yes")
1784 #t))
1785 (add-after 'configure 'configure-fixups
1786 (lambda _
1787 (let ((config.h (open-file "config.h" "a")))
1788 (display (string-append "
1789#define enable_hostname_completion(on_or_off) 0
1790")
1791 config.h)
1792 (close config.h))
1793 #t))
1794 (replace 'check
1795 (lambda _
1796 (invoke "./bash" "--version")))
1797 (replace 'install
1798 (lambda _
1799 (let* ((out (assoc-ref %outputs "out"))
1800 (bin (string-append out "/bin")))
1801 (mkdir-p bin)
1802 (copy-file "bash" (string-append bin "/bash"))
1803 (copy-file "bash" (string-append bin "/sh"))
1804 #t))))))))
1805
1806(define (%boot-mesboot1-inputs)
1807 `(("bash" ,bash-mesboot)
1808 ("binutils" ,binutils-mesboot1)
1809 ("coreutils" ,coreutils-mesboot0)
1810 ("gawk" ,gawk-mesboot)
1811 ("grep" ,grep-mesboot)
476614f7 1812 ("make" ,gnu-make-mesboot)
c1deb838
JN
1813 ("sed" ,sed-mesboot)
1814 ("tar" ,tar-mesboot)
1815 ,@(fold alist-delete (%boot-mesboot0-inputs)
1816 '("bash" "bash" "binutils" "coreutils" "gash" "gawk" "grep " "guile"
1817 "make" "sed" "tar"))))
1818
0b652851
JN
1819(define gmp-boot
1820 (package
1821 (inherit gmp)
1822 (version "4.3.2")
1823 (source (origin
1824 (method url-fetch)
1825 (uri (string-append "mirror://gnu/gmp/gmp-" version
1826 ".tar.gz"))
1827 (sha256 (base32
1828 "15rwq54fi3s11izas6g985y9jklm3xprfsmym3v1g6xr84bavqvv"))))))
1829
1830(define mpfr-boot
1831 (package
1832 (inherit mpfr)
1833 (version "2.4.2")
1834 (source (origin
1835 (method url-fetch)
1836 (uri (string-append "mirror://gnu/mpfr/mpfr-" version
1837 ".tar.gz"))
1838 (sha256 (base32
1839 "0dxn4904dra50xa22hi047lj8kkpr41d6vb9sd4grca880c7wv94"))))))
1840
1841(define mpc-boot
1842 (package
1843 (inherit mpc)
1844 (version "1.0.3")
1845 (source (origin
1846 (method url-fetch)
1847 (uri (string-append
1848 "mirror://gnu/mpc/mpc-" version ".tar.gz"))
1849 (sha256
1850 (base32
1851 "1hzci2zrrd7v3g1jk35qindq05hbl0bhjcyyisq9z209xb3fqzb1"))))))
1852
9a935f66
JN
1853(define gcc-core-mesboot1
1854 ;; GCC 4.6.4 is the latest modular distribution. This package is not
1855 ;; stricly needed, but very helpful for development because it builds
1856 ;; relatively fast. If this configures and builds then gcc-mesboot1 also
1857 ;; builds.
1858 (package
1859 (inherit gcc-mesboot0)
1860 (name "gcc-core-mesboot1")
1861 (version "4.6.4")
1862 (source (origin
1863 (method url-fetch)
1864 (uri (string-append "mirror://gnu/gcc/gcc-"
1865 version "/gcc-core-" version ".tar.gz"))
1866 (sha256
1867 (base32
1868 "173kdb188qg79pcz073cj9967rs2vzanyjdjyxy9v0xb0p5sad75"))
1869 ;; Patch needs XZ
1870 ;; (patches (search-patches "gcc-boot-4.6.4.patch"))
1871 ))
1872 (inputs `(("gmp-source" ,(package-source gmp-boot))
1873 ("mpfr-source" ,(package-source mpfr-boot))
1874 ("mpc-source" ,(package-source mpc-boot))))
1875 (native-inputs `(("boot-patch" ,(search-patch "gcc-boot-4.6.4.patch"))
1876 ,@(%boot-mesboot1-inputs)))
1877 (arguments
1878 `(#:implicit-inputs? #f
1879 #:guile ,%bootstrap-guile
1880 #:tests? #f
1881 #:modules ((guix build gnu-build-system)
1882 (guix build utils)
1883 (srfi srfi-1))
1884 #:parallel-build? #f ; for debugging
1885 #:make-flags
1886 (let* ((libc (assoc-ref %build-inputs "libc"))
1887 (ldflags (string-append
1888 "-B" libc "/lib "
1889 "-Wl,-dynamic-linker "
1890 "-Wl," libc
1891 ,(glibc-dynamic-linker "i686-linux"))))
1892 (list (string-append "LDFLAGS=" ldflags)
1893 (string-append "LDFLAGS_FOR_TARGET=" ldflags)))
1894 #:configure-flags
1895 (let ((out (assoc-ref %outputs "out"))
1896 (glibc (assoc-ref %build-inputs "libc")))
1897 (list (string-append "--prefix=" out)
1898 "--build=i686-unknown-linux-gnu"
1899 "--host=i686-unknown-linux-gnu"
1900 (string-append "--with-native-system-header-dir=" glibc "/include")
1901 (string-append "--with-build-sysroot=" glibc "/include")
1902 "--disable-bootstrap"
1903 "--disable-decimal-float"
1904 "--disable-libatomic"
1905 "--disable-libcilkrts"
1906 "--disable-libgomp"
1907 "--disable-libitm"
1908 "--disable-libmudflap"
1909 "--disable-libquadmath"
1910 "--disable-libsanitizer"
1911 "--disable-libssp"
1912 "--disable-libvtv"
1913 "--disable-lto"
1914 "--disable-lto-plugin"
1915 "--disable-multilib"
1916 "--disable-plugin"
1917 "--disable-threads"
1918 "--enable-languages=c"
1919 "--enable-static"
1920 "--disable-shared"
1921 "--enable-threads=single"
1922 "--disable-libstdcxx-pch"
1923 "--disable-build-with-cxx"))
1924 #:phases
1925 (modify-phases %standard-phases
1926 (add-after 'unpack 'apply-boot-patch
1927 (lambda* (#:key inputs #:allow-other-keys)
1928 (let ((patch-file (assoc-ref inputs "boot-patch")))
1929 (format (current-error-port) "patch file=~s\n" patch-file)
1930 (system* "patch" "--force" "-p1" "-i" patch-file))
1931 #t))
1932 ;; c&p from commencement.scm:gcc-boot0
1933 (add-after 'unpack 'unpack-gmp&co
1934 (lambda* (#:key inputs #:allow-other-keys)
1935 (let ((gmp (assoc-ref %build-inputs "gmp-source"))
1936 (mpfr (assoc-ref %build-inputs "mpfr-source"))
1937 (mpc (assoc-ref %build-inputs "mpc-source")))
1938
1939 ;; To reduce the set of pre-built bootstrap inputs, build
1940 ;; GMP & co. from GCC.
1941 (for-each (lambda (source)
1942 (or (invoke "tar" "xvf" source)
1943 (error "failed to unpack tarball"
1944 source)))
1945 (list gmp mpfr mpc))
1946
1947 ;; Create symlinks like `gmp' -> `gmp-x.y.z'.
1948 ,@(map (lambda (lib)
1949 ;; Drop trailing letters, as gmp-6.0.0a unpacks
1950 ;; into gmp-6.0.0.
1951 `(symlink ,(string-trim-right
1952 (package-full-name lib "-")
1953 char-set:letter)
1954 ,(package-name lib)))
1955 (list gmp-boot mpfr-boot mpc-boot))
1956 #t)))
1957 (add-before 'configure 'setenv
1958 (lambda* (#:key outputs #:allow-other-keys)
1959 (let* ((out (assoc-ref outputs "out"))
1960 (binutils (assoc-ref %build-inputs "binutils"))
1961 (bash (assoc-ref %build-inputs "bash"))
1962 (gcc (assoc-ref %build-inputs "gcc"))
1963 (glibc (assoc-ref %build-inputs "libc"))
1964 (kernel-headers (assoc-ref %build-inputs "kernel-headers")))
1965 (setenv "CONFIG_SHELL" (string-append bash "/bin/sh"))
1966 (setenv "C_INCLUDE_PATH" (string-append
1967 gcc "/lib/gcc-lib/i686-unknown-linux-gnu/2.95.3/include"
1968 ":" kernel-headers "/include"
1969 ":" glibc "/include"
1970 ":" (getcwd) "/mpfr/src"))
1971 (setenv "LIBRARY_PATH" (string-append glibc "/lib"
1972 ":" gcc "/lib"))
1973 (format (current-error-port) "C_INCLUDE_PATH=~a\n" (getenv "C_INCLUDE_PATH"))
1974 (format (current-error-port) "LIBRARY_PATH=~a\n" (getenv "LIBRARY_PATH"))
1975 #t))))))))
1976
f48fe4e9
JN
1977(define gcc-mesboot1
1978 (package
1979 (inherit gcc-core-mesboot1)
1980 (name "gcc-mesboot1")
1981 (version "4.6.4")
1982 (native-inputs
1983 `(("gcc-g++"
1984 ,(origin
1985 (method url-fetch)
1986 (uri (string-append "mirror://gnu/gcc/gcc-"
1987 version "/gcc-g++-" version ".tar.gz"))
1988 (sha256
1989 (base32
1990 "1fqqk5zkmdg4vmqzdmip9i42q6b82i3f6yc0n86n9021cr7ms2k9"))))
1991 ,@(package-native-inputs gcc-core-mesboot1)))
1992 (arguments
1993 (substitute-keyword-arguments (package-arguments gcc-core-mesboot1)
1994 ((#:configure-flags configure-flags)
1995 `(let ((out (assoc-ref %outputs "out")))
1996 `("--enable-languages=c,c++"
1997 ,@(filter
1998 (negate (lambda (x) (string-prefix? "--enable-languages=" x)))
1999 ,configure-flags))))
2000 ((#:phases phases)
2001 `(modify-phases ,phases
2002 (add-before 'unpack 'unpack-g++
2003 (lambda _
2004 (let ((source-g++ (assoc-ref %build-inputs "gcc-g++")))
2005 (invoke "tar" "xvf" source-g++))
2006 #t))
2007 (replace 'setenv
2008 (lambda _
2009 (setenv "CONFIG_SHELL" (which "sh"))
2010
2011 ;; Allow MPFR headers to be found.
2012 (setenv "C_INCLUDE_PATH"
2013 (string-append (getcwd) "/mpfr/src:"
2014 (getenv "C_INCLUDE_PATH")))
2015
2016 ;; Set the C++ search path so that C headers can be found as
2017 ;; libstdc++ is being compiled.
2018 (setenv "CPLUS_INCLUDE_PATH" (getenv "C_INCLUDE_PATH"))
2019 #t))))))))
2020
2021(define (%boot-mesboot2-inputs)
2022 `(("gcc" ,gcc-mesboot1)
2023 ,@(alist-delete "gcc" (%boot-mesboot1-inputs))))
2024
9c4a0212
JN
2025(define xz-mesboot
2026 ;; Finally, we can build xz.
2027 (package
2028 (inherit xz)
2029 (name "xz-mesboot")
2030 (version "5.0.0")
2031 (source (bootstrap-origin
2032 (origin
2033 (method url-fetch)
2034 (uri (list (string-append "http://tukaani.org/xz/xz-" version
2035 ".tar.gz")
2036 (string-append "http://multiprecision.org/guix/xz-"
2037 version ".tar.gz")))
2038 (sha256
2039 (base32
2040 "0kf40ggbs1vaaj5s9k4csycahzqcf65n20pa6lngqhm6j0cj3agb")))))
2041 (supported-systems '("i686-linux" "x86_64-linux"))
2042 (inputs '())
2043 (outputs '("out"))
2044 (propagated-inputs '())
2045 (native-inputs (%boot-mesboot2-inputs))
2046 (arguments
2047 `(#:implicit-inputs? #f
2048 #:guile ,%bootstrap-guile
2049 #:parallel-build? #f
2050 #:configure-flags
2051 `("--disable-assembler"
2052 "--disable-shared"
2053 "--enable-small"
2054 "--disable-threads"
2055 "--disable-xzdec"
2056 "--disable-lzmadec"
2057 "--disable-lzmainfo"
2058 "--disable-lzma-links"
2059 "--disable-scripts"
2060 "--disable-doc"
2061 "--disable-nls"
2062 "--disable-symbol-versions"
2063 ;; configure disqualifies BASH, CPP, GCC and GREP
2064 ;; all of which seem fine for the build
2065 "ac_cv_prog_cc_c99=-std=gnu9x"
2066 "ac_cv_path_GREP=grep"
2067 "gl_cv_posix_shell=bash"
2068 "ac_cv_have_decl_optreset=no"
2069 "CPPFLAGS=-D__GNUC__=1")))))
2070
079b2cf3
JN
2071(define hello-mesboot
2072 ;; Check for Scheme-only bootstrap.
2073 (package
2074 (inherit hello)
2075 (name "hello-mesboot")
2076 (supported-systems '("i686-linux" "x86_64-linux"))
2077 (inputs '())
2078 (propagated-inputs '())
2079 (native-inputs (%boot-mesboot2-inputs))
2080 (arguments
2081 `(#:implicit-inputs? #f
2082 #:guile ,%bootstrap-guile
2083 #:parallel-build? #f
2084 ;; checking for grep that handles long lines and -e...
2085 ;; configure: error: no acceptable grep could be found
2086 #:configure-flags '("ac_cv_path_GREP=grep")
2087 #:phases
2088 (modify-phases %standard-phases
2089 (replace 'check
2090 (lambda _
2091 (invoke "./hello"))))))))
2092
9a935f66
JN
2093(define binutils-mesboot
2094 (package
8bf7b703 2095 (inherit binutils)
9a935f66 2096 (name "binutils-mesboot")
8bf7b703
JN
2097 (version "2.20.1a")
2098 (source (bootstrap-origin
2099 (origin
2100 (method url-fetch)
2101 (uri (string-append "mirror://gnu/binutils/binutils-"
2102 version ".tar.bz2"))
2103 (patches (search-patches "binutils-boot-2.20.1a.patch"))
2104 (sha256
2105 (base32
2106 "0r7dr0brfpchh5ic0z9r4yxqn4ybzmlh25sbp30cacqk8nb7rlvi")))))
2107 (inputs '())
2108 (propagated-inputs '())
2109 (native-inputs `(("xz" ,xz-mesboot)
2110 ,@(%boot-mesboot2-inputs)))
2111 (supported-systems '("i686-linux" "x86_64-linux"))
9a935f66 2112 (arguments
8bf7b703
JN
2113 `(#:implicit-inputs? #f
2114 #:guile ,%bootstrap-guile
2115 #:tests? #f ; runtest: command not found
2116 #:parallel-build? #f
2117 #:strip-binaries? #f ; no strip yet
2118 #:configure-flags
2119 `("CC=gcc"
2120 "CXX=false"
2121 "RANLIB=true"
2122 "--disable-doc"
2123 "--disable-nls"
2124 "--disable-shared"
2125 "--disable-werror"
2126 "--build=i686-unknown-linux-gnu"
2127 "--host=i686-unknown-linux-gnu"
2128 "--with-sysroot=/"
2129 ;; checking for grep that handles long lines and -e
2130 "ac_cv_path_GREP=grep")
2131 ;; FIXME: ac_cv_path_GREP=grep doesn't seem to be forwarded to
2132 ;; cascading configure's?
2133 #:make-flags '("ac_cv_path_GREP=grep")
2134 #:phases
2135 (modify-phases %standard-phases
2136 (add-after 'unpack 'scripted-patch
2137 (lambda _
2138 ;; sed-mesboot0 cannot build these
2139 (copy-file "binutils/Makefile.in" "binutils/Makefile.in.orig")
2140 (substitute* "binutils/Makefile.in"
2141 ;; binutils/binutils uses an amazingly complex install
2142 ;; command, using FOR, SED, READ, IF, ECHO, SED, SED, AWK,
2143 ;; READ, and then LIBTOOL (to do something like
2144 ;; `mkdir $DESTDIR$bindir; cp readline $DESTDIR$bindir ...')
2145
2146 ;; Some tool [debugme!] cannot handle two escaped newlines
2147 ;; (bash?), and the install stops after $(am__EXEEXT_11)
2148 ;; ("objcopy"), so $(am__EXEEXT_13) ("readelf") and others do
2149 ;; not get installed. Remove the stray newline:
2150 (("^\t@BUILD_NLMCONV@ @BUILD_SRCONV@ @BUILD_DLLTOOL@ @BUILD_WINDRES@ .*") ""))
2151 (substitute* "opcodes/Makefile.in"
2152 (("^SUBDIRS = [.] po") "SUBDIRS = ."))
2153 (substitute* "binutils/Makefile.in"
2154 (("^SUBDIRS = doc po") "SUBDIRS ="))
2155 (substitute* "gas/Makefile.in"
2156 (("^SUBDIRS = doc po") "SUBDIRS ="))
2157 (substitute* "gprof/Makefile.in"
2158 (("^SUBDIRS = po") "SUBDIRS ="))
2159 (substitute* "ld/Makefile.in"
2160 (("^SUBDIRS = po") "SUBDIRS ="))
2161 #t)))))))
9a935f66 2162
8bf7b703
JN
2163(define (%boot-mesboot3-inputs)
2164 `(("binutils" ,binutils-mesboot)
2165 ("xz" ,xz-mesboot)
2166 ,@(alist-delete "binutils" (%boot-mesboot2-inputs))))
2167
0b652851 2168(define glibc-headers-mesboot
9a45a24f
LC
2169 (package
2170 (inherit glibc-mesboot0)
2171 (name "glibc-headers-mesboot")
2172 (version "2.16.0")
2173 (source (bootstrap-origin
2174 (origin
0b652851
JN
2175 (method url-fetch)
2176 (uri (string-append "mirror://gnu/glibc/glibc-"
2177 version
2178 ".tar.gz"))
2179 (patches (search-patches "glibc-boot-2.16.0.patch"
2180 "glibc-bootstrap-system-2.16.0.patch"))
2181 (sha256
2182 (base32
9a45a24f 2183 "0vlz4x6cgz7h54qq4528q526qlhnsjzbsvgc4iizn76cb0bfanx7")))))
c8a2128a
JN
2184 (native-inputs `(("headers" ,mesboot-headers)
2185 ,@(%boot-mesboot3-inputs)))
9a45a24f
LC
2186 (arguments
2187 (substitute-keyword-arguments (package-arguments glibc-mesboot0)
2188 ((#:configure-flags configure-flags)
2189 `(let ((out (assoc-ref %outputs "out"))
2190 (headers (assoc-ref %build-inputs "headers")))
2191 (list
2192 (string-append "--prefix=" out)
2193 "--disable-obsolete-rpc"
2194 "--host=i686-unknown-linux-gnu"
2195 (string-append "--with-headers=" headers "/include")
2196 "--enable-static-nss"
2197 "--with-pthread"
2198 "--without-cvs"
2199 "--without-gd"
c8a2128a
JN
2200 "--enable-add-ons=nptl"
2201 ;; avoid: configure: error: confusing output from nm -u
2202 "libc_cv_predef_stack_protector=no")))
9a45a24f 2203 ((#:make-flags make-flags)
c8a2128a 2204 '(list "install-bootstrap-headers=yes" "install-headers"))
9a45a24f
LC
2205 ((#:phases phases)
2206 `(modify-phases ,phases
c8a2128a
JN
2207 (delete 'apply-boot-patch)
2208 (delete 'fixup-configure)
2209 (delete 'set-path)
2210 (replace 'unpack
2211 (lambda* (#:key source #:allow-other-keys)
2212 (invoke "tar" "xvf" source)
2213 (chdir (string-append "glibc-" ,version))
2214 #t))
9a45a24f 2215 (replace 'setenv
558b0bbe
LC
2216 (lambda* (#:key inputs #:allow-other-keys)
2217 (let* ((headers (assoc-ref inputs "headers"))
2218 (libc (assoc-ref inputs "libc"))
2219 (gcc (assoc-ref inputs "gcc"))
9a45a24f
LC
2220 (cppflags (string-append
2221 " -I " (getcwd) "/nptl/sysdeps/pthread/bits"
2222 " -D BOOTSTRAP_GLIBC=1"))
2223 (cflags (string-append " -L " (getcwd)
2224 " -L " libc "/lib")))
2225 (setenv "libc_cv_friendly_stddef" "yes")
558b0bbe
LC
2226 (setenv "CONFIG_SHELL" (which "sh"))
2227 (setenv "SHELL" (which "sh"))
0b652851 2228
9a45a24f
LC
2229 (setenv "CPP" (string-append gcc "/bin/gcc -E " cppflags))
2230 (setenv "CC" (string-append gcc "/bin/gcc " cppflags cflags))
c8a2128a 2231 (setenv "LD" "gcc")
0b652851 2232
9a45a24f
LC
2233 ;; avoid -fstack-protector
2234 (setenv "libc_cv_ssp" "false")
2235 (substitute* "configure"
558b0bbe 2236 (("/bin/pwd") "pwd"))
9a45a24f
LC
2237 #t)))
2238 (replace 'install
2239 (lambda* (#:key outputs make-flags #:allow-other-keys)
2240 (let ((kernel-headers (assoc-ref %build-inputs "kernel-headers"))
2241 (out (assoc-ref outputs "out")))
c8a2128a
JN
2242 (and (apply invoke "make" make-flags)
2243 (copy-recursively kernel-headers out)
2244 #t))))
9a45a24f
LC
2245 (replace 'configure
2246 (lambda* (#:key configure-flags #:allow-other-keys)
2247 (format (current-error-port) "running ../configure ~a\n" (string-join configure-flags))
2248 (mkdir-p "build")
2249 (chdir "build")
2250 (apply invoke "../configure" configure-flags)))
2251 (add-after 'configure 'remove-sunrpc
2252 (lambda _
c8a2128a
JN
2253 (let* ((out (assoc-ref %outputs "out"))
2254 (bash (assoc-ref %build-inputs "bash"))
2255 (shell (string-append bash "/bin/bash")))
2256
2257 (let ((Makefile (open-file "Makefile" "a")))
2258 (display (string-append "
2259
2260SHELL := " shell "
2261")
2262 Makefile)
2263 (close Makefile))
2264 (substitute* "../Makefile"
2265 (("^SHELL := /bin/sh") (string-append "SHELL := " shell)))
2266 (substitute* "../Makeconfig"
2267 (("^SHELL := /bin/sh") (string-append "SHELL := " shell)))
2268 (substitute* "../elf/Makefile"
2269 (("^SHELL := /bin/sh") (string-append "SHELL := " shell)))
2270 (invoke "make" (string-append (getcwd) "/sysd-sorted" ))
2271 (substitute* "sysd-sorted"
2272 ((" sunrpc") " ")
2273 ((" nis") " "))
2274 #t)))))))))
0b652851
JN
2275
2276(define glibc-mesboot
9a45a24f
LC
2277 (package
2278 (inherit glibc-headers-mesboot)
2279 (name "glibc-mesboot")
6ff41881
JN
2280 (native-inputs `(("headers" ,glibc-headers-mesboot)
2281 ,@(%boot-mesboot3-inputs)))
9a45a24f 2282 (arguments
6ff41881 2283 `(#:validate-runpath? #f ; fails when using --enable-shared
9a45a24f
LC
2284 ,@(substitute-keyword-arguments (package-arguments glibc-headers-mesboot)
2285 ((#:make-flags make-flags)
2286 `(let ((bash (assoc-ref %build-inputs "bash")))
2287 (list (string-append "SHELL=" bash "/bin/sh"))))
2288 ((#:phases phases)
2289 `(modify-phases ,phases
2290 (replace 'install
2291 (lambda* (#:key outputs make-flags #:allow-other-keys)
2292 (let* ((kernel-headers (assoc-ref %build-inputs "kernel-headers"))
2293 (out (assoc-ref outputs "out"))
2294 (install-flags (cons "install" make-flags)))
6ff41881
JN
2295 (and (apply invoke "make" install-flags)
2296 (copy-recursively kernel-headers out)
2297 #t)))))))))))
2298
2299(define (%boot-mesboot4-inputs)
2300 `(("libc" ,glibc-mesboot)
2301 ,@(alist-delete "libc" (%boot-mesboot3-inputs))))
0b652851 2302
8b58e499
JN
2303(define gcc-mesboot1-wrapper
2304 ;; We need this so gcc-mesboot1 can be used to create shared binaries that
2305 ;; have the correct interpreter, otherwise configuring gcc-mesboot using
2306 ;; --enable-shared will fail.
2307 (package
2308 (inherit gcc-mesboot1)
2309 (name "gcc-mesboot1-wrapper")
2310 (source #f)
2311 (inputs '())
2312 (native-inputs `(("bash" ,bash-mesboot)
2313 ("coreutils" ,coreutils-mesboot0)
2314 ("libc" ,glibc-mesboot)
2315 ("gcc" ,gcc-mesboot1)))
2316 (arguments
2317 `(#:implicit-inputs? #f
2318 #:guile ,%bootstrap-guile
2319 #:phases
2320 (modify-phases %standard-phases
2321 (delete 'unpack)
2322 (delete 'configure)
2323 (delete 'install)
2324 (replace 'build
2325 (lambda* (#:key outputs #:allow-other-keys)
2326 (let* ((out (assoc-ref outputs "out"))
2327 (bash (assoc-ref %build-inputs "bash"))
2328 (libc (assoc-ref %build-inputs "libc"))
2329 (gcc (assoc-ref %build-inputs "gcc"))
2330 (bin (string-append out "/bin")))
2331 (mkdir-p bin)
2332 (for-each
2333 (lambda (program)
2334 (let ((wrapper (string-append bin "/" program)))
2335 (with-output-to-file wrapper
2336 (lambda _
2337 (display (string-append "#! " bash "/bin/bash
2338exec " gcc "/bin/" program
2339" -Wl,--dynamic-linker"
2340;; also for x86_64-linux, we are still on i686-linux
2341" -Wl," libc ,(glibc-dynamic-linker "i686-linux")
2342" -Wl,--rpath"
2343" -Wl," libc "/lib"
2344" \"$@\"
2345"))
2346 (chmod wrapper #o555)))))
2347 '("cpp"
2348 "gcc"
2349 "g++"
2350 "i686-unknown-linux-gnu-cpp"
2351 "i686-unknown-linux-gnu-gcc"
2352 "i686-unknown-linux-gnu-g++"))
2353 #t)))
2354 (replace 'check
2355 (lambda* (#:key outputs #:allow-other-keys)
2356 (let* ((out (assoc-ref outputs "out"))
2357 (bin (string-append out "/bin"))
2358 (program (string-append bin "/gcc")))
2359 (invoke program "--help")))))))))
2360
0b652851 2361(define gcc-mesboot
9a45a24f
LC
2362 (package
2363 (inherit gcc-mesboot1)
2364 (name "gcc-mesboot")
a1caea07 2365 (version (package-version gcc-4.9))
9a45a24f 2366 (source (bootstrap-origin (package-source gcc-4.9)))
d9de3abc 2367 (native-inputs `(("gcc-wrapper" ,gcc-mesboot1-wrapper)
9a45a24f 2368 ("gcc" ,gcc-mesboot1)
d9de3abc
JN
2369 ("headers" ,glibc-headers-mesboot)
2370 ,@(%boot-mesboot4-inputs)))
9a45a24f
LC
2371 (arguments
2372 `(#:validate-runpath? #f
2373 ,@(substitute-keyword-arguments (package-arguments gcc-mesboot1)
2374 ((#:configure-flags configure-flags)
2375 `(let ((out (assoc-ref %outputs "out"))
2376 (glibc (assoc-ref %build-inputs "libc")))
2377 (list (string-append "--prefix=" out)
2378 "--build=i686-unknown-linux-gnu"
2379 "--host=i686-unknown-linux-gnu"
0b652851 2380
9a45a24f 2381 "--with-host-libstdcxx=-lsupc++"
0b652851 2382
9a45a24f
LC
2383 (string-append "--with-native-system-header-dir=" glibc "/include")
2384 (string-append "--with-build-sysroot=" glibc "/include")
0b652851 2385
9a45a24f
LC
2386 "--disable-bootstrap"
2387 "--disable-decimal-float"
2388 "--disable-libatomic"
2389 "--disable-libcilkrts"
2390 "--disable-libgomp"
2391 "--disable-libitm"
2392 "--disable-libmudflap"
2393 "--disable-libquadmath"
2394 "--disable-libsanitizer"
2395 "--disable-libssp"
2396 "--disable-libvtv"
2397 "--disable-lto"
2398 "--disable-lto-plugin"
2399 "--disable-multilib"
2400 "--disable-plugin"
2401 "--disable-threads"
2402 "--enable-languages=c,c++"
0b652851 2403
9a45a24f
LC
2404 "--enable-static"
2405 "--enable-shared"
2406 "--enable-threads=single"
0b652851 2407
9a45a24f
LC
2408 ;; No pre-compiled libstdc++ headers, to save space.
2409 "--disable-libstdcxx-pch"
0b652851 2410
9a45a24f 2411 ;; for libcpp ...
d9de3abc
JN
2412 "--disable-build-with-cxx")))
2413 ((#:phases phases)
2414 `(modify-phases ,phases
2415 (delete 'apply-boot-patch)
2416 (delete 'unpack-g++) ; sadly, gcc-4.9.4 does not provide
2417 ; modular core/language downloads
2418 (replace 'setenv
2419 (lambda* (#:key outputs #:allow-other-keys)
2420 (let* ((out (assoc-ref outputs "out"))
2421 (binutils (assoc-ref %build-inputs "binutils"))
2422 (bash (assoc-ref %build-inputs "bash"))
2423 (gcc (assoc-ref %build-inputs "gcc"))
2424 (glibc (assoc-ref %build-inputs "libc"))
2425 (kernel-headers (assoc-ref %build-inputs "kernel-headers")))
2426 (setenv "CONFIG_SHELL" (string-append bash "/bin/sh"))
2427 (setenv "C_INCLUDE_PATH" (string-append
2428 gcc "/lib/gcc-lib/i686-unknown-linux-gnu/4.6.4/include"
2429 ":" kernel-headers "/include"
2430 ":" glibc "/include"
2431 ":" (getcwd) "/mpfr/src"))
2432 (setenv "CPLUS_INCLUDE_PATH" (string-append
2433 gcc "/lib/gcc-lib/i686-unknown-linux-gnu/4.6.4/include"
2434 ":" kernel-headers "/include"
2435 ":" glibc "/include"
2436 ":" (getcwd) "/mpfr/src"))
2437 (setenv "LIBRARY_PATH" (string-append glibc "/lib"
2438 ":" gcc "/lib"))
2439 (format (current-error-port) "C_INCLUDE_PATH=~a\n" (getenv "C_INCLUDE_PATH"))
2440 (format (current-error-port) "CPLUS_INCLUDE_PATH=~a\n" (getenv "CPLUS_INCLUDE_PATH"))
2441 (format (current-error-port) "LIBRARY_PATH=~a\n" (getenv "LIBRARY_PATH"))
2442 #t))))))))))
0b652851
JN
2443
2444(define gcc-mesboot-wrapper
2445 ;; We need this so gcc-mesboot can be used to create shared binaries that
2446 ;; have the correct interpreter and runpath to libc.
9a45a24f
LC
2447 (package
2448 (inherit gcc-mesboot1-wrapper)
2449 (name "gcc-mesboot-wrapper")
2450 (version (package-version gcc-mesboot))
2451 (source #f)
2452 (inputs '())
d7e8467f
JN
2453 (native-inputs `(("bash" ,bash-mesboot)
2454 ("coreutils" ,coreutils-mesboot0)
9a45a24f
LC
2455 ("libc" ,glibc-mesboot)
2456 ("gcc" ,gcc-mesboot)))))
0b652851 2457
d7e8467f
JN
2458(define (%boot-mesboot5-inputs)
2459 `(("gcc-wrapper" ,gcc-mesboot-wrapper)
2460 ("gcc" ,gcc-mesboot)
2461 ,@(fold alist-delete (%boot-mesboot4-inputs) '("gcc" "gcc-wrapper"))))
2462
15af8e1d
JN
2463(define-public coreutils-mesboot
2464 (package
2465 (inherit coreutils)
2466 (name "coreutils-mesboot")
2467 (source (bootstrap-origin (package-source coreutils)))
2468 (native-inputs (%boot-mesboot5-inputs))
2469 (supported-systems '("i686-linux" "x86_64-linux"))
2470 (inputs '())
2471 (propagated-inputs '())
2472 (arguments
2473 `(#:implicit-inputs? #f
2474 #:guile ,%bootstrap-guile
2475 #:tests? #f))))
2476
2477(define (%boot-mesboot6-inputs)
2478 `(("coreutils" ,coreutils-mesboot)
2479 ,@(fold alist-delete (%boot-mesboot5-inputs)
2480 '("coreutils" "kernel-headers"))))
2481
c3629044 2482(define (%bootstrap-inputs+toolchain)
f29fdd4e
JN
2483 ;; The traditional bootstrap-inputs. For the i686-linux, x86_64-linux
2484 ;; Scheme-only bootstrap the actual reduced set with bootstrapped toolchain.
1380be3c
LC
2485 (match (%current-system)
2486 ((or "i686-linux" "x86_64-linux")
f29fdd4e 2487 (%boot-mesboot6-inputs))
1380be3c
LC
2488 (_
2489 (%bootstrap-inputs))))
c3629044 2490
bdb36958 2491(define gnu-make-boot0
9a45a24f
LC
2492 (package
2493 (inherit gnu-make)
2494 (source (bootstrap-origin (package-source gnu-make)))
2495 (name "make-boot0")
2496 (arguments
2497 `(#:guile ,%bootstrap-guile
2498 #:implicit-inputs? #f
2499 #:tests? #f ; cannot run "make check"
2500 ,@(substitute-keyword-arguments (package-arguments gnu-make)
cdba9148
MB
2501 ((#:configure-flags flags ''())
2502 ;; The generated config.status has some problems due to the
2503 ;; bootstrap environment. Disable dependency tracking to work
2504 ;; around it.
2505 `(cons "--disable-dependency-tracking" ,flags))
9a45a24f
LC
2506 ((#:phases phases)
2507 `(modify-phases ,phases
2508 (replace 'build
2509 (lambda _
2510 (invoke "./build.sh")))
2511 (replace 'install
2512 (lambda* (#:key outputs #:allow-other-keys)
2513 (let* ((out (assoc-ref outputs "out"))
2514 (bin (string-append out "/bin")))
2515 (install-file "make" bin)
2516 #t))))))))
2517 (native-inputs '()) ; no need for 'pkg-config'
2518 (inputs (%bootstrap-inputs+toolchain))))
bdb36958 2519
2e41da94
JN
2520(define bzip2-boot0
2521 (package
2522 (inherit bzip2)
2523 (name "bzip2-boot0")
2524 (native-inputs `())
2525 (inputs
2526 `(("make" ,gnu-make-boot0)
2527 ,@(%bootstrap-inputs+toolchain)))
2528 (arguments
2529 `(#:guile ,%bootstrap-guile
2530 #:implicit-inputs? #f
2531 ,@(package-arguments bzip2)))))
2532
cacb6b90
JN
2533(define coreutils-boot0
2534 (package
2535 (inherit coreutils)
2536 (source (bootstrap-origin (package-source coreutils)))
2537 (name "coreutils-boot0")
2538 (native-inputs `())
2539 (inputs
2540 `(("make" ,gnu-make-boot0)
2541 ,@(%bootstrap-inputs+toolchain)))
2542 (arguments
2543 `(#:tests? #f
2544 #:implicit-inputs? #f
2545 #:guile ,%bootstrap-guile
2546 ,@(package-arguments coreutils)))))
2547
bdb36958 2548(define diffutils-boot0
99b73d0f
LC
2549 (package
2550 (inherit diffutils)
2551 (name "diffutils-boot0")
2552 (native-inputs `())
2553 (inputs
2554 `(("make" ,gnu-make-boot0)
2555 ,@(%bootstrap-inputs+toolchain)))
2556 (arguments
2557 `(#:tests? #f ; the test suite needs diffutils
2558 #:guile ,%bootstrap-guile
2559 #:implicit-inputs? #f
2560 ,@(package-arguments diffutils)))))
bdb36958
LC
2561
2562(define findutils-boot0
99b73d0f
LC
2563 (package
2564 (inherit findutils)
2565 (name "findutils-boot0")
2566 (source (bootstrap-origin (package-source findutils)))
2567 (inputs
2568 `(("make" ,gnu-make-boot0)
2569 ("diffutils" ,diffutils-boot0) ; for tests
2570 ,@(%bootstrap-inputs+toolchain)))
2571 (arguments
2572 `(#:implicit-inputs? #f
2573 #:guile ,%bootstrap-guile
717867a6
MB
2574
2575 ;; The build system assumes we have done a mistake when time_t is 32-bit
2576 ;; on a 64-bit system. Ignore that for our bootstrap toolchain.
2577 ,@(if (target-64bit?)
2578 (substitute-keyword-arguments (package-arguments findutils)
2579 ((#:configure-flags flags ''())
2580 `(cons "TIME_T_32_BIT_OK=yes"
2581 ,flags)))
2582 (package-arguments findutils))))))
bdb36958 2583
f8d1a95e
JN
2584(define file
2585 (package
2586 (inherit (@ (gnu packages file) file))
2587 (arguments
2588 `(#:configure-flags '("--disable-bzlib")))))
2589
c00a9fbf 2590(define file-boot0
99b73d0f
LC
2591 (package
2592 (inherit file)
2593 (source (bootstrap-origin (package-source file)))
2594 (name "file-boot0")
2595 (inputs
2596 `(("make" ,gnu-make-boot0)
2597 ,@(%bootstrap-inputs+toolchain)))
2598 (arguments
f8d1a95e
JN
2599 `(#:tests? #f ; merge test fails
2600 #:implicit-inputs? #f
99b73d0f 2601 #:guile ,%bootstrap-guile
6340afee 2602 #:configure-flags '("--disable-bzlib")
99b73d0f 2603 #:strip-binaries? #f
f8d1a95e
JN
2604 #:validate-runpath? #f
2605 ,@(package-arguments file)))))
c00a9fbf 2606
4bfce839
JN
2607(define gawk-boot0
2608 (package
2609 (inherit patch)
2610 (source (bootstrap-origin (package-source gawk)))
2611 (name "gawk-boot0")
2612 (native-inputs '())
2613 (inputs
2614 `(("make" ,gnu-make-boot0)
2615 ,@(%bootstrap-inputs+toolchain)))
2616 (arguments
2617 `(#:tests? #f
2618 #:implicit-inputs? #f
2619 #:guile ,%bootstrap-guile
2620 #:strip-binaries? #f
2621 #:validate-runpath? #f))))
2622
31a3db77
JN
2623(define patch-boot0
2624 (package
2625 (inherit patch)
2626 (source (bootstrap-origin (package-source patch)))
2627 (name "patch-boot0")
2628 (native-inputs '())
2629 (inputs
2630 `(("make" ,gnu-make-boot0)
2631 ,@(%bootstrap-inputs+toolchain)))
2632 (arguments
2633 `(#:tests? #f ; merge test fails
2634 #:implicit-inputs? #f
2635 #:guile ,%bootstrap-guile
2636 #:strip-binaries? #f
2637 #:validate-runpath? #f))))
2638
fdab0619
JN
2639(define sed-boot0
2640 (package
2641 (inherit sed)
2642 (name "sed-boot0")
2643 (source (bootstrap-origin (package-source sed)))
2644 (native-inputs '())
2645 (inputs
2646 `(("make" ,gnu-make-boot0)
2647 ,@(%bootstrap-inputs+toolchain)))
2648 (arguments
2649 `(#:implicit-inputs? #f
2650 #:tests? #f
2651 #:guile ,%bootstrap-guile
2652 ,@(package-arguments sed)))))
2653
1d313d6d
JN
2654(define tar-boot0
2655 (package
2656 (inherit tar)
2657 (name "tar-boot0")
2658 (source (bootstrap-origin (package-source tar)))
2659 (native-inputs '())
2660 (inputs
2661 `(("make" ,gnu-make-boot0)
2662 ,@(%bootstrap-inputs+toolchain)))
2663 (arguments
2664 `(#:implicit-inputs? #f
2665 #:tests? #f
2666 #:guile ,%bootstrap-guile
2667 ,@(package-arguments tar)))))
2668
a2b2070b 2669(define (%boot0-inputs)
2e41da94 2670 `(("bzip2" ,bzip2-boot0)
cacb6b90 2671 ("coreutils" ,coreutils-boot0)
bdb36958
LC
2672 ("diffutils" ,diffutils-boot0)
2673 ("findutils" ,findutils-boot0)
c00a9fbf 2674 ("file" ,file-boot0)
4bfce839 2675 ("gawk" ,gawk-boot0)
2e41da94 2676 ("make" ,gnu-make-boot0)
31a3db77 2677 ("patch" ,patch-boot0)
fdab0619 2678 ("sed" ,sed-boot0)
1d313d6d 2679 ("tar" ,tar-boot0)
c3629044 2680 ,@(%bootstrap-inputs+toolchain)))
bdb36958 2681
bdb36958
LC
2682(define* (boot-triplet #:optional (system (%current-system)))
2683 ;; Return the triplet used to create the cross toolchain needed in the
2684 ;; first bootstrapping stage.
2685 (nix-system->gnu-triplet system "guix"))
2686
2687;; Following Linux From Scratch, build a cross-toolchain in stage 0. That
2688;; toolchain actually targets the same OS and arch, but it has the advantage
c3629044
JN
2689;; of being independent of the libc and tools in
2690;; (%BOOTSTRAP-INPUTS+TOOLCHAIN), since GCC-BOOT0 (below) is built without any
2691;; reference to the target libc.
bdb36958
LC
2692
2693(define binutils-boot0
99b73d0f
LC
2694 (package
2695 (inherit binutils)
2696 (source (bootstrap-origin (package-source binutils)))
2697 (name "binutils-cross-boot0")
2698 (arguments
2699 `(#:guile ,%bootstrap-guile
2700 #:implicit-inputs? #f
2701
2702 #:modules ((guix build gnu-build-system)
2703 (guix build utils)
2704 (ice-9 ftw)) ; for 'scandir'
2705 #:phases (modify-phases %standard-phases
2706 (add-after 'install 'add-symlinks
2707 (lambda* (#:key outputs #:allow-other-keys)
2708 ;; The cross-gcc invokes 'as', 'ld', etc, without the
2709 ;; triplet prefix, so add symlinks.
2710 (let ((out (assoc-ref outputs "out"))
2711 (triplet-prefix (string-append ,(boot-triplet) "-")))
2712 (define (has-triplet-prefix? name)
2713 (string-prefix? triplet-prefix name))
2714 (define (remove-triplet-prefix name)
2715 (substring name (string-length triplet-prefix)))
2716 (with-directory-excursion (string-append out "/bin")
2717 (for-each (lambda (name)
2718 (symlink name (remove-triplet-prefix name)))
2719 (scandir "." has-triplet-prefix?)))
2720 #t))))
2721
2722 ,@(substitute-keyword-arguments (package-arguments binutils)
2723 ((#:configure-flags cf)
2724 `(cons ,(string-append "--target=" (boot-triplet))
2725 ,cf)))))
2726 (inputs (%boot0-inputs))))
bdb36958 2727
b810a850
LC
2728(define libstdc++-boot0
2729 ;; GCC's libcc1 is always built as a shared library (the top-level
2730 ;; 'Makefile.def' forcefully adds --enable-shared) and thus needs to refer
2731 ;; to libstdc++.so. We cannot build libstdc++-5.3 because it relies on
809b0a90 2732 ;; C++14 features missing in some of our bootstrap compilers.
99b73d0f 2733 (let ((lib (make-libstdc++ gcc-4.9)))
b810a850
LC
2734 (package
2735 (inherit lib)
99b73d0f 2736 (source (bootstrap-origin (package-source lib)))
b810a850
LC
2737 (name "libstdc++-boot0")
2738 (arguments
2739 `(#:guile ,%bootstrap-guile
2740 #:implicit-inputs? #f
2741
2742 ;; XXX: libstdc++.so NEEDs ld.so for some reason.
2743 #:validate-runpath? #f
2744
d536c39e 2745 ,@(match (%current-system)
eb443459 2746 ((or "i686-linux" "x86_64-linux")
d536c39e
JN
2747 (substitute-keyword-arguments (package-arguments lib)
2748 ((#:phases phases)
2749 `(modify-phases ,phases
a6facf94
MB
2750 (add-after 'unpack 'workaround-wrapper-bug
2751 ;; XXX: The crude gcc-cross-wrapper causes "g++ -v" to
2752 ;; fail, which in turn confuses the configure script.
2753 (lambda _
2754 (substitute* "libstdc++-v3/configure"
2755 (("g\\+\\+ -v") "true"))
2756 #t))))))
d536c39e 2757 (_ (package-arguments lib)))))
a2b2070b 2758 (inputs (%boot0-inputs))
b810a850
LC
2759 (native-inputs '()))))
2760
bdb36958 2761(define gcc-boot0
99b73d0f
LC
2762 (package
2763 (inherit gcc)
2764 (name "gcc-cross-boot0")
2765 (source (bootstrap-origin (package-source gcc)))
2766 (arguments
2767 `(#:guile ,%bootstrap-guile
2768 #:implicit-inputs? #f
2769 #:modules ((guix build gnu-build-system)
2770 (guix build utils)
2771 (ice-9 regex)
2772 (srfi srfi-1)
2773 (srfi srfi-26))
2774 ,@(substitute-keyword-arguments (package-arguments gcc)
2775 ((#:configure-flags flags)
2776 `(append (list ,(string-append "--target=" (boot-triplet))
2777
2778 ;; No libc yet.
2779 "--without-headers"
2780
2781 ;; Disable features not needed at this stage.
2782 "--disable-shared"
2783 "--enable-languages=c,c++"
2784
2785 ;; libstdc++ cannot be built at this stage
2786 ;; ("Link tests are not allowed after
2787 ;; GCC_NO_EXECUTABLES.").
2788 "--disable-libstdc++-v3"
2789
2790 "--disable-threads"
2791 "--disable-libmudflap"
2792 "--disable-libatomic"
2793 "--disable-libsanitizer"
2794 "--disable-libitm"
2795 "--disable-libgomp"
2796 "--disable-libmpx"
2797 "--disable-libcilkrts"
2798 "--disable-libvtv"
2799 "--disable-libssp"
2800 "--disable-libquadmath"
2801 "--disable-decimal-float")
2802 (remove (cut string-match
2803 "--(with-system-zlib|enable-languages.*)" <>)
2804 ,flags)))
2805 ((#:make-flags flags)
2806 `(let* ((libc (assoc-ref %build-inputs "libc"))
2807 (libc-native (or (assoc-ref %build-inputs "libc-native")
2808 libc)))
2809 `(,(string-append "LDFLAGS="
2810 "-Wl,-rpath=" libc-native "/lib "
2811 "-Wl,-dynamic-linker "
2812 "-Wl," libc-native ,(glibc-dynamic-linker
2813 (match (%current-system)
2814 ("x86_64-linux" "i686-linux")
2815 (_ (%current-system))))))))
2816 ((#:phases phases)
2817 `(modify-phases ,phases
2818 (add-after 'unpack 'unpack-gmp&co
2819 (lambda* (#:key inputs #:allow-other-keys)
2820 (let ((gmp (assoc-ref %build-inputs "gmp-source"))
2821 (mpfr (assoc-ref %build-inputs "mpfr-source"))
2822 (mpc (assoc-ref %build-inputs "mpc-source")))
2823
2824 ;; To reduce the set of pre-built bootstrap inputs, build
2825 ;; GMP & co. from GCC.
2826 (for-each (lambda (source)
2827 (invoke "tar" "xvf" source))
2828 (list gmp mpfr mpc))
2829
2830 ;; Create symlinks like `gmp' -> `gmp-x.y.z'.
2831 ,@(map (lambda (lib)
2832 ;; Drop trailing letters, as gmp-6.0.0a unpacks
2833 ;; into gmp-6.0.0.
2834 `(symlink ,(string-trim-right
2835 (package-full-name lib "-")
2836 char-set:letter)
2837 ,(package-name lib)))
2838 (list gmp-6.0 mpfr mpc))
2839 #t)))
2840 ,(match (%current-system)
2841 ((or "i686-linux" "x86_64-linux")
2842 '(add-before 'configure 'fix-libcc1
77e02d94
MB
2843 (lambda* (#:key inputs #:allow-other-keys)
2844 ;; libcc1.so NEEDs libgcc_s.so, so provide one here
2845 ;; to placate the 'validate-runpath' phase.
2846 (substitute* "libcc1/Makefile.in"
2847 (("la_LDFLAGS =")
2848 (string-append "la_LDFLAGS = -Wl,-rpath="
2849 (assoc-ref inputs "gcc") "/lib")))
2850 ;; XXX: "g++ -v" is broken (see also libstdc++ above).
2851 (substitute* "libcc1/configure"
2852 (("g\\+\\+ -v") "true"))
2853 #t)))
99b73d0f
LC
2854 (_ '(add-before 'configure 'return-true
2855 (lambda _ #t))))
2856 (add-after 'install 'symlink-libgcc_eh
2857 (lambda* (#:key outputs #:allow-other-keys)
2858 (let ((out (assoc-ref outputs "lib")))
2859 ;; Glibc wants to link against libgcc_eh, so provide
2860 ;; it.
2861 (with-directory-excursion
2862 (string-append out "/lib/gcc/"
2863 ,(boot-triplet)
2864 "/" ,(package-version gcc))
2865 (symlink "libgcc.a" "libgcc_eh.a"))
2866 #t))))))))
bdb36958 2867
99b73d0f
LC
2868 (inputs `(("gmp-source" ,(bootstrap-origin (package-source gmp-6.0)))
2869 ("mpfr-source" ,(bootstrap-origin (package-source mpfr)))
2870 ("mpc-source" ,(bootstrap-origin (package-source mpc)))
2871 ("binutils-cross" ,binutils-boot0)
bdb36958 2872
99b73d0f
LC
2873 ;; The libstdc++ that libcc1 links against.
2874 ("libstdc++" ,libstdc++-boot0)
b810a850 2875
99b73d0f
LC
2876 ;; Call it differently so that the builder can check whether
2877 ;; the "libc" input is #f.
2878 ("libc-native" ,@(assoc-ref (%boot0-inputs) "libc"))
2879 ,@(alist-delete "libc" (%boot0-inputs))))
9dee9e8f 2880
99b73d0f
LC
2881 ;; No need for the native-inputs to build the documentation at this stage.
2882 (native-inputs `())))
bdb36958
LC
2883
2884(define perl-boot0
99b73d0f
LC
2885 (package
2886 (inherit perl)
2887 (name "perl-boot0")
2888 (source (bootstrap-origin (package-source perl)))
2889 (inputs (%boot0-inputs))
2890 (arguments
2891 `(#:implicit-inputs? #f
2892 #:guile ,%bootstrap-guile
2893 #:validate-runpath? #f
2894
2895 ;; At the very least, this must not depend on GCC & co.
2896 #:disallowed-references ,(list %bootstrap-binutils)
2897
2898 ,@(substitute-keyword-arguments (package-arguments perl)
2899 ((#:phases phases)
2900 `(modify-phases ,phases
2901 ;; Pthread support is missing in the bootstrap compiler
2902 ;; (broken spec file), so disable it.
2903 (add-before 'configure 'disable-pthreads
2904 (lambda _
2905 (substitute* "Configure"
2906 (("^libswanted=(.*)pthread" _ before)
2907 (string-append "libswanted=" before)))
2908 #t))))
2909 ;; Do not configure with '-Dusethreads' since pthread
2910 ;; support is missing.
2911 ((#:configure-flags configure-flags)
2912 `(delete "-Dusethreads" ,configure-flags)))))))
bdb36958 2913
32f4a073 2914(define m4-boot0
99b73d0f
LC
2915 (package
2916 (inherit m4)
2917 (name "m4-boot0")
2918 (source (bootstrap-origin (package-source m4)))
2919 (inputs (%boot0-inputs))
2920 (arguments
2921 `(#:guile ,%bootstrap-guile
2922 #:implicit-inputs? #f
2923 ,@(package-arguments m4)))))
2924
d75acc29
MR
2925(define bison-boot0
2926 ;; This Bison is needed to build MiG so we need it early in the process.
12908554 2927 ;; Recent versions of Linux-Libre headers also depend on this.
99b73d0f
LC
2928 (package
2929 (inherit bison)
e5c1f5cf 2930 (name "bison-boot0")
57bc2dcf 2931 (propagated-inputs `(("m4" ,m4-boot0)))
99b73d0f
LC
2932 (native-inputs `(("perl" ,perl-boot0)))
2933 (inputs (%boot0-inputs)) ;remove Flex...
2934 (arguments
2935 `(#:tests? #f ;... and thus disable tests
2936 #:implicit-inputs? #f
2937 #:guile ,%bootstrap-guile
2938
99b73d0f
LC
2939 ;; Zero timestamps in liby.a; this must be done
2940 ;; explicitly here because the bootstrap Binutils don't
2941 ;; do that (default is "cru".)
2942 #:make-flags `("ARFLAGS=crD"
2943 ,,(match (%current-system)
2944 ;; ranlib: '-D': No such file
2945 ((or "i686-linux" "x86_64-linux")
2946 "RANLIB=ranlib")
2947 (_
2948 "RANLIB=ranlib -D"))
62548232
LC
2949 "V=1")
2950
2951 ,@(package-arguments bison)))))
d75acc29
MR
2952
2953(define flex-boot0
12908554 2954 ;; This Flex is needed to build MiG as well as Linux-Libre headers.
99b73d0f
LC
2955 (package
2956 (inherit flex)
2957 (native-inputs `(("bison" ,bison-boot0)))
57bc2dcf 2958 (propagated-inputs `(("m4" ,m4-boot0)))
99b73d0f
LC
2959 (inputs (%boot0-inputs))
2960 (arguments
2961 `(#:implicit-inputs? #f
2962 #:guile ,%bootstrap-guile
2963 #:tests? #f))))
d75acc29 2964
429243a4
MB
2965(define rsync-boot0
2966 (package
2967 (inherit rsync)
2968 (native-inputs `(("perl" ,perl-boot0)))
2969 (inputs (%boot0-inputs))
2970 (arguments
2971 `(#:implicit-inputs? #f
2972 #:guile ,%bootstrap-guile))))
2973
8102cf0b
LC
2974(define linux-libre-headers-boot0
2975 (mlambda ()
2976 "Return Linux-Libre header files for the bootstrap environment."
2977 ;; Note: this is wrapped in a thunk to nicely handle circular dependencies
2978 ;; between (gnu packages linux) and this module. Additionally, memoize
2979 ;; the result to play well with further memoization and code that relies
2980 ;; on pointer identity; see <https://bugs.gnu.org/30155>.
99b73d0f
LC
2981 (package
2982 (inherit linux-libre-headers)
2983 (arguments
2984 `(#:guile ,%bootstrap-guile
2985 #:implicit-inputs? #f
2986 ,@(package-arguments linux-libre-headers)))
2987 (native-inputs
2988 `(("perl" ,perl-boot0)
2989
2990 ;; Flex and Bison are required since version 4.16.
2991 ("flex" ,flex-boot0)
2992 ("bison" ,bison-boot0)
429243a4
MB
2993
2994 ;; Rsync is required since version 5.3.
2995 ("rsync" ,rsync-boot0)
99b73d0f 2996 ,@(%boot0-inputs))))))
bdb36958 2997
efa8fdda
LC
2998(define with-boot0
2999 (package-with-explicit-inputs %boot0-inputs
3000 %bootstrap-guile))
3001
d75acc29 3002(define gnumach-headers-boot0
efa8fdda 3003 (with-boot0 (package-with-bootstrap-guile gnumach-headers)))
d75acc29
MR
3004
3005(define mig-boot0
efa8fdda
LC
3006 (let* ((mig (package
3007 (inherit (package-with-bootstrap-guile mig))
d75acc29
MR
3008 (native-inputs `(("bison" ,bison-boot0)
3009 ("flex" ,flex-boot0)))
3010 (inputs `(("flex" ,flex-boot0)))
3011 (arguments
3012 `(#:configure-flags
3013 `(,(string-append "LDFLAGS=-Wl,-rpath="
3014 (assoc-ref %build-inputs "flex") "/lib/")))))))
efa8fdda 3015 (with-boot0 mig)))
d75acc29
MR
3016
3017(define hurd-headers-boot0
3018 (let ((hurd-headers (package (inherit hurd-headers)
3019 (native-inputs `(("mig" ,mig-boot0)))
3020 (inputs '()))))
efa8fdda 3021 (with-boot0 (package-with-bootstrap-guile hurd-headers))))
d75acc29
MR
3022
3023(define hurd-minimal-boot0
3024 (let ((hurd-minimal (package (inherit hurd-minimal)
3025 (native-inputs `(("mig" ,mig-boot0)))
3026 (inputs '()))))
efa8fdda 3027 (with-boot0 (package-with-bootstrap-guile hurd-minimal))))
d75acc29 3028
8102cf0b
LC
3029(define hurd-core-headers-boot0
3030 (mlambda ()
3031 "Return the Hurd and Mach headers as well as initial Hurd libraries for
d75acc29 3032the bootstrap environment."
efa8fdda
LC
3033 (package (inherit (package-with-bootstrap-guile hurd-core-headers))
3034 (arguments `(#:guile ,%bootstrap-guile
3035 ,@(package-arguments hurd-core-headers)))
3036 (inputs
3037 `(("gnumach-headers" ,gnumach-headers-boot0)
3038 ("hurd-headers" ,hurd-headers-boot0)
3039 ("hurd-minimal" ,hurd-minimal-boot0)
3040 ,@(%boot0-inputs))))))
d75acc29
MR
3041
3042(define* (kernel-headers-boot0 #:optional (system (%current-system)))
3043 (match system
3044 ("i586-gnu" (hurd-core-headers-boot0))
3045 (_ (linux-libre-headers-boot0))))
3046
bdb36958
LC
3047(define texinfo-boot0
3048 ;; Texinfo used to build libc's manual.
3049 ;; We build without ncurses because it fails to build at this stage, and
3050 ;; because we don't need the stand-alone Info reader.
a2b2070b 3051 ;; Also, use (%BOOT0-INPUTS) to avoid building Perl once more.
99b73d0f
LC
3052 (package
3053 (inherit texinfo)
3054 (native-inputs '())
3055 (inputs `(,@(%boot0-inputs)
3056 ("perl" ,perl-boot0)))
3057 (arguments
3058 `(#:implicit-inputs? #f
3059 #:guile ,%bootstrap-guile
3060
3061 ;; Some of Texinfo 6.1's tests would fail with "Couldn't set UTF-8
3062 ;; character type in locale" but we don't have a UTF-8 locale at this
3063 ;; stage, so skip them.
3064 #:tests? #f))))
bdb36958 3065
5f3f7039
MB
3066(define expat-sans-tests
3067 (package
3068 (inherit expat)
99b73d0f 3069 (inputs (%boot0-inputs))
5f3f7039
MB
3070 (arguments
3071 ;; XXX: Linking 'runtestscpp' fails with things like:
3072 ;;
3073 ;; ld: Dwarf Error: found dwarf version '3789', this reader only handles version 2 and 3 information.
3074 ;;
3075 ;; Skip tests altogether.
99b73d0f
LC
3076 `(#:implicit-inputs? #f
3077 #:guile ,%bootstrap-guile
3078
3079 ,@(substitute-keyword-arguments (package-arguments expat)
3080 ((#:configure-flags flags ''())
3081 ;; Since we're not passing the right -Wl,-rpath flags, build the
3082 ;; static library to avoid RUNPATH validation failure.
3083 `(cons "--disable-shared" ,flags))
3084 ((#:tests? _ #f) #f))))))
5f3f7039
MB
3085
3086(define python-boot0
99b73d0f
LC
3087 (package
3088 (inherit python-minimal)
3089 ;; We cannot use Python 3.7 and later here, because they require
3090 ;; pthreads, which is missing on non-x86 platforms at this stage.
3091 ;; Python 3.6 technically supports being built without threading
3092 ;; support, but requires additional patches.
73fec9ca 3093 (version "3.5.9")
99b73d0f
LC
3094 (source (bootstrap-origin
3095 (origin
404efac4 3096 (method url-fetch)
99b73d0f
LC
3097 (uri (string-append "https://www.python.org/ftp/python/"
3098 version "/Python-" version ".tar.xz"))
99b73d0f
LC
3099 (sha256
3100 (base32
73fec9ca 3101 "0jdh9pvx6m6lfz2liwvvhn7vks7qrysqgwn517fkpxb77b33fjn2"))
404efac4
MB
3102 (modules '((guix build utils)))
3103 (snippet
3104 '(begin
3105 ;; Delete the bundled copy of libexpat.
3106 (delete-file-recursively "Modules/expat")
3107 (substitute* "Modules/Setup.dist"
3108 ;; Link Expat instead of embedding the bundled one.
3109 (("^#pyexpat.*") "pyexpat pyexpat.c -lexpat\n"))
3110 #t)))))
99b73d0f
LC
3111 (inputs
3112 `(,@(%boot0-inputs)
3113 ("expat" ,expat-sans-tests))) ;remove OpenSSL, zlib, etc.
3114 (native-inputs '()) ;and pkg-config
3115 (arguments
3116 `(#:implicit-inputs? #f
3117 #:guile ,%bootstrap-guile
3118
3119 ,@(substitute-keyword-arguments (package-arguments python-minimal)
3120 ;; Disable features that cannot be built at this stage.
3121 ((#:configure-flags _ ''())
3122 `(list "--without-ensurepip"
3123 "--without-threads"))
3124 ;; Clear #:make-flags, such that changes to the regular
3125 ;; Python package won't interfere with this one.
3126 ((#:make-flags _ ''()) ''())
3127 ((#:phases phases)
3128 `(modify-phases ,phases
3129 (add-before 'configure 'disable-modules
3130 (lambda _
3131 (substitute* "setup.py"
3132 ;; Disable ctypes, since it requires libffi.
3133 (("extensions\\.append\\(ctypes\\)") "")
3134 ;; Prevent the 'ossaudiodev' extension from being
3135 ;; built, since it requires Linux headers.
3136 (("'linux', ") ""))
3137 #t))
3138 (delete 'set-TZDIR)))
3139 ((#:tests? _ #f) #f))))))
5f3f7039 3140
dab669e0
LC
3141(define ld-wrapper-boot0
3142 (mlambda ()
3143 ;; We need this so binaries on Hurd will have libmachuser and libhurduser
3144 ;; in their RUNPATH, otherwise validate-runpath will fail.
3145 (make-ld-wrapper "ld-wrapper-boot0"
3146 #:target boot-triplet
3147 #:binutils binutils-boot0
3148 #:guile %bootstrap-guile
3149 #:bash (car (assoc-ref (%boot0-inputs) "bash"))
3150 #:guile-for-build %bootstrap-guile)))
d75acc29 3151
a2b2070b 3152(define (%boot1-inputs)
bdb36958
LC
3153 ;; 2nd stage inputs.
3154 `(("gcc" ,gcc-boot0)
f50b013f 3155 ("ld-wrapper-cross" ,(ld-wrapper-boot0))
bdb36958 3156 ("binutils-cross" ,binutils-boot0)
a2b2070b 3157 ,@(alist-delete "binutils" (%boot0-inputs))))
bdb36958
LC
3158
3159(define glibc-final-with-bootstrap-bash
3160 ;; The final libc, "cross-built". If everything went well, the resulting
3161 ;; store path has no dependencies. Actually, the really-final libc is
3162 ;; built just below; the only difference is that this one uses the
3163 ;; bootstrap Bash.
99b73d0f
LC
3164 (package
3165 (inherit glibc)
3166 (name "glibc-intermediate")
3167 (source (bootstrap-origin (package-source glibc)))
3168 (arguments
3169 `(#:guile ,%bootstrap-guile
3170 #:implicit-inputs? #f
3171
3172 ,@(substitute-keyword-arguments (package-arguments glibc)
3173 ((#:configure-flags flags)
3174 `(append (list ,(string-append "--host=" (boot-triplet))
3175 ,(string-append "--build="
3176 (nix-system->gnu-triplet)))
3177 ,flags))
3178 ((#:phases phases)
3179 `(modify-phases ,phases
3180 (add-before 'configure 'pre-configure
3181 (lambda* (#:key inputs #:allow-other-keys)
3182 ;; Don't clobber CPATH with the bootstrap libc.
3183 (setenv "NATIVE_CPATH" (getenv "CPATH"))
3184 (unsetenv "CPATH")
3185
3186 ;; Tell 'libpthread' where to find 'libihash' on Hurd systems.
3187 ,@(if (hurd-triplet? (%current-system))
3188 `((substitute* "libpthread/Makefile"
3189 (("LDLIBS-pthread.so =.*")
3190 (string-append "LDLIBS-pthread.so = "
3191 (assoc-ref %build-inputs "kernel-headers")
3192 "/lib/libihash.a\n"))))
3193 '())
3194
3195 ;; 'rpcgen' needs native libc headers to be built.
3196 (substitute* "sunrpc/Makefile"
3197 (("sunrpc-CPPFLAGS =.*" all)
3198 (string-append "CPATH = $(NATIVE_CPATH)\n"
3199 "export CPATH\n"
3200 all "\n")))
3201 #t)))))))
3202 (propagated-inputs `(("kernel-headers" ,(kernel-headers-boot0))))
3203 (native-inputs
3204 `(("bison" ,bison-boot0)
3205 ("texinfo" ,texinfo-boot0)
3206 ("perl" ,perl-boot0)
3207 ("python" ,python-boot0)))
3208 (inputs
3209 `( ;; The boot inputs. That includes the bootstrap libc. We don't want
3210 ;; it in $CPATH, hence the 'pre-configure' phase above.
3211 ,@(%boot1-inputs)
3212
3213 ;; A native MiG is needed to build Glibc on Hurd.
3214 ,@(if (hurd-triplet? (%current-system))
3215 `(("mig" ,mig-boot0))
3216 '())
3217
3218 ;; A native GCC is needed to build `cross-rpcgen'.
3219 ("native-gcc" ,@(assoc-ref (%boot0-inputs) "gcc"))
3220
3221 ;; Here, we use the bootstrap Bash, which is not satisfactory
3222 ;; because we don't want to depend on bootstrap tools.
3223 ("static-bash" ,@(assoc-ref (%boot0-inputs) "bash"))))))
bdb36958
LC
3224
3225(define (cross-gcc-wrapper gcc binutils glibc bash)
3226 "Return a wrapper for the pseudo-cross toolchain GCC/BINUTILS/GLIBC
3227that makes it available under the native tool names."
c92f1c0a 3228 (package (inherit gcc)
bdb36958
LC
3229 (name (string-append (package-name gcc) "-wrapped"))
3230 (source #f)
3231 (build-system trivial-build-system)
3232 (outputs '("out"))
3233 (arguments
3234 `(#:guile ,%bootstrap-guile
3235 #:modules ((guix build utils))
3236 #:builder (begin
3237 (use-modules (guix build utils))
3238
3239 (let* ((binutils (assoc-ref %build-inputs "binutils"))
3240 (gcc (assoc-ref %build-inputs "gcc"))
3241 (libc (assoc-ref %build-inputs "libc"))
3242 (bash (assoc-ref %build-inputs "bash"))
3243 (out (assoc-ref %outputs "out"))
3244 (bindir (string-append out "/bin"))
3245 (triplet ,(boot-triplet)))
3246 (define (wrap-program program)
3247 ;; GCC-BOOT0 is a libc-less cross-compiler, so it
3248 ;; needs to be told where to find the crt files and
3249 ;; the dynamic linker.
3250 (call-with-output-file program
3251 (lambda (p)
3252 (format p "#!~a/bin/bash
3253exec ~a/bin/~a-~a -B~a/lib -Wl,-dynamic-linker -Wl,~a/~a \"$@\"~%"
3254 bash
3255 gcc triplet program
3256 libc libc
3257 ,(glibc-dynamic-linker))))
3258
3259 (chmod program #o555))
3260
3261 (mkdir-p bindir)
3262 (with-directory-excursion bindir
3263 (for-each (lambda (tool)
3264 (symlink (string-append binutils "/bin/"
3265 triplet "-" tool)
3266 tool))
3267 '("ar" "ranlib"))
e3cfef22
MW
3268 (for-each wrap-program '("gcc" "g++")))
3269
3270 #t))))
bdb36958
LC
3271 (native-inputs
3272 `(("binutils" ,binutils)
3273 ("gcc" ,gcc)
3274 ("libc" ,glibc)
3275 ("bash" ,bash)))
3276 (inputs '())))
3277
32793c09
LC
3278(define gcc-boot0-intermediate-wrapped
3279 (mlambda ()
3280 ;; Make the cross-tools GCC-BOOT0 and BINUTILS-BOOT0 available under the
3281 ;; non-cross names.
3282 (cross-gcc-wrapper gcc-boot0 binutils-boot0
3283 glibc-final-with-bootstrap-bash
3284 (car (assoc-ref (%boot1-inputs) "bash")))))
eb443459 3285
bdb36958 3286(define static-bash-for-glibc
90d891fc 3287 ;; A statically-linked Bash to be used by GLIBC-FINAL in system(3) & co.
99b73d0f
LC
3288 (package
3289 (inherit static-bash)
3290 (source (bootstrap-origin (package-source static-bash)))
3291 (inputs `(("gcc" ,(gcc-boot0-intermediate-wrapped))
3292 ("libc" ,glibc-final-with-bootstrap-bash)
3293 ("libc:static" ,glibc-final-with-bootstrap-bash "static")
3294 ,@(fold alist-delete (%boot1-inputs)
3295 '("gcc" "libc"))))
3296 (arguments
3297 `(#:implicit-inputs? #f
3298 #:guile ,%bootstrap-guile
3299
3300 ,@(substitute-keyword-arguments (package-arguments static-bash)
3301 ((#:configure-flags flags '())
3302 ;; Add a '-L' flag so that the pseudo-cross-ld of
3303 ;; BINUTILS-BOOT0 can find libc.a.
3304 `(append ,flags
3305 (list (string-append "LDFLAGS=-static -L"
3306 (assoc-ref %build-inputs
3307 "libc:static")
3308 "/lib")))))))))
bdb36958 3309
6162b95d
LC
3310(define gettext-boot0
3311 ;; A minimal gettext used during bootstrap.
99b73d0f
LC
3312 (package
3313 (inherit gettext-minimal)
3314 (name "gettext-boot0")
3315 ;; Newer versions of GNU gettext depends on libxml2 and ncurses. To
3316 ;; simplify the dependency chain, we stick to this version here.
3317 (version "0.19.8.1")
3318 (source (origin
3319 (method url-fetch)
3320 (uri (string-append "mirror://gnu/gettext/gettext-"
3321 version ".tar.gz"))
3322 (sha256
3323 (base32
3324 "0hsw28f9q9xaggjlsdp2qmbp2rbd1mp0njzan2ld9kiqwkq2m57z"))))
3325 (inputs (%boot1-inputs)) ;zero dependencies
3326 (arguments
3327 `(#:implicit-inputs? #f
3328 #:guile ,%bootstrap-guile
3329 #:tests? #f
3330 #:phases (modify-phases %standard-phases
3331 ;; Build only the tools.
3332 (add-after 'unpack 'chdir
3333 (lambda _
3334 (chdir "gettext-tools")
3335 #t))
3336
3337 ;; Some test programs require pthreads, which we don't have.
3338 (add-before 'configure 'no-test-programs
3339 (lambda _
3340 (substitute* "tests/Makefile.in"
3341 (("^PROGRAMS =.*$")
3342 "PROGRAMS =\n"))
3343 #t)))))))
6162b95d 3344
89223417 3345(define glibc-final
bdb36958 3346 ;; The final glibc, which embeds the statically-linked Bash built above.
7c788ed2 3347 ;; Use 'package/inherit' so we get the 'replacement' of 'glibc', if any.
99b73d0f
LC
3348 (package/inherit
3349 glibc
3350 (name "glibc")
3351 (source (bootstrap-origin (package-source glibc)))
3352 (inputs `(("static-bash" ,static-bash-for-glibc)
3353 ,@(alist-delete
3354 "static-bash"
3355 (package-inputs glibc-final-with-bootstrap-bash))))
3356
3357 ;; This time we need 'msgfmt' to install all the libc.mo files.
3358 (native-inputs `(,@(package-native-inputs glibc-final-with-bootstrap-bash)
3359 ("gettext" ,gettext-boot0)))
3360
3361 (propagated-inputs
3362 (package-propagated-inputs glibc-final-with-bootstrap-bash))
3363
3364 ;; The final libc only refers to itself, but the 'debug' output contains
3365 ;; references to GCC-BOOT0 and to the Linux headers. XXX: Would be great
3366 ;; if 'allowed-references' were per-output.
3367 (arguments
3368 `(#:allowed-references
3369 ,(cons* `(,gcc-boot0 "lib") (kernel-headers-boot0)
3370 static-bash-for-glibc
3371 (package-outputs glibc-final-with-bootstrap-bash))
3372
3373 ,@(package-arguments glibc-final-with-bootstrap-bash)))))
bdb36958 3374
32793c09
LC
3375(define gcc-boot0-wrapped
3376 (mlambda ()
3377 ;; Make the cross-tools GCC-BOOT0 and BINUTILS-BOOT0 available under the
3378 ;; non-cross names.
3379 (cross-gcc-wrapper gcc-boot0 binutils-boot0 glibc-final
3380 (car (assoc-ref (%boot1-inputs) "bash")))))
bdb36958 3381
a2b2070b 3382(define (%boot2-inputs)
bdb36958
LC
3383 ;; 3rd stage inputs.
3384 `(("libc" ,glibc-final)
6dff905e 3385 ("libc:static" ,glibc-final "static")
f50b013f 3386 ("gcc" ,(gcc-boot0-wrapped))
4ae7dc7b 3387 ,@(fold alist-delete (%boot1-inputs) '("libc" "gcc" "linux-libre-headers"))))
bdb36958
LC
3388
3389(define binutils-final
99b73d0f
LC
3390 (package
3391 (inherit binutils)
3392 (source (bootstrap-origin (package-source binutils)))
3393 (arguments
3394 `(#:guile ,%bootstrap-guile
3395 #:implicit-inputs? #f
3396 #:allowed-references ("out" ,glibc-final)
3397 ,@(package-arguments binutils)))
3398 (inputs (%boot2-inputs))))
bdb36958
LC
3399
3400(define libstdc++
3401 ;; Intermediate libstdc++ that will allow us to build the final GCC
3402 ;; (remember that GCC-BOOT0 cannot build libstdc++.)
99b73d0f 3403 (let ((lib (make-libstdc++ gcc)))
86d02fa8
EF
3404 (package
3405 (inherit lib)
99b73d0f 3406 (source (bootstrap-origin (package-source lib)))
86d02fa8
EF
3407 (arguments
3408 `(#:guile ,%bootstrap-guile
3409 #:implicit-inputs? #f
3410 #:allowed-references ("out")
3411
3412 ;; XXX: libstdc++.so NEEDs ld.so for some reason.
3413 #:validate-runpath? #f
3414
3415 ;; All of the package arguments from 'make-libstdc++
3416 ;; except for the configure-flags.
3417 ,@(package-arguments lib)
3418 #:configure-flags `("--disable-shared"
01e8263f 3419 "--disable-libstdcxx-dual-abi"
86d02fa8
EF
3420 "--disable-libstdcxx-threads"
3421 "--disable-libstdcxx-pch"
3422 ,(string-append "--with-gxx-include-dir="
3423 (assoc-ref %outputs "out")
3424 "/include"))))
3425 (outputs '("out"))
a2b2070b 3426 (inputs (%boot2-inputs))
86d02fa8 3427 (synopsis "GNU C++ standard library (intermediate)"))))
bdb36958 3428
98bd851e
LC
3429(define zlib-final
3430 ;; Zlib used by GCC-FINAL.
99b73d0f
LC
3431 (package
3432 (inherit zlib)
3433 (arguments
3434 `(#:guile ,%bootstrap-guile
3435 #:implicit-inputs? #f
3436 #:allowed-references ("out" ,glibc-final)
3437 ,@(package-arguments zlib)))
3438 (inputs (%boot2-inputs))))
98bd851e 3439
dab669e0
LC
3440(define ld-wrapper-boot3
3441 (mlambda ()
3442 ;; A linker wrapper that uses the bootstrap Guile.
3443 (make-ld-wrapper "ld-wrapper-boot3"
3444 #:binutils binutils-final
3445 #:guile %bootstrap-guile
3446 #:bash (car (assoc-ref (%boot2-inputs) "bash"))
3447 #:guile-for-build %bootstrap-guile)))
98bd851e 3448
89223417 3449(define gcc-final
bdb36958
LC
3450 ;; The final GCC.
3451 (package (inherit gcc-boot0)
3452 (name "gcc")
ab999c25
LC
3453
3454 ;; XXX: Currently #:allowed-references applies to all the outputs but the
3455 ;; "debug" output contains disallowed references, notably
3456 ;; linux-libre-headers. Disable the debugging output to work around that.
3457 (outputs (delete "debug" (package-outputs gcc-boot0)))
3458
bdb36958
LC
3459 (arguments
3460 `(#:guile ,%bootstrap-guile
3461 #:implicit-inputs? #f
3462
98bd851e 3463 #:allowed-references ("out" "lib" ,zlib-final
90d891fc 3464 ,glibc-final ,static-bash-for-glibc)
bdb36958 3465
d485ebba
LC
3466 ;; Things like libasan.so and libstdc++.so NEED ld.so for some
3467 ;; reason, but it is not in their RUNPATH. This is a false
3468 ;; positive, so turn it off.
3469 #:validate-runpath? #f
3470
eb443459 3471 ,@(substitute-keyword-arguments (package-arguments gcc)
bdb36958 3472 ((#:make-flags flags)
52cfd8cb 3473 ;; Since $LIBRARY_PATH is not honored, add the relevant flags.
98bd851e
LC
3474 `(let ((zlib (assoc-ref %build-inputs "zlib")))
3475 (map (lambda (flag)
3476 (if (string-prefix? "LDFLAGS=" flag)
3477 (string-append flag " -L"
3478 (assoc-ref %build-inputs "libstdc++")
3479 "/lib -L" zlib "/lib -Wl,-rpath="
3480 zlib "/lib")
3481 flag))
3482 ,flags)))
eb443459
JN
3483 ;; Build again GMP & co. within GCC's build process, because it's hard
3484 ;; to do outside (because GCC-BOOT0 is a cross-compiler, and thus
3485 ;; doesn't honor $LIBRARY_PATH, which breaks `gnu-build-system'.)
bdb36958 3486 ((#:phases phases)
eb443459
JN
3487 `(modify-phases ,phases
3488 (add-after 'unpack 'unpack-gmp&co
3489 (lambda* (#:key inputs #:allow-other-keys)
3490 (let ((gmp (assoc-ref %build-inputs "gmp-source"))
3491 (mpfr (assoc-ref %build-inputs "mpfr-source"))
3492 (mpc (assoc-ref %build-inputs "mpc-source")))
3493
3494 ;; To reduce the set of pre-built bootstrap inputs, build
3495 ;; GMP & co. from GCC.
3496 (for-each (lambda (source)
3497 (invoke "tar" "xvf" source))
3498 (list gmp mpfr mpc))
3499
3500 ;; Create symlinks like `gmp' -> `gmp-x.y.z'.
3501 ,@(map (lambda (lib)
3502 ;; Drop trailing letters, as gmp-6.0.0a unpacks
3503 ;; into gmp-6.0.0.
3504 `(symlink ,(string-trim-right
3505 (package-full-name lib "-")
3506 char-set:letter)
3507 ,(package-name lib)))
3508 (list gmp-6.0 mpfr mpc))
3509 #t))))))))
bdb36958 3510
90d891fc
LC
3511 ;; This time we want Texinfo, so we get the manual. Add
3512 ;; STATIC-BASH-FOR-GLIBC so that it's used in the final shebangs of
3513 ;; scripts such as 'mkheaders' and 'fixinc.sh' (XXX: who cares about these
3514 ;; scripts?).
bdb36958 3515 (native-inputs `(("texinfo" ,texinfo-boot0)
19d27131 3516 ("perl" ,perl-boot0) ;for manpages
90d891fc 3517 ("static-bash" ,static-bash-for-glibc)
bdb36958
LC
3518 ,@(package-native-inputs gcc-boot0)))
3519
8309c389 3520 (inputs `(("gmp-source" ,(bootstrap-origin (package-source gmp-6.0)))
bdb36958
LC
3521 ("mpfr-source" ,(package-source mpfr))
3522 ("mpc-source" ,(package-source mpc))
f50b013f 3523 ("ld-wrapper" ,(ld-wrapper-boot3))
bdb36958
LC
3524 ("binutils" ,binutils-final)
3525 ("libstdc++" ,libstdc++)
98bd851e 3526 ("zlib" ,zlib-final)
a2b2070b 3527 ,@(%boot2-inputs)))))
bdb36958 3528
a2b2070b 3529(define (%boot3-inputs)
bdb36958
LC
3530 ;; 4th stage inputs.
3531 `(("gcc" ,gcc-final)
f50b013f 3532 ("ld-wrapper" ,(ld-wrapper-boot3))
a2b2070b 3533 ,@(alist-delete "gcc" (%boot2-inputs))))
bdb36958
LC
3534
3535(define bash-final
3536 ;; Link with `-static-libgcc' to make sure we don't retain a reference
704243e0
LC
3537 ;; to the bootstrap GCC. Use "bash-minimal" to avoid an extra dependency
3538 ;; on Readline and ncurses.
99b73d0f
LC
3539 (let ((bash (static-libgcc-package bash-minimal)))
3540 (package
3541 (inherit bash)
3542 (source (bootstrap-origin (package-source bash)))
3543 (inputs (%boot3-inputs))
3544 (arguments
3545 `(#:implicit-inputs? #f
3546 #:guile ,%bootstrap-guile
3547
3548 #:disallowed-references ,(assoc-ref (%boot3-inputs) "coreutils&co")
3549
3550 ,@(package-arguments bash))))))
bdb36958 3551
a2b2070b 3552(define (%boot4-inputs)
bdb36958
LC
3553 ;; Now use the final Bash.
3554 `(("bash" ,bash-final)
a2b2070b 3555 ,@(alist-delete "bash" (%boot3-inputs))))
bdb36958 3556
8f417ed2
LC
3557(define with-boot4
3558 (package-with-explicit-inputs %boot4-inputs %bootstrap-guile))
3559
bdb36958 3560(define-public guile-final
386b71d1
LC
3561 ;; This package must be public because other modules refer to it. However,
3562 ;; mark it as hidden so that 'fold-packages' ignores it.
8f417ed2
LC
3563 (with-boot4 (hidden-package
3564 (package-with-bootstrap-guile guile-2.2/fixed))))
bdb36958 3565
89223417 3566(define glibc-utf8-locales-final
87c8b92f
LC
3567 ;; Now that we have GUILE-FINAL, build the UTF-8 locales. They are needed
3568 ;; by the build processes afterwards so their 'scm_to_locale_string' works
3569 ;; with the full range of Unicode codepoints (remember
3570 ;; 'scm_to_locale_string' is called every time a string is passed to a C
3571 ;; function.)
3572 (package
3573 (inherit glibc-utf8-locales)
58a75996
MO
3574 (native-inputs
3575 `(("glibc" ,glibc-final)
8f417ed2 3576 ("gzip" ,(with-boot4 gzip))))))
87c8b92f 3577
28cbc587
LC
3578(define-public ld-wrapper
3579 ;; The final 'ld' wrapper, which uses the final Guile and Binutils.
78dea6f1
LC
3580 (make-ld-wrapper "ld-wrapper"
3581 #:binutils binutils-final
3582 #:guile guile-final
3583 #:bash bash-final))
28cbc587 3584
a2b2070b 3585(define (%boot5-inputs)
b6ac5451
LC
3586 ;; Now with UTF-8 locales. Remember that the bootstrap binaries were built
3587 ;; with an older libc, which cannot load the new locale format. See
28cbc587 3588 ;; <https://lists.gnu.org/archive/html/guix-devel/2015-08/msg00737.html>.
b6ac5451 3589 `(("locales" ,glibc-utf8-locales-final)
a2b2070b 3590 ,@(%boot4-inputs)))
87c8b92f 3591
8f417ed2
LC
3592(define with-boot5
3593 (package-with-explicit-inputs %boot5-inputs))
3594
bdb36958
LC
3595(define gnu-make-final
3596 ;; The final GNU Make, which uses the final Guile.
8f417ed2 3597 (let ((pkg-config (package
537b2dab 3598 (inherit %pkg-config) ;the native pkg-config
8f417ed2
LC
3599 (inputs `(("guile" ,guile-final)
3600 ,@(%boot5-inputs)))
3601 (arguments
3602 `(#:implicit-inputs? #f
3603 ,@(package-arguments pkg-config))))))
3604 (package
3605 (inherit (package-with-bootstrap-guile gnu-make))
3606 (inputs `(("guile" ,guile-final)
3607 ,@(%boot5-inputs)))
3608 (native-inputs `(("pkg-config" ,pkg-config)))
3609 (arguments
3610 `(#:implicit-inputs? #f
3611 ,@(package-arguments gnu-make))))))
3612
bdb36958 3613
bdb36958
LC
3614(define coreutils-final
3615 ;; The final Coreutils. Treat them specially because some packages, such as
3616 ;; Findutils, keep a reference to the Coreutils they were built with.
f0505fde
JN
3617 (with-boot5 (package-with-bootstrap-guile
3618 (package
3619 (inherit coreutils-minimal)
3620 (name "coreutils")))
8f417ed2
LC
3621 ;; Use the final Guile, linked against the
3622 ;; final libc with working iconv, so that
3623 ;; 'substitute*' works well when touching
3624 ;; test files in Gettext.
3625 ))
bdb36958
LC
3626
3627(define grep-final
3628 ;; The final grep. Gzip holds a reference to it (via zgrep), so it must be
3629 ;; built before gzip.
8f417ed2 3630 (let ((grep (with-boot5 (package-with-bootstrap-guile grep))))
78ca500a
LC
3631 (package/inherit grep
3632 (inputs (alist-delete "pcre" (package-inputs grep)))
3633 (native-inputs `(("perl" ,perl-boot0))))))
bdb36958 3634
a2b2070b 3635(define (%boot6-inputs)
bdb36958
LC
3636 ;; Now use the final Coreutils.
3637 `(("coreutils" ,coreutils-final)
3638 ("grep" ,grep-final)
a2b2070b 3639 ,@(%boot5-inputs)))
b0fd2bd3 3640
8f417ed2
LC
3641(define with-boot6
3642 (package-with-explicit-inputs %boot6-inputs))
3643
301a4249
LC
3644(define sed-final
3645 ;; The final sed.
8f417ed2 3646 (let ((sed (with-boot6 (package-with-bootstrap-guile sed))))
301a4249
LC
3647 (package/inherit sed (native-inputs `(("perl" ,perl-boot0))))))
3648
bdb36958
LC
3649(define-public %final-inputs
3650 ;; Final derivations used as implicit inputs by 'gnu-build-system'. We
3651 ;; still use 'package-with-bootstrap-guile' so that the bootstrap tools are
3652 ;; used for origins that have patches, thereby avoiding circular
3653 ;; dependencies.
8f417ed2 3654 (let ((finalize (compose with-boot6
099dbc4f 3655 package-with-bootstrap-guile)))
bdb36958 3656 `(,@(map (match-lambda
099dbc4f
LC
3657 ((name package)
3658 (list name (finalize package))))
bdb36958 3659 `(("tar" ,tar)
87c8b92f 3660 ("gzip" ,gzip)
bdb36958
LC
3661 ("bzip2" ,bzip2)
3662 ("xz" ,xz)
c00a9fbf 3663 ("file" ,file)
bdb36958
LC
3664 ("diffutils" ,diffutils)
3665 ("patch" ,patch)
bdb36958
LC
3666 ("findutils" ,findutils)
3667 ("gawk" ,gawk)))
301a4249 3668 ("sed" ,sed-final)
bdb36958
LC
3669 ("grep" ,grep-final)
3670 ("coreutils" ,coreutils-final)
3671 ("make" ,gnu-make-final)
3672 ("bash" ,bash-final)
3673 ("ld-wrapper" ,ld-wrapper)
3674 ("binutils" ,binutils-final)
3675 ("gcc" ,gcc-final)
b0fd2bd3 3676 ("libc" ,glibc-final)
6dff905e 3677 ("libc:static" ,glibc-final "static")
b0fd2bd3 3678 ("locales" ,glibc-utf8-locales-final))))
bdb36958
LC
3679
3680(define-public canonical-package
3681 (let ((name->package (fold (lambda (input result)
3682 (match input
6dff905e 3683 ((_ package . outputs)
bdb36958
LC
3684 (vhash-cons (package-full-name package)
3685 package result))))
3686 vlist-null
3687 `(("guile" ,guile-final)
3688 ,@%final-inputs))))
3689 (lambda (package)
3690 "Return the 'canonical' variant of PACKAGE---i.e., if PACKAGE is one of
3691the implicit inputs of 'gnu-build-system', return that one, otherwise return
3692PACKAGE.
3693
34d624ce 3694The goal is to avoid duplication in cases like GUILE-FINAL vs. GUILE-2.2,
bdb36958
LC
3695COREUTILS-FINAL vs. COREUTILS, etc."
3696 ;; XXX: This doesn't handle dependencies of the final inputs, such as
3697 ;; libunistring, GMP, etc.
3698 (match (vhash-assoc (package-full-name package) name->package)
3699 ((_ . canon)
3700 ;; In general we want CANON, except if we're cross-compiling: CANON
3701 ;; uses explicit inputs, so it is "anchored" in the bootstrapped
3702 ;; process, with dependencies on things that cannot be
3703 ;; cross-compiled.
3704 (if (%current-target-system)
3705 package
3706 canon))
3707 (_ package)))))
3708
3709\f
3710;;;
3711;;; GCC toolchain.
3712;;;
3713
6869b663
CD
3714;; Using the following procedure, a gcc toolchain targeting glibc-2.27 can be
3715;; instantiated like this:
3716;;
3717;; (define-public gcc-glibc-2.27-toolchain
3718;; (make-gcc-toolchain gcc glibc-2.27))
3719
3720(define* (make-gcc-toolchain gcc
3721 #:optional
3722 (libc #f))
3723 "Return a complete toolchain for GCC. If LIBC is specified, target that libc."
3724 (let ((gcc (if libc (make-gcc-libc gcc libc) gcc))
3725 (libc (if libc libc glibc-final)))
3726 (package
3727 (name (string-append (package-name gcc) "-toolchain"))
3728 (version (package-version gcc))
3729 (source #f)
3730 (build-system trivial-build-system)
3731 (arguments
3732 '(#:modules ((guix build union))
3733 #:builder (begin
3734 (use-modules (ice-9 match)
3735 (srfi srfi-26)
3736 (guix build union))
3737
3738 (let ((out (assoc-ref %outputs "out")))
3739
3740 (match %build-inputs
3741 (((names . directories) ...)
3742 (union-build out directories)))
3743
3744 (union-build (assoc-ref %outputs "debug")
3745 (list (assoc-ref %build-inputs
3746 "libc-debug")))
3747 (union-build (assoc-ref %outputs "static")
3748 (list (assoc-ref %build-inputs
3749 "libc-static")))
3750 #t))))
3751
3752 (native-search-paths (package-native-search-paths gcc))
3753 (search-paths (package-search-paths gcc))
3754
3755 (license (package-license gcc))
3756 (synopsis "Complete GCC tool chain for C/C++ development")
3757 (description
3758 "This package provides a complete GCC tool chain for C/C++ development to
34e8f0af
JB
3759be installed in user profiles. This includes GCC, as well as libc (headers and
3760binaries, plus debugging symbols in the @code{debug} output), and Binutils.")
6869b663
CD
3761 (home-page "https://gcc.gnu.org/")
3762 (outputs '("out" "debug" "static"))
3763
3764 ;; The main raison d'être of this "meta-package" is (1) to conveniently
3765 ;; install everything that we need, and (2) to make sure ld-wrapper comes
3766 ;; before Binutils' ld in the user's profile.
3767 (inputs `(("gcc" ,gcc)
3768 ("ld-wrapper" ,(car (assoc-ref %final-inputs "ld-wrapper")))
3769 ("binutils" ,binutils-final)
3770 ("libc" ,libc)
3771 ("libc-debug" ,libc "debug")
3772 ("libc-static" ,libc "static"))))))
bdb36958 3773
01e8263f
MB
3774(define-public gcc-toolchain
3775 (make-gcc-toolchain gcc-final))
3776
bdb36958 3777(define-public gcc-toolchain-4.8
b887ede1 3778 (make-gcc-toolchain gcc-4.8))
bdb36958
LC
3779
3780(define-public gcc-toolchain-4.9
b887ede1
LC
3781 (make-gcc-toolchain gcc-4.9))
3782
629f4d2e 3783(define-public gcc-toolchain-5
01e8263f 3784 (make-gcc-toolchain gcc-5))
60e2d5fe 3785
e760ec41 3786(define-public gcc-toolchain-6
b887ede1 3787 (make-gcc-toolchain gcc-6))
e760ec41 3788
d7ecab74 3789(define-public gcc-toolchain-7
01e8263f 3790 gcc-toolchain)
d7ecab74 3791
5ae27f57
LC
3792(define-public gcc-toolchain-8
3793 (make-gcc-toolchain gcc-8))
3794
bdfc3276
CD
3795(define-public gcc-toolchain-9
3796 (make-gcc-toolchain gcc-9))
3797
4ac5d4fe
KH
3798;; Provide the Fortran toolchain package only for the version of gfortran that
3799;; is used by Guix internally to build Fortran libraries, because combining
3800;; code compiled with different versions can cause problems.
3801
3802(define-public gfortran-toolchain
3803 (package (inherit (make-gcc-toolchain gfortran))
3804 (synopsis "Complete GCC tool chain for Fortran development")
3805 (description "This package provides a complete GCC tool chain for
3806Fortran development to be installed in user profiles. This includes
3807gfortran, as well as libc (headers and binaries, plus debugging symbols
3808in the @code{debug} output), and binutils.")))
3809
3810
bdb36958 3811;;; commencement.scm ends here