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