1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2014 Andreas Enge <andreas@enge.fr>
4 ;;; Copyright © 2012 Nikita Karetnikov <nikita@karetnikov.org>
5 ;;; Copyright © 2014, 2015, 2017 Mark H Weaver <mhw@netris.org>
6 ;;; Copyright © 2017 Efraim Flashner <efraim@flashner.co.il>
8 ;;; This file is part of GNU Guix.
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.
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.
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/>.
23 (define-module (gnu packages commencement)
24 #:use-module ((guix licenses)
25 #:select (gpl3+ lgpl2.0+ public-domain))
26 #:use-module (gnu packages)
27 #:use-module (gnu packages bootstrap)
28 #:use-module (gnu packages base)
29 #:use-module (gnu packages bash)
30 #:use-module (gnu packages gcc)
31 #:use-module (gnu packages m4)
32 #:use-module (gnu packages indent)
33 #:use-module (gnu packages file)
34 #:use-module (gnu packages gawk)
35 #:use-module (gnu packages bison)
36 #:use-module (gnu packages flex)
37 #:use-module (gnu packages guile)
38 #:use-module (gnu packages gettext)
39 #:use-module (gnu packages multiprecision)
40 #:use-module (gnu packages compression)
41 #:use-module (gnu packages perl)
42 #:use-module (gnu packages linux)
43 #:use-module (gnu packages hurd)
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)
54 #:use-module (ice-9 match)
55 #:use-module (ice-9 regex))
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'.
65 ;;; To avoid circular dependencies, this module should not be imported
66 ;;; directly from anywhere.
70 (define gnu-make-boot0
71 (package-with-bootstrap-guile
72 (package (inherit gnu-make)
75 `(#:guile ,%bootstrap-guile
77 #:tests? #f ; cannot run "make check"
78 ,@(substitute-keyword-arguments (package-arguments gnu-make)
80 `(modify-phases ,phases
83 (zero? (system* "./build.sh"))))
85 (lambda* (#:key outputs #:allow-other-keys)
86 (let* ((out (assoc-ref outputs "out"))
87 (bin (string-append out "/bin")))
88 (install-file "make" bin)))))))))
89 (native-inputs '()) ; no need for 'pkg-config'
90 (inputs %bootstrap-inputs))))
92 (define diffutils-boot0
93 (package-with-bootstrap-guile
94 (let ((p (package-with-explicit-inputs diffutils
95 `(("make" ,gnu-make-boot0)
97 #:guile %bootstrap-guile)))
99 (name "diffutils-boot0")
100 (arguments `(#:tests? #f ; the test suite needs diffutils
101 ,@(package-arguments p)))))))
103 (define findutils-boot0
104 (package-with-bootstrap-guile
105 (package-with-explicit-inputs (package
107 (name "findutils-boot0"))
108 `(("make" ,gnu-make-boot0)
109 ("diffutils" ,diffutils-boot0) ; for tests
111 (current-source-location)
112 #:guile %bootstrap-guile)))
115 (package-with-bootstrap-guile
116 (package-with-explicit-inputs (package
119 `(("make" ,gnu-make-boot0)
121 (current-source-location)
122 #:guile %bootstrap-guile)))
125 (define %boot0-inputs
126 `(("make" ,gnu-make-boot0)
127 ("diffutils" ,diffutils-boot0)
128 ("findutils" ,findutils-boot0)
130 ,@%bootstrap-inputs))
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"))
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.
142 (define binutils-boot0
143 (package-with-bootstrap-guile
144 (package (inherit binutils)
145 (name "binutils-cross-boot0")
147 `(#:guile ,%bootstrap-guile
148 #:implicit-inputs? #f
150 #:modules ((guix build gnu-build-system)
152 (ice-9 ftw)) ; for 'scandir'
153 #:phases (alist-cons-after
154 '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?)))
171 ,@(substitute-keyword-arguments (package-arguments binutils)
172 ((#:configure-flags cf)
173 `(cons ,(string-append "--target=" (boot-triplet))
175 (inputs %boot0-inputs))))
177 (define libstdc++-boot0
178 ;; GCC's libcc1 is always built as a shared library (the top-level
179 ;; 'Makefile.def' forcefully adds --enable-shared) and thus needs to refer
180 ;; to libstdc++.so. We cannot build libstdc++-5.3 because it relies on
181 ;; C++14 features missing in our bootstrap compiler.
182 (let ((lib (package-with-bootstrap-guile (make-libstdc++ gcc-4.9))))
185 (name "libstdc++-boot0")
187 `(#:guile ,%bootstrap-guile
188 #:implicit-inputs? #f
190 ;; XXX: libstdc++.so NEEDs ld.so for some reason.
191 #:validate-runpath? #f
193 ,@(package-arguments lib)))
194 (inputs %boot0-inputs)
195 (native-inputs '()))))
198 (package-with-bootstrap-guile
199 (package (inherit gcc)
200 (name "gcc-cross-boot0")
202 `(#:guile ,%bootstrap-guile
203 #:implicit-inputs? #f
204 #:modules ((guix build gnu-build-system)
209 ,@(substitute-keyword-arguments (package-arguments gcc)
210 ((#:configure-flags flags)
211 `(append (list ,(string-append "--target=" (boot-triplet))
216 ;; Disable features not needed at this stage.
218 "--enable-languages=c,c++"
220 ;; libstdc++ cannot be built at this stage
221 ;; ("Link tests are not allowed after
222 ;; GCC_NO_EXECUTABLES.").
223 "--disable-libstdc++-v3"
226 "--disable-libmudflap"
227 "--disable-libatomic"
228 "--disable-libsanitizer"
231 "--disable-libcilkrts"
234 "--disable-libquadmath"
235 "--disable-decimal-float")
236 (remove (cut string-match
237 "--(with-system-zlib|enable-languages.*)" <>)
241 'unpack 'unpack-gmp&co
242 (lambda* (#:key inputs #:allow-other-keys)
243 (let ((gmp (assoc-ref %build-inputs "gmp-source"))
244 (mpfr (assoc-ref %build-inputs "mpfr-source"))
245 (mpc (assoc-ref %build-inputs "mpc-source")))
247 ;; To reduce the set of pre-built bootstrap inputs, build
248 ;; GMP & co. from GCC.
249 (for-each (lambda (source)
250 (or (zero? (system* "tar" "xvf" source))
251 (error "failed to unpack tarball"
255 ;; Create symlinks like `gmp' -> `gmp-x.y.z'.
257 ;; Drop trailing letters, as gmp-6.0.0a unpacks
259 `(symlink ,(string-trim-right
260 (package-full-name lib)
262 ,(package-name lib)))
263 (list gmp-6.0 mpfr mpc))))
265 'install 'symlink-libgcc_eh
266 (lambda* (#:key outputs #:allow-other-keys)
267 (let ((out (assoc-ref outputs "lib")))
268 ;; Glibc wants to link against libgcc_eh, so provide
270 (with-directory-excursion
271 (string-append out "/lib/gcc/"
273 "/" ,(package-version gcc))
274 (symlink "libgcc.a" "libgcc_eh.a"))))
277 (inputs `(("gmp-source" ,(package-source gmp-6.0))
278 ("mpfr-source" ,(package-source mpfr))
279 ("mpc-source" ,(package-source mpc))
280 ("binutils-cross" ,binutils-boot0)
282 ;; The libstdc++ that libcc1 links against.
283 ("libstdc++" ,libstdc++-boot0)
285 ;; Call it differently so that the builder can check whether
286 ;; the "libc" input is #f.
287 ("libc-native" ,@(assoc-ref %boot0-inputs "libc"))
288 ,@(alist-delete "libc" %boot0-inputs)))
290 ;; No need for Texinfo at this stage.
291 (native-inputs (alist-delete "texinfo"
292 (package-native-inputs gcc))))))
299 ;; At the very least, this must not depend on GCC & co.
300 (let ((args `(#:disallowed-references
301 ,(list %bootstrap-binutils))))
302 (substitute-keyword-arguments (package-arguments perl)
304 `(modify-phases ,phases
305 ;; Pthread support is missing in the bootstrap compiler
306 ;; (broken spec file), so disable it.
307 (add-before 'configure 'disable-pthreads
309 (substitute* "Configure"
310 (("^libswanted=(.*)pthread" _ before)
311 (string-append "libswanted=" before)))))))
312 ;; Do not configure with '-Dusethreads' since pthread
313 ;; support is missing.
314 ((#:configure-flags configure-flags)
315 `(delete "-Dusethreads" ,configure-flags))))))))
316 (package-with-bootstrap-guile
317 (package-with-explicit-inputs perl
319 (current-source-location)
320 #:guile %bootstrap-guile))))
323 ;; This Bison is needed to build MiG so we need it early in the process.
324 ;; It is also needed to rebuild Bash's parser, which is modified by
325 ;; its CVE patches. Remove it when it's no longer needed.
326 (let* ((m4 (package-with-bootstrap-guile
327 (package-with-explicit-inputs m4 %boot0-inputs
328 (current-source-location)
329 #:guile %bootstrap-guile)))
330 (bison (package (inherit bison)
331 (propagated-inputs `(("m4" ,m4)))
332 (inputs '()) ;remove Flex...
334 '(#:tests? #f ;... and thus disable tests
336 ;; Zero timestamps in liby.a; this must be done
337 ;; explicitly here because the bootstrap Binutils don't
338 ;; do that (default is "cru".)
339 #:make-flags '("ARFLAGS=crD" "RANLIB=ranlib -D"
342 (inherit (package-with-bootstrap-guile
343 (package-with-explicit-inputs bison %boot0-inputs
344 (current-source-location)
345 #:guile %bootstrap-guile)))
346 (native-inputs `(("perl" ,perl-boot0))))))
349 ;; This Flex is needed to build MiG.
350 (let* ((flex (package (inherit flex)
351 (native-inputs `(("bison" ,bison-boot0)))
352 (propagated-inputs `(("m4" ,m4)))
353 (inputs `(("indent" ,indent)))
354 (arguments '(#:tests? #f)))))
355 (package-with-bootstrap-guile
356 (package-with-explicit-inputs flex %boot0-inputs
357 (current-source-location)
358 #:guile %bootstrap-guile))))
360 (define (linux-libre-headers-boot0)
361 "Return Linux-Libre header files for the bootstrap environment."
362 ;; Note: this is wrapped in a thunk to nicely handle circular dependencies
363 ;; between (gnu packages linux) and this module.
364 (package-with-bootstrap-guile
365 (package (inherit linux-libre-headers)
366 (arguments `(#:guile ,%bootstrap-guile
367 #:implicit-inputs? #f
368 ,@(package-arguments linux-libre-headers)))
370 `(("perl" ,perl-boot0)
373 (define gnumach-headers-boot0
374 (package-with-bootstrap-guile
375 (package-with-explicit-inputs gnumach-headers
377 (current-source-location)
378 #:guile %bootstrap-guile)))
381 (let* ((mig (package (inherit mig)
382 (native-inputs `(("bison" ,bison-boot0)
383 ("flex" ,flex-boot0)))
384 (inputs `(("flex" ,flex-boot0)))
387 `(,(string-append "LDFLAGS=-Wl,-rpath="
388 (assoc-ref %build-inputs "flex") "/lib/")))))))
389 (package-with-bootstrap-guile
390 (package-with-explicit-inputs mig %boot0-inputs
391 (current-source-location)
392 #:guile %bootstrap-guile))))
394 (define hurd-headers-boot0
395 (let ((hurd-headers (package (inherit hurd-headers)
396 (native-inputs `(("mig" ,mig-boot0)))
398 (package-with-bootstrap-guile
399 (package-with-explicit-inputs hurd-headers %boot0-inputs
400 (current-source-location)
401 #:guile %bootstrap-guile))))
403 (define hurd-minimal-boot0
404 (let ((hurd-minimal (package (inherit hurd-minimal)
405 (native-inputs `(("mig" ,mig-boot0)))
407 (package-with-bootstrap-guile
408 (package-with-explicit-inputs hurd-minimal %boot0-inputs
409 (current-source-location)
410 #:guile %bootstrap-guile))))
412 (define (hurd-core-headers-boot0)
413 "Return the Hurd and Mach headers as well as initial Hurd libraries for
414 the bootstrap environment."
415 (package-with-bootstrap-guile
416 (package (inherit hurd-core-headers)
417 (arguments `(#:guile ,%bootstrap-guile
418 ,@(package-arguments hurd-core-headers)))
420 `(("gnumach-headers" ,gnumach-headers-boot0)
421 ("hurd-headers" ,hurd-headers-boot0)
422 ("hurd-minimal" ,hurd-minimal-boot0)
425 (define* (kernel-headers-boot0 #:optional (system (%current-system)))
427 ("i586-gnu" (hurd-core-headers-boot0))
428 (_ (linux-libre-headers-boot0))))
430 (define texinfo-boot0
431 ;; Texinfo used to build libc's manual.
432 ;; We build without ncurses because it fails to build at this stage, and
433 ;; because we don't need the stand-alone Info reader.
434 ;; Also, use %BOOT0-INPUTS to avoid building Perl once more.
435 (let ((texinfo (package (inherit texinfo)
437 (inputs `(("perl" ,perl-boot0)))
439 ;; Some of Texinfo 6.1's tests would fail with "Couldn't
440 ;; set UTF-8 character type in locale" but we don't have a
441 ;; UTF-8 locale at this stage, so skip them.
442 (arguments '(#:tests? #f)))))
443 (package-with-bootstrap-guile
444 (package-with-explicit-inputs texinfo %boot0-inputs
445 (current-source-location)
446 #:guile %bootstrap-guile))))
448 (define ld-wrapper-boot0
449 ;; We need this so binaries on Hurd will have libmachuser and libhurduser
450 ;; in their RUNPATH, otherwise validate-runpath will fail.
451 (make-ld-wrapper "ld-wrapper-boot0"
452 #:target boot-triplet
453 #:binutils binutils-boot0
454 #:guile %bootstrap-guile
455 #:bash (car (assoc-ref %boot0-inputs "bash"))))
457 (define %boot1-inputs
460 ("ld-wrapper-cross" ,ld-wrapper-boot0)
461 ("binutils-cross" ,binutils-boot0)
462 ,@(alist-delete "binutils" %boot0-inputs)))
464 (define glibc-final-with-bootstrap-bash
465 ;; The final libc, "cross-built". If everything went well, the resulting
466 ;; store path has no dependencies. Actually, the really-final libc is
467 ;; built just below; the only difference is that this one uses the
469 (package-with-bootstrap-guile
470 (package/inherit glibc
471 (name "glibc-intermediate")
473 `(#:guile ,%bootstrap-guile
474 #:implicit-inputs? #f
476 ,@(substitute-keyword-arguments (package-arguments glibc)
477 ((#:configure-flags flags)
478 `(append (list ,(string-append "--host=" (boot-triplet))
479 ,(string-append "--build="
480 (nix-system->gnu-triplet))
482 ;; Build Sun/ONC RPC support. In particular,
484 "--enable-obsolete-rpc")
488 'configure 'pre-configure
489 (lambda* (#:key inputs #:allow-other-keys)
490 ;; Don't clobber CPATH with the bootstrap libc.
491 (setenv "NATIVE_CPATH" (getenv "CPATH"))
494 ;; Tell 'libpthread' where to find 'libihash' on Hurd systems.
495 ,@(if (hurd-triplet? (%current-system))
496 `((substitute* "libpthread/Makefile"
497 (("LDLIBS-pthread.so =.*")
498 (string-append "LDLIBS-pthread.so = "
499 (assoc-ref %build-inputs "kernel-headers")
500 "/lib/libihash.a\n"))))
503 ;; 'rpcgen' needs native libc headers to be built.
504 (substitute* "sunrpc/Makefile"
505 (("sunrpc-CPPFLAGS =.*" all)
506 (string-append "CPATH = $(NATIVE_CPATH)\n"
510 (propagated-inputs `(("kernel-headers" ,(kernel-headers-boot0))))
512 `(("texinfo" ,texinfo-boot0)
513 ("perl" ,perl-boot0)))
515 `(;; The boot inputs. That includes the bootstrap libc. We don't want
516 ;; it in $CPATH, hence the 'pre-configure' phase above.
519 ;; A native MiG is needed to build Glibc on Hurd.
520 ,@(if (hurd-triplet? (%current-system))
521 `(("mig" ,mig-boot0))
524 ;; A native GCC is needed to build `cross-rpcgen'.
525 ("native-gcc" ,@(assoc-ref %boot0-inputs "gcc"))
527 ;; Here, we use the bootstrap Bash, which is not satisfactory
528 ;; because we don't want to depend on bootstrap tools.
529 ("static-bash" ,@(assoc-ref %boot0-inputs "bash")))))))
531 (define (cross-gcc-wrapper gcc binutils glibc bash)
532 "Return a wrapper for the pseudo-cross toolchain GCC/BINUTILS/GLIBC
533 that makes it available under the native tool names."
534 (package (inherit gcc)
535 (name (string-append (package-name gcc) "-wrapped"))
537 (build-system trivial-build-system)
540 `(#:guile ,%bootstrap-guile
541 #:modules ((guix build utils))
543 (use-modules (guix build utils))
545 (let* ((binutils (assoc-ref %build-inputs "binutils"))
546 (gcc (assoc-ref %build-inputs "gcc"))
547 (libc (assoc-ref %build-inputs "libc"))
548 (bash (assoc-ref %build-inputs "bash"))
549 (out (assoc-ref %outputs "out"))
550 (bindir (string-append out "/bin"))
551 (triplet ,(boot-triplet)))
552 (define (wrap-program program)
553 ;; GCC-BOOT0 is a libc-less cross-compiler, so it
554 ;; needs to be told where to find the crt files and
555 ;; the dynamic linker.
556 (call-with-output-file program
558 (format p "#!~a/bin/bash
559 exec ~a/bin/~a-~a -B~a/lib -Wl,-dynamic-linker -Wl,~a/~a \"$@\"~%"
563 ,(glibc-dynamic-linker))))
565 (chmod program #o555))
568 (with-directory-excursion bindir
569 (for-each (lambda (tool)
570 (symlink (string-append binutils "/bin/"
574 (for-each wrap-program '("gcc" "g++")))))))
576 `(("binutils" ,binutils)
582 (define static-bash-for-glibc
583 ;; A statically-linked Bash to be used by GLIBC-FINAL in system(3) & co.
584 (let* ((gcc (cross-gcc-wrapper gcc-boot0 binutils-boot0
585 glibc-final-with-bootstrap-bash
586 (car (assoc-ref %boot1-inputs "bash"))))
587 (bash (package (inherit static-bash)
589 `(#:guile ,%bootstrap-guile
590 ,@(package-arguments static-bash)))))
591 (inputs `(("gcc" ,gcc)
592 ("libc" ,glibc-final-with-bootstrap-bash)
593 ,@(fold alist-delete %boot1-inputs
595 (package-with-bootstrap-guile
596 (package-with-explicit-inputs bash inputs
597 (current-source-location)
598 #:guile %bootstrap-guile))))
600 (define gettext-boot0
601 ;; A minimal gettext used during bootstrap.
602 (let ((gettext-minimal
603 (package (inherit gettext-minimal)
604 (name "gettext-boot0")
605 (inputs '()) ;zero dependencies
607 (substitute-keyword-arguments
609 ,@(package-arguments gettext-minimal))
611 `(modify-phases ,phases
612 ;; Build only the tools.
613 (add-after 'unpack 'chdir
615 (chdir "gettext-tools")))
617 ;; Some test programs require pthreads, which we don't have.
618 (add-before 'configure 'no-test-programs
620 (substitute* "tests/Makefile.in"
625 ;; Don't try to link against libexpat.
627 (delete 'patch-tests))))))))
628 (package-with-bootstrap-guile
629 (package-with-explicit-inputs gettext-minimal
631 (current-source-location)
632 #:guile %bootstrap-guile))))
635 ;; The final glibc, which embeds the statically-linked Bash built above.
636 (package/inherit glibc-final-with-bootstrap-bash
638 (inputs `(("static-bash" ,static-bash-for-glibc)
641 (package-inputs glibc-final-with-bootstrap-bash))))
643 ;; This time we need 'msgfmt' to install all the libc.mo files.
644 (native-inputs `(,@(package-native-inputs glibc-final-with-bootstrap-bash)
645 ("gettext" ,gettext-boot0)))
647 ;; The final libc only refers to itself, but the 'debug' output contains
648 ;; references to GCC-BOOT0 and to the Linux headers. XXX: Would be great
649 ;; if 'allowed-references' were per-output.
651 `(#:allowed-references
652 ,(cons* `(,gcc-boot0 "lib") (kernel-headers-boot0)
653 static-bash-for-glibc
654 (package-outputs glibc-final-with-bootstrap-bash))
656 ,@(package-arguments glibc-final-with-bootstrap-bash)))))
658 (define gcc-boot0-wrapped
659 ;; Make the cross-tools GCC-BOOT0 and BINUTILS-BOOT0 available under the
661 (cross-gcc-wrapper gcc-boot0 binutils-boot0 glibc-final
662 (car (assoc-ref %boot1-inputs "bash"))))
664 (define %boot2-inputs
666 `(("libc" ,glibc-final)
667 ("gcc" ,gcc-boot0-wrapped)
668 ,@(fold alist-delete %boot1-inputs '("libc" "gcc"))))
670 (define binutils-final
671 (package-with-bootstrap-guile
672 (package/inherit binutils
674 `(#:guile ,%bootstrap-guile
675 #:implicit-inputs? #f
676 #:allowed-references ("out" ,glibc-final)
677 ,@(package-arguments binutils)))
678 (inputs %boot2-inputs))))
681 ;; Intermediate libstdc++ that will allow us to build the final GCC
682 ;; (remember that GCC-BOOT0 cannot build libstdc++.)
683 ;; TODO: Write in terms of 'make-libstdc++'.
684 (package-with-bootstrap-guile
685 (package (inherit gcc)
688 `(#:guile ,%bootstrap-guile
689 #:implicit-inputs? #f
690 #:allowed-references ("out")
692 #:phases (alist-cons-before
695 (chdir "libstdc++-v3"))
697 #:configure-flags `("--disable-shared"
698 "--disable-libstdcxx-threads"
699 "--disable-libstdcxx-pch"
700 ,(string-append "--with-gxx-include-dir="
701 (assoc-ref %outputs "out")
704 ;; ,(package-version gcc)
707 (inputs %boot2-inputs)
709 (propagated-inputs '())
710 (synopsis "GNU C++ standard library (intermediate)"))))
713 ;; Zlib used by GCC-FINAL.
714 (package-with-bootstrap-guile
718 `(#:guile ,%bootstrap-guile
719 #:implicit-inputs? #f
720 #:allowed-references ("out" ,glibc-final)
721 ,@(package-arguments zlib)))
722 (inputs %boot2-inputs))))
724 (define ld-wrapper-boot3
725 ;; A linker wrapper that uses the bootstrap Guile.
726 (make-ld-wrapper "ld-wrapper-boot3"
727 #:binutils binutils-final
728 #:guile %bootstrap-guile
729 #:bash (car (assoc-ref %boot2-inputs "bash"))))
733 (package (inherit gcc-boot0)
736 ;; XXX: Currently #:allowed-references applies to all the outputs but the
737 ;; "debug" output contains disallowed references, notably
738 ;; linux-libre-headers. Disable the debugging output to work around that.
739 (outputs (delete "debug" (package-outputs gcc-boot0)))
742 `(#:guile ,%bootstrap-guile
743 #:implicit-inputs? #f
745 #:allowed-references ("out" "lib" ,zlib-final
746 ,glibc-final ,static-bash-for-glibc)
748 ;; Things like libasan.so and libstdc++.so NEED ld.so for some
749 ;; reason, but it is not in their RUNPATH. This is a false
750 ;; positive, so turn it off.
751 #:validate-runpath? #f
753 ;; Build again GMP & co. within GCC's build process, because it's hard
754 ;; to do outside (because GCC-BOOT0 is a cross-compiler, and thus
755 ;; doesn't honor $LIBRARY_PATH, which breaks `gnu-build-system'.)
756 ,@(substitute-keyword-arguments (package-arguments gcc-boot0)
757 ((#:configure-flags boot-flags)
758 (let loop ((args (package-arguments gcc)))
760 ((#:configure-flags normal-flags _ ...)
764 ((#:make-flags flags)
765 ;; Since $LIBRARY_PATH is not honored, add the relevant flags.
766 `(let ((zlib (assoc-ref %build-inputs "zlib")))
768 (if (string-prefix? "LDFLAGS=" flag)
769 (string-append flag " -L"
770 (assoc-ref %build-inputs "libstdc++")
771 "/lib -L" zlib "/lib -Wl,-rpath="
776 `(alist-delete 'symlink-libgcc_eh ,phases)))))
778 ;; This time we want Texinfo, so we get the manual. Add
779 ;; STATIC-BASH-FOR-GLIBC so that it's used in the final shebangs of
780 ;; scripts such as 'mkheaders' and 'fixinc.sh' (XXX: who cares about these
782 (native-inputs `(("texinfo" ,texinfo-boot0)
783 ("static-bash" ,static-bash-for-glibc)
784 ,@(package-native-inputs gcc-boot0)))
786 (inputs `(("gmp-source" ,(bootstrap-origin (package-source gmp-6.0)))
787 ("mpfr-source" ,(package-source mpfr))
788 ("mpc-source" ,(package-source mpc))
789 ("ld-wrapper" ,ld-wrapper-boot3)
790 ("binutils" ,binutils-final)
791 ("libstdc++" ,libstdc++)
795 (define %boot3-inputs
798 ("ld-wrapper" ,ld-wrapper-boot3)
799 ,@(alist-delete "gcc" %boot2-inputs)))
802 ;; Link with `-static-libgcc' to make sure we don't retain a reference
803 ;; to the bootstrap GCC. Use "bash-minimal" to avoid an extra dependency
804 ;; on Readline and ncurses.
806 (inherit bash-minimal)
808 `(#:disallowed-references
809 ,(assoc-ref %boot3-inputs "coreutils&co")
810 ,@(package-arguments bash-minimal))))))
811 (package-with-bootstrap-guile
812 (package-with-explicit-inputs (static-libgcc-package bash)
814 (current-source-location)
815 #:guile %bootstrap-guile))))
817 (define %boot4-inputs
818 ;; Now use the final Bash.
819 `(("bash" ,bash-final)
820 ,@(alist-delete "bash" %boot3-inputs)))
822 (define-public guile-final
823 ;; This package must be public because other modules refer to it. However,
824 ;; mark it as hidden so that 'fold-packages' ignores it.
825 (package-with-bootstrap-guile
826 (package-with-explicit-inputs (hidden-package guile-2.2/fixed)
828 (current-source-location)
829 #:guile %bootstrap-guile)))
831 (define glibc-utf8-locales-final
832 ;; Now that we have GUILE-FINAL, build the UTF-8 locales. They are needed
833 ;; by the build processes afterwards so their 'scm_to_locale_string' works
834 ;; with the full range of Unicode codepoints (remember
835 ;; 'scm_to_locale_string' is called every time a string is passed to a C
838 (inherit glibc-utf8-locales)
839 (inputs `(("glibc" ,glibc-final)
841 ,(package-with-explicit-inputs gzip %boot4-inputs
842 (current-source-location)
843 #:guile %bootstrap-guile))))))
845 (define-public ld-wrapper
846 ;; The final 'ld' wrapper, which uses the final Guile and Binutils.
847 (make-ld-wrapper "ld-wrapper"
848 #:binutils binutils-final
852 (define %boot5-inputs
853 ;; Now with UTF-8 locales. Remember that the bootstrap binaries were built
854 ;; with an older libc, which cannot load the new locale format. See
855 ;; <https://lists.gnu.org/archive/html/guix-devel/2015-08/msg00737.html>.
856 `(("locales" ,glibc-utf8-locales-final)
859 (define gnu-make-final
860 ;; The final GNU Make, which uses the final Guile.
861 (package-with-bootstrap-guile
862 (package-with-explicit-inputs gnu-make
863 `(("guile" ,guile-final)
865 (current-source-location))))
867 (define coreutils-final
868 ;; The final Coreutils. Treat them specially because some packages, such as
869 ;; Findutils, keep a reference to the Coreutils they were built with.
870 (package-with-bootstrap-guile
871 (package-with-explicit-inputs coreutils
873 (current-source-location)
875 ;; Use the final Guile, linked against the
876 ;; final libc with working iconv, so that
877 ;; 'substitute*' works well when touching
878 ;; test files in Gettext.
879 #:guile guile-final)))
882 ;; The final grep. Gzip holds a reference to it (via zgrep), so it must be
883 ;; built before gzip.
884 (package-with-bootstrap-guile
885 (package-with-explicit-inputs (package
887 (native-inputs `(("perl" ,perl-boot0))))
889 (current-source-location)
890 #:guile guile-final)))
892 (define %boot6-inputs
893 ;; Now use the final Coreutils.
894 `(("coreutils" ,coreutils-final)
898 (define-public %final-inputs
899 ;; Final derivations used as implicit inputs by 'gnu-build-system'. We
900 ;; still use 'package-with-bootstrap-guile' so that the bootstrap tools are
901 ;; used for origins that have patches, thereby avoiding circular
903 (let ((finalize (compose package-with-bootstrap-guile
904 (cut package-with-explicit-inputs <> %boot6-inputs
905 (current-source-location)))))
906 `(,@(map (match-lambda
908 (list name (finalize package))))
914 ("diffutils" ,diffutils)
917 ("findutils" ,findutils)
920 ("coreutils" ,coreutils-final)
921 ("make" ,gnu-make-final)
923 ("ld-wrapper" ,ld-wrapper)
924 ("binutils" ,binutils-final)
926 ("libc" ,glibc-final)
927 ("locales" ,glibc-utf8-locales-final))))
929 (define-public canonical-package
930 (let ((name->package (fold (lambda (input result)
933 (vhash-cons (package-full-name package)
936 `(("guile" ,guile-final)
939 "Return the 'canonical' variant of PACKAGE---i.e., if PACKAGE is one of
940 the implicit inputs of 'gnu-build-system', return that one, otherwise return
943 The goal is to avoid duplication in cases like GUILE-FINAL vs. GUILE-2.2,
944 COREUTILS-FINAL vs. COREUTILS, etc."
945 ;; XXX: This doesn't handle dependencies of the final inputs, such as
946 ;; libunistring, GMP, etc.
947 (match (vhash-assoc (package-full-name package) name->package)
949 ;; In general we want CANON, except if we're cross-compiling: CANON
950 ;; uses explicit inputs, so it is "anchored" in the bootstrapped
951 ;; process, with dependencies on things that cannot be
953 (if (%current-target-system)
963 (define (make-gcc-toolchain gcc)
964 "Return a complete toolchain for GCC."
966 (name "gcc-toolchain")
967 (version (package-version gcc))
969 (build-system trivial-build-system)
971 '(#:modules ((guix build union))
973 (use-modules (ice-9 match)
977 (let ((out (assoc-ref %outputs "out")))
980 (((names . directories) ...)
981 (union-build out directories)))
983 (union-build (assoc-ref %outputs "debug")
984 (list (assoc-ref %build-inputs
987 (native-search-paths (package-native-search-paths gcc))
988 (search-paths (package-search-paths gcc))
990 (license (package-license gcc))
991 (synopsis "Complete GCC tool chain for C/C++ development")
993 "This package provides a complete GCC tool chain for C/C++ development to
994 be installed in user profiles. This includes GCC, as well as libc (headers
995 and binaries, plus debugging symbols in the 'debug' output), and Binutils.")
996 (home-page "https://gcc.gnu.org/")
997 (outputs '("out" "debug"))
999 ;; The main raison d'être of this "meta-package" is (1) to conveniently
1000 ;; install everything that we need, and (2) to make sure ld-wrapper comes
1001 ;; before Binutils' ld in the user's profile.
1002 (inputs `(("gcc" ,gcc)
1003 ("ld-wrapper" ,(car (assoc-ref %final-inputs "ld-wrapper")))
1004 ("binutils" ,binutils-final)
1005 ("libc" ,glibc-final)
1006 ("libc-debug" ,glibc-final "debug")))))
1008 (define-public gcc-toolchain-4.8
1009 (make-gcc-toolchain gcc-4.8))
1011 (define-public gcc-toolchain-4.9
1012 (make-gcc-toolchain gcc-4.9))
1014 (define-public gcc-toolchain
1015 (make-gcc-toolchain gcc-final))
1017 (define-public gcc-toolchain-5
1020 (define-public gcc-toolchain-6
1021 (make-gcc-toolchain gcc-6))
1023 (define-public gcc-toolchain-7
1024 (make-gcc-toolchain gcc-7))
1026 ;;; commencement.scm ends here