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