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