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