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