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