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