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