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