1 ;;; Guix --- Nix package management from Guile. -*- coding: utf-8 -*-
2 ;;; Copyright (C) 2012 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright (C) 2012 Nikita Karetnikov <nikita@karetnikov.org>
5 ;;; This file is part of Guix.
7 ;;; Guix is free software; you can redistribute it and/or modify it
8 ;;; under the terms of the GNU General Public License as published by
9 ;;; the Free Software Foundation; either version 3 of the License, or (at
10 ;;; your option) any later version.
12 ;;; Guix is distributed in the hope that it will be useful, but
13 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;;; GNU General Public License for more details.
17 ;;; You should have received a copy of the GNU General Public License
18 ;;; along with Guix. If not, see <http://www.gnu.org/licenses/>.
20 (define-module (distro packages base)
21 #:use-module (guix licenses)
23 #:use-module (distro packages bash)
24 #:use-module (distro packages bootstrap)
25 #:use-module (distro packages compression)
26 #:use-module (distro packages gawk)
27 #:use-module (distro packages guile)
28 #:use-module (distro packages multiprecision)
29 #:use-module (distro packages perl)
30 #:use-module (distro packages linux)
31 #:use-module (guix packages)
32 #:use-module (guix download)
33 #:use-module (guix build-system gnu)
34 #:use-module (guix build-system trivial)
35 #:use-module (guix utils)
36 #:use-module (srfi srfi-1)
37 #:use-module (srfi srfi-26)
38 #:use-module (ice-9 match))
42 ;;; Base packages of the Guix-based GNU user-land software distribution.
52 (uri (string-append "mirror://gnu/hello/hello-" version
55 (base32 "0wqd8sjmxfskrflaxywc7gqw7sfawrfvdxd9skxawzfgyy0pzdz6"))))
56 (build-system gnu-build-system)
57 (arguments '(#:configure-flags
58 `("--disable-dependency-tracking"
59 ,(string-append "--with-gawk=" ; for illustration purposes
60 (assoc-ref %build-inputs "gawk")))))
61 (inputs `(("gawk" ,gawk)))
62 (synopsis "GNU Hello")
63 (description "Yeah...")
64 (home-page "http://www.gnu.org/software/hello/")
73 (uri (string-append "mirror://gnu/grep/grep-"
77 "1qbjb1l7f9blckc5pqy8jlf6482hpx4awn2acmhyf5mv9wfq03p7"))))
78 (build-system gnu-build-system)
79 (synopsis "GNU implementation of the Unix grep command")
81 "The grep command searches one or more input files for lines containing a
82 match to a specified pattern. By default, grep prints the matching
85 (home-page "http://www.gnu.org/software/grep/")))
93 (uri (string-append "mirror://gnu/sed/sed-" version
97 "13wlsb4sf5d5a82xjhxqmdvrrn36rmw5f0pl9qyb9zkvldnb7hra"))))
98 (build-system gnu-build-system)
99 (synopsis "GNU sed, a batch stream editor")
101 "Sed (stream editor) isn't really a true text editor or text processor.
102 Instead, it is used to filter text, i.e., it takes text input and performs
103 some operation (or set of operations) on it and outputs the modified text.
104 Sed is typically used for extracting part of a file using pattern matching or
105 substituting multiple occurrences of a string within a file.")
107 (home-page "http://www.gnu.org/software/sed/")))
115 (uri (string-append "mirror://gnu/tar/tar-"
119 "0hbdkzmchq9ycr2x1pxqdcgdbaxksh8c6ac0jf75jajhcks6jlss"))))
120 (build-system gnu-build-system)
121 (inputs `(("patch/gets" ,(search-patch "tar-gets-undeclared.patch"))))
123 `(#:patches (list (assoc-ref %build-inputs "patch/gets"))))
124 (synopsis "GNU implementation of the `tar' archiver")
126 "The Tar program provides the ability to create tar archives, as well as
127 various other kinds of manipulation. For example, you can use Tar on
128 previously created archives to extract files, to store additional files, or
129 to update or list files which were already stored.
131 Initially, tar archives were used to store files conveniently on magnetic
132 tape. The name \"Tar\" comes from this use; it stands for tape archiver.
133 Despite the utility's name, Tar can direct its output to available devices,
134 files, or other programs (using pipes), it can even access remote devices or
135 files (as archives).")
137 (home-page "http://www.gnu.org/software/tar/")))
145 (uri (string-append "mirror://gnu/patch/patch-"
149 "18012gxs9wc96izskp1q7bclrwns6rdmkn4jj31c8jbyfz6l5npq"))))
150 (build-system gnu-build-system)
151 (native-inputs '()) ; FIXME: needs `ed' for the tests
154 ((system) '(#:tests? #f))
155 ((system cross-system)
156 '(#:configure-flags '("ac_cv_func_strnlen_working=yes")))))
157 (synopsis "GNU Patch, a program to apply differences to files")
159 "GNU Patch takes a patch file containing a difference listing produced by
160 the diff program and applies those differences to one or more original files,
161 producing patched versions.")
163 (home-page "http://savannah.gnu.org/projects/patch/")))
165 (define-public diffutils
171 (uri (string-append "mirror://gnu/diffutils/diffutils-"
175 "0jci0wv68025xd0s0rq4s5qxpx56dd9d730lka63qpzk1rfvfkxb"))))
176 (build-system gnu-build-system)
177 (inputs `(("patch/gets"
178 ,(search-patch "diffutils-gets-undeclared.patch"))))
179 (arguments `(#:patches (list (assoc-ref %build-inputs "patch/gets"))))
180 (synopsis "Programs to find differences among text files")
182 "GNU Diffutils is a package of several programs related to finding
183 differences between files.
185 Computer users often find occasion to ask how two files differ. Perhaps one
186 file is a newer version of the other file. Or maybe the two files started out
187 as identical copies but were changed by different people.
189 You can use the diff command to show differences between two files, or each
190 corresponding file in two directories. diff outputs differences between files
191 line by line in any of several formats, selectable by command line
192 options. This set of differences is often called a ‘diff’ or ‘patch’. For
193 files that are identical, diff normally produces no output; for
194 binary (non-text) files, diff normally reports only that they are different.
196 You can use the cmp command to show the offsets and line numbers where two
197 files differ. cmp can also show all the characters that differ between the
198 two files, side by side.
200 You can use the diff3 command to show differences among three files. When two
201 people have made independent changes to a common original, diff3 can report
202 the differences between the original and the two changed versions, and can
203 produce a merged file that contains both persons' changes together with
204 warnings about conflicts.
206 You can use the sdiff command to merge two files interactively.")
208 (home-page "http://www.gnu.org/software/diffutils/")))
210 (define-public findutils
216 (uri (string-append "mirror://gnu/findutils/findutils-"
220 "0amn0bbwqvsvvsh6drfwz20ydc2czk374lzw5kksbh6bf78k4ks3"))))
221 (build-system gnu-build-system)
223 `(("patch/absolute-paths"
224 ,(search-patch "findutils-absolute-paths.patch"))))
228 `(#:patches (list (assoc-ref %build-inputs "patch/absolute-paths"))))
229 ((system cross-system)
230 ;; Work around cross-compilation failure.
231 ;; See <http://savannah.gnu.org/bugs/?27299#comment1>.
232 `(#:configure-flags '("gl_cv_func_wcwidth_works=yes")
233 ,@(arguments cross-system)))))
234 (synopsis "Basic directory searching utilities of the GNU operating
237 "The GNU Find Utilities are the basic directory searching utilities of
238 the GNU operating system. These programs are typically used in conjunction
239 with other programs to provide modular and powerful directory search and file
240 locating capabilities to other commands.
242 The tools supplied with this package are:
244 * find - search for files in a directory hierarchy;
245 * locate - list files in databases that match a pattern;
246 * updatedb - update a file name database;
247 * xargs - build and execute command lines from standard input.
250 (home-page "http://www.gnu.org/software/findutils/")))
252 (define-public coreutils
258 (uri (string-append "mirror://gnu/coreutils/coreutils-"
262 "1rx9x3fp848w4nny7irdkcpkan9fcx24d99v5dkwgkyq7wc76f5d"))))
263 (build-system gnu-build-system)
264 (inputs `()) ; TODO: optional deps: SELinux, ACL, GMP
266 '(;; Perl is missing, and some tests are failing.
269 "The basic file, shell and text manipulation utilities of the GNU
272 "The GNU Core Utilities are the basic file, shell and text manipulation
273 utilities of the GNU operating system. These are the core utilities which
274 are expected to exist on every operating system.")
276 (home-page "http://www.gnu.org/software/coreutils/")))
278 (define-public gnu-make
284 (uri (string-append "mirror://gnu/make/make-" version
288 "0ri98385hsd7li6rh4l5afcq92v8l2lgiaz85wgcfh4w2wzsghg2"))))
289 (build-system gnu-build-system)
291 `(("patch/impure-dirs" ,(search-patch "make-impure-dirs.patch"))))
292 (arguments `(#:patches (list (assoc-ref %build-inputs
293 "patch/impure-dirs"))))
294 (synopsis "GNU Make, a program controlling the generation of non-source
297 "Make is a tool which controls the generation of executables and other
298 non-source files of a program from the program's source files.
300 Make gets its knowledge of how to build your program from a file called the
301 makefile, which lists each of the non-source files and how to compute it from
302 other files. When you write a program, you should write a makefile for it, so
303 that it is possible to use Make to build and install the program.")
305 (home-page "http://www.gnu.org/software/make/")))
307 (define-public binutils
313 (uri (string-append "mirror://gnu/binutils/binutils-"
317 "1a9w66v5dwvbnawshjwqcgz7km6kw6ihkzp6sswv9ycc3knzhykc"))))
318 (build-system gnu-build-system)
320 ;; TODO: Add dependency on zlib + those for Gold.
322 `(("patch/new-dtags" ,(search-patch "binutils-ld-new-dtags.patch"))))
324 `(#:patches (list (assoc-ref %build-inputs "patch/new-dtags"))
325 #:configure-flags '(;; Add `-static-libgcc' to not retain a dependency
326 ;; on GCC when bootstrapping.
327 "LDFLAGS=-static-libgcc"
329 ;; Don't search under /usr/lib & co.
330 "--with-lib-path=/no-ld-lib-path")))
332 (synopsis "GNU Binutils, tools for manipulating binaries (linker,
335 "The GNU Binutils are a collection of binary tools. The main ones are
336 `ld' (the GNU linker) and `as' (the GNU assembler). They also include the
337 BFD (Binary File Descriptor) library, `gprof', `nm', `strip', etc.")
339 (home-page "http://www.gnu.org/software/binutils/")))
341 (define-public gcc-4.7
342 (let ((stripped? #t)) ; TODO: make this a parameter
348 (uri (string-append "mirror://gnu/gcc/gcc-"
349 version "/gcc-" version ".tar.bz2"))
352 "115h03hil99ljig8lkrq4qk426awmzh0g99wrrggxf8g07bq74la"))))
353 (build-system gnu-build-system)
354 (inputs `(("gmp" ,gmp)
356 ("mpc" ,mpc))) ; TODO: libelf, ppl, cloog, zlib, etc.
359 `(#:out-of-source? #t
360 #:strip-binaries? ,stripped?
363 "--enable-languages=c,c++"
366 "--with-local-prefix=/no-gcc-local-prefix"
368 ,(let ((libc (assoc-ref %build-inputs "libc")))
370 (string-append "--with-native-system-header-dir=" libc
372 "--without-headers")))
374 (let ((libc (assoc-ref %build-inputs "libc")))
376 (list (string-append "LDFLAGS_FOR_BUILD="
378 "-Wl,-dynamic-linker "
380 ,(glibc-dynamic-linker system)))
382 ,(string-append "BOOT_CFLAGS=-O2 "
383 ,(if stripped? "-g0" "-g"))))
388 'configure 'pre-configure
389 (lambda* (#:key inputs outputs #:allow-other-keys)
390 (let ((out (assoc-ref outputs "out"))
391 (libc (assoc-ref inputs "libc")))
393 ;; The following is not performed for `--without-headers'
394 ;; cross-compiler builds.
396 ;; Fix the dynamic linker's file name.
397 (substitute* (find-files "gcc/config"
398 "^linux(64|-elf)?\\.h$")
399 (("#define GLIBC_DYNAMIC_LINKER([^ ]*).*$" _ suffix)
400 (format #f "#define GLIBC_DYNAMIC_LINKER~a \"~a\"~%"
402 (string-append libc ,(glibc-dynamic-linker system)))))
404 ;; Tell where to find libstdc++, libc, and `?crt*.o', except
405 ;; `crt{begin,end}.o', which come with GCC.
406 (substitute* (find-files "gcc/config"
407 "^(gnu-user(64)?|linux-elf)\\.h$")
408 (("#define LIB_SPEC (.*)$" _ suffix)
409 ;; Note that with this "lib" spec, we may still add a
410 ;; RUNPATH to GCC even when `libgcc_s' is not NEEDED.
411 ;; There's not much that can be done to avoid it, though.
412 (format #f "#define LIB_SPEC \"-L~a/lib %{!static:-rpath=~a/lib \
413 %{!static-libgcc:-rpath=~a/lib64 -rpath=~a/lib}} \" ~a~%"
414 libc libc out out suffix))
415 (("#define STARTFILE_SPEC.*$" line)
416 (format #f "#define STANDARD_STARTFILE_PREFIX_1 \"~a/lib\"
417 #define STANDARD_STARTFILE_PREFIX_2 \"\"
421 ;; Don't retain a dependency on the build-time sed.
422 (substitute* "fixincludes/fixincl.x"
423 (("static char const sed_cmd_z\\[\\] =.*;")
424 "static char const sed_cmd_z[] = \"sed\";"))))
427 'configure 'post-configure
429 ;; Don't store configure flags, to avoid retaining references to
430 ;; build-time dependencies---e.g., `--with-ppl=/nix/store/xxx'.
431 (substitute* "Makefile"
432 (("^TOPLEVEL_CONFIGURE_ARGUMENTS=(.*)$" _ rest)
433 "TOPLEVEL_CONFIGURE_ARGUMENTS=\n")))
434 (alist-replace 'install
435 (lambda* (#:key outputs #:allow-other-keys)
441 %standard-phases))))))
443 (properties `((gcc-libc . ,(assoc-ref inputs "libc"))))
444 (synopsis "The GNU Compiler Collection")
446 "The GNU Compiler Collection includes compiler front ends for C, C++,
447 Objective-C, Fortran, OpenMP for C/C++/Fortran, Java, and Ada, as well as
448 libraries for these languages (libstdc++, libgcj, libgomp,...).
450 GCC development is a part of the GNU Project, aiming to improve the compiler
451 used in the GNU system including the GNU/Linux variant.")
453 (home-page "http://gcc.gnu.org/"))))
461 (uri (string-append "mirror://gnu/glibc/glibc-"
465 "092rdm49zh6l1pqkxbcpcaawgsgzxhpf1s7wf5wi5dvc5am3dp0y"))))
466 (build-system gnu-build-system)
468 ;; Glibc's <limits.h> refers to <linux/limit.h>, for instance, so glibc
469 ;; users should automatically pull Linux headers as well.
470 (propagated-inputs `(("linux-headers" ,linux-libre-headers)))
473 `(#:out-of-source? #t
474 #:patches (list (assoc-ref %build-inputs "patch/ld.so.cache"))
476 (list "--enable-add-ons"
478 "--localedir=/var/run/current-system/sw/lib/locale" ; XXX
479 (string-append "--with-headers="
480 (assoc-ref %build-inputs "linux-headers")
483 ;; The default is to assume a 2.4 Linux interface, but we'll
484 ;; always use something newer. See "kernel-features.h" in the
485 ;; GNU libc for details.
486 "--enable-kernel=2.6.30"
488 ;; XXX: Work around "undefined reference to `__stack_chk_guard'".
491 #:phases (alist-cons-before
492 'configure 'pre-configure
493 (lambda* (#:key outputs #:allow-other-keys)
494 (let ((out (assoc-ref outputs "out")))
495 ;; Use `pwd', not `/bin/pwd'.
496 (substitute* "configure"
497 (("/bin/pwd") "pwd"))
499 ;; Install the rpc data base file under `$out/etc/rpc'.
500 ;; FIXME: Use installFlags = [ "sysconfdir=$(out)/etc" ];
501 (substitute* "sunrpc/Makefile"
502 (("^\\$\\(inst_sysconfdir\\)/rpc(.*)$" _ suffix)
503 (string-append out "/etc/rpc" suffix "\n"))
504 (("^install-others =.*$")
505 (string-append "install-others = " out "/etc/rpc\n")))
507 (substitute* "Makeconfig"
509 ;; <http://www.linuxfromscratch.org/lfs/view/stable/chapter05/glibc.html>,
510 ;; linking against libgcc_s is not needed with GCC
514 (inputs `(("patch/ld.so.cache"
515 ,(search-patch "glibc-no-ld-so-cache.patch"))))
516 (synopsis "The GNU C Library")
518 "Any Unix-like operating system needs a C library: the library which
519 defines the \"system calls\" and other basic facilities such as open, malloc,
522 The GNU C library is used as the C library in the GNU system and most systems
523 with the Linux kernel.")
525 (home-page "http://www.gnu.org/software/libc/")))
529 ;;; Bootstrap packages.
532 (define gnu-make-boot0
533 (package-with-bootstrap-guile
534 (package (inherit gnu-make)
536 (location (source-properties->location (current-source-location)))
537 (arguments `(#:guile ,%bootstrap-guile
538 #:implicit-inputs? #f
539 #:tests? #f ; cannot run "make check"
543 (zero? (system* "./build.sh")))
545 'install (lambda* (#:key outputs #:allow-other-keys)
546 (let* ((out (assoc-ref outputs "out"))
547 (bin (string-append out "/bin")))
550 (string-append bin "/make"))))
552 (inputs %bootstrap-inputs))))
554 (define diffutils-boot0
555 (package-with-bootstrap-guile
556 (let ((p (package-with-explicit-inputs diffutils
557 `(("make" ,gnu-make-boot0)
559 #:guile %bootstrap-guile)))
561 (location (source-properties->location (current-source-location)))
562 (arguments `(#:tests? #f ; the test suite needs diffutils
563 ,@(package-arguments p)))))))
565 (define findutils-boot0
566 (package-with-bootstrap-guile
567 (package-with-explicit-inputs findutils
568 `(("make" ,gnu-make-boot0)
569 ("diffutils" ,diffutils-boot0) ; for tests
571 (current-source-location)
572 #:guile %bootstrap-guile)))
575 (define %boot0-inputs
576 `(("make" ,gnu-make-boot0)
577 ("diffutils" ,diffutils-boot0)
578 ("findutils" ,findutils-boot0)
579 ,@%bootstrap-inputs))
581 (define* (nix-system->gnu-triplet system #:optional (vendor "unknown"))
582 "Return an a guess of the GNU triplet corresponding to Nix system
584 (let* ((dash (string-index system #\-))
585 (arch (substring system 0 dash))
586 (os (substring system (+ 1 dash))))
589 (if (string=? os "linux")
594 ;; Return the triplet used to create the cross toolchain needed in the
595 ;; first bootstrapping stage.
596 (cut nix-system->gnu-triplet <> "guix"))
598 ;; Following Linux From Scratch, build a cross-toolchain in stage 0. That
599 ;; toolchain actually targets the same OS and arch, but it has the advantage
600 ;; of being independent of the libc and tools in %BOOTSTRAP-INPUTS, since
601 ;; GCC-BOOT0 (below) is built without any reference to the target libc.
603 (define binutils-boot0
604 (package-with-bootstrap-guile
605 (package (inherit binutils)
606 (name "binutils-cross-boot0")
609 `(#:guile ,%bootstrap-guile
610 #:implicit-inputs? #f
611 ,@(substitute-keyword-arguments (package-arguments binutils)
612 ((#:configure-flags cf)
613 `(list ,(string-append "--target=" (boot-triplet system))))))))
614 (inputs %boot0-inputs))))
617 (package-with-bootstrap-guile
618 (package (inherit gcc-4.7)
619 (name "gcc-cross-boot0")
622 `(#:guile ,%bootstrap-guile
623 #:implicit-inputs? #f
624 #:modules ((guix build gnu-build-system)
629 ,@(substitute-keyword-arguments ((package-arguments gcc-4.7) system)
630 ((#:configure-flags flags)
631 `(append (list ,(string-append "--target="
632 (boot-triplet system))
637 ;; Disable features not needed at this stage.
639 "--enable-languages=c"
640 "--disable-libmudflap"
643 "--disable-libquadmath"
644 "--disable-decimal-float")
645 (remove (cut string-match "--enable-languages.*" <>)
649 'unpack 'unpack-gmp&co
650 (lambda* (#:key inputs #:allow-other-keys)
651 (let ((gmp (assoc-ref %build-inputs "gmp-source"))
652 (mpfr (assoc-ref %build-inputs "mpfr-source"))
653 (mpc (assoc-ref %build-inputs "mpc-source")))
655 ;; To reduce the set of pre-built bootstrap inputs, build
656 ;; GMP & co. from GCC.
657 (for-each (lambda (source)
658 (or (zero? (system* "tar" "xvf" source))
659 (error "failed to unpack tarball"
663 ;; Create symlinks like `gmp' -> `gmp-5.0.5'.
665 `(symlink ,(package-full-name lib)
666 ,(package-name lib)))
669 ;; MPFR headers/lib are found under $(MPFR)/src, but
670 ;; `configure' wrongfully tells MPC too look under
671 ;; $(MPFR), so fix that.
672 (substitute* "configure"
673 (("extra_mpc_mpfr_configure_flags(.+)--with-mpfr-include=([^/]+)/mpfr(.*)--with-mpfr-lib=([^ ]+)/mpfr"
674 _ equals include middle lib)
675 (string-append "extra_mpc_mpfr_configure_flags" equals
676 "--with-mpfr-include=" include
678 "--with-mpfr-lib=" lib
680 (("gmpinc='-I([^ ]+)/mpfr -I([^ ]+)/mpfr" _ a b)
681 (string-append "gmpinc='-I" a "/mpfr/src "
683 (("gmplibs='-L([^ ]+)/mpfr" _ a)
684 (string-append "gmplibs='-L" a "/mpfr/src")))))
686 'install 'symlink-libgcc_eh
687 (lambda* (#:key outputs #:allow-other-keys)
688 (let ((out (assoc-ref outputs "out")))
689 ;; Glibc wants to link against libgcc_eh, so provide
691 (with-directory-excursion
692 (string-append out "/lib/gcc/"
693 ,(boot-triplet system)
694 "/" ,(package-version gcc-4.7))
695 (symlink "libgcc.a" "libgcc_eh.a"))))
698 (inputs `(("gmp-source" ,(package-source gmp))
699 ("mpfr-source" ,(package-source mpfr))
700 ("mpc-source" ,(package-source mpc))
701 ("binutils-cross" ,binutils-boot0)
703 ;; Call it differently so that the builder can check whether
704 ;; the "libc" input is #f.
705 ("libc-native" ,@(assoc-ref %boot0-inputs "libc"))
706 ,@(alist-delete "libc" %boot0-inputs))))))
708 (define linux-libre-headers-boot0
709 (package-with-bootstrap-guile
710 (package (inherit linux-libre-headers)
711 (arguments `(#:guile ,%bootstrap-guile
712 #:implicit-inputs? #f
713 ,@(package-arguments linux-libre-headers)))
715 (let ((perl (package-with-explicit-inputs perl
717 (current-source-location)
718 #:guile %bootstrap-guile)))
720 ,@%boot0-inputs))))))
722 (define %boot1-inputs
725 ("binutils-cross" ,binutils-boot0)
727 ;; Keep "binutils" here because the cross-gcc invokes `as', not the
731 (define-public glibc-final
732 ;; The final libc, "cross-built". If everything went well, the resulting
733 ;; store path has no dependencies.
734 (package-with-bootstrap-guile
735 (package (inherit glibc)
738 `(#:guile ,%bootstrap-guile
739 #:implicit-inputs? #f
741 ;; Leave /bin/sh as the interpreter for `ldd', `sotruss', etc. to
742 ;; avoid keeping a reference to the bootstrap Bash.
744 ,@(substitute-keyword-arguments (package-arguments glibc)
745 ((#:configure-flags flags)
746 `(append (list ,(string-append "--host=" (boot-triplet system))
747 ,(string-append "--build="
748 (nix-system->gnu-triplet system))
751 ;; Build Sun/ONC RPC support. In particular,
753 "--enable-obsolete-rpc")
755 (propagated-inputs `(("linux-headers" ,linux-libre-headers-boot0)))
756 (inputs `( ;; A native GCC is needed to build `cross-rpcgen'.
757 ("native-gcc" ,@(assoc-ref %boot0-inputs "gcc"))
759 ,@(package-inputs glibc)))))) ; patches
761 (define gcc-boot0-wrapped
762 ;; Make the cross-tools GCC-BOOT0 and BINUTILS-BOOT0 available under the
764 (package (inherit gcc-4.7)
765 (name (string-append (package-name gcc-boot0) "-wrapped"))
767 (build-system trivial-build-system)
770 `(#:guile ,%bootstrap-guile
771 #:modules ((guix build utils))
773 (use-modules (guix build utils))
775 (let* ((binutils (assoc-ref %build-inputs "binutils"))
776 (gcc (assoc-ref %build-inputs "gcc"))
777 (libc (assoc-ref %build-inputs "libc"))
778 (bash (assoc-ref %build-inputs "bash"))
779 (out (assoc-ref %outputs "out"))
780 (bindir (string-append out "/bin"))
781 (triplet ,(boot-triplet system)))
783 (with-directory-excursion bindir
784 (for-each (lambda (tool)
785 (symlink (string-append binutils "/bin/"
790 ;; GCC-BOOT0 is a libc-less cross-compiler, so it
791 ;; needs to be told where to find the crt files and
792 ;; the dynamic linker.
793 (call-with-output-file "gcc"
795 (format p "#!~a/bin/bash
796 exec ~a/bin/~a-gcc -B~a/lib -Wl,-dynamic-linker -Wl,~a/~a \"$@\"~%"
800 ,(glibc-dynamic-linker system))))
802 (chmod "gcc" #o555)))))))
804 `(("binutils" ,binutils-boot0)
806 ("libc" ,glibc-final)
807 ,(assoc "bash" %boot1-inputs)))
810 (define %boot2-inputs
812 `(("libc" ,glibc-final)
813 ("gcc" ,gcc-boot0-wrapped)
814 ,@(fold alist-delete %boot1-inputs '("libc" "gcc"))))
816 (define-public binutils-final
817 (package-with-bootstrap-guile
818 (package (inherit binutils)
821 `(#:guile ,%bootstrap-guile
822 #:implicit-inputs? #f
823 ,@(package-arguments binutils))))
824 (inputs %boot2-inputs))))
826 (define-public gcc-final
828 (package (inherit gcc-boot0)
832 `(#:guile ,%bootstrap-guile
833 #:implicit-inputs? #f
835 ;; Build again GMP & co. within GCC's build process, because it's hard
836 ;; to do outside (because GCC-BOOT0 is a cross-compiler, and thus
837 ;; doesn't honor $LIBRARY_PATH, which breaks `gnu-build-system'.)
838 ,@(substitute-keyword-arguments ((package-arguments gcc-boot0) system)
839 ((#:configure-flags boot-flags)
840 (let loop ((args ((package-arguments gcc-4.7) system)))
842 ((#:configure-flags normal-flags _ ...)
847 `(alist-delete 'symlink-libgcc_eh ,phases))))))
849 (inputs `(("gmp-source" ,(package-source gmp))
850 ("mpfr-source" ,(package-source mpfr))
851 ("mpc-source" ,(package-source mpc))
852 ("binutils" ,binutils-final)
855 (define ld-wrapper-boot3
856 ;; A linker wrapper that uses the bootstrap Guile.
858 (name "ld-wrapper-boot3")
861 (build-system trivial-build-system)
862 (inputs `(("binutils" ,binutils-final)
863 ("guile" ,%bootstrap-guile)
864 ("wrapper" ,(search-path %load-path
865 "distro/packages/ld-wrapper.scm"))))
867 `(#:guile ,%bootstrap-guile
868 #:modules ((guix build utils))
870 (use-modules (guix build utils)
871 (system base compile))
873 (let* ((out (assoc-ref %outputs "out"))
874 (bin (string-append out "/bin"))
875 (ld (string-append bin "/ld"))
876 (go (string-append bin "/ld.go")))
878 (setvbuf (current-output-port) _IOLBF)
879 (format #t "building ~s/bin/ld wrapper in ~s~%"
880 (assoc-ref %build-inputs "binutils")
884 (copy-file (assoc-ref %build-inputs "wrapper") ld)
887 (string-append (assoc-ref %build-inputs "guile")
890 (string-append (assoc-ref %build-inputs "binutils")
893 (compile-file ld #:output-file go)))))
894 (synopsis "The linker wrapper")
896 "The linker wrapper (or `ld-wrapper') wraps the linker to add any
897 missing `-rpath' flags, and to detect any misuse of libraries outside of the
902 (define %boot3-inputs
905 ("ld-wrapper" ,ld-wrapper-boot3)
906 ,@(alist-delete "gcc" %boot2-inputs)))
908 (define-public bash-final
909 ;; Link with `-static-libgcc' to make sure we don't retain a reference
910 ;; to the bootstrap GCC.
911 (package-with-bootstrap-guile
912 (package-with-explicit-inputs (static-libgcc-package bash)
914 (current-source-location)
915 #:guile %bootstrap-guile)))
917 (define %boot4-inputs
918 ;; Now use the final Bash.
919 `(("bash" ,bash-final)
920 ,@(alist-delete "bash" %boot3-inputs)))
922 (define-public guile-final
923 ;; FIXME: The Libtool used here, specifically its `bin/libtool' script,
924 ;; holds a dependency on the bootstrap Binutils. Use multiple outputs for
925 ;; Libtool, so that that dependency is isolated in the "bin" output.
926 (package-with-bootstrap-guile
927 (package-with-explicit-inputs guile-2.0/fixed
929 (current-source-location)
930 #:guile %bootstrap-guile)))
932 (define-public ld-wrapper
933 ;; The final `ld' wrapper, which uses the final Guile.
934 (package (inherit ld-wrapper-boot3)
936 (inputs `(("guile" ,guile-final)
937 ,@(alist-delete "guile" (package-inputs ld-wrapper-boot3))))))
939 (define-public %final-inputs
940 ;; Final derivations used as implicit inputs by `gnu-build-system'.
941 (let ((finalize (cut package-with-explicit-inputs <> %boot4-inputs
942 (current-source-location))))
943 `(,@(map (match-lambda
945 (list name (finalize package))))
950 ("diffutils" ,diffutils)
952 ("coreutils" ,coreutils)
955 ("findutils" ,findutils)
959 ("ld-wrapper" ,ld-wrapper)
960 ("binutils" ,binutils-final)
962 ("libc" ,glibc-final))))
964 ;;; base.scm ends here