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) | |
32 | #:use-module (gnu packages gcc) | |
2d5d63d7 | 33 | #:use-module (gnu packages m4) |
8efe2a22 | 34 | #:use-module (gnu packages code) |
c00a9fbf | 35 | #:use-module (gnu packages file) |
bdb36958 | 36 | #:use-module (gnu packages gawk) |
2d5d63d7 | 37 | #:use-module (gnu packages bison) |
d75acc29 | 38 | #:use-module (gnu packages flex) |
bdb36958 | 39 | #:use-module (gnu packages guile) |
6162b95d | 40 | #:use-module (gnu packages gettext) |
bdb36958 LC |
41 | #:use-module (gnu packages multiprecision) |
42 | #:use-module (gnu packages compression) | |
43 | #:use-module (gnu packages perl) | |
44 | #:use-module (gnu packages linux) | |
d75acc29 | 45 | #:use-module (gnu packages hurd) |
bdb36958 LC |
46 | #:use-module (gnu packages texinfo) |
47 | #:use-module (gnu packages pkg-config) | |
48 | #:use-module (guix packages) | |
49 | #:use-module (guix download) | |
50 | #:use-module (guix build-system gnu) | |
51 | #:use-module (guix build-system trivial) | |
8102cf0b | 52 | #:use-module (guix memoization) |
bdb36958 LC |
53 | #:use-module (guix utils) |
54 | #:use-module (srfi srfi-1) | |
55 | #:use-module (srfi srfi-26) | |
56 | #:use-module (ice-9 vlist) | |
d75acc29 MR |
57 | #:use-module (ice-9 match) |
58 | #:use-module (ice-9 regex)) | |
bdb36958 LC |
59 | |
60 | ;;; Commentary: | |
61 | ;;; | |
62 | ;;; This is the commencement, this is where things start. Before the | |
63 | ;;; commencement, of course, there's the 'bootstrap' module, which provides us | |
64 | ;;; with the initial binaries. This module uses those bootstrap binaries to | |
65 | ;;; actually build up the whole tool chain that make up the implicit inputs of | |
66 | ;;; 'gnu-build-system'. | |
67 | ;;; | |
68 | ;;; To avoid circular dependencies, this module should not be imported | |
69 | ;;; directly from anywhere. | |
70 | ;;; | |
a1df45e9 CM |
71 | ;;; Below, we frequently use "inherit" to create modified packages. The |
72 | ;;; reason why we use "inherit" instead of "package/inherit" is because we do | |
73 | ;;; not want these commencement packages to inherit grafts. By definition, | |
74 | ;;; these packages are not depended on at run time by any of the packages we | |
75 | ;;; use. Thus it does not make sense to inherit grafts. Furthermore, those | |
76 | ;;; grafts would often lead to extra overhead for users who would end up | |
77 | ;;; downloading those "-boot0" packages just to build package replacements | |
78 | ;;; that are in fact not going to be used. | |
79 | ;;; | |
bdb36958 LC |
80 | ;;; Code: |
81 | ||
82 | (define gnu-make-boot0 | |
83 | (package-with-bootstrap-guile | |
84 | (package (inherit gnu-make) | |
85 | (name "make-boot0") | |
bdb36958 LC |
86 | (arguments |
87 | `(#:guile ,%bootstrap-guile | |
88 | #:implicit-inputs? #f | |
89 | #:tests? #f ; cannot run "make check" | |
90 | ,@(substitute-keyword-arguments (package-arguments gnu-make) | |
91 | ((#:phases phases) | |
8e5e8724 LC |
92 | `(modify-phases ,phases |
93 | (replace 'build | |
94 | (lambda _ | |
53bfec7b TGR |
95 | (invoke "./build.sh") |
96 | #t)) | |
8e5e8724 LC |
97 | (replace 'install |
98 | (lambda* (#:key outputs #:allow-other-keys) | |
99 | (let* ((out (assoc-ref outputs "out")) | |
100 | (bin (string-append out "/bin"))) | |
53bfec7b TGR |
101 | (install-file "make" bin) |
102 | #t)))))))) | |
bdb36958 | 103 | (native-inputs '()) ; no need for 'pkg-config' |
a2b2070b | 104 | (inputs (%bootstrap-inputs))))) |
bdb36958 LC |
105 | |
106 | (define diffutils-boot0 | |
107 | (package-with-bootstrap-guile | |
108 | (let ((p (package-with-explicit-inputs diffutils | |
109 | `(("make" ,gnu-make-boot0) | |
a2b2070b | 110 | ,@(%bootstrap-inputs)) |
bdb36958 LC |
111 | #:guile %bootstrap-guile))) |
112 | (package (inherit p) | |
09964b4f | 113 | (name "diffutils-boot0") |
bdb36958 LC |
114 | (arguments `(#:tests? #f ; the test suite needs diffutils |
115 | ,@(package-arguments p))))))) | |
116 | ||
117 | (define findutils-boot0 | |
118 | (package-with-bootstrap-guile | |
09964b4f LC |
119 | (package-with-explicit-inputs (package |
120 | (inherit findutils) | |
121 | (name "findutils-boot0")) | |
bdb36958 LC |
122 | `(("make" ,gnu-make-boot0) |
123 | ("diffutils" ,diffutils-boot0) ; for tests | |
a2b2070b | 124 | ,@(%bootstrap-inputs)) |
bdb36958 LC |
125 | (current-source-location) |
126 | #:guile %bootstrap-guile))) | |
127 | ||
c00a9fbf MW |
128 | (define file-boot0 |
129 | (package-with-bootstrap-guile | |
f00b85ff LC |
130 | (package-with-explicit-inputs (package |
131 | (inherit file) | |
09964b4f | 132 | (name "file-boot0")) |
c00a9fbf | 133 | `(("make" ,gnu-make-boot0) |
a2b2070b | 134 | ,@(%bootstrap-inputs)) |
c00a9fbf MW |
135 | (current-source-location) |
136 | #:guile %bootstrap-guile))) | |
137 | ||
bdb36958 | 138 | |
a2b2070b | 139 | (define (%boot0-inputs) |
bdb36958 LC |
140 | `(("make" ,gnu-make-boot0) |
141 | ("diffutils" ,diffutils-boot0) | |
142 | ("findutils" ,findutils-boot0) | |
c00a9fbf | 143 | ("file" ,file-boot0) |
a2b2070b | 144 | ,@(%bootstrap-inputs))) |
bdb36958 | 145 | |
bdb36958 LC |
146 | (define* (boot-triplet #:optional (system (%current-system))) |
147 | ;; Return the triplet used to create the cross toolchain needed in the | |
148 | ;; first bootstrapping stage. | |
149 | (nix-system->gnu-triplet system "guix")) | |
150 | ||
151 | ;; Following Linux From Scratch, build a cross-toolchain in stage 0. That | |
152 | ;; toolchain actually targets the same OS and arch, but it has the advantage | |
a2b2070b | 153 | ;; of being independent of the libc and tools in (%BOOTSTRAP-INPUTS), since |
bdb36958 LC |
154 | ;; GCC-BOOT0 (below) is built without any reference to the target libc. |
155 | ||
156 | (define binutils-boot0 | |
157 | (package-with-bootstrap-guile | |
45953b1f | 158 | (package (inherit binutils) |
bdb36958 LC |
159 | (name "binutils-cross-boot0") |
160 | (arguments | |
161 | `(#:guile ,%bootstrap-guile | |
162 | #:implicit-inputs? #f | |
f8badf15 MW |
163 | |
164 | #:modules ((guix build gnu-build-system) | |
165 | (guix build utils) | |
166 | (ice-9 ftw)) ; for 'scandir' | |
ac423120 EF |
167 | #:phases (modify-phases %standard-phases |
168 | (add-after 'install 'add-symlinks | |
169 | (lambda* (#:key outputs #:allow-other-keys) | |
170 | ;; The cross-gcc invokes 'as', 'ld', etc, without the | |
171 | ;; triplet prefix, so add symlinks. | |
172 | (let ((out (assoc-ref outputs "out")) | |
173 | (triplet-prefix (string-append ,(boot-triplet) "-"))) | |
174 | (define (has-triplet-prefix? name) | |
175 | (string-prefix? triplet-prefix name)) | |
176 | (define (remove-triplet-prefix name) | |
177 | (substring name (string-length triplet-prefix))) | |
178 | (with-directory-excursion (string-append out "/bin") | |
179 | (for-each (lambda (name) | |
180 | (symlink name (remove-triplet-prefix name))) | |
181 | (scandir "." has-triplet-prefix?))) | |
182 | #t)))) | |
f8badf15 | 183 | |
bdb36958 LC |
184 | ,@(substitute-keyword-arguments (package-arguments binutils) |
185 | ((#:configure-flags cf) | |
186 | `(cons ,(string-append "--target=" (boot-triplet)) | |
187 | ,cf))))) | |
a2b2070b | 188 | (inputs (%boot0-inputs))))) |
bdb36958 | 189 | |
3469a5ea MB |
190 | ;; Use a "fixed" package source for this early libstdc++ variant so we can |
191 | ;; update GCC 4.9 without triggering a full rebuild. | |
192 | (define gcc-for-libstdc++ | |
193 | (package | |
194 | (inherit gcc-4.9) | |
195 | (source (origin | |
196 | (inherit (package-source gcc-4.9)) | |
197 | (patches (search-patches "gcc-4.9-libsanitizer-fix.patch" | |
198 | "gcc-arm-bug-71399.patch" | |
199 | "gcc-asan-missing-include.patch" | |
200 | "gcc-libvtv-runpath.patch" | |
201 | "gcc-fix-texi2pod.patch")))))) | |
202 | ||
b810a850 LC |
203 | (define libstdc++-boot0 |
204 | ;; GCC's libcc1 is always built as a shared library (the top-level | |
205 | ;; 'Makefile.def' forcefully adds --enable-shared) and thus needs to refer | |
206 | ;; to libstdc++.so. We cannot build libstdc++-5.3 because it relies on | |
809b0a90 | 207 | ;; C++14 features missing in some of our bootstrap compilers. |
3469a5ea | 208 | (let ((lib (package-with-bootstrap-guile (make-libstdc++ gcc-for-libstdc++)))) |
b810a850 LC |
209 | (package |
210 | (inherit lib) | |
211 | (name "libstdc++-boot0") | |
212 | (arguments | |
213 | `(#:guile ,%bootstrap-guile | |
214 | #:implicit-inputs? #f | |
215 | ||
216 | ;; XXX: libstdc++.so NEEDs ld.so for some reason. | |
217 | #:validate-runpath? #f | |
218 | ||
219 | ,@(package-arguments lib))) | |
a2b2070b | 220 | (inputs (%boot0-inputs)) |
b810a850 LC |
221 | (native-inputs '())))) |
222 | ||
bdb36958 LC |
223 | (define gcc-boot0 |
224 | (package-with-bootstrap-guile | |
c92f1c0a | 225 | (package (inherit gcc) |
bdb36958 LC |
226 | (name "gcc-cross-boot0") |
227 | (arguments | |
228 | `(#:guile ,%bootstrap-guile | |
229 | #:implicit-inputs? #f | |
230 | #:modules ((guix build gnu-build-system) | |
231 | (guix build utils) | |
232 | (ice-9 regex) | |
233 | (srfi srfi-1) | |
234 | (srfi srfi-26)) | |
c92f1c0a | 235 | ,@(substitute-keyword-arguments (package-arguments gcc) |
bdb36958 LC |
236 | ((#:configure-flags flags) |
237 | `(append (list ,(string-append "--target=" (boot-triplet)) | |
238 | ||
239 | ;; No libc yet. | |
240 | "--without-headers" | |
241 | ||
242 | ;; Disable features not needed at this stage. | |
243 | "--disable-shared" | |
244 | "--enable-languages=c,c++" | |
245 | ||
246 | ;; libstdc++ cannot be built at this stage | |
247 | ;; ("Link tests are not allowed after | |
248 | ;; GCC_NO_EXECUTABLES."). | |
249 | "--disable-libstdc++-v3" | |
250 | ||
251 | "--disable-threads" | |
252 | "--disable-libmudflap" | |
253 | "--disable-libatomic" | |
254 | "--disable-libsanitizer" | |
255 | "--disable-libitm" | |
256 | "--disable-libgomp" | |
de4ac325 LC |
257 | "--disable-libcilkrts" |
258 | "--disable-libvtv" | |
bdb36958 LC |
259 | "--disable-libssp" |
260 | "--disable-libquadmath" | |
261 | "--disable-decimal-float") | |
98bd851e LC |
262 | (remove (cut string-match |
263 | "--(with-system-zlib|enable-languages.*)" <>) | |
bdb36958 LC |
264 | ,flags))) |
265 | ((#:phases phases) | |
53bfec7b TGR |
266 | `(modify-phases ,phases |
267 | (add-after 'unpack 'unpack-gmp&co | |
268 | (lambda* (#:key inputs #:allow-other-keys) | |
269 | (let ((gmp (assoc-ref %build-inputs "gmp-source")) | |
270 | (mpfr (assoc-ref %build-inputs "mpfr-source")) | |
271 | (mpc (assoc-ref %build-inputs "mpc-source"))) | |
272 | ||
273 | ;; To reduce the set of pre-built bootstrap inputs, build | |
274 | ;; GMP & co. from GCC. | |
275 | (for-each (lambda (source) | |
276 | (invoke "tar" "xvf" source)) | |
277 | (list gmp mpfr mpc)) | |
278 | ||
279 | ;; Create symlinks like `gmp' -> `gmp-x.y.z'. | |
280 | ,@(map (lambda (lib) | |
281 | ;; Drop trailing letters, as gmp-6.0.0a unpacks | |
282 | ;; into gmp-6.0.0. | |
283 | `(symlink ,(string-trim-right | |
539bf8f2 | 284 | (package-full-name lib "-") |
53bfec7b TGR |
285 | char-set:letter) |
286 | ,(package-name lib))) | |
287 | (list gmp-6.0 mpfr mpc)) | |
288 | #t))) | |
289 | (add-after 'install 'symlink-libgcc_eh | |
290 | (lambda* (#:key outputs #:allow-other-keys) | |
291 | (let ((out (assoc-ref outputs "lib"))) | |
292 | ;; Glibc wants to link against libgcc_eh, so provide | |
293 | ;; it. | |
294 | (with-directory-excursion | |
295 | (string-append out "/lib/gcc/" | |
296 | ,(boot-triplet) | |
297 | "/" ,(package-version gcc)) | |
298 | (symlink "libgcc.a" "libgcc_eh.a")) | |
299 | #t)))))))) | |
bdb36958 | 300 | |
8309c389 | 301 | (inputs `(("gmp-source" ,(package-source gmp-6.0)) |
bdb36958 LC |
302 | ("mpfr-source" ,(package-source mpfr)) |
303 | ("mpc-source" ,(package-source mpc)) | |
304 | ("binutils-cross" ,binutils-boot0) | |
305 | ||
b810a850 LC |
306 | ;; The libstdc++ that libcc1 links against. |
307 | ("libstdc++" ,libstdc++-boot0) | |
308 | ||
bdb36958 LC |
309 | ;; Call it differently so that the builder can check whether |
310 | ;; the "libc" input is #f. | |
a2b2070b JN |
311 | ("libc-native" ,@(assoc-ref (%boot0-inputs) "libc")) |
312 | ,@(alist-delete "libc" (%boot0-inputs)))) | |
9dee9e8f | 313 | |
19d27131 MC |
314 | ;; No need for the native-inputs to build the documentation at this stage. |
315 | (native-inputs `())))) | |
bdb36958 LC |
316 | |
317 | (define perl-boot0 | |
4de35074 LC |
318 | (let ((perl (package |
319 | (inherit perl) | |
09964b4f | 320 | (name "perl-boot0") |
4de35074 | 321 | (arguments |
81cea47d LC |
322 | ;; At the very least, this must not depend on GCC & co. |
323 | (let ((args `(#:disallowed-references | |
324 | ,(list %bootstrap-binutils)))) | |
325 | (substitute-keyword-arguments (package-arguments perl) | |
326 | ((#:phases phases) | |
327 | `(modify-phases ,phases | |
328 | ;; Pthread support is missing in the bootstrap compiler | |
329 | ;; (broken spec file), so disable it. | |
330 | (add-before 'configure 'disable-pthreads | |
331 | (lambda _ | |
332 | (substitute* "Configure" | |
333 | (("^libswanted=(.*)pthread" _ before) | |
75f3aace MW |
334 | (string-append "libswanted=" before))) |
335 | #t)))) | |
156c0810 BW |
336 | ;; Do not configure with '-Dusethreads' since pthread |
337 | ;; support is missing. | |
338 | ((#:configure-flags configure-flags) | |
339 | `(delete "-Dusethreads" ,configure-flags)))))))) | |
81cea47d LC |
340 | (package-with-bootstrap-guile |
341 | (package-with-explicit-inputs perl | |
a2b2070b | 342 | (%boot0-inputs) |
81cea47d LC |
343 | (current-source-location) |
344 | #:guile %bootstrap-guile)))) | |
bdb36958 | 345 | |
d75acc29 MR |
346 | (define bison-boot0 |
347 | ;; This Bison is needed to build MiG so we need it early in the process. | |
348 | ;; It is also needed to rebuild Bash's parser, which is modified by | |
349 | ;; its CVE patches. Remove it when it's no longer needed. | |
350 | (let* ((m4 (package-with-bootstrap-guile | |
a2b2070b | 351 | (package-with-explicit-inputs m4 (%boot0-inputs) |
d75acc29 MR |
352 | (current-source-location) |
353 | #:guile %bootstrap-guile))) | |
354 | (bison (package (inherit bison) | |
355 | (propagated-inputs `(("m4" ,m4))) | |
356 | (inputs '()) ;remove Flex... | |
357 | (arguments | |
358 | '(#:tests? #f ;... and thus disable tests | |
359 | ||
360 | ;; Zero timestamps in liby.a; this must be done | |
361 | ;; explicitly here because the bootstrap Binutils don't | |
362 | ;; do that (default is "cru".) | |
363 | #:make-flags '("ARFLAGS=crD" "RANLIB=ranlib -D" | |
364 | "V=1")))))) | |
365 | (package | |
366 | (inherit (package-with-bootstrap-guile | |
a2b2070b | 367 | (package-with-explicit-inputs bison (%boot0-inputs) |
d75acc29 MR |
368 | (current-source-location) |
369 | #:guile %bootstrap-guile))) | |
370 | (native-inputs `(("perl" ,perl-boot0)))))) | |
371 | ||
372 | (define flex-boot0 | |
373 | ;; This Flex is needed to build MiG. | |
374 | (let* ((flex (package (inherit flex) | |
375 | (native-inputs `(("bison" ,bison-boot0))) | |
376 | (propagated-inputs `(("m4" ,m4))) | |
377 | (inputs `(("indent" ,indent))) | |
378 | (arguments '(#:tests? #f))))) | |
379 | (package-with-bootstrap-guile | |
a2b2070b | 380 | (package-with-explicit-inputs flex (%boot0-inputs) |
d75acc29 MR |
381 | (current-source-location) |
382 | #:guile %bootstrap-guile)))) | |
383 | ||
8102cf0b LC |
384 | (define linux-libre-headers-boot0 |
385 | (mlambda () | |
386 | "Return Linux-Libre header files for the bootstrap environment." | |
387 | ;; Note: this is wrapped in a thunk to nicely handle circular dependencies | |
388 | ;; between (gnu packages linux) and this module. Additionally, memoize | |
389 | ;; the result to play well with further memoization and code that relies | |
390 | ;; on pointer identity; see <https://bugs.gnu.org/30155>. | |
391 | (package-with-bootstrap-guile | |
392 | (package (inherit linux-libre-headers) | |
393 | (arguments `(#:guile ,%bootstrap-guile | |
394 | #:implicit-inputs? #f | |
395 | ,@(package-arguments linux-libre-headers))) | |
396 | (native-inputs | |
397 | `(("perl" ,perl-boot0) | |
a2b2070b | 398 | ,@(%boot0-inputs))))))) |
bdb36958 | 399 | |
d75acc29 MR |
400 | (define gnumach-headers-boot0 |
401 | (package-with-bootstrap-guile | |
402 | (package-with-explicit-inputs gnumach-headers | |
a2b2070b | 403 | (%boot0-inputs) |
d75acc29 MR |
404 | (current-source-location) |
405 | #:guile %bootstrap-guile))) | |
406 | ||
407 | (define mig-boot0 | |
408 | (let* ((mig (package (inherit mig) | |
409 | (native-inputs `(("bison" ,bison-boot0) | |
410 | ("flex" ,flex-boot0))) | |
411 | (inputs `(("flex" ,flex-boot0))) | |
412 | (arguments | |
413 | `(#:configure-flags | |
414 | `(,(string-append "LDFLAGS=-Wl,-rpath=" | |
415 | (assoc-ref %build-inputs "flex") "/lib/"))))))) | |
416 | (package-with-bootstrap-guile | |
a2b2070b | 417 | (package-with-explicit-inputs mig (%boot0-inputs) |
d75acc29 MR |
418 | (current-source-location) |
419 | #:guile %bootstrap-guile)))) | |
420 | ||
421 | (define hurd-headers-boot0 | |
422 | (let ((hurd-headers (package (inherit hurd-headers) | |
423 | (native-inputs `(("mig" ,mig-boot0))) | |
424 | (inputs '())))) | |
425 | (package-with-bootstrap-guile | |
a2b2070b | 426 | (package-with-explicit-inputs hurd-headers (%boot0-inputs) |
d75acc29 MR |
427 | (current-source-location) |
428 | #:guile %bootstrap-guile)))) | |
429 | ||
430 | (define hurd-minimal-boot0 | |
431 | (let ((hurd-minimal (package (inherit hurd-minimal) | |
432 | (native-inputs `(("mig" ,mig-boot0))) | |
433 | (inputs '())))) | |
434 | (package-with-bootstrap-guile | |
a2b2070b | 435 | (package-with-explicit-inputs hurd-minimal (%boot0-inputs) |
d75acc29 MR |
436 | (current-source-location) |
437 | #:guile %bootstrap-guile)))) | |
438 | ||
8102cf0b LC |
439 | (define hurd-core-headers-boot0 |
440 | (mlambda () | |
441 | "Return the Hurd and Mach headers as well as initial Hurd libraries for | |
d75acc29 | 442 | the bootstrap environment." |
8102cf0b LC |
443 | (package-with-bootstrap-guile |
444 | (package (inherit hurd-core-headers) | |
445 | (arguments `(#:guile ,%bootstrap-guile | |
446 | ,@(package-arguments hurd-core-headers))) | |
447 | (inputs | |
448 | `(("gnumach-headers" ,gnumach-headers-boot0) | |
449 | ("hurd-headers" ,hurd-headers-boot0) | |
450 | ("hurd-minimal" ,hurd-minimal-boot0) | |
a2b2070b | 451 | ,@(%boot0-inputs))))))) |
d75acc29 MR |
452 | |
453 | (define* (kernel-headers-boot0 #:optional (system (%current-system))) | |
454 | (match system | |
455 | ("i586-gnu" (hurd-core-headers-boot0)) | |
456 | (_ (linux-libre-headers-boot0)))) | |
457 | ||
bdb36958 LC |
458 | (define texinfo-boot0 |
459 | ;; Texinfo used to build libc's manual. | |
460 | ;; We build without ncurses because it fails to build at this stage, and | |
461 | ;; because we don't need the stand-alone Info reader. | |
a2b2070b | 462 | ;; Also, use (%BOOT0-INPUTS) to avoid building Perl once more. |
bdb36958 | 463 | (let ((texinfo (package (inherit texinfo) |
47ed8e04 | 464 | (native-inputs '()) |
5d6c4d37 LC |
465 | (inputs `(("perl" ,perl-boot0))) |
466 | ||
467 | ;; Some of Texinfo 6.1's tests would fail with "Couldn't | |
468 | ;; set UTF-8 character type in locale" but we don't have a | |
469 | ;; UTF-8 locale at this stage, so skip them. | |
470 | (arguments '(#:tests? #f))))) | |
bdb36958 | 471 | (package-with-bootstrap-guile |
a2b2070b | 472 | (package-with-explicit-inputs texinfo (%boot0-inputs) |
bdb36958 LC |
473 | (current-source-location) |
474 | #:guile %bootstrap-guile)))) | |
475 | ||
d75acc29 MR |
476 | (define ld-wrapper-boot0 |
477 | ;; We need this so binaries on Hurd will have libmachuser and libhurduser | |
478 | ;; in their RUNPATH, otherwise validate-runpath will fail. | |
168c4000 LC |
479 | (make-ld-wrapper "ld-wrapper-boot0" |
480 | #:target boot-triplet | |
d75acc29 MR |
481 | #:binutils binutils-boot0 |
482 | #:guile %bootstrap-guile | |
a2b2070b | 483 | #:bash (car (assoc-ref (%boot0-inputs) "bash")))) |
d75acc29 | 484 | |
a2b2070b | 485 | (define (%boot1-inputs) |
bdb36958 LC |
486 | ;; 2nd stage inputs. |
487 | `(("gcc" ,gcc-boot0) | |
d75acc29 | 488 | ("ld-wrapper-cross" ,ld-wrapper-boot0) |
bdb36958 | 489 | ("binutils-cross" ,binutils-boot0) |
a2b2070b | 490 | ,@(alist-delete "binutils" (%boot0-inputs)))) |
bdb36958 LC |
491 | |
492 | (define glibc-final-with-bootstrap-bash | |
493 | ;; The final libc, "cross-built". If everything went well, the resulting | |
494 | ;; store path has no dependencies. Actually, the really-final libc is | |
495 | ;; built just below; the only difference is that this one uses the | |
496 | ;; bootstrap Bash. | |
497 | (package-with-bootstrap-guile | |
848f550f | 498 | (package (inherit glibc) |
bdb36958 LC |
499 | (name "glibc-intermediate") |
500 | (arguments | |
501 | `(#:guile ,%bootstrap-guile | |
502 | #:implicit-inputs? #f | |
503 | ||
504 | ,@(substitute-keyword-arguments (package-arguments glibc) | |
505 | ((#:configure-flags flags) | |
506 | `(append (list ,(string-append "--host=" (boot-triplet)) | |
507 | ,(string-append "--build=" | |
508 | (nix-system->gnu-triplet)) | |
509 | ||
510 | ;; Build Sun/ONC RPC support. In particular, | |
511 | ;; install rpc/*.h. | |
512 | "--enable-obsolete-rpc") | |
513 | ,flags)) | |
514 | ((#:phases phases) | |
53bfec7b TGR |
515 | `(modify-phases ,phases |
516 | (add-before 'configure 'pre-configure | |
517 | (lambda* (#:key inputs #:allow-other-keys) | |
518 | ;; Don't clobber CPATH with the bootstrap libc. | |
519 | (setenv "NATIVE_CPATH" (getenv "CPATH")) | |
520 | (unsetenv "CPATH") | |
521 | ||
522 | ;; Tell 'libpthread' where to find 'libihash' on Hurd systems. | |
523 | ,@(if (hurd-triplet? (%current-system)) | |
524 | `((substitute* "libpthread/Makefile" | |
525 | (("LDLIBS-pthread.so =.*") | |
526 | (string-append "LDLIBS-pthread.so = " | |
527 | (assoc-ref %build-inputs "kernel-headers") | |
528 | "/lib/libihash.a\n")))) | |
529 | '()) | |
530 | ||
531 | ;; 'rpcgen' needs native libc headers to be built. | |
532 | (substitute* "sunrpc/Makefile" | |
533 | (("sunrpc-CPPFLAGS =.*" all) | |
534 | (string-append "CPATH = $(NATIVE_CPATH)\n" | |
535 | "export CPATH\n" | |
536 | all "\n"))) | |
537 | #t))))))) | |
d75acc29 | 538 | (propagated-inputs `(("kernel-headers" ,(kernel-headers-boot0)))) |
bdb36958 | 539 | (native-inputs |
5e8cb5e6 MB |
540 | `(("bison" ,bison-boot0) |
541 | ("texinfo" ,texinfo-boot0) | |
ff647c3d | 542 | ("perl" ,perl-boot0))) |
bdb36958 LC |
543 | (inputs |
544 | `(;; The boot inputs. That includes the bootstrap libc. We don't want | |
545 | ;; it in $CPATH, hence the 'pre-configure' phase above. | |
a2b2070b | 546 | ,@(%boot1-inputs) |
bdb36958 | 547 | |
d75acc29 | 548 | ;; A native MiG is needed to build Glibc on Hurd. |
62596a15 | 549 | ,@(if (hurd-triplet? (%current-system)) |
d75acc29 MR |
550 | `(("mig" ,mig-boot0)) |
551 | '()) | |
552 | ||
bdb36958 | 553 | ;; A native GCC is needed to build `cross-rpcgen'. |
a2b2070b | 554 | ("native-gcc" ,@(assoc-ref (%boot0-inputs) "gcc")) |
bdb36958 LC |
555 | |
556 | ;; Here, we use the bootstrap Bash, which is not satisfactory | |
557 | ;; because we don't want to depend on bootstrap tools. | |
a2b2070b | 558 | ("static-bash" ,@(assoc-ref (%boot0-inputs) "bash"))))))) |
bdb36958 LC |
559 | |
560 | (define (cross-gcc-wrapper gcc binutils glibc bash) | |
561 | "Return a wrapper for the pseudo-cross toolchain GCC/BINUTILS/GLIBC | |
562 | that makes it available under the native tool names." | |
c92f1c0a | 563 | (package (inherit gcc) |
bdb36958 LC |
564 | (name (string-append (package-name gcc) "-wrapped")) |
565 | (source #f) | |
566 | (build-system trivial-build-system) | |
567 | (outputs '("out")) | |
568 | (arguments | |
569 | `(#:guile ,%bootstrap-guile | |
570 | #:modules ((guix build utils)) | |
571 | #:builder (begin | |
572 | (use-modules (guix build utils)) | |
573 | ||
574 | (let* ((binutils (assoc-ref %build-inputs "binutils")) | |
575 | (gcc (assoc-ref %build-inputs "gcc")) | |
576 | (libc (assoc-ref %build-inputs "libc")) | |
577 | (bash (assoc-ref %build-inputs "bash")) | |
578 | (out (assoc-ref %outputs "out")) | |
579 | (bindir (string-append out "/bin")) | |
580 | (triplet ,(boot-triplet))) | |
581 | (define (wrap-program program) | |
582 | ;; GCC-BOOT0 is a libc-less cross-compiler, so it | |
583 | ;; needs to be told where to find the crt files and | |
584 | ;; the dynamic linker. | |
585 | (call-with-output-file program | |
586 | (lambda (p) | |
587 | (format p "#!~a/bin/bash | |
588 | exec ~a/bin/~a-~a -B~a/lib -Wl,-dynamic-linker -Wl,~a/~a \"$@\"~%" | |
589 | bash | |
590 | gcc triplet program | |
591 | libc libc | |
592 | ,(glibc-dynamic-linker)))) | |
593 | ||
594 | (chmod program #o555)) | |
595 | ||
596 | (mkdir-p bindir) | |
597 | (with-directory-excursion bindir | |
598 | (for-each (lambda (tool) | |
599 | (symlink (string-append binutils "/bin/" | |
600 | triplet "-" tool) | |
601 | tool)) | |
602 | '("ar" "ranlib")) | |
e3cfef22 MW |
603 | (for-each wrap-program '("gcc" "g++"))) |
604 | ||
605 | #t)))) | |
bdb36958 LC |
606 | (native-inputs |
607 | `(("binutils" ,binutils) | |
608 | ("gcc" ,gcc) | |
609 | ("libc" ,glibc) | |
610 | ("bash" ,bash))) | |
611 | (inputs '()))) | |
612 | ||
613 | (define static-bash-for-glibc | |
90d891fc | 614 | ;; A statically-linked Bash to be used by GLIBC-FINAL in system(3) & co. |
bdb36958 LC |
615 | (let* ((gcc (cross-gcc-wrapper gcc-boot0 binutils-boot0 |
616 | glibc-final-with-bootstrap-bash | |
a2b2070b | 617 | (car (assoc-ref (%boot1-inputs) "bash")))) |
6dff905e LC |
618 | (bash (package |
619 | (inherit static-bash) | |
bdb36958 | 620 | (arguments |
6dff905e LC |
621 | (substitute-keyword-arguments |
622 | (package-arguments static-bash) | |
623 | ((#:guile _ #f) | |
624 | '%bootstrap-guile) | |
625 | ((#:configure-flags flags '()) | |
626 | ;; Add a '-L' flag so that the pseudo-cross-ld of | |
627 | ;; BINUTILS-BOOT0 can find libc.a. | |
628 | `(append ,flags | |
629 | (list (string-append "LDFLAGS=-static -L" | |
630 | (assoc-ref %build-inputs | |
631 | "libc:static") | |
632 | "/lib")))))))) | |
32243bfb LC |
633 | (inputs `(("gcc" ,gcc) |
634 | ("libc" ,glibc-final-with-bootstrap-bash) | |
6dff905e | 635 | ("libc:static" ,glibc-final-with-bootstrap-bash "static") |
a2b2070b | 636 | ,@(fold alist-delete (%boot1-inputs) |
32243bfb | 637 | '("gcc" "libc"))))) |
c573f5a5 LC |
638 | (package-with-bootstrap-guile |
639 | (package-with-explicit-inputs bash inputs | |
640 | (current-source-location) | |
641 | #:guile %bootstrap-guile)))) | |
bdb36958 | 642 | |
6162b95d LC |
643 | (define gettext-boot0 |
644 | ;; A minimal gettext used during bootstrap. | |
669b8639 | 645 | (let ((gettext-minimal |
b94a6ca0 | 646 | (package (inherit gettext-minimal) |
669b8639 LC |
647 | (name "gettext-boot0") |
648 | (inputs '()) ;zero dependencies | |
649 | (arguments | |
650 | (substitute-keyword-arguments | |
651 | `(#:tests? #f | |
b94a6ca0 | 652 | ,@(package-arguments gettext-minimal)) |
669b8639 LC |
653 | ((#:phases phases) |
654 | `(modify-phases ,phases | |
655 | ;; Build only the tools. | |
656 | (add-after 'unpack 'chdir | |
657 | (lambda _ | |
60ff6ec4 MW |
658 | (chdir "gettext-tools") |
659 | #t)) | |
669b8639 LC |
660 | |
661 | ;; Some test programs require pthreads, which we don't have. | |
662 | (add-before 'configure 'no-test-programs | |
663 | (lambda _ | |
664 | (substitute* "tests/Makefile.in" | |
665 | (("^PROGRAMS =.*$") | |
666 | "PROGRAMS =\n")) | |
667 | #t)) | |
668 | ||
669 | ;; Don't try to link against libexpat. | |
670 | (delete 'link-expat) | |
671 | (delete 'patch-tests)))))))) | |
6162b95d LC |
672 | (package-with-bootstrap-guile |
673 | (package-with-explicit-inputs gettext-minimal | |
a2b2070b | 674 | (%boot1-inputs) |
6162b95d LC |
675 | (current-source-location) |
676 | #:guile %bootstrap-guile)))) | |
677 | ||
89223417 | 678 | (define glibc-final |
bdb36958 | 679 | ;; The final glibc, which embeds the statically-linked Bash built above. |
7c788ed2 LC |
680 | ;; Use 'package/inherit' so we get the 'replacement' of 'glibc', if any. |
681 | (let ((glibc (package-with-bootstrap-guile glibc))) | |
682 | (package/inherit glibc | |
683 | (name "glibc") | |
684 | (inputs `(("static-bash" ,static-bash-for-glibc) | |
685 | ,@(alist-delete | |
686 | "static-bash" | |
687 | (package-inputs glibc-final-with-bootstrap-bash)))) | |
688 | ||
689 | ;; This time we need 'msgfmt' to install all the libc.mo files. | |
690 | (native-inputs `(,@(package-native-inputs glibc-final-with-bootstrap-bash) | |
691 | ("gettext" ,gettext-boot0))) | |
692 | ||
693 | (propagated-inputs | |
694 | (package-propagated-inputs glibc-final-with-bootstrap-bash)) | |
695 | ||
696 | ;; The final libc only refers to itself, but the 'debug' output contains | |
697 | ;; references to GCC-BOOT0 and to the Linux headers. XXX: Would be great | |
698 | ;; if 'allowed-references' were per-output. | |
699 | (arguments | |
700 | `(#:allowed-references | |
701 | ,(cons* `(,gcc-boot0 "lib") (kernel-headers-boot0) | |
702 | static-bash-for-glibc | |
703 | (package-outputs glibc-final-with-bootstrap-bash)) | |
bdb36958 | 704 | |
7c788ed2 | 705 | ,@(package-arguments glibc-final-with-bootstrap-bash)))))) |
bdb36958 LC |
706 | |
707 | (define gcc-boot0-wrapped | |
708 | ;; Make the cross-tools GCC-BOOT0 and BINUTILS-BOOT0 available under the | |
709 | ;; non-cross names. | |
710 | (cross-gcc-wrapper gcc-boot0 binutils-boot0 glibc-final | |
a2b2070b | 711 | (car (assoc-ref (%boot1-inputs) "bash")))) |
bdb36958 | 712 | |
a2b2070b | 713 | (define (%boot2-inputs) |
bdb36958 LC |
714 | ;; 3rd stage inputs. |
715 | `(("libc" ,glibc-final) | |
6dff905e | 716 | ("libc:static" ,glibc-final "static") |
bdb36958 | 717 | ("gcc" ,gcc-boot0-wrapped) |
a2b2070b | 718 | ,@(fold alist-delete (%boot1-inputs) '("libc" "gcc")))) |
bdb36958 LC |
719 | |
720 | (define binutils-final | |
721 | (package-with-bootstrap-guile | |
45953b1f | 722 | (package (inherit binutils) |
bdb36958 LC |
723 | (arguments |
724 | `(#:guile ,%bootstrap-guile | |
725 | #:implicit-inputs? #f | |
726 | #:allowed-references ("out" ,glibc-final) | |
727 | ,@(package-arguments binutils))) | |
a2b2070b | 728 | (inputs (%boot2-inputs))))) |
bdb36958 LC |
729 | |
730 | (define libstdc++ | |
731 | ;; Intermediate libstdc++ that will allow us to build the final GCC | |
732 | ;; (remember that GCC-BOOT0 cannot build libstdc++.) | |
86d02fa8 EF |
733 | (let ((lib (package-with-bootstrap-guile (make-libstdc++ gcc)))) |
734 | (package | |
735 | (inherit lib) | |
736 | (arguments | |
737 | `(#:guile ,%bootstrap-guile | |
738 | #:implicit-inputs? #f | |
739 | #:allowed-references ("out") | |
740 | ||
741 | ;; XXX: libstdc++.so NEEDs ld.so for some reason. | |
742 | #:validate-runpath? #f | |
743 | ||
744 | ;; All of the package arguments from 'make-libstdc++ | |
745 | ;; except for the configure-flags. | |
746 | ,@(package-arguments lib) | |
747 | #:configure-flags `("--disable-shared" | |
748 | "--disable-libstdcxx-threads" | |
749 | "--disable-libstdcxx-pch" | |
750 | ,(string-append "--with-gxx-include-dir=" | |
751 | (assoc-ref %outputs "out") | |
752 | "/include")))) | |
753 | (outputs '("out")) | |
a2b2070b | 754 | (inputs (%boot2-inputs)) |
86d02fa8 | 755 | (synopsis "GNU C++ standard library (intermediate)")))) |
bdb36958 | 756 | |
98bd851e LC |
757 | (define zlib-final |
758 | ;; Zlib used by GCC-FINAL. | |
759 | (package-with-bootstrap-guile | |
760 | (package | |
761 | (inherit zlib) | |
762 | (arguments | |
763 | `(#:guile ,%bootstrap-guile | |
764 | #:implicit-inputs? #f | |
765 | #:allowed-references ("out" ,glibc-final) | |
766 | ,@(package-arguments zlib))) | |
a2b2070b | 767 | (inputs (%boot2-inputs))))) |
98bd851e LC |
768 | |
769 | (define ld-wrapper-boot3 | |
770 | ;; A linker wrapper that uses the bootstrap Guile. | |
771 | (make-ld-wrapper "ld-wrapper-boot3" | |
772 | #:binutils binutils-final | |
773 | #:guile %bootstrap-guile | |
a2b2070b | 774 | #:bash (car (assoc-ref (%boot2-inputs) "bash")))) |
98bd851e | 775 | |
89223417 | 776 | (define gcc-final |
bdb36958 LC |
777 | ;; The final GCC. |
778 | (package (inherit gcc-boot0) | |
779 | (name "gcc") | |
ab999c25 LC |
780 | |
781 | ;; XXX: Currently #:allowed-references applies to all the outputs but the | |
782 | ;; "debug" output contains disallowed references, notably | |
783 | ;; linux-libre-headers. Disable the debugging output to work around that. | |
784 | (outputs (delete "debug" (package-outputs gcc-boot0))) | |
785 | ||
bdb36958 LC |
786 | (arguments |
787 | `(#:guile ,%bootstrap-guile | |
788 | #:implicit-inputs? #f | |
789 | ||
98bd851e | 790 | #:allowed-references ("out" "lib" ,zlib-final |
90d891fc | 791 | ,glibc-final ,static-bash-for-glibc) |
bdb36958 | 792 | |
d485ebba LC |
793 | ;; Things like libasan.so and libstdc++.so NEED ld.so for some |
794 | ;; reason, but it is not in their RUNPATH. This is a false | |
795 | ;; positive, so turn it off. | |
796 | #:validate-runpath? #f | |
797 | ||
bdb36958 LC |
798 | ;; Build again GMP & co. within GCC's build process, because it's hard |
799 | ;; to do outside (because GCC-BOOT0 is a cross-compiler, and thus | |
800 | ;; doesn't honor $LIBRARY_PATH, which breaks `gnu-build-system'.) | |
801 | ,@(substitute-keyword-arguments (package-arguments gcc-boot0) | |
802 | ((#:configure-flags boot-flags) | |
c92f1c0a | 803 | (let loop ((args (package-arguments gcc))) |
bdb36958 LC |
804 | (match args |
805 | ((#:configure-flags normal-flags _ ...) | |
806 | normal-flags) | |
807 | ((_ rest ...) | |
808 | (loop rest))))) | |
809 | ((#:make-flags flags) | |
52cfd8cb | 810 | ;; Since $LIBRARY_PATH is not honored, add the relevant flags. |
98bd851e LC |
811 | `(let ((zlib (assoc-ref %build-inputs "zlib"))) |
812 | (map (lambda (flag) | |
813 | (if (string-prefix? "LDFLAGS=" flag) | |
814 | (string-append flag " -L" | |
815 | (assoc-ref %build-inputs "libstdc++") | |
816 | "/lib -L" zlib "/lib -Wl,-rpath=" | |
817 | zlib "/lib") | |
818 | flag)) | |
819 | ,flags))) | |
bdb36958 LC |
820 | ((#:phases phases) |
821 | `(alist-delete 'symlink-libgcc_eh ,phases))))) | |
822 | ||
90d891fc LC |
823 | ;; This time we want Texinfo, so we get the manual. Add |
824 | ;; STATIC-BASH-FOR-GLIBC so that it's used in the final shebangs of | |
825 | ;; scripts such as 'mkheaders' and 'fixinc.sh' (XXX: who cares about these | |
826 | ;; scripts?). | |
bdb36958 | 827 | (native-inputs `(("texinfo" ,texinfo-boot0) |
19d27131 | 828 | ("perl" ,perl-boot0) ;for manpages |
90d891fc | 829 | ("static-bash" ,static-bash-for-glibc) |
bdb36958 LC |
830 | ,@(package-native-inputs gcc-boot0))) |
831 | ||
8309c389 | 832 | (inputs `(("gmp-source" ,(bootstrap-origin (package-source gmp-6.0))) |
bdb36958 LC |
833 | ("mpfr-source" ,(package-source mpfr)) |
834 | ("mpc-source" ,(package-source mpc)) | |
98bd851e | 835 | ("ld-wrapper" ,ld-wrapper-boot3) |
bdb36958 LC |
836 | ("binutils" ,binutils-final) |
837 | ("libstdc++" ,libstdc++) | |
98bd851e | 838 | ("zlib" ,zlib-final) |
a2b2070b | 839 | ,@(%boot2-inputs))))) |
bdb36958 | 840 | |
a2b2070b | 841 | (define (%boot3-inputs) |
bdb36958 LC |
842 | ;; 4th stage inputs. |
843 | `(("gcc" ,gcc-final) | |
844 | ("ld-wrapper" ,ld-wrapper-boot3) | |
a2b2070b | 845 | ,@(alist-delete "gcc" (%boot2-inputs)))) |
bdb36958 LC |
846 | |
847 | (define bash-final | |
848 | ;; Link with `-static-libgcc' to make sure we don't retain a reference | |
704243e0 LC |
849 | ;; to the bootstrap GCC. Use "bash-minimal" to avoid an extra dependency |
850 | ;; on Readline and ncurses. | |
d9b4cbc2 | 851 | (let ((bash (package |
704243e0 | 852 | (inherit bash-minimal) |
d9b4cbc2 LC |
853 | (arguments |
854 | `(#:disallowed-references | |
a2b2070b | 855 | ,(assoc-ref (%boot3-inputs) "coreutils&co") |
704243e0 | 856 | ,@(package-arguments bash-minimal)))))) |
d9b4cbc2 LC |
857 | (package-with-bootstrap-guile |
858 | (package-with-explicit-inputs (static-libgcc-package bash) | |
a2b2070b | 859 | (%boot3-inputs) |
d9b4cbc2 LC |
860 | (current-source-location) |
861 | #:guile %bootstrap-guile)))) | |
bdb36958 | 862 | |
a2b2070b | 863 | (define (%boot4-inputs) |
bdb36958 LC |
864 | ;; Now use the final Bash. |
865 | `(("bash" ,bash-final) | |
a2b2070b | 866 | ,@(alist-delete "bash" (%boot3-inputs)))) |
bdb36958 LC |
867 | |
868 | (define-public guile-final | |
386b71d1 LC |
869 | ;; This package must be public because other modules refer to it. However, |
870 | ;; mark it as hidden so that 'fold-packages' ignores it. | |
bdb36958 | 871 | (package-with-bootstrap-guile |
34d624ce | 872 | (package-with-explicit-inputs (hidden-package guile-2.2/fixed) |
a2b2070b | 873 | (%boot4-inputs) |
bdb36958 LC |
874 | (current-source-location) |
875 | #:guile %bootstrap-guile))) | |
876 | ||
89223417 | 877 | (define glibc-utf8-locales-final |
87c8b92f LC |
878 | ;; Now that we have GUILE-FINAL, build the UTF-8 locales. They are needed |
879 | ;; by the build processes afterwards so their 'scm_to_locale_string' works | |
880 | ;; with the full range of Unicode codepoints (remember | |
881 | ;; 'scm_to_locale_string' is called every time a string is passed to a C | |
882 | ;; function.) | |
883 | (package | |
884 | (inherit glibc-utf8-locales) | |
885 | (inputs `(("glibc" ,glibc-final) | |
886 | ("gzip" | |
a2b2070b | 887 | ,(package-with-explicit-inputs gzip (%boot4-inputs) |
87c8b92f LC |
888 | (current-source-location) |
889 | #:guile %bootstrap-guile)))))) | |
890 | ||
28cbc587 LC |
891 | (define-public ld-wrapper |
892 | ;; The final 'ld' wrapper, which uses the final Guile and Binutils. | |
78dea6f1 LC |
893 | (make-ld-wrapper "ld-wrapper" |
894 | #:binutils binutils-final | |
895 | #:guile guile-final | |
896 | #:bash bash-final)) | |
28cbc587 | 897 | |
a2b2070b | 898 | (define (%boot5-inputs) |
b6ac5451 LC |
899 | ;; Now with UTF-8 locales. Remember that the bootstrap binaries were built |
900 | ;; with an older libc, which cannot load the new locale format. See | |
28cbc587 | 901 | ;; <https://lists.gnu.org/archive/html/guix-devel/2015-08/msg00737.html>. |
b6ac5451 | 902 | `(("locales" ,glibc-utf8-locales-final) |
a2b2070b | 903 | ,@(%boot4-inputs))) |
87c8b92f | 904 | |
bdb36958 LC |
905 | (define gnu-make-final |
906 | ;; The final GNU Make, which uses the final Guile. | |
907 | (package-with-bootstrap-guile | |
908 | (package-with-explicit-inputs gnu-make | |
909 | `(("guile" ,guile-final) | |
a2b2070b | 910 | ,@(%boot5-inputs)) |
bdb36958 LC |
911 | (current-source-location)))) |
912 | ||
bdb36958 LC |
913 | (define coreutils-final |
914 | ;; The final Coreutils. Treat them specially because some packages, such as | |
915 | ;; Findutils, keep a reference to the Coreutils they were built with. | |
916 | (package-with-bootstrap-guile | |
917 | (package-with-explicit-inputs coreutils | |
a2b2070b | 918 | (%boot5-inputs) |
bdb36958 LC |
919 | (current-source-location) |
920 | ||
921 | ;; Use the final Guile, linked against the | |
922 | ;; final libc with working iconv, so that | |
923 | ;; 'substitute*' works well when touching | |
924 | ;; test files in Gettext. | |
925 | #:guile guile-final))) | |
926 | ||
927 | (define grep-final | |
928 | ;; The final grep. Gzip holds a reference to it (via zgrep), so it must be | |
929 | ;; built before gzip. | |
78ca500a | 930 | (let ((grep (package-with-bootstrap-guile |
a2b2070b | 931 | (package-with-explicit-inputs grep (%boot5-inputs) |
78ca500a LC |
932 | (current-source-location) |
933 | #:guile guile-final)))) | |
934 | (package/inherit grep | |
935 | (inputs (alist-delete "pcre" (package-inputs grep))) | |
936 | (native-inputs `(("perl" ,perl-boot0)))))) | |
bdb36958 | 937 | |
a2b2070b | 938 | (define (%boot6-inputs) |
bdb36958 LC |
939 | ;; Now use the final Coreutils. |
940 | `(("coreutils" ,coreutils-final) | |
941 | ("grep" ,grep-final) | |
a2b2070b | 942 | ,@(%boot5-inputs))) |
b0fd2bd3 | 943 | |
301a4249 LC |
944 | (define sed-final |
945 | ;; The final sed. | |
946 | (let ((sed (package-with-bootstrap-guile | |
a2b2070b | 947 | (package-with-explicit-inputs sed (%boot6-inputs) |
301a4249 LC |
948 | (current-source-location) |
949 | #:guile guile-final)))) | |
950 | (package/inherit sed (native-inputs `(("perl" ,perl-boot0)))))) | |
951 | ||
bdb36958 LC |
952 | (define-public %final-inputs |
953 | ;; Final derivations used as implicit inputs by 'gnu-build-system'. We | |
954 | ;; still use 'package-with-bootstrap-guile' so that the bootstrap tools are | |
955 | ;; used for origins that have patches, thereby avoiding circular | |
956 | ;; dependencies. | |
957 | (let ((finalize (compose package-with-bootstrap-guile | |
a2b2070b | 958 | (cut package-with-explicit-inputs <> (%boot6-inputs) |
bdb36958 LC |
959 | (current-source-location))))) |
960 | `(,@(map (match-lambda | |
961 | ((name package) | |
962 | (list name (finalize package)))) | |
963 | `(("tar" ,tar) | |
87c8b92f | 964 | ("gzip" ,gzip) |
bdb36958 LC |
965 | ("bzip2" ,bzip2) |
966 | ("xz" ,xz) | |
c00a9fbf | 967 | ("file" ,file) |
bdb36958 LC |
968 | ("diffutils" ,diffutils) |
969 | ("patch" ,patch) | |
bdb36958 LC |
970 | ("findutils" ,findutils) |
971 | ("gawk" ,gawk))) | |
301a4249 | 972 | ("sed" ,sed-final) |
bdb36958 LC |
973 | ("grep" ,grep-final) |
974 | ("coreutils" ,coreutils-final) | |
975 | ("make" ,gnu-make-final) | |
976 | ("bash" ,bash-final) | |
977 | ("ld-wrapper" ,ld-wrapper) | |
978 | ("binutils" ,binutils-final) | |
979 | ("gcc" ,gcc-final) | |
b0fd2bd3 | 980 | ("libc" ,glibc-final) |
6dff905e | 981 | ("libc:static" ,glibc-final "static") |
b0fd2bd3 | 982 | ("locales" ,glibc-utf8-locales-final)))) |
bdb36958 LC |
983 | |
984 | (define-public canonical-package | |
985 | (let ((name->package (fold (lambda (input result) | |
986 | (match input | |
6dff905e | 987 | ((_ package . outputs) |
bdb36958 LC |
988 | (vhash-cons (package-full-name package) |
989 | package result)))) | |
990 | vlist-null | |
991 | `(("guile" ,guile-final) | |
992 | ,@%final-inputs)))) | |
993 | (lambda (package) | |
994 | "Return the 'canonical' variant of PACKAGE---i.e., if PACKAGE is one of | |
995 | the implicit inputs of 'gnu-build-system', return that one, otherwise return | |
996 | PACKAGE. | |
997 | ||
34d624ce | 998 | The goal is to avoid duplication in cases like GUILE-FINAL vs. GUILE-2.2, |
bdb36958 LC |
999 | COREUTILS-FINAL vs. COREUTILS, etc." |
1000 | ;; XXX: This doesn't handle dependencies of the final inputs, such as | |
1001 | ;; libunistring, GMP, etc. | |
1002 | (match (vhash-assoc (package-full-name package) name->package) | |
1003 | ((_ . canon) | |
1004 | ;; In general we want CANON, except if we're cross-compiling: CANON | |
1005 | ;; uses explicit inputs, so it is "anchored" in the bootstrapped | |
1006 | ;; process, with dependencies on things that cannot be | |
1007 | ;; cross-compiled. | |
1008 | (if (%current-target-system) | |
1009 | package | |
1010 | canon)) | |
1011 | (_ package))))) | |
1012 | ||
1013 | \f | |
1014 | ;;; | |
1015 | ;;; GCC toolchain. | |
1016 | ;;; | |
1017 | ||
b887ede1 | 1018 | (define (make-gcc-toolchain gcc) |
bdb36958 LC |
1019 | "Return a complete toolchain for GCC." |
1020 | (package | |
1021 | (name "gcc-toolchain") | |
1022 | (version (package-version gcc)) | |
1023 | (source #f) | |
1024 | (build-system trivial-build-system) | |
1025 | (arguments | |
1026 | '(#:modules ((guix build union)) | |
1027 | #:builder (begin | |
1028 | (use-modules (ice-9 match) | |
6f450b87 | 1029 | (srfi srfi-26) |
bdb36958 LC |
1030 | (guix build union)) |
1031 | ||
6f450b87 | 1032 | (let ((out (assoc-ref %outputs "out"))) |
bdb36958 | 1033 | |
6f450b87 LC |
1034 | (match %build-inputs |
1035 | (((names . directories) ...) | |
1036 | (union-build out directories))) | |
1037 | ||
6f450b87 LC |
1038 | (union-build (assoc-ref %outputs "debug") |
1039 | (list (assoc-ref %build-inputs | |
e3cfef22 | 1040 | "libc-debug"))) |
5a48a066 LC |
1041 | (union-build (assoc-ref %outputs "static") |
1042 | (list (assoc-ref %build-inputs | |
3d5ad159 | 1043 | "libc-static"))) |
e3cfef22 | 1044 | #t)))) |
d474d5d0 LC |
1045 | |
1046 | (native-search-paths (package-native-search-paths gcc)) | |
1047 | (search-paths (package-search-paths gcc)) | |
1048 | ||
bdb36958 LC |
1049 | (license (package-license gcc)) |
1050 | (synopsis "Complete GCC tool chain for C/C++ development") | |
1051 | (description | |
1052 | "This package provides a complete GCC tool chain for C/C++ development to | |
1053 | be installed in user profiles. This includes GCC, as well as libc (headers | |
1054 | and binaries, plus debugging symbols in the 'debug' output), and Binutils.") | |
6fd52309 | 1055 | (home-page "https://gcc.gnu.org/") |
5a48a066 | 1056 | (outputs '("out" "debug" "static")) |
bdb36958 LC |
1057 | |
1058 | ;; The main raison d'être of this "meta-package" is (1) to conveniently | |
1059 | ;; install everything that we need, and (2) to make sure ld-wrapper comes | |
1060 | ;; before Binutils' ld in the user's profile. | |
1061 | (inputs `(("gcc" ,gcc) | |
cbbb11c8 | 1062 | ("ld-wrapper" ,(car (assoc-ref %final-inputs "ld-wrapper"))) |
bdb36958 LC |
1063 | ("binutils" ,binutils-final) |
1064 | ("libc" ,glibc-final) | |
5a48a066 LC |
1065 | ("libc-debug" ,glibc-final "debug") |
1066 | ("libc-static" ,glibc-final "static"))))) | |
bdb36958 LC |
1067 | |
1068 | (define-public gcc-toolchain-4.8 | |
b887ede1 | 1069 | (make-gcc-toolchain gcc-4.8)) |
bdb36958 LC |
1070 | |
1071 | (define-public gcc-toolchain-4.9 | |
b887ede1 LC |
1072 | (make-gcc-toolchain gcc-4.9)) |
1073 | ||
1074 | (define-public gcc-toolchain | |
1075 | (make-gcc-toolchain gcc-final)) | |
bdb36958 | 1076 | |
629f4d2e | 1077 | (define-public gcc-toolchain-5 |
b887ede1 | 1078 | gcc-toolchain) |
60e2d5fe | 1079 | |
e760ec41 | 1080 | (define-public gcc-toolchain-6 |
b887ede1 | 1081 | (make-gcc-toolchain gcc-6)) |
e760ec41 | 1082 | |
d7ecab74 | 1083 | (define-public gcc-toolchain-7 |
b887ede1 | 1084 | (make-gcc-toolchain gcc-7)) |
d7ecab74 | 1085 | |
5ae27f57 LC |
1086 | (define-public gcc-toolchain-8 |
1087 | (make-gcc-toolchain gcc-8)) | |
1088 | ||
bdb36958 | 1089 | ;;; commencement.scm ends here |