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