Commit | Line | Data |
---|---|---|
bdb36958 | 1 | ;;; GNU Guix --- Functional package management for GNU |
20bf5fce | 2 | ;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018 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> |
809b0a90 | 6 | ;;; Copyright © 2017, 2018 Efraim Flashner <efraim@flashner.co.il> |
53bfec7b | 7 | ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr> |
a2b2070b | 8 | ;;; Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> |
bdb36958 LC |
9 | ;;; |
10 | ;;; This file is part of GNU Guix. | |
11 | ;;; | |
12 | ;;; GNU Guix is free software; you can redistribute it and/or modify it | |
13 | ;;; under the terms of the GNU General Public License as published by | |
14 | ;;; the Free Software Foundation; either version 3 of the License, or (at | |
15 | ;;; your option) any later version. | |
16 | ;;; | |
17 | ;;; GNU Guix is distributed in the hope that it will be useful, but | |
18 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 | ;;; GNU General Public License for more details. | |
21 | ;;; | |
22 | ;;; You should have received a copy of the GNU General Public License | |
23 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. | |
24 | ||
25 | (define-module (gnu packages commencement) | |
26 | #:use-module ((guix licenses) | |
27 | #:select (gpl3+ lgpl2.0+ public-domain)) | |
b2fd8f63 | 28 | #:use-module (gnu packages) |
bdb36958 LC |
29 | #:use-module (gnu packages bootstrap) |
30 | #:use-module (gnu packages base) | |
31 | #:use-module (gnu packages bash) | |
0b652851 | 32 | #:use-module (gnu packages c) |
bdb36958 | 33 | #:use-module (gnu packages gcc) |
2d5d63d7 | 34 | #:use-module (gnu packages m4) |
8efe2a22 | 35 | #:use-module (gnu packages code) |
c00a9fbf | 36 | #:use-module (gnu packages file) |
bdb36958 | 37 | #:use-module (gnu packages gawk) |
2d5d63d7 | 38 | #:use-module (gnu packages bison) |
d75acc29 | 39 | #:use-module (gnu packages flex) |
bdb36958 | 40 | #:use-module (gnu packages guile) |
6162b95d | 41 | #:use-module (gnu packages gettext) |
bdb36958 LC |
42 | #:use-module (gnu packages multiprecision) |
43 | #:use-module (gnu packages compression) | |
0b652851 | 44 | #:use-module (gnu packages mes) |
bdb36958 LC |
45 | #:use-module (gnu packages perl) |
46 | #:use-module (gnu packages linux) | |
d75acc29 | 47 | #:use-module (gnu packages hurd) |
bdb36958 LC |
48 | #:use-module (gnu packages texinfo) |
49 | #:use-module (gnu packages pkg-config) | |
50 | #:use-module (guix packages) | |
51 | #:use-module (guix download) | |
52 | #:use-module (guix build-system gnu) | |
53 | #:use-module (guix build-system trivial) | |
8102cf0b | 54 | #:use-module (guix memoization) |
bdb36958 LC |
55 | #:use-module (guix utils) |
56 | #:use-module (srfi srfi-1) | |
57 | #:use-module (srfi srfi-26) | |
58 | #:use-module (ice-9 vlist) | |
d75acc29 MR |
59 | #:use-module (ice-9 match) |
60 | #:use-module (ice-9 regex)) | |
bdb36958 LC |
61 | |
62 | ;;; Commentary: | |
63 | ;;; | |
64 | ;;; This is the commencement, this is where things start. Before the | |
65 | ;;; commencement, of course, there's the 'bootstrap' module, which provides us | |
66 | ;;; with the initial binaries. This module uses those bootstrap binaries to | |
67 | ;;; actually build up the whole tool chain that make up the implicit inputs of | |
68 | ;;; 'gnu-build-system'. | |
69 | ;;; | |
70 | ;;; To avoid circular dependencies, this module should not be imported | |
71 | ;;; directly from anywhere. | |
72 | ;;; | |
a1df45e9 CM |
73 | ;;; Below, we frequently use "inherit" to create modified packages. The |
74 | ;;; reason why we use "inherit" instead of "package/inherit" is because we do | |
75 | ;;; not want these commencement packages to inherit grafts. By definition, | |
76 | ;;; these packages are not depended on at run time by any of the packages we | |
77 | ;;; use. Thus it does not make sense to inherit grafts. Furthermore, those | |
78 | ;;; grafts would often lead to extra overhead for users who would end up | |
79 | ;;; downloading those "-boot0" packages just to build package replacements | |
80 | ;;; that are in fact not going to be used. | |
81 | ;;; | |
bdb36958 LC |
82 | ;;; Code: |
83 | ||
0b652851 JN |
84 | (define %fake-bootstrap? #t) ; cheat using Guile (instead of Mes) in MesCC |
85 | ; for speed-up? | |
86 | ||
87 | (define mes-boot0 | |
189ac60e JN |
88 | (let ((version "0.18") |
89 | (revision "0") | |
0b652851 JN |
90 | (commit #f)) |
91 | (package | |
92 | (inherit mes) | |
93 | (name "mes-boot0") | |
94 | (version (if commit (string-append version "-" revision "." (string-take commit 7)) | |
95 | version)) | |
96 | (source (if commit | |
97 | (origin | |
98 | (method url-fetch) | |
99 | (uri (string-append "https://gitlab.com/janneke/mes" | |
100 | "/-/archive/" commit | |
101 | "/mes-" commit ".tar.gz")) | |
102 | (sha256 | |
103 | (base32 | |
189ac60e | 104 | "1whbzahv16bwhavr2azqli0dcbk29p9rsqfbjl69la135z8vgdhx"))) |
1a99a9c4 | 105 | (package-source mes))) |
0b652851 JN |
106 | (native-inputs '()) |
107 | (propagated-inputs '())))) | |
108 | ||
0b652851 JN |
109 | (define nyacc-boot |
110 | (let ((version "0.86.0") | |
111 | (revision "0") | |
112 | (commit #f)) | |
113 | (package | |
114 | (inherit nyacc) | |
115 | (name "nyacc-boot") | |
116 | (version | |
117 | (if commit | |
118 | (string-append version "-" revision "." (string-take commit 7)) | |
119 | version)) | |
120 | (source | |
121 | (if commit | |
122 | (origin | |
123 | (method url-fetch) | |
124 | (uri (string-append "https://gitlab.com/janneke/nyacc" | |
125 | "/-/archive/" commit | |
126 | "/nyacc-" commit ".tar.gz")) | |
127 | (sha256 | |
128 | (base32 | |
129 | "0dlcqmchhl57nh7f0v6qb1kkbi7zbs3b185hcqv57fhb60b7rgcq"))) | |
130 | (package-source nyacc)))))) | |
131 | ||
132 | (define mes-boot | |
133 | (package-with-bootstrap-guile | |
134 | (package | |
135 | (inherit mes) | |
136 | (source (package-source mes-boot0)) | |
137 | (name "mes-boot") | |
138 | (inputs '()) | |
139 | (propagated-inputs '()) | |
140 | (native-inputs | |
4fd4efc8 | 141 | `(("mescc-tools" ,%bootstrap-mescc-tools) |
0b652851 JN |
142 | ("nyacc-source" ,(package-source nyacc-boot)) |
143 | ||
144 | ("coreutils" , %bootstrap-coreutils&co) | |
1a99a9c4 | 145 | ("bootstrap-mes" ,%bootstrap-mes) |
0b652851 JN |
146 | ,@(if %fake-bootstrap? ; cheat: fast non-bootstrap testing with Guile |
147 | `(("guile" ,%bootstrap-guile) | |
148 | ("srfi-43" ,%srfi-43)) ; guile-2.0.9 lacks srfi-43; cherry-pick | |
149 | '()))) | |
150 | (arguments | |
151 | `(#:implicit-inputs? #f | |
152 | #:guile ,%bootstrap-guile | |
153 | #:strip-binaries? #f ; binutil's strip b0rkes MesCC/M1/hex2 binaries | |
154 | #:phases | |
155 | (modify-phases %standard-phases | |
156 | (add-after 'unpack 'unpack-seeds | |
157 | (lambda* (#:key outputs #:allow-other-keys) | |
158 | (let ((coreutils (assoc-ref %build-inputs "coreutils")) | |
159 | (srfi-43 (assoc-ref %build-inputs "srfi-43")) | |
160 | (nyacc-source (assoc-ref %build-inputs "nyacc-source")) | |
1a99a9c4 | 161 | (bootstrap-mes (assoc-ref %build-inputs "bootstrap-mes"))) |
0b652851 JN |
162 | (with-directory-excursion ".." |
163 | (and | |
164 | (mkdir-p "nyacc-source") | |
165 | (invoke "tar" "--strip=1" "-C" "nyacc-source" "-xvf" nyacc-source) | |
1a99a9c4 | 166 | (symlink (string-append bootstrap-mes "/lib") "mes-seed") |
0b652851 JN |
167 | (or (not srfi-43) |
168 | (and (mkdir-p "srfi") | |
169 | (copy-file srfi-43 "srfi/srfi-43.scm") | |
170 | #t))))))) | |
171 | (replace 'configure | |
172 | (lambda* (#:key outputs #:allow-other-keys) | |
173 | (let ((out (assoc-ref %outputs "out"))) | |
174 | (symlink (string-append "../nyacc-source/module") "nyacc") | |
175 | (setenv "GUILE_LOAD_PATH" "nyacc") | |
176 | (setenv "GUILE_TOOLS" "true") ; no tools in bootstrap-guile | |
da91723c JN |
177 | (substitute* "configure.sh" |
178 | (("^arch=.*") "arch=i686\n")) | |
1a99a9c4 | 179 | (invoke "bash" "configure.sh" |
0b652851 JN |
180 | (string-append "--prefix=" out)) |
181 | (setenv "MES" "src/mes") | |
182 | (setenv "MESCC" "scripts/mescc") | |
183 | (when ,%fake-bootstrap? ; Cheat using Guile+Nyacc+MesCC; ~30 times faster | |
184 | (let ((dir (with-directory-excursion ".." (getcwd))) | |
185 | (guile (assoc-ref %build-inputs "guile")) | |
186 | (srfi-43 (assoc-ref %build-inputs "srfi-43"))) | |
187 | (setenv "MES" "guile") | |
188 | (setenv "GUILE_AUTO_COMPILE" "1") | |
189 | (setenv "GUILE_LOAD_COMPILED_PATH" | |
190 | (string-append guile "/lib/guile/2.0/ccache")) | |
191 | (setenv "GUILE_LOAD_PATH" | |
192 | (string-append (string-append dir "/nyacc-source/module") | |
193 | ":" dir | |
194 | ":" guile "/share/guile/2.0/")) | |
195 | ;; these fail with guile-2.0 | |
196 | (when srfi-43 | |
197 | (delete-file "tests/srfi-9.test") | |
198 | (delete-file "tests/srfi-43.test")) | |
199 | ;; give auto-compile a home -- massive speed-up | |
200 | (mkdir-p "/tmp/home") | |
201 | (setenv "HOME" "/tmp/home"))) | |
202 | #t))) | |
203 | (replace 'build | |
204 | (lambda _ | |
205 | (invoke "sh" "build.sh"))) | |
206 | (replace 'check | |
207 | (lambda _ | |
208 | (when ,%fake-bootstrap? | |
1a99a9c4 | 209 | ;; break with guile-2.0 |
0b652851 JN |
210 | (delete-file "scaffold/boot/50-primitive-load.scm") |
211 | (delete-file "scaffold/boot/51-module.scm")) | |
212 | (and | |
213 | (setenv "MES_ARENA" "100000000") | |
214 | (setenv "DIFF" "sh scripts/diff.scm") | |
1a99a9c4 JN |
215 | ;; fail fast tests |
216 | ;; (invoke "sh" "-x" "build-aux/test.sh" "scaffold/tests/t") | |
217 | ;; (invoke "sh" "-x" "build-aux/test.sh" "scaffold/tests/63-struct-cell") | |
218 | (invoke "sh" "check.sh")))) | |
0b652851 JN |
219 | (replace 'install |
220 | (lambda _ | |
221 | (invoke "sh" "install.sh")))))) | |
222 | (native-search-paths | |
223 | ;; Use the language-specific variables rather than 'CPATH' because they | |
224 | ;; are equivalent to '-isystem' whereas 'CPATH' is equivalent to '-I'. | |
225 | ;; The intent is to allow headers that are in the search path to be | |
226 | ;; treated as "system headers" (headers exempt from warnings) just like | |
227 | ;; the typical /usr/include headers on an FHS system. | |
228 | (list (search-path-specification | |
229 | (variable "C_INCLUDE_PATH") | |
230 | (files '("share/mes/include"))) | |
231 | (search-path-specification | |
232 | (variable "LIBRARY_PATH") | |
233 | (files '("share/mes/lib")))))))) | |
234 | ||
235 | (define tcc-boot0 | |
236 | ;; Pristine tcc cannot be built by MesCC, we are keeping a delta of 11 | |
237 | ;; patches. In a very early and rough form they were presented to the | |
238 | ;; TinyCC developers, who at the time showed no interest in supporting the | |
239 | ;; bootstrappable effort; we will try again later. These patches have been | |
240 | ;; ported to 0.9.27, alas the resulting tcc is buggy. Once MesCC is more | |
241 | ;; mature, this package should use the 0.9.27 sources (or later). | |
242 | (let ((version "0.9.26") | |
1a99a9c4 JN |
243 | (revision "5") |
244 | (commit "c7b3f59d1a71e71b470f859b20f0cfe840f3954d")) | |
0b652851 JN |
245 | (package-with-bootstrap-guile |
246 | (package | |
247 | (inherit tcc) | |
248 | (name "tcc-boot0") | |
249 | (version (string-append version "-" revision "." (string-take commit 7))) | |
250 | (source (origin | |
251 | (method url-fetch) | |
252 | (uri (string-append "https://gitlab.com/janneke/tinycc" | |
253 | "/-/archive/" commit | |
254 | "/tinycc-" commit ".tar.gz")) | |
255 | (sha256 | |
256 | (base32 | |
1a99a9c4 | 257 | "1agz5w5q6dm51n63hsxii33hxdghmdiacbb5zzxzac3aarfxjb2m")))) |
0b652851 JN |
258 | (build-system gnu-build-system) |
259 | (supported-systems '("i686-linux" "x86_64-linux")) | |
260 | (inputs '()) | |
261 | (propagated-inputs '()) | |
262 | (native-inputs | |
263 | `(("mes" ,mes-boot) | |
4fd4efc8 | 264 | ("mescc-tools" ,%bootstrap-mescc-tools) |
0b652851 JN |
265 | ("nyacc-source" ,(package-source nyacc-boot)) |
266 | ||
267 | ("coreutils" , %bootstrap-coreutils&co) | |
1a99a9c4 | 268 | ("bootstrap-mes" ,%bootstrap-mes) |
0b652851 JN |
269 | ,@(if %fake-bootstrap? ; cheat: fast non-bootstrap testing with Guile |
270 | `(("guile" ,%bootstrap-guile) | |
271 | ("srfi-43" ,%srfi-43)) ; guile-2.0.9 lacks srfi-43; cherry-pick | |
272 | '()))) | |
273 | (arguments | |
274 | `(#:implicit-inputs? #f | |
275 | #:guile ,%bootstrap-guile | |
276 | #:strip-binaries? #f ; binutil's strip b0rkes MesCC/M1/hex2 binaries | |
277 | #:phases | |
278 | (modify-phases %standard-phases | |
279 | (add-after 'unpack 'unpack-seeds | |
280 | (lambda* (#:key outputs #:allow-other-keys) | |
281 | (let* ((coreutils (assoc-ref %build-inputs "coreutils")) | |
282 | (srfi-43 (assoc-ref %build-inputs "srfi-43")) | |
283 | (nyacc-source (assoc-ref %build-inputs "nyacc-source")) | |
1a99a9c4 | 284 | (bootstrap-mes (assoc-ref %build-inputs "bootstrap-mes"))) |
0b652851 JN |
285 | (setenv "PATH" (string-append |
286 | coreutils "/bin")) | |
287 | (format (current-error-port) "PATH=~s\n" (getenv "PATH")) | |
288 | (with-directory-excursion ".." | |
289 | (and | |
290 | (mkdir-p "nyacc-source") | |
291 | (invoke "tar" "--strip=1" "-C" "nyacc-source" | |
292 | "-xvf" nyacc-source) | |
1a99a9c4 | 293 | (symlink (string-append bootstrap-mes "/lib") "mes-seed") |
0b652851 JN |
294 | (or (not srfi-43) |
295 | (and (mkdir-p "srfi") | |
296 | (copy-file srfi-43 "srfi/srfi-43.scm") | |
297 | #t))))))) | |
298 | (replace 'configure | |
299 | (lambda* (#:key outputs #:allow-other-keys) | |
300 | (let* ((out (assoc-ref %outputs "out")) | |
301 | (dir (with-directory-excursion ".." (getcwd))) | |
302 | (coreutils (assoc-ref %build-inputs "coreutils")) | |
303 | (guile (assoc-ref %build-inputs "guile")) | |
304 | (mes (assoc-ref %build-inputs "mes")) | |
305 | (mescc-tools (assoc-ref %build-inputs "mescc-tools")) | |
306 | (libc (assoc-ref %build-inputs "libc")) | |
307 | (interpreter (if libc | |
eb443459 JN |
308 | ;; also for x86_64-linux, we are still on i686-linux |
309 | (string-append libc ,(glibc-dynamic-linker "i686-linux")) | |
0b652851 JN |
310 | (string-append mes "/lib/mes-loader")))) |
311 | (setenv "PATH" (string-append | |
312 | coreutils "/bin" | |
313 | ":" mes "/bin" | |
314 | (if guile (string-append ":" guile "/bin") | |
315 | "") | |
316 | ":" mescc-tools "/bin")) | |
317 | ||
318 | (setenv "PREFIX" out) | |
319 | (setenv "MESCC" (string-append mes "/bin/mescc")) | |
320 | (symlink (string-append mes "/share/mes") "mes") | |
321 | (setenv "MES_PREFIX" "mes") | |
322 | (setenv "OBJDUMP" "true") | |
323 | (setenv "ONE_SOURCE" "1") | |
324 | (setenv "PREPROCESS" "1") | |
0b652851 JN |
325 | (setenv "MES_ARENA" "70000000") |
326 | (setenv "MES_MAX_ARENA" "70000000") | |
327 | ||
328 | (if ,%fake-bootstrap? | |
329 | (begin ; Cheat using Guile+Nyacc+MesCC; ~30 times faster | |
330 | (setenv "MES" "guile") | |
331 | (setenv "GUILE_AUTO_COMPILE" "1") | |
332 | (setenv "GUILE_LOAD_COMPILED_PATH" | |
333 | (string-append guile "/lib/guile/2.0/ccache")) | |
334 | (setenv "GUILE_LOAD_PATH" | |
335 | (string-append dir | |
336 | ":" guile "/share/guile/2.0/" | |
337 | ":" dir "/nyacc-source/module" | |
338 | ":" mes "/share/mes/guile")) | |
339 | ||
340 | ;; give auto-compile a home -- massive speed-up | |
341 | (mkdir-p "/tmp/home") | |
342 | (setenv "HOME" "/tmp/home")) | |
343 | ||
344 | (begin ; True bootstrap build with Mes+Nyacc+MesCC | |
345 | (setenv "MES" "mes") | |
346 | (setenv "GUILE_LOAD_PATH" "nyacc") | |
347 | (symlink (string-append "../nyacc-source/module") "nyacc"))) | |
348 | (invoke "sh" "configure" | |
349 | "--prefix=$PREFIX" | |
350 | (string-append "--elfinterp=" interpreter) | |
351 | "--crtprefix=." | |
352 | "--tccdir=.")))) | |
353 | (replace 'build | |
354 | (lambda _ | |
355 | (invoke "sh" "build.sh"))) | |
356 | (replace 'check | |
357 | (lambda _ | |
358 | (setenv "DIFF" "diff.scm") | |
359 | ;; fail fast tests | |
360 | ;; (invoke "sh" "test.sh" "mes/scaffold/tests/30-strlen") | |
361 | ;; (invoke "sh" "-x" "test.sh" "mes/scaffold/tinycc/00_assignment") | |
362 | (setenv "TCC" "./tcc") | |
363 | (invoke "sh" "check.sh"))) | |
364 | (replace 'install | |
365 | (lambda _ | |
366 | (invoke "sh" "install.sh")))))) | |
367 | (native-search-paths | |
368 | ;; Use the language-specific variables rather than 'CPATH' because they | |
369 | ;; are equivalent to '-isystem' whereas 'CPATH' is equivalent to '-I'. | |
370 | ;; The intent is to allow headers that are in the search path to be | |
371 | ;; treated as "system headers" (headers exempt from warnings) just like | |
372 | ;; the typical /usr/include headers on an FHS system. | |
373 | (list (search-path-specification | |
374 | (variable "C_INCLUDE_PATH") | |
375 | (files '("include"))) | |
376 | (search-path-specification | |
377 | (variable "LIBRARY_PATH") | |
378 | (files '("lib"))))))))) | |
379 | ||
380 | (define tcc-boot | |
381 | (package-with-bootstrap-guile | |
382 | (package | |
383 | (inherit tcc-boot0) | |
384 | (name "tcc-boot") | |
385 | (version "0.9.27") | |
386 | (source (origin | |
387 | (inherit (package-source tcc)) | |
388 | (patches (search-patches "tcc-boot-0.9.27.patch")))) | |
389 | (build-system gnu-build-system) | |
390 | (inputs '()) | |
391 | (propagated-inputs '()) | |
392 | (native-inputs | |
393 | `(("mes" ,mes-boot) | |
394 | ("tcc" ,tcc-boot0) | |
395 | ||
396 | ("coreutils" , %bootstrap-coreutils&co))) | |
397 | (arguments | |
398 | `(#:implicit-inputs? #f | |
399 | #:guile ,%bootstrap-guile | |
400 | #:strip-binaries? #f ; binutil's strip b0rkes MesCC/M1/hex2 | |
401 | ; binaries, tcc-boot also comes with | |
402 | ; MesCC/M1/hex2-built binaries | |
403 | #:phases | |
404 | (modify-phases %standard-phases | |
405 | (replace 'configure | |
406 | (lambda* (#:key outputs #:allow-other-keys) | |
407 | (let* ((out (assoc-ref %outputs "out")) | |
408 | (coreutils (assoc-ref %build-inputs "coreutils")) | |
409 | (mes (assoc-ref %build-inputs "mes")) | |
410 | (tcc (assoc-ref %build-inputs "tcc")) | |
411 | (libc (assoc-ref %build-inputs "libc")) | |
412 | (interpreter (if libc | |
eb443459 JN |
413 | ;; also for x86_64-linux, we are still on i686-linux |
414 | (string-append libc ,(glibc-dynamic-linker "i686-linux")) | |
0b652851 JN |
415 | (string-append mes "/lib/mes-loader")))) |
416 | ;; unpack | |
417 | (setenv "PATH" (string-append | |
418 | coreutils "/bin" | |
419 | ":" tcc "/bin")) | |
420 | (format (current-error-port) "PATH=~s\n" (getenv "PATH")) | |
421 | (invoke "sh" "configure" | |
422 | (string-append "--cc=tcc") | |
423 | (string-append "--cpu=i386") | |
424 | (string-append "--prefix=" out) | |
425 | (string-append "--elfinterp=" interpreter) | |
426 | (string-append "--crtprefix=" tcc "/lib") | |
427 | (string-append "--sysincludepaths=" tcc "/include") | |
428 | (string-append "--libpaths=" tcc "/lib"))))) | |
429 | (replace 'build | |
430 | (lambda* (#:key outputs #:allow-other-keys) | |
431 | (let* ((out (assoc-ref %outputs "out")) | |
432 | (mes (assoc-ref %build-inputs "mes")) | |
433 | (tcc (assoc-ref %build-inputs "tcc")) | |
434 | (libc (assoc-ref %build-inputs "libc")) | |
435 | (interpreter (if libc | |
eb443459 JN |
436 | ;; also for x86_64-linux, we are still on i686-linux |
437 | (string-append libc ,(glibc-dynamic-linker "i686-linux")) | |
0b652851 JN |
438 | (string-append mes "/lib/mes-loader")))) |
439 | (invoke "tcc" | |
440 | "-vvv" | |
441 | "-D" "BOOTSTRAP=1" | |
442 | "-D" "ONE_SOURCE=1" | |
443 | "-D" "TCC_TARGET_I386=1" | |
444 | "-D" "CONFIG_TCC_STATIC=1" | |
445 | "-D" "CONFIG_USE_LIBGCC=1" | |
446 | "-D" (string-append "CONFIG_TCCDIR=\"" out "/lib/tcc\"") | |
447 | "-D" (string-append "CONFIG_TCC_CRTPREFIX=\"" out "/lib:{B}/lib:.\"") | |
448 | "-D" (string-append "CONFIG_TCC_CRTPREFIX=\"" out "/lib:{B}/lib:.\"") | |
449 | "-D" (string-append "CONFIG_TCC_ELFINTERP=\"" interpreter "\"") | |
450 | "-D" (string-append "CONFIG_TCC_LIBPATHS=\"" tcc "/lib:{B}/lib:.\"") | |
451 | "-D" (string-append "CONFIG_TCC_SYSINCLUDEPATHS=\"" tcc "/include" ":/include:{B}/include\"") | |
452 | "-D" (string-append "TCC_LIBGCC=\"" tcc "/lib/libc.a\"") | |
453 | "-o" "tcc" | |
454 | "tcc.c")))) | |
455 | (replace 'check | |
456 | (lambda _ | |
457 | ;; FIXME: add sensible check target (without depending on make) | |
458 | ;; ./check.sh ? | |
459 | (= 1 (status:exit-val (system* "./tcc" "--help"))))) | |
460 | (replace 'install | |
461 | (lambda* (#:key outputs #:allow-other-keys) | |
462 | (let ((out (assoc-ref %outputs "out")) | |
463 | (tcc (assoc-ref %build-inputs "tcc"))) | |
464 | (and | |
465 | (mkdir-p (string-append out "/bin")) | |
466 | (copy-file "tcc" (string-append out "/bin/tcc")) | |
467 | (mkdir-p (string-append out "/lib/tcc")) | |
468 | (copy-recursively (string-append tcc "/include") | |
469 | (string-append out "/include")) | |
470 | (copy-recursively (string-append tcc "/lib") | |
471 | (string-append out "/lib")) | |
472 | (invoke "tcc" "-D" "TCC_TARGET_I386=1" "-c" "-o" "libtcc1.o" "lib/libtcc1.c") | |
473 | (invoke "tcc" "-ar" "rc" "libtcc1.a" "libtcc1.o") | |
474 | (copy-file "libtcc1.a" (string-append out "/lib/libtcc1.a")) | |
475 | (delete-file (string-append out "/lib/tcc/libtcc1.a")) | |
476 | (copy-file "libtcc1.a" (string-append out "/lib/tcc/libtcc1.a")) | |
477 | #t)))))))))) | |
478 | ||
479 | (define make-mesboot0 | |
480 | (package-with-bootstrap-guile | |
481 | (package | |
482 | (inherit gnu-make) | |
483 | (name "make-mesboot0") | |
484 | (version "3.80") | |
485 | (source (origin | |
486 | (method url-fetch) | |
487 | (uri (string-append "mirror://gnu/make/make-" | |
488 | version ".tar.gz")) | |
489 | (sha256 | |
490 | (base32 | |
491 | "1pb7fb7fqf9wz9najm85qdma1xhxzf1rhj5gwrlzdsz2zm0hpcv4")))) | |
492 | (supported-systems '("i686-linux" "x86_64-linux")) | |
493 | (inputs '()) | |
494 | (propagated-inputs '()) | |
495 | (native-inputs `(("tcc" ,tcc-boot) | |
496 | ||
497 | ("bash" ,%bootstrap-coreutils&co) | |
498 | ("coreutils" ,%bootstrap-coreutils&co))) | |
499 | (arguments | |
500 | `(#:implicit-inputs? #f | |
501 | #:tests? #f ; check depends on perl | |
502 | #:guile ,%bootstrap-guile | |
503 | #:configure-flags `("CC=tcc -DO_RDONLY=0" | |
504 | "LD=tcc" | |
505 | "--disable-nls") | |
506 | #:phases | |
507 | (modify-phases %standard-phases | |
508 | (add-after 'configure 'configure-fixup | |
509 | (lambda _ | |
510 | (substitute* "build.sh" | |
511 | (("^REMOTE=.*") "REMOTE=stub\n") | |
512 | (("^extras=.*") "extras=getloadavg.c\n")) | |
513 | (substitute* "make.h" | |
514 | (("^extern long int lseek.*" all) (string-append "// " all))) | |
515 | #t)) | |
516 | (delete 'patch-generated-file-shebangs) ; no perl | |
517 | (replace 'build | |
518 | (lambda _ | |
519 | (invoke "sh" "./build.sh"))) | |
520 | (replace 'install | |
521 | (lambda* (#:key outputs #:allow-other-keys) | |
522 | (let* ((out (assoc-ref outputs "out")) | |
523 | (bin (string-append out "/bin"))) | |
524 | (install-file "make" bin)))))))))) | |
525 | ||
526 | (define diffutils-mesboot | |
527 | (package-with-bootstrap-guile | |
528 | (package | |
529 | (inherit diffutils) | |
530 | (name "diffutils-mesboot") | |
531 | (version "2.7") | |
532 | (source (origin | |
533 | (method url-fetch) | |
534 | (uri (string-append "mirror://gnu/diffutils/diffutils-" | |
535 | version ".tar.gz")) | |
536 | (sha256 | |
537 | (base32 | |
538 | "1mirn5i825bn5w7rh6mgn0r8aj9xqanav95dwcl1b8sn82f4iwnm")))) | |
539 | (supported-systems '("i686-linux" "x86_64-linux")) | |
540 | (inputs '()) | |
541 | (propagated-inputs '()) | |
542 | (native-inputs `(("mes" ,mes-boot) | |
543 | ("tcc" ,tcc-boot) | |
544 | ||
545 | ("bash" ,%bootstrap-coreutils&co) | |
546 | ("coreutils" ,%bootstrap-coreutils&co) | |
547 | ("make" ,make-mesboot0))) | |
548 | (arguments | |
549 | `(#:implicit-inputs? #f | |
550 | #:guile ,%bootstrap-guile | |
551 | #:parallel-build? #f | |
552 | #:tests? #f ; check is naive, also checks non-built PROGRAMS | |
553 | #:strip-binaries? #f ; no strip yet | |
554 | #:phases | |
555 | (modify-phases %standard-phases | |
556 | ;; diffutils-2.7 needs more traditional configure | |
557 | (replace 'configure | |
558 | (lambda* (#:key outputs #:allow-other-keys) | |
559 | (let ((out (assoc-ref outputs "out")) | |
560 | (bash (assoc-ref %build-inputs "bash"))) | |
561 | (setenv "CONFIG_SHELL" (string-append bash "/bin/sh")) | |
562 | (setenv "CC" "tcc") | |
563 | (setenv "LD" "tcc") | |
564 | (invoke "./configure" (string-append "--prefix=" out))))) | |
565 | (add-before 'configure 'remove-diff3-sdiff | |
566 | (lambda* (#:key outputs #:allow-other-keys) | |
567 | (substitute* "Makefile.in" | |
568 | (("PROGRAMS = .*" all) "PROGRAMS = cmp diff")))))))))) | |
569 | ||
570 | ||
571 | (define binutils-mesboot0 | |
572 | (package-with-bootstrap-guile | |
573 | (package | |
574 | (inherit binutils) | |
575 | (name "binutils-mesboot0") | |
576 | (version "2.20.1a") | |
577 | (source (origin | |
578 | (method url-fetch) | |
579 | (uri (string-append "mirror://gnu/binutils/binutils-" | |
580 | version ".tar.bz2")) | |
581 | (patches (search-patches "binutils-boot-2.20.1a.patch")) | |
582 | (sha256 | |
583 | (base32 | |
584 | "0r7dr0brfpchh5ic0z9r4yxqn4ybzmlh25sbp30cacqk8nb7rlvi")))) | |
585 | (inputs '()) | |
586 | (propagated-inputs '()) | |
587 | (native-inputs `(("tcc" ,tcc-boot) | |
588 | ||
589 | ("bash" ,%bootstrap-coreutils&co) | |
590 | ("coreutils" ,%bootstrap-coreutils&co) | |
591 | ("diffutils" ,diffutils-mesboot) | |
592 | ("make" ,make-mesboot0))) | |
593 | (supported-systems '("i686-linux" "x86_64-linux")) | |
594 | (arguments | |
595 | `(#:implicit-inputs? #f | |
596 | #:guile ,%bootstrap-guile | |
597 | #:tests? #f ; runtest: command not found | |
598 | #:parallel-build? #f | |
599 | #:strip-binaries? #f ; no strip yet | |
600 | #:configure-flags | |
601 | (let ((cppflags (string-append " -D __GLIBC_MINOR__=6" | |
602 | " -D MES_BOOTSTRAP=1")) | |
603 | (bash (assoc-ref %build-inputs "bash"))) | |
604 | `(,(string-append "CONFIG_SHELL=" bash "/bin/sh") | |
605 | ,(string-append "CPPFLAGS=" cppflags) | |
606 | "AR=tcc -ar" | |
607 | "CXX=false" | |
608 | "RANLIB=true" | |
609 | ,(string-append "CC=tcc" cppflags) | |
610 | "--disable-nls" | |
611 | "--disable-shared" | |
612 | "--disable-werror" | |
613 | "--build=i686-unknown-linux-gnu" | |
614 | "--host=i686-unknown-linux-gnu" | |
615 | "--with-sysroot=/"))))))) | |
616 | ||
617 | (define gcc-core-mesboot | |
618 | ;; Gcc-2.95.3 is the most recent GCC that is supported by what the Mes C | |
619 | ;; Library v0.16 offers. Gcc-3.x (and 4.x) place higher demands on a C | |
620 | ;; library, such as dir.h/struct DIR/readdir, locales, signals... Also, | |
621 | ;; with gcc-2.95.3, binutils-boot-2.20.1a and glibc-2.2.5 we found a GNU | |
622 | ;; toolchain triplet "that works". | |
623 | (package-with-bootstrap-guile | |
624 | (package | |
625 | (inherit gcc) | |
626 | (name "gcc-core-mesboot") | |
627 | (version "2.95.3") | |
628 | (source (origin | |
629 | (method url-fetch) | |
630 | (uri (string-append "mirror://gnu/gcc/gcc-2.95.3/gcc-core-" | |
631 | version | |
632 | ".tar.gz")) | |
633 | (patches (search-patches "gcc-boot-2.95.3.patch")) | |
634 | (sha256 | |
635 | (base32 | |
636 | "1xvfy4pqhrd5v2cv8lzf63iqg92k09g6z9n2ah6ndd4h17k1x0an")))) | |
637 | (supported-systems '("i686-linux" "x86_64-linux")) | |
638 | (inputs '()) | |
639 | (propagated-inputs '()) | |
640 | (native-inputs `(("binutils" ,binutils-mesboot0) | |
641 | ("tcc" ,tcc-boot) | |
642 | ||
643 | ("bash" ,%bootstrap-coreutils&co) | |
644 | ("coreutils" ,%bootstrap-coreutils&co) | |
645 | ("diffutils" ,diffutils-mesboot) | |
646 | ("make" ,make-mesboot0))) | |
647 | (outputs '("out")) | |
648 | (arguments | |
649 | `(#:implicit-inputs? #f | |
650 | #:guile ,%bootstrap-guile | |
651 | #:tests? #f | |
652 | #:parallel-build? #f | |
653 | #:strip-binaries? #f | |
654 | #:configure-flags | |
655 | (let ((out (assoc-ref %outputs "out"))) | |
656 | `("--enable-static" | |
657 | "--disable-shared" | |
658 | "--disable-werror" | |
659 | "--build=i686-unknown-linux-gnu" | |
660 | "--host=i686-unknown-linux-gnu" | |
661 | ,(string-append "--prefix=" out))) | |
662 | #:make-flags (list | |
663 | "CC=tcc -static -D __GLIBC_MINOR__=6" | |
664 | "OLDCC=tcc -static -D __GLIBC_MINOR__=6" | |
665 | "CC_FOR_BUILD=tcc -static -D __GLIBC_MINOR__=6" | |
666 | "AR=ar" | |
667 | "RANLIB=ranlib" | |
668 | (string-append "LIBGCC2_INCLUDES=-I " | |
669 | (assoc-ref %build-inputs "tcc") | |
670 | "/include") | |
671 | "LANGUAGES=c" | |
672 | (string-append "BOOT_LDFLAGS=" | |
673 | " -B" (assoc-ref %build-inputs "tcc") | |
674 | "/lib/")) | |
675 | #:modules ((guix build gnu-build-system) | |
676 | (guix build utils) | |
677 | (srfi srfi-1)) | |
678 | #:phases | |
679 | (modify-phases %standard-phases | |
680 | ;; gcc-2.95.3 needs more traditional configure | |
681 | (add-before 'configure 'setenv | |
682 | (lambda* (#:key outputs #:allow-other-keys) | |
683 | (let ((out (assoc-ref outputs "out")) | |
684 | (bash (assoc-ref %build-inputs "bash")) | |
685 | (tcc (assoc-ref %build-inputs "tcc")) | |
686 | (cppflags " -D __GLIBC_MINOR__=6")) | |
687 | (setenv "CONFIG_SHELL" (string-append bash "/bin/sh")) | |
688 | (setenv "CPPFLAGS" cppflags) | |
689 | (setenv "CC" (string-append "tcc" cppflags)) | |
690 | (setenv "CC_FOR_BUILD" (string-append "tcc" cppflags)) | |
691 | (setenv "CPP" (string-append "tcc -E" cppflags)) | |
692 | (with-output-to-file "config.cache" | |
693 | (lambda _ | |
694 | (display " | |
695 | ac_cv_c_float_format='IEEE (little-endian)' | |
696 | ")))))) | |
697 | (replace 'configure | |
698 | (lambda* (#:key configure-flags #:allow-other-keys) | |
699 | (format (current-error-port) | |
700 | "running ./configure ~a\n" (string-join configure-flags)) | |
701 | (apply invoke "./configure" configure-flags))) | |
702 | (add-after 'configure 'remove-info | |
703 | (lambda _ | |
704 | ;; no info at this stage | |
705 | (delete-file-recursively "texinfo") | |
706 | (invoke "touch" "gcc/cpp.info" "gcc/gcc.info"))) | |
707 | (add-after 'install 'install2 | |
708 | (lambda* (#:key outputs #:allow-other-keys) | |
709 | (let* ((tcc (assoc-ref %build-inputs "tcc")) | |
710 | (tcc-lib (string-append tcc "/lib/x86-mes-gcc")) | |
711 | (out (assoc-ref outputs "out")) | |
712 | (gcc-dir (string-append | |
713 | out "/lib/gcc-lib/i686-unknown-linux-gnu/2.95.3"))) | |
714 | (and | |
715 | (mkdir-p "tmp") | |
716 | (zero? (system (string-append "set -x; cd tmp && ar x ../gcc/libgcc2.a"))) | |
717 | (zero? (system (string-append "set -x; cd tmp && ar r " gcc-dir "/libgcc.a *.o"))) | |
718 | (copy-file "gcc/libgcc2.a" (string-append out "/lib/libgcc2.a")) | |
719 | (copy-file (string-append tcc "/lib/libtcc1.a") | |
720 | (string-append out "/lib/libtcc1.a")) | |
721 | (invoke "ar" "r" (string-append gcc-dir "/libc.a") | |
722 | (string-append tcc-lib "/libc+gnu.o") | |
723 | (string-append tcc-lib "/libtcc1.o")) | |
724 | (invoke "ar" "r" (string-append out "/lib/libc.a") | |
725 | (string-append tcc-lib "/libc+gnu.o") | |
726 | (string-append tcc-lib "/libtcc1.o")) | |
727 | (invoke "ls" "-ltrF" gcc-dir) | |
728 | (copy-recursively (string-append tcc "/include") | |
729 | (string-append out "/include")) | |
730 | #t))))))) | |
731 | (native-search-paths | |
732 | ;; Use the language-specific variables rather than 'CPATH' because they | |
733 | ;; are equivalent to '-isystem' whereas 'CPATH' is equivalent to '-I'. | |
734 | ;; The intent is to allow headers that are in the search path to be | |
735 | ;; treated as "system headers" (headers exempt from warnings) just like | |
736 | ;; the typical /usr/include headers on an FHS system. | |
737 | (list (search-path-specification | |
738 | (variable "C_INCLUDE_PATH") | |
739 | (files '("include" "/lib/gcc-lib/i686-unknown-linux-gnu/2.95.3/include"))) | |
740 | (search-path-specification | |
741 | (variable "LIBRARY_PATH") | |
742 | (files '("lib")))))))) | |
743 | ||
744 | (define mesboot-headers | |
745 | (package-with-bootstrap-guile | |
746 | (package | |
747 | (inherit mes-boot) | |
748 | (name "mesboot-headers") | |
749 | (supported-systems '("i686-linux" "x86_64-linux")) | |
750 | (inputs '()) | |
751 | (propagated-inputs '()) | |
752 | (native-inputs `(("coreutils" ,%bootstrap-coreutils&co) | |
753 | ("headers" ,%bootstrap-linux-libre-headers))) | |
754 | (arguments | |
755 | `(#:implicit-inputs? #f | |
756 | #:guile ,%bootstrap-guile | |
757 | #:tests? #f | |
758 | #:strip-binaries? #f | |
759 | #:phases | |
760 | (modify-phases %standard-phases | |
761 | (delete 'configure) | |
762 | (delete 'build) | |
763 | (replace 'install | |
764 | (lambda* (#:key outputs #:allow-other-keys) | |
765 | (let* ((out (assoc-ref outputs "out")) | |
766 | (include (string-append out "/include")) | |
767 | (headers (assoc-ref %build-inputs "headers" ))) | |
768 | (mkdir-p include) | |
769 | (copy-recursively "include" out) | |
770 | (copy-recursively headers out) | |
771 | #t)))))) | |
772 | (native-search-paths | |
773 | ;; Use the language-specific variables rather than 'CPATH' because they | |
774 | ;; are equivalent to '-isystem' whereas 'CPATH' is equivalent to '-I'. | |
775 | ;; The intent is to allow headers that are in the search path to be | |
776 | ;; treated as "system headers" (headers exempt from warnings) just like | |
777 | ;; the typical /usr/include headers on an FHS system. | |
778 | (list (search-path-specification | |
779 | (variable "C_INCLUDE_PATH") | |
780 | (files '("include")))))))) | |
781 | ||
782 | (define glibc-mesboot0 | |
783 | ;; GNU C Library 2.2.5 is the most recent glibc that we managed to build | |
784 | ;; using gcc-2.95.3. Newer versions (2.3.x, 2.6, 2.1x) seem to need a newer | |
785 | ;; gcc. | |
786 | (package-with-bootstrap-guile | |
787 | (package | |
788 | (inherit glibc) | |
789 | (name "glibc-mesboot0") | |
790 | (version "2.2.5") | |
791 | (source (origin | |
792 | (method url-fetch) | |
793 | (uri (string-append "mirror://gnu/glibc/glibc-" | |
794 | version | |
795 | ".tar.gz")) | |
796 | (patches (search-patches "glibc-boot-2.2.5.patch")) | |
797 | (sha256 | |
798 | (base32 | |
799 | "1vl48i16gx6h68whjyhgnn1s57vqq32f9ygfa2fls7pdkbsqvp2q")))) | |
800 | (supported-systems '("i686-linux" "x86_64-linux")) | |
801 | (inputs '()) | |
802 | (propagated-inputs '()) | |
803 | (native-inputs `(("binutils" ,binutils-mesboot0) | |
804 | ("gcc" ,gcc-core-mesboot) | |
805 | ||
806 | ("bash" ,%bootstrap-coreutils&co) | |
807 | ("coreutils" ,%bootstrap-coreutils&co) | |
808 | ("diffutils" ,diffutils-mesboot) | |
809 | ("headers" ,mesboot-headers) | |
810 | ("make" ,make-mesboot0))) | |
811 | (outputs '("out")) | |
812 | (arguments | |
813 | `(#:implicit-inputs? #f | |
814 | #:guile ,%bootstrap-guile | |
815 | #:tests? #f | |
816 | #:strip-binaries? #f | |
817 | #:parallel-build? #f ; gcc-2.95.3 ICEs on massively parallel builds | |
818 | #:make-flags (list (string-append | |
819 | "SHELL=" | |
820 | (assoc-ref %build-inputs "bash") | |
821 | "/bin/sh")) | |
822 | #:configure-flags | |
823 | (let ((out (assoc-ref %outputs "out")) | |
824 | (headers (assoc-ref %build-inputs "headers"))) | |
825 | (list | |
826 | "--disable-shared" | |
827 | "--enable-static" | |
828 | "--disable-sanity-checks" | |
829 | "--build=i686-unknown-linux-gnu" | |
830 | "--host=i686-unknown-linux-gnu" | |
831 | (string-append "--with-headers=" headers "/include") | |
832 | "--enable-static-nss" | |
833 | "--without-__thread" | |
834 | "--without-cvs" | |
835 | "--without-gd" | |
836 | "--without-tls" | |
837 | (string-append "--prefix=" out))) | |
838 | #:phases | |
839 | (modify-phases %standard-phases | |
840 | (add-before 'configure 'setenv | |
841 | (lambda* (#:key outputs #:allow-other-keys) | |
842 | (let* ((out (assoc-ref outputs "out")) | |
843 | (bash (assoc-ref %build-inputs "bash")) | |
844 | (gcc (assoc-ref %build-inputs "gcc")) | |
845 | (headers (assoc-ref %build-inputs "headers")) | |
846 | (cppflags (string-append | |
847 | ;;" -D __STDC__=1" | |
848 | " -D MES_BOOTSTRAP=1" | |
849 | " -D BOOTSTRAP_GLIBC=1")) | |
850 | (cflags (string-append " -L " (getcwd)))) | |
851 | (setenv "CONFIG_SHELL" (string-append bash "/bin/sh")) | |
852 | (setenv "SHELL" (getenv "CONFIG_SHELL")) | |
853 | (setenv "CPP" (string-append gcc "/bin/gcc -E " cppflags)) | |
854 | (setenv "CC" (string-append gcc "/bin/gcc " cppflags cflags)) | |
855 | #t))) | |
856 | ;; glibc-2.2.5 needs a more classic invocation of configure | |
857 | ;; configure: warning: CONFIG_SHELL=/gnu/store/kpxi8h3669afr9r1bgvaf9ij3y4wdyyn-bash-minimal-4.4.12/bin/bash: invalid host type | |
858 | (replace 'configure | |
859 | (lambda* (#:key configure-flags #:allow-other-keys) | |
860 | (format (current-error-port) | |
861 | "running ./configure ~a\n" (string-join configure-flags)) | |
862 | (apply invoke "./configure" configure-flags)))))) | |
863 | (native-search-paths | |
864 | ;; Use the language-specific variables rather than 'CPATH' because they | |
865 | ;; are equivalent to '-isystem' whereas 'CPATH' is equivalent to '-I'. | |
866 | ;; The intent is to allow headers that are in the search path to be | |
867 | ;; treated as "system headers" (headers exempt from warnings) just like | |
868 | ;; the typical /usr/include headers on an FHS system. | |
869 | (list (search-path-specification | |
870 | (variable "C_INCLUDE_PATH") | |
871 | (files '("include"))) | |
872 | (search-path-specification | |
873 | (variable "CPLUS_INCLUDE_PATH") | |
874 | (files '("include"))) | |
875 | (search-path-specification | |
876 | (variable "LIBRARY_PATH") | |
877 | (files '("lib")))))))) | |
878 | ||
879 | (define gcc-mesboot0 | |
880 | (package-with-bootstrap-guile | |
881 | (package | |
882 | (inherit gcc-core-mesboot) | |
883 | (name "gcc-mesboot0") | |
884 | (native-inputs `(("binutils" ,binutils-mesboot0) | |
885 | ("gcc" ,gcc-core-mesboot) | |
886 | ("libc" ,glibc-mesboot0) | |
887 | ||
888 | ("bash" ,%bootstrap-coreutils&co) | |
889 | ("coreutils" ,%bootstrap-coreutils&co) | |
890 | ("diffutils" ,diffutils-mesboot) | |
891 | ("kernel-headers" ,%bootstrap-linux-libre-headers) | |
892 | ("make" ,make-mesboot0))) | |
893 | (arguments | |
894 | (substitute-keyword-arguments (package-arguments gcc-core-mesboot) | |
895 | ((#:phases phases) | |
896 | `(modify-phases ,phases | |
897 | (replace 'setenv | |
898 | (lambda* (#:key outputs #:allow-other-keys) | |
899 | (let ((out (assoc-ref outputs "out")) | |
900 | (bash (assoc-ref %build-inputs "bash")) | |
901 | (gcc (assoc-ref %build-inputs "gcc")) | |
902 | (glibc (assoc-ref %build-inputs "libc")) | |
903 | (kernel-headers (assoc-ref %build-inputs "kernel-headers"))) | |
904 | (setenv "CONFIG_SHELL" (string-append bash "/bin/sh")) | |
905 | (format (current-error-port) "C_INCLUDE_PATH=~a\n" (getenv "C_INCLUDE_PATH")) | |
906 | (setenv "C_INCLUDE_PATH" (string-append | |
907 | gcc "/lib/gcc-lib/i686-unknown-linux-gnu/2.95.3/include" | |
908 | ":" kernel-headers "/include" | |
909 | ":" glibc "/include")) | |
910 | (format (current-error-port) "C_INCLUDE_PATH=~a\n" (getenv "C_INCLUDE_PATH")) | |
911 | (format (current-error-port) "LIBRARY_PATH=~a\n" (getenv "LIBRARY_PATH")) | |
912 | ;; FIXME: add glibc dirs to paths manually | |
913 | (setenv "LIBRARY_PATH" (string-join | |
914 | (list (string-append glibc "/lib") | |
915 | (getenv "LIBRARY_PATH")) | |
916 | ":")) | |
917 | (format (current-error-port) "LIBRARY_PATH=~a\n" (getenv "LIBRARY_PATH")) | |
918 | (with-output-to-file "config.cache" | |
919 | (lambda _ | |
920 | (display " | |
921 | ac_cv_c_float_format='IEEE (little-endian)' | |
922 | "))) | |
923 | #t))) | |
924 | (replace 'install2 | |
925 | (lambda* (#:key outputs #:allow-other-keys) | |
926 | (let* ((out (assoc-ref outputs "out")) | |
927 | (gcc-dir (string-append | |
928 | out "/lib/gcc-lib/i686-unknown-linux-gnu/2.95.3"))) | |
929 | (and | |
930 | (mkdir-p "tmp") | |
931 | (zero? (system (string-append "set -x; cd tmp && ar x ../gcc/libgcc2.a"))) | |
932 | (zero? (system (string-append "set -x; cd tmp && ar r " gcc-dir "/libgcc.a *.o"))) | |
933 | (copy-file "gcc/libgcc2.a" (string-append out "/lib/libgcc2.a")))))))) | |
934 | ((#:configure-flags configure-flags) | |
935 | `(let ((out (assoc-ref %outputs "out"))) | |
936 | `("--disable-shared" | |
937 | "--disable-werror" | |
938 | "--build=i686-unknown-linux-gnu" | |
939 | "--host=i686-unknown-linux-gnu" | |
940 | ,(string-append "--prefix=" out)))) | |
941 | ((#:make-flags make-flags) | |
942 | `(let ((gcc (assoc-ref %build-inputs "gcc"))) | |
943 | `("RANLIB=true" | |
944 | ,(string-append "LIBGCC2_INCLUDES=-I " gcc "/include") | |
945 | "LANGUAGES=c")))))))) | |
946 | ||
947 | (define binutils-mesboot | |
948 | (package-with-bootstrap-guile | |
949 | (package | |
950 | (inherit binutils-mesboot0) | |
951 | (name "binutils-mesboot") | |
952 | (native-inputs `(("binutils" ,binutils-mesboot0) | |
953 | ("libc" ,glibc-mesboot0) | |
954 | ("gcc" ,gcc-mesboot0) | |
955 | ||
956 | ("bash" ,%bootstrap-coreutils&co) | |
957 | ("coreutils" ,%bootstrap-coreutils&co) | |
958 | ("diffutils" ,diffutils-mesboot) | |
959 | ("kernel-headers" ,%bootstrap-linux-libre-headers) | |
960 | ("make" ,make-mesboot0))) | |
961 | (arguments | |
962 | (substitute-keyword-arguments (package-arguments binutils-mesboot0) | |
963 | ((#:configure-flags configure-flags) | |
964 | '(list "--disable-nls" | |
965 | "--disable-shared" | |
966 | "--disable-werror" | |
967 | "--build=i686-unknown-linux-gnu" | |
968 | "--host=i686-unknown-linux-gnu" | |
969 | "--with-sysroot=/"))))))) | |
970 | ||
971 | (define make-mesboot | |
972 | (package-with-bootstrap-guile | |
973 | (package | |
974 | (inherit make-mesboot0) | |
975 | (name "make-mesboot") | |
976 | (version "3.82") | |
977 | (source (origin | |
978 | (method url-fetch) | |
979 | (uri (string-append "mirror://gnu/make/make-" | |
980 | version ".tar.gz")) | |
981 | (sha256 | |
982 | (base32 | |
983 | "1rs2f9hmvy3q6zkl15jnlmnpgffm0bhw5ax0h5c7q604wqrip69x")))) | |
984 | (native-inputs `(("binutils" ,binutils-mesboot0) | |
985 | ("libc" ,glibc-mesboot0) | |
986 | ("gcc" ,gcc-mesboot0) | |
987 | ("make" ,make-mesboot0) | |
988 | ||
989 | ("bash" ,%bootstrap-coreutils&co) | |
990 | ("coreutils" ,%bootstrap-coreutils&co) | |
991 | ("kernel-headers" ,%bootstrap-linux-libre-headers))) | |
992 | (arguments | |
993 | (substitute-keyword-arguments (package-arguments make-mesboot0) | |
994 | ((#:configure-flags configure-flags) | |
995 | `(let ((out (assoc-ref %outputs "out"))) | |
996 | `(,(string-append "--prefix=" out)))) | |
997 | ((#:phases phases) | |
998 | `(modify-phases ,phases | |
999 | (delete 'configure-fixup) | |
1000 | (add-before 'configure 'setenv | |
1001 | (lambda _ | |
1002 | (setenv "LIBS" "-lc -lnss_files -lnss_dns -lresolv") | |
1003 | #t))))))))) | |
1004 | ||
1005 | (define gmp-boot | |
1006 | (package | |
1007 | (inherit gmp) | |
1008 | (version "4.3.2") | |
1009 | (source (origin | |
1010 | (method url-fetch) | |
1011 | (uri (string-append "mirror://gnu/gmp/gmp-" version | |
1012 | ".tar.gz")) | |
1013 | (sha256 (base32 | |
1014 | "15rwq54fi3s11izas6g985y9jklm3xprfsmym3v1g6xr84bavqvv")))))) | |
1015 | ||
1016 | (define mpfr-boot | |
1017 | (package | |
1018 | (inherit mpfr) | |
1019 | (version "2.4.2") | |
1020 | (source (origin | |
1021 | (method url-fetch) | |
1022 | (uri (string-append "mirror://gnu/mpfr/mpfr-" version | |
1023 | ".tar.gz")) | |
1024 | (sha256 (base32 | |
1025 | "0dxn4904dra50xa22hi047lj8kkpr41d6vb9sd4grca880c7wv94")))))) | |
1026 | ||
1027 | (define mpc-boot | |
1028 | (package | |
1029 | (inherit mpc) | |
1030 | (version "1.0.3") | |
1031 | (source (origin | |
1032 | (method url-fetch) | |
1033 | (uri (string-append | |
1034 | "mirror://gnu/mpc/mpc-" version ".tar.gz")) | |
1035 | (sha256 | |
1036 | (base32 | |
1037 | "1hzci2zrrd7v3g1jk35qindq05hbl0bhjcyyisq9z209xb3fqzb1")))))) | |
1038 | ||
1039 | (define gcc-mesboot1 | |
1040 | (package-with-bootstrap-guile | |
1041 | (package | |
1042 | (inherit gcc-mesboot0) | |
1043 | (name "gcc-mesboot1") | |
1044 | (version "4.7.4") | |
1045 | (source (origin (inherit (package-source gcc-4.7)) | |
1046 | (patches (search-patches "gcc-boot-4.7.4.patch")))) | |
1047 | (inputs `(("gmp-source" ,(package-source gmp-boot)) | |
1048 | ("mpfr-source" ,(package-source mpfr-boot)) | |
1049 | ("mpc-source" ,(package-source mpc-boot)))) | |
1050 | (native-inputs `(("binutils" ,binutils-mesboot) | |
1051 | ("gcc" ,gcc-mesboot0) | |
1052 | ("libc" ,glibc-mesboot0) | |
1053 | ||
1054 | ("bash" ,%bootstrap-coreutils&co) | |
1055 | ("coreutils" ,%bootstrap-coreutils&co) | |
1056 | ("diffutils" ,diffutils-mesboot) | |
1057 | ("kernel-headers" ,%bootstrap-linux-libre-headers) | |
1058 | ("make" ,make-mesboot))) | |
1059 | (arguments | |
1060 | (substitute-keyword-arguments (package-arguments gcc-core-mesboot) | |
1061 | ((#:make-flags make-flags) | |
1062 | `(let* ((libc (assoc-ref %build-inputs "libc")) | |
1063 | (ldflags (string-append | |
1064 | "-B" libc "/lib " | |
1065 | "-Wl,-dynamic-linker " | |
1066 | "-Wl," libc | |
eb443459 | 1067 | ,(glibc-dynamic-linker "i686-linux")))) |
0b652851 JN |
1068 | (list (string-append "LDFLAGS=" ldflags) |
1069 | (string-append "LDFLAGS_FOR_TARGET=" ldflags)))) | |
1070 | ((#:phases phases) | |
1071 | `(modify-phases ,phases | |
1072 | ;; c&p from commencement.scm:gcc-boot0 | |
1073 | (add-after 'unpack 'unpack-gmp&co | |
1074 | (lambda* (#:key inputs #:allow-other-keys) | |
1075 | (let ((gmp (assoc-ref %build-inputs "gmp-source")) | |
1076 | (mpfr (assoc-ref %build-inputs "mpfr-source")) | |
1077 | (mpc (assoc-ref %build-inputs "mpc-source"))) | |
1078 | ||
1079 | ;; To reduce the set of pre-built bootstrap inputs, build | |
1080 | ;; GMP & co. from GCC. | |
1081 | (for-each (lambda (source) | |
1082 | (or (invoke "tar" "xvf" source) | |
1083 | (error "failed to unpack tarball" | |
1084 | source))) | |
1085 | (list gmp mpfr mpc)) | |
1086 | ||
1087 | ;; Create symlinks like `gmp' -> `gmp-x.y.z'. | |
1088 | ,@(map (lambda (lib) | |
1089 | ;; Drop trailing letters, as gmp-6.0.0a unpacks | |
1090 | ;; into gmp-6.0.0. | |
1091 | `(symlink ,(string-trim-right | |
1092 | (package-full-name lib "-") | |
1093 | char-set:letter) | |
1094 | ,(package-name lib))) | |
1095 | (list gmp-boot mpfr-boot mpc-boot)) | |
1096 | #t))) | |
1097 | (delete 'remove-info) | |
1098 | (replace 'setenv | |
1099 | (lambda* (#:key outputs #:allow-other-keys) | |
1100 | (let* ((out (assoc-ref outputs "out")) | |
1101 | (binutils (assoc-ref %build-inputs "binutils")) | |
1102 | (bash (assoc-ref %build-inputs "bash")) | |
1103 | (gcc (assoc-ref %build-inputs "gcc")) | |
1104 | (glibc (assoc-ref %build-inputs "libc")) | |
1105 | (kernel-headers (assoc-ref %build-inputs "kernel-headers"))) | |
1106 | (setenv "CONFIG_SHELL" (string-append bash "/bin/sh")) | |
1107 | (setenv "C_INCLUDE_PATH" (string-append | |
1108 | gcc "/lib/gcc-lib/i686-unknown-linux-gnu/2.95.3/include" | |
1109 | ":" kernel-headers "/include" | |
1110 | ":" glibc "/include" | |
1111 | ":" (getcwd) "/mpfr/src")) | |
1112 | (setenv "LIBRARY_PATH" (string-append glibc "/lib" | |
1113 | ":" gcc "/lib")) | |
1114 | (format (current-error-port) "C_INCLUDE_PATH=~a\n" (getenv "C_INCLUDE_PATH")) | |
1115 | (format (current-error-port) "LIBRARY_PATH=~a\n" (getenv "LIBRARY_PATH")) | |
1116 | #t))) | |
1117 | (delete 'install2))) | |
1118 | ((#:configure-flags configure-flags) | |
1119 | `(let ((out (assoc-ref %outputs "out")) | |
1120 | (glibc (assoc-ref %build-inputs "libc"))) | |
1121 | (list (string-append "--prefix=" out) | |
1122 | "--build=i686-unknown-linux-gnu" | |
1123 | "--host=i686-unknown-linux-gnu" | |
1124 | ||
1125 | (string-append "--with-native-system-header-dir=" glibc "/include") | |
1126 | (string-append "--with-build-sysroot=" glibc "/include") | |
1127 | ||
1128 | "--disable-bootstrap" | |
1129 | "--disable-decimal-float" | |
1130 | "--disable-libatomic" | |
1131 | "--disable-libcilkrts" | |
1132 | "--disable-libgomp" | |
1133 | "--disable-libitm" | |
1134 | "--disable-libmudflap" | |
1135 | "--disable-libquadmath" | |
1136 | "--disable-libsanitizer" | |
1137 | "--disable-libssp" | |
1138 | "--disable-libvtv" | |
1139 | "--disable-lto" | |
1140 | "--disable-lto-plugin" | |
1141 | "--disable-multilib" | |
1142 | "--disable-plugin" | |
1143 | "--disable-threads" | |
1144 | "--enable-languages=c,c++" | |
1145 | ||
1146 | "--enable-static" | |
1147 | ;; libstdc++.so: error: depends on 'libgcc_s.so.1', which cannot be found in RUNPATH () | |
1148 | "--disable-shared" | |
1149 | "--enable-threads=single" | |
1150 | ||
1151 | ;; No pre-compiled libstdc++ headers, to save space. | |
1152 | "--disable-libstdcxx-pch" | |
1153 | ||
1154 | ;; for libcpp ... | |
1155 | "--disable-build-with-cxx")))))))) | |
1156 | ||
1157 | (define gcc-mesboot1-wrapper | |
1158 | ;; We need this so gcc-mesboot1 can be used to create shared binaries that | |
1159 | ;; have the correct interpreter, otherwise configuring gcc-mesboot using | |
1160 | ;; --enable-shared will fail. | |
1161 | (package-with-bootstrap-guile | |
1162 | (package | |
1163 | (inherit gcc-mesboot1) | |
1164 | (name "gcc-mesboot1-wrapper") | |
1165 | (source #f) | |
1166 | (inputs '()) | |
1167 | (native-inputs `(("bash" ,%bootstrap-coreutils&co) | |
1168 | ("libc" ,glibc-mesboot) | |
1169 | ("gcc" ,gcc-mesboot1))) | |
1170 | (arguments | |
1171 | `(#:implicit-inputs? #f | |
1172 | #:guile ,%bootstrap-guile | |
1173 | #:phases | |
1174 | (modify-phases %standard-phases | |
1175 | (delete 'unpack) | |
1176 | (delete 'configure) | |
1177 | (delete 'install) | |
1178 | (replace 'build | |
1179 | (lambda* (#:key outputs #:allow-other-keys) | |
1180 | (let* ((out (assoc-ref outputs "out")) | |
1181 | (bash (assoc-ref %build-inputs "bash")) | |
1182 | (libc (assoc-ref %build-inputs "libc")) | |
1183 | (gcc (assoc-ref %build-inputs "gcc")) | |
1184 | (bin (string-append out "/bin"))) | |
1185 | (mkdir-p bin) | |
1186 | (for-each | |
1187 | (lambda (program) | |
1188 | (let ((wrapper (string-append bin "/" program))) | |
1189 | (with-output-to-file wrapper | |
1190 | (lambda _ | |
1191 | (display (string-append "#! " bash "/bin/bash | |
1192 | exec " gcc "/bin/" program | |
1193 | " -Wl,--dynamic-linker" | |
eb443459 JN |
1194 | ;; also for x86_64-linux, we are still on i686-linux |
1195 | " -Wl," libc ,(glibc-dynamic-linker "i686-linux") | |
0b652851 JN |
1196 | " -Wl,--rpath" |
1197 | " -Wl," libc "/lib" | |
1198 | " \"$@\" | |
1199 | ")) | |
1200 | (chmod wrapper #o555))))) | |
1201 | '( | |
1202 | "gcc" | |
1203 | "g++" | |
1204 | "i686-unknown-linux-gnu-gcc" | |
1205 | "i686-unknown-linux-gnu-g++" | |
1206 | )) | |
1207 | #t))) | |
1208 | (replace 'check | |
1209 | (lambda* (#:key outputs #:allow-other-keys) | |
1210 | (let* ((out (assoc-ref outputs "out")) | |
1211 | (bin (string-append out "/bin")) | |
1212 | (program (string-append bin "/gcc"))) | |
1213 | (invoke program "--help")))))))))) | |
1214 | ||
1215 | (define glibc-headers-mesboot | |
1216 | (package-with-bootstrap-guile | |
1217 | (package | |
1218 | (inherit glibc-mesboot0) | |
1219 | (name "glibc-headers-mesboot") | |
1220 | (version "2.16.0") | |
1221 | (source (origin | |
1222 | (method url-fetch) | |
1223 | (uri (string-append "mirror://gnu/glibc/glibc-" | |
1224 | version | |
1225 | ".tar.gz")) | |
1226 | (patches (search-patches "glibc-boot-2.16.0.patch" | |
1227 | "glibc-bootstrap-system-2.16.0.patch")) | |
1228 | (sha256 | |
1229 | (base32 | |
1230 | "0vlz4x6cgz7h54qq4528q526qlhnsjzbsvgc4iizn76cb0bfanx7")))) | |
1231 | (native-inputs `(("binutils" ,binutils-mesboot) | |
1232 | ("libc" ,glibc-mesboot0) | |
1233 | ("gcc" ,gcc-mesboot1) | |
1234 | ("headers" ,mesboot-headers) | |
1235 | ||
1236 | ("bash" ,%bootstrap-coreutils&co) | |
1237 | ("coreutils" ,%bootstrap-coreutils&co) | |
1238 | ("diffutils" ,diffutils-mesboot) | |
1239 | ("kernel-headers" ,%bootstrap-linux-libre-headers) | |
1240 | ("make" ,make-mesboot))) | |
1241 | ||
1242 | (arguments | |
1243 | (substitute-keyword-arguments (package-arguments glibc-mesboot0) | |
1244 | ((#:configure-flags configure-flags) | |
1245 | `(let ((out (assoc-ref %outputs "out")) | |
1246 | (headers (assoc-ref %build-inputs "headers"))) | |
1247 | (list | |
1248 | (string-append "--prefix=" out) | |
1249 | "--disable-obsolete-rpc" | |
1250 | "--host=i686-unknown-linux-gnu" | |
1251 | (string-append "--with-headers=" headers "/include") | |
1252 | "--enable-static-nss" | |
1253 | "--with-pthread" | |
1254 | "--without-cvs" | |
1255 | "--without-gd" | |
1256 | "--enable-add-ons=nptl"))) | |
1257 | ((#:make-flags make-flags) | |
1258 | `(let ((bash (assoc-ref %build-inputs "bash"))) | |
1259 | (list (string-append "SHELL=" bash "/bin/sh") | |
1260 | "install-bootstrap-headers=yes" "install-headers"))) | |
1261 | ((#:phases phases) | |
1262 | `(modify-phases ,phases | |
1263 | (replace 'setenv | |
1264 | (lambda* (#:key outputs #:allow-other-keys) | |
1265 | (let* ((out (assoc-ref outputs "out")) | |
1266 | (headers (assoc-ref %build-inputs "headers")) | |
1267 | (bash (assoc-ref %build-inputs "bash")) | |
1268 | (coreutils (assoc-ref %build-inputs "coreutils")) | |
1269 | (libc (assoc-ref %build-inputs "libc")) | |
1270 | (gcc (assoc-ref %build-inputs "gcc")) | |
1271 | (cppflags (string-append | |
1272 | " -I " (getcwd) "/nptl/sysdeps/pthread/bits" | |
1273 | " -D BOOTSTRAP_GLIBC=1")) | |
1274 | (cflags (string-append " -L " (getcwd) | |
1275 | " -L " libc "/lib"))) | |
1276 | (setenv "libc_cv_friendly_stddef" "yes") | |
1277 | (setenv "CONFIG_SHELL" (string-append bash "/bin/sh")) | |
1278 | (setenv "SHELL" (getenv "CONFIG_SHELL")) | |
1279 | (format (current-error-port) "CONFIG_SHELL=~s\n" (getenv "CONFIG_SHELL")) | |
1280 | ||
1281 | (setenv "CPP" (string-append gcc "/bin/gcc -E " cppflags)) | |
1282 | (setenv "CC" (string-append gcc "/bin/gcc " cppflags cflags)) | |
1283 | ||
1284 | ;; avoid -fstack-protector | |
1285 | (setenv "libc_cv_ssp" "false") | |
1286 | (substitute* "configure" | |
1287 | (("/bin/pwd") (string-append coreutils "/bin/pwd"))) | |
1288 | (setenv "C_INCLUDE_PATH" (string-append libc "/include" | |
1289 | headers "/include")) | |
1290 | (setenv "LIBRARY_PATH" (string-append libc "/lib"))))) | |
1291 | (replace 'install | |
1292 | (lambda* (#:key outputs make-flags #:allow-other-keys) | |
1293 | (let ((kernel-headers (assoc-ref %build-inputs "kernel-headers")) | |
1294 | (out (assoc-ref outputs "out"))) | |
1295 | (and (apply invoke "make" make-flags) | |
1296 | (copy-recursively kernel-headers out) | |
1297 | #t)))) | |
1298 | (replace 'configure | |
1299 | (lambda* (#:key configure-flags #:allow-other-keys) | |
1300 | (format (current-error-port) "running ../configure ~a\n" (string-join configure-flags)) | |
1301 | (mkdir-p "build") | |
1302 | (chdir "build") | |
1303 | (apply invoke "../configure" configure-flags))) | |
1304 | (add-after 'configure 'remove-sunrpc | |
1305 | (lambda _ | |
1306 | (invoke "make" (string-append (getcwd) "/sysd-sorted" ) | |
1307 | (string-append "SHELL=" (getenv "CONFIG_SHELL"))) | |
1308 | (substitute* "sysd-sorted" | |
1309 | ((" sunrpc") " ") | |
1310 | ((" nis") " ")) | |
1311 | ;; 'rpcgen' needs native libc headers to be built. | |
1312 | (substitute* "../Makefile" | |
1313 | (("^SHELL := /bin/sh") (string-append "SHELL := " (getenv "CONFIG_SHELL")))) | |
1314 | (substitute* "../Makeconfig" | |
1315 | (("^SHELL := /bin/sh") (string-append "SHELL := " (getenv "CONFIG_SHELL")))) | |
1316 | (substitute* "../elf/Makefile" | |
1317 | (("^SHELL := /bin/sh") (string-append "SHELL := " (getenv "CONFIG_SHELL"))))))))))))) | |
1318 | ||
1319 | (define glibc-mesboot | |
1320 | (package-with-bootstrap-guile | |
1321 | (package | |
1322 | (inherit glibc-headers-mesboot) | |
1323 | (name "glibc-mesboot") | |
1324 | (native-inputs `(("binutils" ,binutils-mesboot) | |
1325 | ("libc" ,glibc-mesboot0) | |
1326 | ("headers" ,glibc-headers-mesboot) | |
1327 | ("gcc" ,gcc-mesboot1) | |
1328 | ||
1329 | ("bash" ,%bootstrap-coreutils&co) | |
1330 | ("coreutils" ,%bootstrap-coreutils&co) | |
1331 | ("diffutils" ,diffutils-mesboot) | |
1332 | ("kernel-headers" ,%bootstrap-linux-libre-headers) | |
1333 | ("make" ,make-mesboot))) | |
1334 | ||
1335 | (arguments | |
1336 | `(#:validate-runpath? #f ; fails when using --enable-shared | |
1337 | ,@(substitute-keyword-arguments (package-arguments glibc-headers-mesboot) | |
1338 | ((#:make-flags make-flags) | |
1339 | `(let ((bash (assoc-ref %build-inputs "bash"))) | |
1340 | (list (string-append "SHELL=" bash "/bin/sh")))) | |
1341 | ((#:phases phases) | |
1342 | `(modify-phases ,phases | |
1343 | (replace 'install | |
1344 | (lambda* (#:key outputs make-flags #:allow-other-keys) | |
1345 | (let* ((kernel-headers (assoc-ref %build-inputs "kernel-headers")) | |
1346 | (out (assoc-ref outputs "out")) | |
1347 | (install-flags (cons "install" make-flags))) | |
1348 | (and (apply invoke "make" install-flags) | |
1349 | (copy-recursively kernel-headers out) | |
1350 | #t))))))))) | |
1351 | (native-search-paths ;; FIXME: move to glibc-mesboot0 | |
1352 | ;; Use the language-specific variables rather than 'CPATH' because they | |
1353 | ;; are equivalent to '-isystem' whereas 'CPATH' is equivalent to '-I'. | |
1354 | ;; The intent is to allow headers that are in the search path to be | |
1355 | ;; treated as "system headers" (headers exempt from warnings) just like | |
1356 | ;; the typical /usr/include headers on an FHS system. | |
1357 | (list (search-path-specification | |
1358 | (variable "C_INCLUDE_PATH") | |
1359 | (files '("include"))) | |
1360 | (search-path-specification | |
1361 | (variable "CPLUS_INCLUDE_PATH") | |
1362 | (files '("include"))) | |
1363 | (search-path-specification | |
1364 | (variable "LIBRARY_PATH") | |
1365 | (files '("lib")))))))) | |
1366 | ||
1367 | (define gcc-mesboot | |
1368 | (package-with-bootstrap-guile | |
1369 | (package | |
1370 | (inherit gcc-mesboot1) | |
1371 | (name "gcc-mesboot") | |
1372 | (version "4.9.4") | |
1373 | (source (package-source gcc-4.9)) | |
1374 | (native-inputs `(("binutils" ,binutils-mesboot) | |
1375 | ("gcc-wrapper" ,gcc-mesboot1-wrapper) | |
1376 | ("gcc" ,gcc-mesboot1) | |
1377 | ("libc" ,glibc-mesboot) | |
1378 | ||
1379 | ("bash" ,%bootstrap-coreutils&co) | |
1380 | ("coreutils" ,%bootstrap-coreutils&co) | |
1381 | ("diffutils" ,diffutils-mesboot) | |
1382 | ("kernel-headers" ,%bootstrap-linux-libre-headers) | |
1383 | ("make" ,make-mesboot))) | |
1384 | (arguments | |
1385 | `(#:validate-runpath? #f | |
1386 | ,@(substitute-keyword-arguments (package-arguments gcc-mesboot1) | |
1387 | ((#:configure-flags configure-flags) | |
1388 | `(let ((out (assoc-ref %outputs "out")) | |
1389 | (glibc (assoc-ref %build-inputs "libc"))) | |
1390 | (list (string-append "--prefix=" out) | |
1391 | "--build=i686-unknown-linux-gnu" | |
1392 | "--host=i686-unknown-linux-gnu" | |
1393 | ||
1394 | "--with-host-libstdcxx=-lsupc++" | |
1395 | ||
1396 | (string-append "--with-native-system-header-dir=" glibc "/include") | |
1397 | (string-append "--with-build-sysroot=" glibc "/include") | |
1398 | ||
1399 | "--disable-bootstrap" | |
1400 | "--disable-decimal-float" | |
1401 | "--disable-libatomic" | |
1402 | "--disable-libcilkrts" | |
1403 | "--disable-libgomp" | |
1404 | "--disable-libitm" | |
1405 | "--disable-libmudflap" | |
1406 | "--disable-libquadmath" | |
1407 | "--disable-libsanitizer" | |
1408 | "--disable-libssp" | |
1409 | "--disable-libvtv" | |
1410 | "--disable-lto" | |
1411 | "--disable-lto-plugin" | |
1412 | "--disable-multilib" | |
1413 | "--disable-plugin" | |
1414 | "--disable-threads" | |
1415 | "--enable-languages=c,c++" | |
1416 | ||
1417 | "--enable-static" | |
1418 | "--enable-shared" | |
1419 | "--enable-threads=single" | |
1420 | ||
1421 | ;; No pre-compiled libstdc++ headers, to save space. | |
1422 | "--disable-libstdcxx-pch" | |
1423 | ||
1424 | ;; for libcpp ... | |
1425 | "--disable-build-with-cxx"))) | |
1426 | ((#:phases phases) | |
1427 | `(modify-phases ,phases | |
1428 | (replace 'setenv | |
1429 | (lambda* (#:key outputs #:allow-other-keys) | |
1430 | (let* ((out (assoc-ref outputs "out")) | |
1431 | (binutils (assoc-ref %build-inputs "binutils")) | |
1432 | (bash (assoc-ref %build-inputs "bash")) | |
1433 | (gcc (assoc-ref %build-inputs "gcc")) | |
1434 | (glibc (assoc-ref %build-inputs "libc")) | |
1435 | (kernel-headers (assoc-ref %build-inputs "kernel-headers"))) | |
1436 | (setenv "CONFIG_SHELL" (string-append bash "/bin/sh")) | |
1437 | (setenv "C_INCLUDE_PATH" (string-append | |
1438 | gcc "/lib/gcc-lib/i686-unknown-linux-gnu/4.7.4/include" | |
1439 | ":" kernel-headers "/include" | |
1440 | ":" glibc "/include" | |
1441 | ":" (getcwd) "/mpfr/src")) | |
1442 | (setenv "CPLUS_INCLUDE_PATH" (string-append | |
1443 | gcc "/lib/gcc-lib/i686-unknown-linux-gnu/4.7.4/include" | |
1444 | ":" kernel-headers "/include" | |
1445 | ":" glibc "/include" | |
1446 | ":" (getcwd) "/mpfr/src")) | |
1447 | (setenv "LIBRARY_PATH" (string-append glibc "/lib" | |
1448 | ":" gcc "/lib")) | |
1449 | (format (current-error-port) "C_INCLUDE_PATH=~a\n" (getenv "C_INCLUDE_PATH")) | |
1450 | (format (current-error-port) "CPLUS_INCLUDE_PATH=~a\n" (getenv "CPLUS_INCLUDE_PATH")) | |
1451 | (format (current-error-port) "LIBRARY_PATH=~a\n" (getenv "LIBRARY_PATH")) | |
1452 | #t))))))))))) | |
1453 | ||
1454 | (define gcc-mesboot-wrapper | |
1455 | ;; We need this so gcc-mesboot can be used to create shared binaries that | |
1456 | ;; have the correct interpreter and runpath to libc. | |
1457 | (package-with-bootstrap-guile | |
1458 | (package | |
1459 | (inherit gcc-mesboot1-wrapper) | |
1460 | (name "gcc-mesboot-wrapper") | |
1461 | (source #f) | |
1462 | (inputs '()) | |
1463 | (native-inputs `(("bash" ,%bootstrap-coreutils&co) | |
1464 | ("libc" ,glibc-mesboot) | |
1465 | ("gcc" ,gcc-mesboot)))))) | |
1466 | ||
1467 | (define m4-mesboot | |
1468 | (package-with-bootstrap-guile | |
1469 | (package | |
1470 | (inherit m4) | |
1471 | (name "m4-mesboot") | |
1472 | (version "1.4") | |
1473 | (source (origin | |
1474 | (method url-fetch) | |
1475 | (uri (string-append "mirror://gnu/m4/m4-" | |
1476 | version ".tar.gz")) | |
1477 | (sha256 | |
1478 | (base32 | |
1479 | "1f9bxj176kf3pvs350w2dfs8jgwhminywri5pyn01b11yc4yhsjw")))) | |
eb443459 | 1480 | (supported-systems '("i686-linux" "x86_64-linux")) |
0b652851 JN |
1481 | (native-inputs `(("mes" ,mes-boot) |
1482 | ("tcc" ,tcc-boot))) | |
1483 | (arguments | |
1484 | `(#:phases | |
1485 | (modify-phases %standard-phases | |
1486 | (replace 'configure | |
1487 | (lambda* (#:key outputs #:allow-other-keys) | |
1488 | (let ((out (assoc-ref outputs "out"))) | |
1489 | (setenv "CONFIG_SHELL" (string-append | |
1490 | (assoc-ref %build-inputs "bash") | |
1491 | "/bin/sh")) | |
1492 | (setenv "CC" "tcc -static") | |
1493 | (setenv "CPP" "tcc -E") | |
1494 | (invoke "./configure" (string-append "--prefix=" out))))))))))) | |
1495 | ||
c3629044 | 1496 | (define (%bootstrap-inputs+toolchain) |
0b652851 JN |
1497 | ;; The traditional bootstrap-inputs. For the i686-linux Reduced Binary Seed |
1498 | ;; the actual reduced set with bootstrapped toolchain. | |
d536c39e | 1499 | (append (match (%current-system) |
eb443459 JN |
1500 | ((or "i686-linux" "x86_64-linux") |
1501 | `(("libc" ,glibc-mesboot) | |
1502 | ("binutils" ,binutils-mesboot) | |
1503 | ("gcc-wrapper" ,gcc-mesboot-wrapper) | |
1504 | ("gcc" ,gcc-mesboot))) | |
1505 | (_ | |
1506 | '())) | |
d536c39e | 1507 | (%bootstrap-inputs))) |
c3629044 | 1508 | |
bdb36958 LC |
1509 | (define gnu-make-boot0 |
1510 | (package-with-bootstrap-guile | |
1511 | (package (inherit gnu-make) | |
1512 | (name "make-boot0") | |
bdb36958 LC |
1513 | (arguments |
1514 | `(#:guile ,%bootstrap-guile | |
1515 | #:implicit-inputs? #f | |
1516 | #:tests? #f ; cannot run "make check" | |
1517 | ,@(substitute-keyword-arguments (package-arguments gnu-make) | |
1518 | ((#:phases phases) | |
8e5e8724 LC |
1519 | `(modify-phases ,phases |
1520 | (replace 'build | |
1521 | (lambda _ | |
53bfec7b TGR |
1522 | (invoke "./build.sh") |
1523 | #t)) | |
8e5e8724 LC |
1524 | (replace 'install |
1525 | (lambda* (#:key outputs #:allow-other-keys) | |
1526 | (let* ((out (assoc-ref outputs "out")) | |
1527 | (bin (string-append out "/bin"))) | |
53bfec7b TGR |
1528 | (install-file "make" bin) |
1529 | #t)))))))) | |
bdb36958 | 1530 | (native-inputs '()) ; no need for 'pkg-config' |
c3629044 | 1531 | (inputs (%bootstrap-inputs+toolchain))))) |
bdb36958 LC |
1532 | |
1533 | (define diffutils-boot0 | |
1534 | (package-with-bootstrap-guile | |
1535 | (let ((p (package-with-explicit-inputs diffutils | |
f50b013f JN |
1536 | (lambda _ |
1537 | `(("make" ,gnu-make-boot0) | |
1538 | ,@(%bootstrap-inputs+toolchain))) | |
bdb36958 LC |
1539 | #:guile %bootstrap-guile))) |
1540 | (package (inherit p) | |
09964b4f | 1541 | (name "diffutils-boot0") |
bdb36958 LC |
1542 | (arguments `(#:tests? #f ; the test suite needs diffutils |
1543 | ,@(package-arguments p))))))) | |
1544 | ||
1545 | (define findutils-boot0 | |
1546 | (package-with-bootstrap-guile | |
09964b4f LC |
1547 | (package-with-explicit-inputs (package |
1548 | (inherit findutils) | |
1549 | (name "findutils-boot0")) | |
f50b013f JN |
1550 | (lambda _ |
1551 | `(("make" ,gnu-make-boot0) | |
1552 | ("diffutils" ,diffutils-boot0) ; for tests | |
1553 | ,@(%bootstrap-inputs+toolchain))) | |
bdb36958 LC |
1554 | (current-source-location) |
1555 | #:guile %bootstrap-guile))) | |
1556 | ||
c00a9fbf MW |
1557 | (define file-boot0 |
1558 | (package-with-bootstrap-guile | |
f00b85ff LC |
1559 | (package-with-explicit-inputs (package |
1560 | (inherit file) | |
f50b013f JN |
1561 | (name "file-boot0") |
1562 | (arguments | |
1563 | '(#:strip-binaries? #f | |
1564 | #:validate-runpath? #f))) | |
1565 | (lambda _ | |
1566 | `(("make" ,gnu-make-boot0) | |
1567 | ,@(%bootstrap-inputs+toolchain))) | |
c00a9fbf MW |
1568 | (current-source-location) |
1569 | #:guile %bootstrap-guile))) | |
1570 | ||
a2b2070b | 1571 | (define (%boot0-inputs) |
bdb36958 LC |
1572 | `(("make" ,gnu-make-boot0) |
1573 | ("diffutils" ,diffutils-boot0) | |
1574 | ("findutils" ,findutils-boot0) | |
c00a9fbf | 1575 | ("file" ,file-boot0) |
c3629044 | 1576 | ,@(%bootstrap-inputs+toolchain))) |
bdb36958 | 1577 | |
bdb36958 LC |
1578 | (define* (boot-triplet #:optional (system (%current-system))) |
1579 | ;; Return the triplet used to create the cross toolchain needed in the | |
1580 | ;; first bootstrapping stage. | |
1581 | (nix-system->gnu-triplet system "guix")) | |
1582 | ||
1583 | ;; Following Linux From Scratch, build a cross-toolchain in stage 0. That | |
1584 | ;; toolchain actually targets the same OS and arch, but it has the advantage | |
c3629044 JN |
1585 | ;; of being independent of the libc and tools in |
1586 | ;; (%BOOTSTRAP-INPUTS+TOOLCHAIN), since GCC-BOOT0 (below) is built without any | |
1587 | ;; reference to the target libc. | |
bdb36958 LC |
1588 | |
1589 | (define binutils-boot0 | |
1590 | (package-with-bootstrap-guile | |
45953b1f | 1591 | (package (inherit binutils) |
bdb36958 LC |
1592 | (name "binutils-cross-boot0") |
1593 | (arguments | |
1594 | `(#:guile ,%bootstrap-guile | |
1595 | #:implicit-inputs? #f | |
f8badf15 MW |
1596 | |
1597 | #:modules ((guix build gnu-build-system) | |
1598 | (guix build utils) | |
1599 | (ice-9 ftw)) ; for 'scandir' | |
ac423120 EF |
1600 | #:phases (modify-phases %standard-phases |
1601 | (add-after 'install 'add-symlinks | |
1602 | (lambda* (#:key outputs #:allow-other-keys) | |
1603 | ;; The cross-gcc invokes 'as', 'ld', etc, without the | |
1604 | ;; triplet prefix, so add symlinks. | |
1605 | (let ((out (assoc-ref outputs "out")) | |
1606 | (triplet-prefix (string-append ,(boot-triplet) "-"))) | |
1607 | (define (has-triplet-prefix? name) | |
1608 | (string-prefix? triplet-prefix name)) | |
1609 | (define (remove-triplet-prefix name) | |
1610 | (substring name (string-length triplet-prefix))) | |
1611 | (with-directory-excursion (string-append out "/bin") | |
1612 | (for-each (lambda (name) | |
1613 | (symlink name (remove-triplet-prefix name))) | |
1614 | (scandir "." has-triplet-prefix?))) | |
1615 | #t)))) | |
f8badf15 | 1616 | |
bdb36958 LC |
1617 | ,@(substitute-keyword-arguments (package-arguments binutils) |
1618 | ((#:configure-flags cf) | |
1619 | `(cons ,(string-append "--target=" (boot-triplet)) | |
1620 | ,cf))))) | |
a2b2070b | 1621 | (inputs (%boot0-inputs))))) |
bdb36958 | 1622 | |
b810a850 LC |
1623 | (define libstdc++-boot0 |
1624 | ;; GCC's libcc1 is always built as a shared library (the top-level | |
1625 | ;; 'Makefile.def' forcefully adds --enable-shared) and thus needs to refer | |
1626 | ;; to libstdc++.so. We cannot build libstdc++-5.3 because it relies on | |
809b0a90 | 1627 | ;; C++14 features missing in some of our bootstrap compilers. |
f4bf6413 | 1628 | (let ((lib (package-with-bootstrap-guile (make-libstdc++ gcc-4.9)))) |
b810a850 LC |
1629 | (package |
1630 | (inherit lib) | |
1631 | (name "libstdc++-boot0") | |
1632 | (arguments | |
1633 | `(#:guile ,%bootstrap-guile | |
1634 | #:implicit-inputs? #f | |
1635 | ||
1636 | ;; XXX: libstdc++.so NEEDs ld.so for some reason. | |
1637 | #:validate-runpath? #f | |
1638 | ||
d536c39e | 1639 | ,@(match (%current-system) |
eb443459 | 1640 | ((or "i686-linux" "x86_64-linux") |
d536c39e JN |
1641 | (substitute-keyword-arguments (package-arguments lib) |
1642 | ((#:phases phases) | |
1643 | `(modify-phases ,phases | |
a6facf94 MB |
1644 | (add-after 'unpack 'workaround-wrapper-bug |
1645 | ;; XXX: The crude gcc-cross-wrapper causes "g++ -v" to | |
1646 | ;; fail, which in turn confuses the configure script. | |
1647 | (lambda _ | |
1648 | (substitute* "libstdc++-v3/configure" | |
1649 | (("g\\+\\+ -v") "true")) | |
1650 | #t)))))) | |
d536c39e | 1651 | (_ (package-arguments lib))))) |
a2b2070b | 1652 | (inputs (%boot0-inputs)) |
b810a850 LC |
1653 | (native-inputs '())))) |
1654 | ||
bdb36958 LC |
1655 | (define gcc-boot0 |
1656 | (package-with-bootstrap-guile | |
c92f1c0a | 1657 | (package (inherit gcc) |
bdb36958 LC |
1658 | (name "gcc-cross-boot0") |
1659 | (arguments | |
1660 | `(#:guile ,%bootstrap-guile | |
1661 | #:implicit-inputs? #f | |
1662 | #:modules ((guix build gnu-build-system) | |
1663 | (guix build utils) | |
1664 | (ice-9 regex) | |
1665 | (srfi srfi-1) | |
1666 | (srfi srfi-26)) | |
c92f1c0a | 1667 | ,@(substitute-keyword-arguments (package-arguments gcc) |
bdb36958 LC |
1668 | ((#:configure-flags flags) |
1669 | `(append (list ,(string-append "--target=" (boot-triplet)) | |
1670 | ||
1671 | ;; No libc yet. | |
1672 | "--without-headers" | |
1673 | ||
1674 | ;; Disable features not needed at this stage. | |
1675 | "--disable-shared" | |
1676 | "--enable-languages=c,c++" | |
1677 | ||
1678 | ;; libstdc++ cannot be built at this stage | |
1679 | ;; ("Link tests are not allowed after | |
1680 | ;; GCC_NO_EXECUTABLES."). | |
1681 | "--disable-libstdc++-v3" | |
1682 | ||
1683 | "--disable-threads" | |
1684 | "--disable-libmudflap" | |
1685 | "--disable-libatomic" | |
1686 | "--disable-libsanitizer" | |
1687 | "--disable-libitm" | |
1688 | "--disable-libgomp" | |
de4ac325 LC |
1689 | "--disable-libcilkrts" |
1690 | "--disable-libvtv" | |
bdb36958 LC |
1691 | "--disable-libssp" |
1692 | "--disable-libquadmath" | |
1693 | "--disable-decimal-float") | |
98bd851e LC |
1694 | (remove (cut string-match |
1695 | "--(with-system-zlib|enable-languages.*)" <>) | |
bdb36958 | 1696 | ,flags))) |
eb443459 JN |
1697 | ((#:make-flags flags) |
1698 | `(let* ((libc (assoc-ref %build-inputs "libc")) | |
1699 | (libc-native (or (assoc-ref %build-inputs "libc-native") | |
1700 | libc))) | |
1701 | `(,(string-append "LDFLAGS=" | |
1702 | "-Wl,-rpath=" libc-native "/lib " | |
1703 | "-Wl,-dynamic-linker " | |
1704 | "-Wl," libc-native ,(glibc-dynamic-linker | |
1705 | (match (%current-system) | |
1706 | ("x86_64-linux" "i686-linux") | |
1707 | (_ (%current-system)))))))) | |
bdb36958 | 1708 | ((#:phases phases) |
53bfec7b TGR |
1709 | `(modify-phases ,phases |
1710 | (add-after 'unpack 'unpack-gmp&co | |
1711 | (lambda* (#:key inputs #:allow-other-keys) | |
1712 | (let ((gmp (assoc-ref %build-inputs "gmp-source")) | |
1713 | (mpfr (assoc-ref %build-inputs "mpfr-source")) | |
1714 | (mpc (assoc-ref %build-inputs "mpc-source"))) | |
1715 | ||
1716 | ;; To reduce the set of pre-built bootstrap inputs, build | |
1717 | ;; GMP & co. from GCC. | |
1718 | (for-each (lambda (source) | |
1719 | (invoke "tar" "xvf" source)) | |
1720 | (list gmp mpfr mpc)) | |
1721 | ||
1722 | ;; Create symlinks like `gmp' -> `gmp-x.y.z'. | |
1723 | ,@(map (lambda (lib) | |
1724 | ;; Drop trailing letters, as gmp-6.0.0a unpacks | |
1725 | ;; into gmp-6.0.0. | |
1726 | `(symlink ,(string-trim-right | |
539bf8f2 | 1727 | (package-full-name lib "-") |
53bfec7b TGR |
1728 | char-set:letter) |
1729 | ,(package-name lib))) | |
1730 | (list gmp-6.0 mpfr mpc)) | |
1731 | #t))) | |
d536c39e | 1732 | ,(match (%current-system) |
eb443459 | 1733 | ((or "i686-linux" "x86_64-linux") |
d536c39e JN |
1734 | '(add-after 'build 'libtool-workaround |
1735 | (lambda _ | |
1736 | ;; libtool: install: /gnu/store/7swwdnq02lqk4xkd8740fxdj1h4va38l-bootstrap-binaries-0/bin/install -c .libs/libcc1.so.0.0.0 /gnu/store/8qf47i99nxz9jvrmq5va0g3q1yvs3x74-gcc-cross-boot0-5.5.0-lib/lib/./libcc1.so.0.0.0 | |
1737 | ;; /gnu/store/7swwdnq02lqk4xkd8740fxdj1h4va38l-bootstrap-binaries-0/bin/install: cannot stat '.libs/libcc1.so.0.0.0': No such file or directory | |
1738 | (system* "touch" | |
1739 | "libcc1/.libs/libcc1.so.0.0.0" | |
1740 | "libcc1/.libs/libcc1plugin.so.0.0.0")))) | |
eb443459 | 1741 | (_ identity)) |
53bfec7b TGR |
1742 | (add-after 'install 'symlink-libgcc_eh |
1743 | (lambda* (#:key outputs #:allow-other-keys) | |
1744 | (let ((out (assoc-ref outputs "lib"))) | |
1745 | ;; Glibc wants to link against libgcc_eh, so provide | |
1746 | ;; it. | |
1747 | (with-directory-excursion | |
1748 | (string-append out "/lib/gcc/" | |
1749 | ,(boot-triplet) | |
1750 | "/" ,(package-version gcc)) | |
1751 | (symlink "libgcc.a" "libgcc_eh.a")) | |
1752 | #t)))))))) | |
bdb36958 | 1753 | |
8309c389 | 1754 | (inputs `(("gmp-source" ,(package-source gmp-6.0)) |
bdb36958 LC |
1755 | ("mpfr-source" ,(package-source mpfr)) |
1756 | ("mpc-source" ,(package-source mpc)) | |
1757 | ("binutils-cross" ,binutils-boot0) | |
1758 | ||
b810a850 LC |
1759 | ;; The libstdc++ that libcc1 links against. |
1760 | ("libstdc++" ,libstdc++-boot0) | |
1761 | ||
bdb36958 LC |
1762 | ;; Call it differently so that the builder can check whether |
1763 | ;; the "libc" input is #f. | |
a2b2070b JN |
1764 | ("libc-native" ,@(assoc-ref (%boot0-inputs) "libc")) |
1765 | ,@(alist-delete "libc" (%boot0-inputs)))) | |
9dee9e8f | 1766 | |
19d27131 MC |
1767 | ;; No need for the native-inputs to build the documentation at this stage. |
1768 | (native-inputs `())))) | |
bdb36958 LC |
1769 | |
1770 | (define perl-boot0 | |
4de35074 LC |
1771 | (let ((perl (package |
1772 | (inherit perl) | |
09964b4f | 1773 | (name "perl-boot0") |
4de35074 | 1774 | (arguments |
81cea47d | 1775 | ;; At the very least, this must not depend on GCC & co. |
cffe966d JN |
1776 | (let ((args `(#:validate-runpath? #f |
1777 | #:disallowed-references | |
81cea47d | 1778 | ,(list %bootstrap-binutils)))) |
cffe966d JN |
1779 | `(,@args |
1780 | ,@(substitute-keyword-arguments (package-arguments perl) | |
1781 | ((#:phases phases) | |
1782 | `(modify-phases ,phases | |
1783 | ;; Pthread support is missing in the bootstrap compiler | |
1784 | ;; (broken spec file), so disable it. | |
1785 | (add-before 'configure 'disable-pthreads | |
1786 | (lambda _ | |
1787 | (substitute* "Configure" | |
1788 | (("^libswanted=(.*)pthread" _ before) | |
1789 | (string-append "libswanted=" before))) | |
1790 | #t)))) | |
1791 | ;; Do not configure with '-Dusethreads' since pthread | |
1792 | ;; support is missing. | |
1793 | ((#:configure-flags configure-flags) | |
1794 | `(delete "-Dusethreads" ,configure-flags))))))))) | |
81cea47d LC |
1795 | (package-with-bootstrap-guile |
1796 | (package-with-explicit-inputs perl | |
f50b013f | 1797 | %boot0-inputs |
81cea47d LC |
1798 | (current-source-location) |
1799 | #:guile %bootstrap-guile)))) | |
bdb36958 | 1800 | |
32f4a073 JN |
1801 | (define m4-boot0 |
1802 | (package-with-bootstrap-guile | |
1803 | (package | |
1804 | (inherit m4) | |
1805 | (name "m4-boot0") | |
1806 | (inputs (%boot0-inputs)) | |
1807 | (arguments | |
1808 | `(#:guile ,%bootstrap-guile | |
1809 | #:implicit-inputs? #f | |
1810 | ,@(package-arguments m4)))))) | |
1811 | ||
d75acc29 MR |
1812 | (define bison-boot0 |
1813 | ;; This Bison is needed to build MiG so we need it early in the process. | |
1814 | ;; It is also needed to rebuild Bash's parser, which is modified by | |
1815 | ;; its CVE patches. Remove it when it's no longer needed. | |
f50b013f | 1816 | (let* ((bison (package (inherit bison) |
d75acc29 MR |
1817 | (propagated-inputs `(("m4" ,m4))) |
1818 | (inputs '()) ;remove Flex... | |
1819 | (arguments | |
56f45b7c | 1820 | `(#:tests? #f ;... and thus disable tests |
d75acc29 MR |
1821 | |
1822 | ;; Zero timestamps in liby.a; this must be done | |
1823 | ;; explicitly here because the bootstrap Binutils don't | |
1824 | ;; do that (default is "cru".) | |
56f45b7c JN |
1825 | #:make-flags `("ARFLAGS=crD" |
1826 | ,,(match (%current-system) | |
eb443459 JN |
1827 | ;; ranlib: '-D': No such file |
1828 | ((or "i686-linux" "x86_64-linux") | |
1829 | "RANLIB=ranlib") | |
1830 | (_ | |
1831 | "RANLIB=ranlib -D")) | |
d75acc29 MR |
1832 | "V=1")))))) |
1833 | (package | |
1834 | (inherit (package-with-bootstrap-guile | |
f50b013f | 1835 | (package-with-explicit-inputs bison %boot0-inputs |
d75acc29 MR |
1836 | (current-source-location) |
1837 | #:guile %bootstrap-guile))) | |
1838 | (native-inputs `(("perl" ,perl-boot0)))))) | |
1839 | ||
1840 | (define flex-boot0 | |
1841 | ;; This Flex is needed to build MiG. | |
1842 | (let* ((flex (package (inherit flex) | |
1843 | (native-inputs `(("bison" ,bison-boot0))) | |
1844 | (propagated-inputs `(("m4" ,m4))) | |
1845 | (inputs `(("indent" ,indent))) | |
1846 | (arguments '(#:tests? #f))))) | |
1847 | (package-with-bootstrap-guile | |
f50b013f | 1848 | (package-with-explicit-inputs flex %boot0-inputs |
d75acc29 MR |
1849 | (current-source-location) |
1850 | #:guile %bootstrap-guile)))) | |
1851 | ||
8102cf0b LC |
1852 | (define linux-libre-headers-boot0 |
1853 | (mlambda () | |
1854 | "Return Linux-Libre header files for the bootstrap environment." | |
1855 | ;; Note: this is wrapped in a thunk to nicely handle circular dependencies | |
1856 | ;; between (gnu packages linux) and this module. Additionally, memoize | |
1857 | ;; the result to play well with further memoization and code that relies | |
1858 | ;; on pointer identity; see <https://bugs.gnu.org/30155>. | |
1859 | (package-with-bootstrap-guile | |
1860 | (package (inherit linux-libre-headers) | |
1861 | (arguments `(#:guile ,%bootstrap-guile | |
1862 | #:implicit-inputs? #f | |
1863 | ,@(package-arguments linux-libre-headers))) | |
1864 | (native-inputs | |
1865 | `(("perl" ,perl-boot0) | |
a2b2070b | 1866 | ,@(%boot0-inputs))))))) |
bdb36958 | 1867 | |
d75acc29 MR |
1868 | (define gnumach-headers-boot0 |
1869 | (package-with-bootstrap-guile | |
1870 | (package-with-explicit-inputs gnumach-headers | |
a2b2070b | 1871 | (%boot0-inputs) |
d75acc29 MR |
1872 | (current-source-location) |
1873 | #:guile %bootstrap-guile))) | |
1874 | ||
1875 | (define mig-boot0 | |
1876 | (let* ((mig (package (inherit mig) | |
1877 | (native-inputs `(("bison" ,bison-boot0) | |
1878 | ("flex" ,flex-boot0))) | |
1879 | (inputs `(("flex" ,flex-boot0))) | |
1880 | (arguments | |
1881 | `(#:configure-flags | |
1882 | `(,(string-append "LDFLAGS=-Wl,-rpath=" | |
1883 | (assoc-ref %build-inputs "flex") "/lib/"))))))) | |
1884 | (package-with-bootstrap-guile | |
a2b2070b | 1885 | (package-with-explicit-inputs mig (%boot0-inputs) |
d75acc29 MR |
1886 | (current-source-location) |
1887 | #:guile %bootstrap-guile)))) | |
1888 | ||
1889 | (define hurd-headers-boot0 | |
1890 | (let ((hurd-headers (package (inherit hurd-headers) | |
1891 | (native-inputs `(("mig" ,mig-boot0))) | |
1892 | (inputs '())))) | |
1893 | (package-with-bootstrap-guile | |
a2b2070b | 1894 | (package-with-explicit-inputs hurd-headers (%boot0-inputs) |
d75acc29 MR |
1895 | (current-source-location) |
1896 | #:guile %bootstrap-guile)))) | |
1897 | ||
1898 | (define hurd-minimal-boot0 | |
1899 | (let ((hurd-minimal (package (inherit hurd-minimal) | |
1900 | (native-inputs `(("mig" ,mig-boot0))) | |
1901 | (inputs '())))) | |
1902 | (package-with-bootstrap-guile | |
a2b2070b | 1903 | (package-with-explicit-inputs hurd-minimal (%boot0-inputs) |
d75acc29 MR |
1904 | (current-source-location) |
1905 | #:guile %bootstrap-guile)))) | |
1906 | ||
8102cf0b LC |
1907 | (define hurd-core-headers-boot0 |
1908 | (mlambda () | |
1909 | "Return the Hurd and Mach headers as well as initial Hurd libraries for | |
d75acc29 | 1910 | the bootstrap environment." |
8102cf0b LC |
1911 | (package-with-bootstrap-guile |
1912 | (package (inherit hurd-core-headers) | |
1913 | (arguments `(#:guile ,%bootstrap-guile | |
1914 | ,@(package-arguments hurd-core-headers))) | |
1915 | (inputs | |
1916 | `(("gnumach-headers" ,gnumach-headers-boot0) | |
1917 | ("hurd-headers" ,hurd-headers-boot0) | |
1918 | ("hurd-minimal" ,hurd-minimal-boot0) | |
a2b2070b | 1919 | ,@(%boot0-inputs))))))) |
d75acc29 MR |
1920 | |
1921 | (define* (kernel-headers-boot0 #:optional (system (%current-system))) | |
1922 | (match system | |
1923 | ("i586-gnu" (hurd-core-headers-boot0)) | |
1924 | (_ (linux-libre-headers-boot0)))) | |
1925 | ||
bdb36958 LC |
1926 | (define texinfo-boot0 |
1927 | ;; Texinfo used to build libc's manual. | |
1928 | ;; We build without ncurses because it fails to build at this stage, and | |
1929 | ;; because we don't need the stand-alone Info reader. | |
a2b2070b | 1930 | ;; Also, use (%BOOT0-INPUTS) to avoid building Perl once more. |
bdb36958 | 1931 | (let ((texinfo (package (inherit texinfo) |
47ed8e04 | 1932 | (native-inputs '()) |
5d6c4d37 LC |
1933 | (inputs `(("perl" ,perl-boot0))) |
1934 | ||
1935 | ;; Some of Texinfo 6.1's tests would fail with "Couldn't | |
1936 | ;; set UTF-8 character type in locale" but we don't have a | |
1937 | ;; UTF-8 locale at this stage, so skip them. | |
1938 | (arguments '(#:tests? #f))))) | |
bdb36958 | 1939 | (package-with-bootstrap-guile |
f50b013f | 1940 | (package-with-explicit-inputs texinfo %boot0-inputs |
bdb36958 LC |
1941 | (current-source-location) |
1942 | #:guile %bootstrap-guile)))) | |
1943 | ||
f50b013f | 1944 | (define (ld-wrapper-boot0) |
d75acc29 MR |
1945 | ;; We need this so binaries on Hurd will have libmachuser and libhurduser |
1946 | ;; in their RUNPATH, otherwise validate-runpath will fail. | |
168c4000 LC |
1947 | (make-ld-wrapper "ld-wrapper-boot0" |
1948 | #:target boot-triplet | |
d75acc29 MR |
1949 | #:binutils binutils-boot0 |
1950 | #:guile %bootstrap-guile | |
f50b013f JN |
1951 | #:bash (car (assoc-ref (%boot0-inputs) "bash")) |
1952 | #:guile-for-build %bootstrap-guile)) | |
d75acc29 | 1953 | |
a2b2070b | 1954 | (define (%boot1-inputs) |
bdb36958 LC |
1955 | ;; 2nd stage inputs. |
1956 | `(("gcc" ,gcc-boot0) | |
f50b013f | 1957 | ("ld-wrapper-cross" ,(ld-wrapper-boot0)) |
bdb36958 | 1958 | ("binutils-cross" ,binutils-boot0) |
a2b2070b | 1959 | ,@(alist-delete "binutils" (%boot0-inputs)))) |
bdb36958 LC |
1960 | |
1961 | (define glibc-final-with-bootstrap-bash | |
1962 | ;; The final libc, "cross-built". If everything went well, the resulting | |
1963 | ;; store path has no dependencies. Actually, the really-final libc is | |
1964 | ;; built just below; the only difference is that this one uses the | |
1965 | ;; bootstrap Bash. | |
1966 | (package-with-bootstrap-guile | |
848f550f | 1967 | (package (inherit glibc) |
bdb36958 LC |
1968 | (name "glibc-intermediate") |
1969 | (arguments | |
1970 | `(#:guile ,%bootstrap-guile | |
1971 | #:implicit-inputs? #f | |
1972 | ||
1973 | ,@(substitute-keyword-arguments (package-arguments glibc) | |
1974 | ((#:configure-flags flags) | |
1975 | `(append (list ,(string-append "--host=" (boot-triplet)) | |
1976 | ,(string-append "--build=" | |
1977 | (nix-system->gnu-triplet)) | |
1978 | ||
1979 | ;; Build Sun/ONC RPC support. In particular, | |
1980 | ;; install rpc/*.h. | |
1981 | "--enable-obsolete-rpc") | |
1982 | ,flags)) | |
1983 | ((#:phases phases) | |
53bfec7b TGR |
1984 | `(modify-phases ,phases |
1985 | (add-before 'configure 'pre-configure | |
1986 | (lambda* (#:key inputs #:allow-other-keys) | |
1987 | ;; Don't clobber CPATH with the bootstrap libc. | |
1988 | (setenv "NATIVE_CPATH" (getenv "CPATH")) | |
1989 | (unsetenv "CPATH") | |
1990 | ||
1991 | ;; Tell 'libpthread' where to find 'libihash' on Hurd systems. | |
1992 | ,@(if (hurd-triplet? (%current-system)) | |
1993 | `((substitute* "libpthread/Makefile" | |
1994 | (("LDLIBS-pthread.so =.*") | |
1995 | (string-append "LDLIBS-pthread.so = " | |
1996 | (assoc-ref %build-inputs "kernel-headers") | |
1997 | "/lib/libihash.a\n")))) | |
1998 | '()) | |
1999 | ||
2000 | ;; 'rpcgen' needs native libc headers to be built. | |
2001 | (substitute* "sunrpc/Makefile" | |
2002 | (("sunrpc-CPPFLAGS =.*" all) | |
2003 | (string-append "CPATH = $(NATIVE_CPATH)\n" | |
2004 | "export CPATH\n" | |
2005 | all "\n"))) | |
2006 | #t))))))) | |
d75acc29 | 2007 | (propagated-inputs `(("kernel-headers" ,(kernel-headers-boot0)))) |
bdb36958 | 2008 | (native-inputs |
5e8cb5e6 MB |
2009 | `(("bison" ,bison-boot0) |
2010 | ("texinfo" ,texinfo-boot0) | |
ff647c3d | 2011 | ("perl" ,perl-boot0))) |
bdb36958 LC |
2012 | (inputs |
2013 | `(;; The boot inputs. That includes the bootstrap libc. We don't want | |
2014 | ;; it in $CPATH, hence the 'pre-configure' phase above. | |
a2b2070b | 2015 | ,@(%boot1-inputs) |
bdb36958 | 2016 | |
d75acc29 | 2017 | ;; A native MiG is needed to build Glibc on Hurd. |
62596a15 | 2018 | ,@(if (hurd-triplet? (%current-system)) |
d75acc29 MR |
2019 | `(("mig" ,mig-boot0)) |
2020 | '()) | |
2021 | ||
bdb36958 | 2022 | ;; A native GCC is needed to build `cross-rpcgen'. |
a2b2070b | 2023 | ("native-gcc" ,@(assoc-ref (%boot0-inputs) "gcc")) |
bdb36958 LC |
2024 | |
2025 | ;; Here, we use the bootstrap Bash, which is not satisfactory | |
2026 | ;; because we don't want to depend on bootstrap tools. | |
a2b2070b | 2027 | ("static-bash" ,@(assoc-ref (%boot0-inputs) "bash"))))))) |
bdb36958 LC |
2028 | |
2029 | (define (cross-gcc-wrapper gcc binutils glibc bash) | |
2030 | "Return a wrapper for the pseudo-cross toolchain GCC/BINUTILS/GLIBC | |
2031 | that makes it available under the native tool names." | |
c92f1c0a | 2032 | (package (inherit gcc) |
bdb36958 LC |
2033 | (name (string-append (package-name gcc) "-wrapped")) |
2034 | (source #f) | |
2035 | (build-system trivial-build-system) | |
2036 | (outputs '("out")) | |
2037 | (arguments | |
2038 | `(#:guile ,%bootstrap-guile | |
2039 | #:modules ((guix build utils)) | |
2040 | #:builder (begin | |
2041 | (use-modules (guix build utils)) | |
2042 | ||
2043 | (let* ((binutils (assoc-ref %build-inputs "binutils")) | |
2044 | (gcc (assoc-ref %build-inputs "gcc")) | |
2045 | (libc (assoc-ref %build-inputs "libc")) | |
2046 | (bash (assoc-ref %build-inputs "bash")) | |
2047 | (out (assoc-ref %outputs "out")) | |
2048 | (bindir (string-append out "/bin")) | |
2049 | (triplet ,(boot-triplet))) | |
2050 | (define (wrap-program program) | |
2051 | ;; GCC-BOOT0 is a libc-less cross-compiler, so it | |
2052 | ;; needs to be told where to find the crt files and | |
2053 | ;; the dynamic linker. | |
2054 | (call-with-output-file program | |
2055 | (lambda (p) | |
2056 | (format p "#!~a/bin/bash | |
2057 | exec ~a/bin/~a-~a -B~a/lib -Wl,-dynamic-linker -Wl,~a/~a \"$@\"~%" | |
2058 | bash | |
2059 | gcc triplet program | |
2060 | libc libc | |
2061 | ,(glibc-dynamic-linker)))) | |
2062 | ||
2063 | (chmod program #o555)) | |
2064 | ||
2065 | (mkdir-p bindir) | |
2066 | (with-directory-excursion bindir | |
2067 | (for-each (lambda (tool) | |
2068 | (symlink (string-append binutils "/bin/" | |
2069 | triplet "-" tool) | |
2070 | tool)) | |
2071 | '("ar" "ranlib")) | |
e3cfef22 MW |
2072 | (for-each wrap-program '("gcc" "g++"))) |
2073 | ||
2074 | #t)))) | |
bdb36958 LC |
2075 | (native-inputs |
2076 | `(("binutils" ,binutils) | |
2077 | ("gcc" ,gcc) | |
2078 | ("libc" ,glibc) | |
2079 | ("bash" ,bash))) | |
2080 | (inputs '()))) | |
2081 | ||
eb443459 JN |
2082 | (define (gcc-boot0-intermediate-wrapped) |
2083 | ;; Make the cross-tools GCC-BOOT0 and BINUTILS-BOOT0 available under the | |
2084 | ;; non-cross names. | |
2085 | (cross-gcc-wrapper gcc-boot0 binutils-boot0 | |
2086 | glibc-final-with-bootstrap-bash | |
2087 | (car (assoc-ref (%boot1-inputs) "bash")))) | |
2088 | ||
bdb36958 | 2089 | (define static-bash-for-glibc |
90d891fc | 2090 | ;; A statically-linked Bash to be used by GLIBC-FINAL in system(3) & co. |
517af02e JN |
2091 | (let ((bash (package |
2092 | (inherit static-bash) | |
2093 | (arguments | |
2094 | (substitute-keyword-arguments | |
2095 | (package-arguments static-bash) | |
2096 | ((#:guile _ #f) | |
2097 | '%bootstrap-guile) | |
2098 | ((#:configure-flags flags '()) | |
2099 | ;; Add a '-L' flag so that the pseudo-cross-ld of | |
2100 | ;; BINUTILS-BOOT0 can find libc.a. | |
2101 | `(append ,flags | |
2102 | (list (string-append "LDFLAGS=-static -L" | |
2103 | (assoc-ref %build-inputs | |
2104 | "libc:static") | |
2105 | "/lib"))))))))) | |
c573f5a5 | 2106 | (package-with-bootstrap-guile |
517af02e JN |
2107 | (package-with-explicit-inputs |
2108 | bash | |
2109 | (lambda _ | |
eb443459 JN |
2110 | `(("gcc" ,(gcc-boot0-intermediate-wrapped)) |
2111 | ("libc" ,glibc-final-with-bootstrap-bash) | |
2112 | ("libc:static" ,glibc-final-with-bootstrap-bash "static") | |
2113 | ,@(fold alist-delete (%boot1-inputs) | |
2114 | '("gcc" "libc")))) | |
517af02e JN |
2115 | (current-source-location) |
2116 | #:guile %bootstrap-guile)))) | |
bdb36958 | 2117 | |
6162b95d LC |
2118 | (define gettext-boot0 |
2119 | ;; A minimal gettext used during bootstrap. | |
669b8639 | 2120 | (let ((gettext-minimal |
b94a6ca0 | 2121 | (package (inherit gettext-minimal) |
669b8639 LC |
2122 | (name "gettext-boot0") |
2123 | (inputs '()) ;zero dependencies | |
2124 | (arguments | |
2125 | (substitute-keyword-arguments | |
2126 | `(#:tests? #f | |
b94a6ca0 | 2127 | ,@(package-arguments gettext-minimal)) |
669b8639 LC |
2128 | ((#:phases phases) |
2129 | `(modify-phases ,phases | |
2130 | ;; Build only the tools. | |
2131 | (add-after 'unpack 'chdir | |
2132 | (lambda _ | |
60ff6ec4 MW |
2133 | (chdir "gettext-tools") |
2134 | #t)) | |
669b8639 LC |
2135 | |
2136 | ;; Some test programs require pthreads, which we don't have. | |
2137 | (add-before 'configure 'no-test-programs | |
2138 | (lambda _ | |
2139 | (substitute* "tests/Makefile.in" | |
2140 | (("^PROGRAMS =.*$") | |
2141 | "PROGRAMS =\n")) | |
2142 | #t)) | |
2143 | ||
2144 | ;; Don't try to link against libexpat. | |
2145 | (delete 'link-expat) | |
2146 | (delete 'patch-tests)))))))) | |
6162b95d LC |
2147 | (package-with-bootstrap-guile |
2148 | (package-with-explicit-inputs gettext-minimal | |
f50b013f | 2149 | %boot1-inputs |
6162b95d LC |
2150 | (current-source-location) |
2151 | #:guile %bootstrap-guile)))) | |
2152 | ||
89223417 | 2153 | (define glibc-final |
bdb36958 | 2154 | ;; The final glibc, which embeds the statically-linked Bash built above. |
7c788ed2 LC |
2155 | ;; Use 'package/inherit' so we get the 'replacement' of 'glibc', if any. |
2156 | (let ((glibc (package-with-bootstrap-guile glibc))) | |
2157 | (package/inherit glibc | |
2158 | (name "glibc") | |
2159 | (inputs `(("static-bash" ,static-bash-for-glibc) | |
2160 | ,@(alist-delete | |
2161 | "static-bash" | |
2162 | (package-inputs glibc-final-with-bootstrap-bash)))) | |
2163 | ||
2164 | ;; This time we need 'msgfmt' to install all the libc.mo files. | |
2165 | (native-inputs `(,@(package-native-inputs glibc-final-with-bootstrap-bash) | |
2166 | ("gettext" ,gettext-boot0))) | |
2167 | ||
2168 | (propagated-inputs | |
2169 | (package-propagated-inputs glibc-final-with-bootstrap-bash)) | |
2170 | ||
2171 | ;; The final libc only refers to itself, but the 'debug' output contains | |
2172 | ;; references to GCC-BOOT0 and to the Linux headers. XXX: Would be great | |
2173 | ;; if 'allowed-references' were per-output. | |
2174 | (arguments | |
2175 | `(#:allowed-references | |
2176 | ,(cons* `(,gcc-boot0 "lib") (kernel-headers-boot0) | |
2177 | static-bash-for-glibc | |
2178 | (package-outputs glibc-final-with-bootstrap-bash)) | |
bdb36958 | 2179 | |
7c788ed2 | 2180 | ,@(package-arguments glibc-final-with-bootstrap-bash)))))) |
bdb36958 | 2181 | |
f50b013f | 2182 | (define (gcc-boot0-wrapped) |
bdb36958 LC |
2183 | ;; Make the cross-tools GCC-BOOT0 and BINUTILS-BOOT0 available under the |
2184 | ;; non-cross names. | |
2185 | (cross-gcc-wrapper gcc-boot0 binutils-boot0 glibc-final | |
a2b2070b | 2186 | (car (assoc-ref (%boot1-inputs) "bash")))) |
bdb36958 | 2187 | |
a2b2070b | 2188 | (define (%boot2-inputs) |
bdb36958 LC |
2189 | ;; 3rd stage inputs. |
2190 | `(("libc" ,glibc-final) | |
6dff905e | 2191 | ("libc:static" ,glibc-final "static") |
f50b013f | 2192 | ("gcc" ,(gcc-boot0-wrapped)) |
a2b2070b | 2193 | ,@(fold alist-delete (%boot1-inputs) '("libc" "gcc")))) |
bdb36958 LC |
2194 | |
2195 | (define binutils-final | |
2196 | (package-with-bootstrap-guile | |
45953b1f | 2197 | (package (inherit binutils) |
bdb36958 LC |
2198 | (arguments |
2199 | `(#:guile ,%bootstrap-guile | |
2200 | #:implicit-inputs? #f | |
2201 | #:allowed-references ("out" ,glibc-final) | |
2202 | ,@(package-arguments binutils))) | |
a2b2070b | 2203 | (inputs (%boot2-inputs))))) |
bdb36958 LC |
2204 | |
2205 | (define libstdc++ | |
2206 | ;; Intermediate libstdc++ that will allow us to build the final GCC | |
2207 | ;; (remember that GCC-BOOT0 cannot build libstdc++.) | |
86d02fa8 EF |
2208 | (let ((lib (package-with-bootstrap-guile (make-libstdc++ gcc)))) |
2209 | (package | |
2210 | (inherit lib) | |
2211 | (arguments | |
2212 | `(#:guile ,%bootstrap-guile | |
2213 | #:implicit-inputs? #f | |
2214 | #:allowed-references ("out") | |
2215 | ||
2216 | ;; XXX: libstdc++.so NEEDs ld.so for some reason. | |
2217 | #:validate-runpath? #f | |
2218 | ||
2219 | ;; All of the package arguments from 'make-libstdc++ | |
2220 | ;; except for the configure-flags. | |
2221 | ,@(package-arguments lib) | |
2222 | #:configure-flags `("--disable-shared" | |
2223 | "--disable-libstdcxx-threads" | |
2224 | "--disable-libstdcxx-pch" | |
2225 | ,(string-append "--with-gxx-include-dir=" | |
2226 | (assoc-ref %outputs "out") | |
2227 | "/include")))) | |
2228 | (outputs '("out")) | |
a2b2070b | 2229 | (inputs (%boot2-inputs)) |
86d02fa8 | 2230 | (synopsis "GNU C++ standard library (intermediate)")))) |
bdb36958 | 2231 | |
98bd851e LC |
2232 | (define zlib-final |
2233 | ;; Zlib used by GCC-FINAL. | |
2234 | (package-with-bootstrap-guile | |
2235 | (package | |
2236 | (inherit zlib) | |
2237 | (arguments | |
2238 | `(#:guile ,%bootstrap-guile | |
2239 | #:implicit-inputs? #f | |
2240 | #:allowed-references ("out" ,glibc-final) | |
2241 | ,@(package-arguments zlib))) | |
a2b2070b | 2242 | (inputs (%boot2-inputs))))) |
98bd851e | 2243 | |
f50b013f | 2244 | (define (ld-wrapper-boot3) |
98bd851e LC |
2245 | ;; A linker wrapper that uses the bootstrap Guile. |
2246 | (make-ld-wrapper "ld-wrapper-boot3" | |
2247 | #:binutils binutils-final | |
2248 | #:guile %bootstrap-guile | |
f50b013f JN |
2249 | #:bash (car (assoc-ref (%boot2-inputs) "bash")) |
2250 | #:guile-for-build %bootstrap-guile)) | |
98bd851e | 2251 | |
89223417 | 2252 | (define gcc-final |
bdb36958 LC |
2253 | ;; The final GCC. |
2254 | (package (inherit gcc-boot0) | |
2255 | (name "gcc") | |
ab999c25 LC |
2256 | |
2257 | ;; XXX: Currently #:allowed-references applies to all the outputs but the | |
2258 | ;; "debug" output contains disallowed references, notably | |
2259 | ;; linux-libre-headers. Disable the debugging output to work around that. | |
2260 | (outputs (delete "debug" (package-outputs gcc-boot0))) | |
2261 | ||
bdb36958 LC |
2262 | (arguments |
2263 | `(#:guile ,%bootstrap-guile | |
2264 | #:implicit-inputs? #f | |
2265 | ||
98bd851e | 2266 | #:allowed-references ("out" "lib" ,zlib-final |
90d891fc | 2267 | ,glibc-final ,static-bash-for-glibc) |
bdb36958 | 2268 | |
d485ebba LC |
2269 | ;; Things like libasan.so and libstdc++.so NEED ld.so for some |
2270 | ;; reason, but it is not in their RUNPATH. This is a false | |
2271 | ;; positive, so turn it off. | |
2272 | #:validate-runpath? #f | |
2273 | ||
eb443459 | 2274 | ,@(substitute-keyword-arguments (package-arguments gcc) |
bdb36958 | 2275 | ((#:make-flags flags) |
52cfd8cb | 2276 | ;; Since $LIBRARY_PATH is not honored, add the relevant flags. |
98bd851e LC |
2277 | `(let ((zlib (assoc-ref %build-inputs "zlib"))) |
2278 | (map (lambda (flag) | |
2279 | (if (string-prefix? "LDFLAGS=" flag) | |
2280 | (string-append flag " -L" | |
2281 | (assoc-ref %build-inputs "libstdc++") | |
2282 | "/lib -L" zlib "/lib -Wl,-rpath=" | |
2283 | zlib "/lib") | |
2284 | flag)) | |
2285 | ,flags))) | |
eb443459 JN |
2286 | ;; Build again GMP & co. within GCC's build process, because it's hard |
2287 | ;; to do outside (because GCC-BOOT0 is a cross-compiler, and thus | |
2288 | ;; doesn't honor $LIBRARY_PATH, which breaks `gnu-build-system'.) | |
bdb36958 | 2289 | ((#:phases phases) |
eb443459 JN |
2290 | `(modify-phases ,phases |
2291 | (add-after 'unpack 'unpack-gmp&co | |
2292 | (lambda* (#:key inputs #:allow-other-keys) | |
2293 | (let ((gmp (assoc-ref %build-inputs "gmp-source")) | |
2294 | (mpfr (assoc-ref %build-inputs "mpfr-source")) | |
2295 | (mpc (assoc-ref %build-inputs "mpc-source"))) | |
2296 | ||
2297 | ;; To reduce the set of pre-built bootstrap inputs, build | |
2298 | ;; GMP & co. from GCC. | |
2299 | (for-each (lambda (source) | |
2300 | (invoke "tar" "xvf" source)) | |
2301 | (list gmp mpfr mpc)) | |
2302 | ||
2303 | ;; Create symlinks like `gmp' -> `gmp-x.y.z'. | |
2304 | ,@(map (lambda (lib) | |
2305 | ;; Drop trailing letters, as gmp-6.0.0a unpacks | |
2306 | ;; into gmp-6.0.0. | |
2307 | `(symlink ,(string-trim-right | |
2308 | (package-full-name lib "-") | |
2309 | char-set:letter) | |
2310 | ,(package-name lib))) | |
2311 | (list gmp-6.0 mpfr mpc)) | |
2312 | #t)))))))) | |
bdb36958 | 2313 | |
90d891fc LC |
2314 | ;; This time we want Texinfo, so we get the manual. Add |
2315 | ;; STATIC-BASH-FOR-GLIBC so that it's used in the final shebangs of | |
2316 | ;; scripts such as 'mkheaders' and 'fixinc.sh' (XXX: who cares about these | |
2317 | ;; scripts?). | |
bdb36958 | 2318 | (native-inputs `(("texinfo" ,texinfo-boot0) |
19d27131 | 2319 | ("perl" ,perl-boot0) ;for manpages |
90d891fc | 2320 | ("static-bash" ,static-bash-for-glibc) |
bdb36958 LC |
2321 | ,@(package-native-inputs gcc-boot0))) |
2322 | ||
8309c389 | 2323 | (inputs `(("gmp-source" ,(bootstrap-origin (package-source gmp-6.0))) |
bdb36958 LC |
2324 | ("mpfr-source" ,(package-source mpfr)) |
2325 | ("mpc-source" ,(package-source mpc)) | |
f50b013f | 2326 | ("ld-wrapper" ,(ld-wrapper-boot3)) |
bdb36958 LC |
2327 | ("binutils" ,binutils-final) |
2328 | ("libstdc++" ,libstdc++) | |
98bd851e | 2329 | ("zlib" ,zlib-final) |
a2b2070b | 2330 | ,@(%boot2-inputs))))) |
bdb36958 | 2331 | |
a2b2070b | 2332 | (define (%boot3-inputs) |
bdb36958 LC |
2333 | ;; 4th stage inputs. |
2334 | `(("gcc" ,gcc-final) | |
f50b013f | 2335 | ("ld-wrapper" ,(ld-wrapper-boot3)) |
a2b2070b | 2336 | ,@(alist-delete "gcc" (%boot2-inputs)))) |
bdb36958 LC |
2337 | |
2338 | (define bash-final | |
2339 | ;; Link with `-static-libgcc' to make sure we don't retain a reference | |
704243e0 LC |
2340 | ;; to the bootstrap GCC. Use "bash-minimal" to avoid an extra dependency |
2341 | ;; on Readline and ncurses. | |
d9b4cbc2 | 2342 | (let ((bash (package |
704243e0 | 2343 | (inherit bash-minimal) |
d9b4cbc2 LC |
2344 | (arguments |
2345 | `(#:disallowed-references | |
a2b2070b | 2346 | ,(assoc-ref (%boot3-inputs) "coreutils&co") |
704243e0 | 2347 | ,@(package-arguments bash-minimal)))))) |
d9b4cbc2 LC |
2348 | (package-with-bootstrap-guile |
2349 | (package-with-explicit-inputs (static-libgcc-package bash) | |
f50b013f | 2350 | %boot3-inputs |
d9b4cbc2 LC |
2351 | (current-source-location) |
2352 | #:guile %bootstrap-guile)))) | |
bdb36958 | 2353 | |
a2b2070b | 2354 | (define (%boot4-inputs) |
bdb36958 LC |
2355 | ;; Now use the final Bash. |
2356 | `(("bash" ,bash-final) | |
a2b2070b | 2357 | ,@(alist-delete "bash" (%boot3-inputs)))) |
bdb36958 LC |
2358 | |
2359 | (define-public guile-final | |
386b71d1 LC |
2360 | ;; This package must be public because other modules refer to it. However, |
2361 | ;; mark it as hidden so that 'fold-packages' ignores it. | |
bdb36958 | 2362 | (package-with-bootstrap-guile |
34d624ce | 2363 | (package-with-explicit-inputs (hidden-package guile-2.2/fixed) |
f50b013f | 2364 | %boot4-inputs |
bdb36958 LC |
2365 | (current-source-location) |
2366 | #:guile %bootstrap-guile))) | |
2367 | ||
89223417 | 2368 | (define glibc-utf8-locales-final |
87c8b92f LC |
2369 | ;; Now that we have GUILE-FINAL, build the UTF-8 locales. They are needed |
2370 | ;; by the build processes afterwards so their 'scm_to_locale_string' works | |
2371 | ;; with the full range of Unicode codepoints (remember | |
2372 | ;; 'scm_to_locale_string' is called every time a string is passed to a C | |
2373 | ;; function.) | |
2374 | (package | |
2375 | (inherit glibc-utf8-locales) | |
2376 | (inputs `(("glibc" ,glibc-final) | |
2377 | ("gzip" | |
f50b013f | 2378 | ,(package-with-explicit-inputs gzip %boot4-inputs |
87c8b92f LC |
2379 | (current-source-location) |
2380 | #:guile %bootstrap-guile)))))) | |
2381 | ||
28cbc587 LC |
2382 | (define-public ld-wrapper |
2383 | ;; The final 'ld' wrapper, which uses the final Guile and Binutils. | |
78dea6f1 LC |
2384 | (make-ld-wrapper "ld-wrapper" |
2385 | #:binutils binutils-final | |
2386 | #:guile guile-final | |
2387 | #:bash bash-final)) | |
28cbc587 | 2388 | |
a2b2070b | 2389 | (define (%boot5-inputs) |
b6ac5451 LC |
2390 | ;; Now with UTF-8 locales. Remember that the bootstrap binaries were built |
2391 | ;; with an older libc, which cannot load the new locale format. See | |
28cbc587 | 2392 | ;; <https://lists.gnu.org/archive/html/guix-devel/2015-08/msg00737.html>. |
b6ac5451 | 2393 | `(("locales" ,glibc-utf8-locales-final) |
a2b2070b | 2394 | ,@(%boot4-inputs))) |
87c8b92f | 2395 | |
bdb36958 LC |
2396 | (define gnu-make-final |
2397 | ;; The final GNU Make, which uses the final Guile. | |
2398 | (package-with-bootstrap-guile | |
2399 | (package-with-explicit-inputs gnu-make | |
f50b013f JN |
2400 | (lambda _ |
2401 | `(("guile" ,guile-final) | |
2402 | ,@(%boot5-inputs))) | |
bdb36958 LC |
2403 | (current-source-location)))) |
2404 | ||
bdb36958 LC |
2405 | (define coreutils-final |
2406 | ;; The final Coreutils. Treat them specially because some packages, such as | |
2407 | ;; Findutils, keep a reference to the Coreutils they were built with. | |
2408 | (package-with-bootstrap-guile | |
2409 | (package-with-explicit-inputs coreutils | |
f50b013f | 2410 | %boot5-inputs |
bdb36958 LC |
2411 | (current-source-location) |
2412 | ||
2413 | ;; Use the final Guile, linked against the | |
2414 | ;; final libc with working iconv, so that | |
2415 | ;; 'substitute*' works well when touching | |
2416 | ;; test files in Gettext. | |
2417 | #:guile guile-final))) | |
2418 | ||
2419 | (define grep-final | |
2420 | ;; The final grep. Gzip holds a reference to it (via zgrep), so it must be | |
2421 | ;; built before gzip. | |
78ca500a | 2422 | (let ((grep (package-with-bootstrap-guile |
f50b013f | 2423 | (package-with-explicit-inputs grep %boot5-inputs |
78ca500a LC |
2424 | (current-source-location) |
2425 | #:guile guile-final)))) | |
2426 | (package/inherit grep | |
2427 | (inputs (alist-delete "pcre" (package-inputs grep))) | |
2428 | (native-inputs `(("perl" ,perl-boot0)))))) | |
bdb36958 | 2429 | |
a2b2070b | 2430 | (define (%boot6-inputs) |
bdb36958 LC |
2431 | ;; Now use the final Coreutils. |
2432 | `(("coreutils" ,coreutils-final) | |
2433 | ("grep" ,grep-final) | |
a2b2070b | 2434 | ,@(%boot5-inputs))) |
b0fd2bd3 | 2435 | |
301a4249 LC |
2436 | (define sed-final |
2437 | ;; The final sed. | |
2438 | (let ((sed (package-with-bootstrap-guile | |
f50b013f | 2439 | (package-with-explicit-inputs sed %boot6-inputs |
301a4249 LC |
2440 | (current-source-location) |
2441 | #:guile guile-final)))) | |
2442 | (package/inherit sed (native-inputs `(("perl" ,perl-boot0)))))) | |
2443 | ||
bdb36958 LC |
2444 | (define-public %final-inputs |
2445 | ;; Final derivations used as implicit inputs by 'gnu-build-system'. We | |
2446 | ;; still use 'package-with-bootstrap-guile' so that the bootstrap tools are | |
2447 | ;; used for origins that have patches, thereby avoiding circular | |
2448 | ;; dependencies. | |
2449 | (let ((finalize (compose package-with-bootstrap-guile | |
f50b013f | 2450 | (cut package-with-explicit-inputs <> %boot6-inputs |
bdb36958 LC |
2451 | (current-source-location))))) |
2452 | `(,@(map (match-lambda | |
2453 | ((name package) | |
2454 | (list name (finalize package)))) | |
2455 | `(("tar" ,tar) | |
87c8b92f | 2456 | ("gzip" ,gzip) |
bdb36958 LC |
2457 | ("bzip2" ,bzip2) |
2458 | ("xz" ,xz) | |
c00a9fbf | 2459 | ("file" ,file) |
bdb36958 LC |
2460 | ("diffutils" ,diffutils) |
2461 | ("patch" ,patch) | |
bdb36958 LC |
2462 | ("findutils" ,findutils) |
2463 | ("gawk" ,gawk))) | |
301a4249 | 2464 | ("sed" ,sed-final) |
bdb36958 LC |
2465 | ("grep" ,grep-final) |
2466 | ("coreutils" ,coreutils-final) | |
2467 | ("make" ,gnu-make-final) | |
2468 | ("bash" ,bash-final) | |
2469 | ("ld-wrapper" ,ld-wrapper) | |
2470 | ("binutils" ,binutils-final) | |
2471 | ("gcc" ,gcc-final) | |
b0fd2bd3 | 2472 | ("libc" ,glibc-final) |
6dff905e | 2473 | ("libc:static" ,glibc-final "static") |
b0fd2bd3 | 2474 | ("locales" ,glibc-utf8-locales-final)))) |
bdb36958 LC |
2475 | |
2476 | (define-public canonical-package | |
2477 | (let ((name->package (fold (lambda (input result) | |
2478 | (match input | |
6dff905e | 2479 | ((_ package . outputs) |
bdb36958 LC |
2480 | (vhash-cons (package-full-name package) |
2481 | package result)))) | |
2482 | vlist-null | |
2483 | `(("guile" ,guile-final) | |
2484 | ,@%final-inputs)))) | |
2485 | (lambda (package) | |
2486 | "Return the 'canonical' variant of PACKAGE---i.e., if PACKAGE is one of | |
2487 | the implicit inputs of 'gnu-build-system', return that one, otherwise return | |
2488 | PACKAGE. | |
2489 | ||
34d624ce | 2490 | The goal is to avoid duplication in cases like GUILE-FINAL vs. GUILE-2.2, |
bdb36958 LC |
2491 | COREUTILS-FINAL vs. COREUTILS, etc." |
2492 | ;; XXX: This doesn't handle dependencies of the final inputs, such as | |
2493 | ;; libunistring, GMP, etc. | |
2494 | (match (vhash-assoc (package-full-name package) name->package) | |
2495 | ((_ . canon) | |
2496 | ;; In general we want CANON, except if we're cross-compiling: CANON | |
2497 | ;; uses explicit inputs, so it is "anchored" in the bootstrapped | |
2498 | ;; process, with dependencies on things that cannot be | |
2499 | ;; cross-compiled. | |
2500 | (if (%current-target-system) | |
2501 | package | |
2502 | canon)) | |
2503 | (_ package))))) | |
2504 | ||
2505 | \f | |
2506 | ;;; | |
2507 | ;;; GCC toolchain. | |
2508 | ;;; | |
2509 | ||
b887ede1 | 2510 | (define (make-gcc-toolchain gcc) |
bdb36958 LC |
2511 | "Return a complete toolchain for GCC." |
2512 | (package | |
2513 | (name "gcc-toolchain") | |
2514 | (version (package-version gcc)) | |
2515 | (source #f) | |
2516 | (build-system trivial-build-system) | |
2517 | (arguments | |
2518 | '(#:modules ((guix build union)) | |
2519 | #:builder (begin | |
2520 | (use-modules (ice-9 match) | |
6f450b87 | 2521 | (srfi srfi-26) |
bdb36958 LC |
2522 | (guix build union)) |
2523 | ||
6f450b87 | 2524 | (let ((out (assoc-ref %outputs "out"))) |
bdb36958 | 2525 | |
6f450b87 LC |
2526 | (match %build-inputs |
2527 | (((names . directories) ...) | |
2528 | (union-build out directories))) | |
2529 | ||
6f450b87 LC |
2530 | (union-build (assoc-ref %outputs "debug") |
2531 | (list (assoc-ref %build-inputs | |
e3cfef22 | 2532 | "libc-debug"))) |
5a48a066 LC |
2533 | (union-build (assoc-ref %outputs "static") |
2534 | (list (assoc-ref %build-inputs | |
3d5ad159 | 2535 | "libc-static"))) |
e3cfef22 | 2536 | #t)))) |
d474d5d0 LC |
2537 | |
2538 | (native-search-paths (package-native-search-paths gcc)) | |
2539 | (search-paths (package-search-paths gcc)) | |
2540 | ||
bdb36958 LC |
2541 | (license (package-license gcc)) |
2542 | (synopsis "Complete GCC tool chain for C/C++ development") | |
2543 | (description | |
2544 | "This package provides a complete GCC tool chain for C/C++ development to | |
2545 | be installed in user profiles. This includes GCC, as well as libc (headers | |
2546 | and binaries, plus debugging symbols in the 'debug' output), and Binutils.") | |
6fd52309 | 2547 | (home-page "https://gcc.gnu.org/") |
5a48a066 | 2548 | (outputs '("out" "debug" "static")) |
bdb36958 LC |
2549 | |
2550 | ;; The main raison d'être of this "meta-package" is (1) to conveniently | |
2551 | ;; install everything that we need, and (2) to make sure ld-wrapper comes | |
2552 | ;; before Binutils' ld in the user's profile. | |
2553 | (inputs `(("gcc" ,gcc) | |
cbbb11c8 | 2554 | ("ld-wrapper" ,(car (assoc-ref %final-inputs "ld-wrapper"))) |
bdb36958 LC |
2555 | ("binutils" ,binutils-final) |
2556 | ("libc" ,glibc-final) | |
5a48a066 LC |
2557 | ("libc-debug" ,glibc-final "debug") |
2558 | ("libc-static" ,glibc-final "static"))))) | |
bdb36958 LC |
2559 | |
2560 | (define-public gcc-toolchain-4.8 | |
b887ede1 | 2561 | (make-gcc-toolchain gcc-4.8)) |
bdb36958 LC |
2562 | |
2563 | (define-public gcc-toolchain-4.9 | |
b887ede1 LC |
2564 | (make-gcc-toolchain gcc-4.9)) |
2565 | ||
2566 | (define-public gcc-toolchain | |
2567 | (make-gcc-toolchain gcc-final)) | |
bdb36958 | 2568 | |
629f4d2e | 2569 | (define-public gcc-toolchain-5 |
b887ede1 | 2570 | gcc-toolchain) |
60e2d5fe | 2571 | |
e760ec41 | 2572 | (define-public gcc-toolchain-6 |
b887ede1 | 2573 | (make-gcc-toolchain gcc-6)) |
e760ec41 | 2574 | |
d7ecab74 | 2575 | (define-public gcc-toolchain-7 |
b887ede1 | 2576 | (make-gcc-toolchain gcc-7)) |
d7ecab74 | 2577 | |
5ae27f57 LC |
2578 | (define-public gcc-toolchain-8 |
2579 | (make-gcc-toolchain gcc-8)) | |
2580 | ||
bdb36958 | 2581 | ;;; commencement.scm ends here |