distro: ld-wrapper: Use the current Bash instead of /bin/sh.
[jackhill/guix/guix.git] / distro / packages / base.scm
CommitLineData
e3ce5d70
LC
1;;; Guix --- Nix package management from Guile. -*- coding: utf-8 -*-
2;;; Copyright (C) 2012 Ludovic Courtès <ludo@gnu.org>
a52e429f 3;;; Copyright (C) 2012 Nikita Karetnikov <nikita@karetnikov.org>
e3ce5d70
LC
4;;;
5;;; This file is part of Guix.
6;;;
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.
11;;;
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.
16;;;
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/>.
19
1f455fdc 20(define-module (distro packages base)
4a44e743 21 #:use-module (guix licenses)
800cdeef 22 #:use-module (distro)
c44899a2 23 #:use-module (distro packages bash)
18633d4f 24 #:use-module (distro packages bootstrap)
a268f085 25 #:use-module (distro packages compression)
c44899a2
LC
26 #:use-module (distro packages gawk)
27 #:use-module (distro packages guile)
28 #:use-module (distro packages multiprecision)
29 #:use-module (distro packages perl)
80fe5c60 30 #:use-module (distro packages linux)
e3ce5d70 31 #:use-module (guix packages)
87f5d366 32 #:use-module (guix download)
e3ce5d70 33 #:use-module (guix build-system gnu)
321b0996 34 #:use-module (guix build-system trivial)
60f984b2
LC
35 #:use-module (guix utils)
36 #:use-module (srfi srfi-1)
37 #:use-module (srfi srfi-26)
38 #:use-module (ice-9 match))
e3ce5d70
LC
39
40;;; Commentary:
41;;;
1722d680 42;;; Base packages of the Guix-based GNU user-land software distribution.
e3ce5d70
LC
43;;;
44;;; Code:
45
46(define-public hello
47 (package
48 (name "hello")
49 (version "2.8")
90c68be8 50 (source (origin
87f5d366 51 (method url-fetch)
0db342a5 52 (uri (string-append "mirror://gnu/hello/hello-" version
90c68be8 53 ".tar.gz"))
e3ce5d70 54 (sha256
e4c245f8 55 (base32 "0wqd8sjmxfskrflaxywc7gqw7sfawrfvdxd9skxawzfgyy0pzdz6"))))
e3ce5d70
LC
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")))))
64fddd74 61 (inputs `(("gawk" ,gawk)))
d45122f5
LC
62 (synopsis "GNU Hello")
63 (description "Yeah...")
45753b65 64 (home-page "http://www.gnu.org/software/hello/")
4a44e743 65 (license gpl3+)))
d7672884 66
6794b278
LC
67(define-public grep
68 (package
69 (name "grep")
70 (version "2.14")
71 (source (origin
87f5d366 72 (method url-fetch)
0db342a5 73 (uri (string-append "mirror://gnu/grep/grep-"
6794b278
LC
74 version ".tar.xz"))
75 (sha256
76 (base32
77 "1qbjb1l7f9blckc5pqy8jlf6482hpx4awn2acmhyf5mv9wfq03p7"))))
78 (build-system gnu-build-system)
d45122f5
LC
79 (synopsis "GNU implementation of the Unix grep command")
80 (description
6794b278
LC
81 "The grep command searches one or more input files for lines containing a
82match to a specified pattern. By default, grep prints the matching
83lines.")
4a44e743 84 (license gpl3+)
6794b278
LC
85 (home-page "http://www.gnu.org/software/grep/")))
86
8dcad9aa
LC
87(define-public sed
88 (package
89 (name "sed")
90 (version "4.2.1")
91 (source (origin
87f5d366 92 (method url-fetch)
0db342a5 93 (uri (string-append "mirror://gnu/sed/sed-" version
8dcad9aa
LC
94 ".tar.bz2"))
95 (sha256
96 (base32
97 "13wlsb4sf5d5a82xjhxqmdvrrn36rmw5f0pl9qyb9zkvldnb7hra"))))
98 (build-system gnu-build-system)
d45122f5
LC
99 (synopsis "GNU sed, a batch stream editor")
100 (description
8dcad9aa
LC
101 "Sed (stream editor) isn't really a true text editor or text processor.
102Instead, it is used to filter text, i.e., it takes text input and performs
103some operation (or set of operations) on it and outputs the modified text.
104Sed is typically used for extracting part of a file using pattern matching or
105substituting multiple occurrences of a string within a file.")
4a44e743 106 (license gpl3+)
8dcad9aa
LC
107 (home-page "http://www.gnu.org/software/sed/")))
108
85240322
LC
109(define-public tar
110 (package
111 (name "tar")
112 (version "1.26")
113 (source (origin
87f5d366 114 (method url-fetch)
0db342a5 115 (uri (string-append "mirror://gnu/tar/tar-"
85240322
LC
116 version ".tar.bz2"))
117 (sha256
118 (base32
119 "0hbdkzmchq9ycr2x1pxqdcgdbaxksh8c6ac0jf75jajhcks6jlss"))))
120 (build-system gnu-build-system)
472894aa
LC
121 (inputs `(("patch/gets" ,(search-patch "tar-gets-undeclared.patch"))))
122 (arguments
123 `(#:patches (list (assoc-ref %build-inputs "patch/gets"))))
d45122f5
LC
124 (synopsis "GNU implementation of the `tar' archiver")
125 (description
85240322
LC
126 "The Tar program provides the ability to create tar archives, as well as
127various other kinds of manipulation. For example, you can use Tar on
128previously created archives to extract files, to store additional files, or
129to update or list files which were already stored.
130
131Initially, tar archives were used to store files conveniently on magnetic
132tape. The name \"Tar\" comes from this use; it stands for tape archiver.
133Despite the utility's name, Tar can direct its output to available devices,
134files, or other programs (using pipes), it can even access remote devices or
135files (as archives).")
4a44e743 136 (license gpl3+)
85240322
LC
137 (home-page "http://www.gnu.org/software/tar/")))
138
fbeec3d9
LC
139(define-public patch
140 (package
141 (name "patch")
142 (version "2.6.1")
143 (source (origin
87f5d366 144 (method url-fetch)
0db342a5 145 (uri (string-append "mirror://gnu/patch/patch-"
fbeec3d9
LC
146 version ".tar.xz"))
147 (sha256
148 (base32
149 "18012gxs9wc96izskp1q7bclrwns6rdmkn4jj31c8jbyfz6l5npq"))))
150 (build-system gnu-build-system)
151 (native-inputs '()) ; FIXME: needs `ed' for the tests
152 (arguments
153 (case-lambda
154 ((system) '(#:tests? #f))
155 ((system cross-system)
156 '(#:configure-flags '("ac_cv_func_strnlen_working=yes")))))
d45122f5
LC
157 (synopsis "GNU Patch, a program to apply differences to files")
158 (description
fbeec3d9
LC
159 "GNU Patch takes a patch file containing a difference listing produced by
160the diff program and applies those differences to one or more original files,
161producing patched versions.")
4a44e743 162 (license gpl3+)
fbeec3d9
LC
163 (home-page "http://savannah.gnu.org/projects/patch/")))
164
04a32ee5
LC
165(define-public diffutils
166 (package
167 (name "diffutils")
168 (version "3.2")
169 (source (origin
87f5d366 170 (method url-fetch)
0db342a5 171 (uri (string-append "mirror://gnu/diffutils/diffutils-"
04a32ee5
LC
172 version ".tar.xz"))
173 (sha256
174 (base32
175 "0jci0wv68025xd0s0rq4s5qxpx56dd9d730lka63qpzk1rfvfkxb"))))
176 (build-system gnu-build-system)
a5071b99
LC
177 (inputs `(("patch/gets"
178 ,(search-patch "diffutils-gets-undeclared.patch"))))
179 (arguments `(#:patches (list (assoc-ref %build-inputs "patch/gets"))))
d45122f5
LC
180 (synopsis "Programs to find differences among text files")
181 (description
04a32ee5
LC
182 "GNU Diffutils is a package of several programs related to finding
183differences between files.
184
185Computer users often find occasion to ask how two files differ. Perhaps one
186file is a newer version of the other file. Or maybe the two files started out
187as identical copies but were changed by different people.
188
189You can use the diff command to show differences between two files, or each
190corresponding file in two directories. diff outputs differences between files
191line by line in any of several formats, selectable by command line
192options. This set of differences is often called a ‘diff’ or ‘patch’. For
193files that are identical, diff normally produces no output; for
194binary (non-text) files, diff normally reports only that they are different.
195
196You can use the cmp command to show the offsets and line numbers where two
197files differ. cmp can also show all the characters that differ between the
198two files, side by side.
199
200You can use the diff3 command to show differences among three files. When two
201people have made independent changes to a common original, diff3 can report
202the differences between the original and the two changed versions, and can
203produce a merged file that contains both persons' changes together with
204warnings about conflicts.
205
206You can use the sdiff command to merge two files interactively.")
4a44e743 207 (license gpl3+)
04a32ee5
LC
208 (home-page "http://www.gnu.org/software/diffutils/")))
209
af5521ca
LC
210(define-public findutils
211 (package
212 (name "findutils")
213 (version "4.4.2")
214 (source (origin
87f5d366 215 (method url-fetch)
0db342a5 216 (uri (string-append "mirror://gnu/findutils/findutils-"
af5521ca
LC
217 version ".tar.gz"))
218 (sha256
219 (base32
220 "0amn0bbwqvsvvsh6drfwz20ydc2czk374lzw5kksbh6bf78k4ks3"))))
221 (build-system gnu-build-system)
222 (native-inputs
223 `(("patch/absolute-paths"
800cdeef 224 ,(search-patch "findutils-absolute-paths.patch"))))
af5521ca
LC
225 (arguments
226 (case-lambda
227 ((system)
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)))))
d45122f5 234 (synopsis "Basic directory searching utilities of the GNU operating
af5521ca 235system")
d45122f5 236 (description
af5521ca
LC
237 "The GNU Find Utilities are the basic directory searching utilities of
238the GNU operating system. These programs are typically used in conjunction
239with other programs to provide modular and powerful directory search and file
240locating capabilities to other commands.
241
242The tools supplied with this package are:
243
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.
248")
4a44e743 249 (license gpl3+)
af5521ca 250 (home-page "http://www.gnu.org/software/findutils/")))
2c957cd2
LC
251
252(define-public coreutils
253 (package
254 (name "coreutils")
255 (version "8.19")
256 (source (origin
87f5d366 257 (method url-fetch)
0db342a5 258 (uri (string-append "mirror://gnu/coreutils/coreutils-"
2c957cd2
LC
259 version ".tar.xz"))
260 (sha256
261 (base32
262 "1rx9x3fp848w4nny7irdkcpkan9fcx24d99v5dkwgkyq7wc76f5d"))))
263 (build-system gnu-build-system)
264 (inputs `()) ; TODO: optional deps: SELinux, ACL, GMP
265 (arguments
dfae21c8 266 '(;; Perl is missing, and some tests are failing.
2c957cd2 267 #:tests? #f))
d45122f5 268 (synopsis
2c957cd2
LC
269 "The basic file, shell and text manipulation utilities of the GNU
270operating system")
d45122f5 271 (description
2c957cd2
LC
272 "The GNU Core Utilities are the basic file, shell and text manipulation
273utilities of the GNU operating system. These are the core utilities which
274are expected to exist on every operating system.")
4a44e743 275 (license gpl3+)
2c957cd2 276 (home-page "http://www.gnu.org/software/coreutils/")))
af5521ca 277
ab776865
LC
278(define-public gnu-make
279 (package
280 (name "make")
281 (version "3.82")
282 (source (origin
87f5d366 283 (method url-fetch)
0db342a5 284 (uri (string-append "mirror://gnu/make/make-" version
ab776865
LC
285 ".tar.bz2"))
286 (sha256
287 (base32
288 "0ri98385hsd7li6rh4l5afcq92v8l2lgiaz85wgcfh4w2wzsghg2"))))
289 (build-system gnu-build-system)
290 (native-inputs
800cdeef 291 `(("patch/impure-dirs" ,(search-patch "make-impure-dirs.patch"))))
ea8fbbf2
LC
292 (arguments
293 '(#:patches (list (assoc-ref %build-inputs "patch/impure-dirs"))
294 #:phases (alist-cons-before
295 'build 'set-default-shell
296 (lambda* (#:key inputs #:allow-other-keys)
297 ;; Change the default shell from /bin/sh.
298 (let ((bash (assoc-ref inputs "bash")))
299 (substitute* "job.c"
300 (("default_shell\\[\\] =.*$")
301 (format #f "default_shell[] = \"~a/bin/bash\";\n"
302 bash)))))
303 %standard-phases)))
d45122f5 304 (synopsis "GNU Make, a program controlling the generation of non-source
ab776865 305files from sources")
d45122f5 306 (description
ab776865
LC
307 "Make is a tool which controls the generation of executables and other
308non-source files of a program from the program's source files.
309
310Make gets its knowledge of how to build your program from a file called the
311makefile, which lists each of the non-source files and how to compute it from
312other files. When you write a program, you should write a makefile for it, so
313that it is possible to use Make to build and install the program.")
4a44e743 314 (license gpl3+)
ab776865
LC
315 (home-page "http://www.gnu.org/software/make/")))
316
8f6201a3
LC
317(define-public binutils
318 (package
319 (name "binutils")
320 (version "2.22")
321 (source (origin
87f5d366 322 (method url-fetch)
0db342a5 323 (uri (string-append "mirror://gnu/binutils/binutils-"
8f6201a3
LC
324 version ".tar.bz2"))
325 (sha256
326 (base32
327 "1a9w66v5dwvbnawshjwqcgz7km6kw6ihkzp6sswv9ycc3knzhykc"))))
328 (build-system gnu-build-system)
329
330 ;; TODO: Add dependency on zlib + those for Gold.
331 (native-inputs
332 `(("patch/new-dtags" ,(search-patch "binutils-ld-new-dtags.patch"))))
333 (arguments
334 `(#:patches (list (assoc-ref %build-inputs "patch/new-dtags"))
01d45404
LC
335 #:configure-flags '(;; Add `-static-libgcc' to not retain a dependency
336 ;; on GCC when bootstrapping.
337 "LDFLAGS=-static-libgcc"
8f6201a3 338
01d45404
LC
339 ;; Don't search under /usr/lib & co.
340 "--with-lib-path=/no-ld-lib-path")))
8f6201a3 341
d45122f5 342 (synopsis "GNU Binutils, tools for manipulating binaries (linker,
8f6201a3 343assembler, etc.)")
d45122f5 344 (description
8f6201a3
LC
345 "The GNU Binutils are a collection of binary tools. The main ones are
346`ld' (the GNU linker) and `as' (the GNU assembler). They also include the
347BFD (Binary File Descriptor) library, `gprof', `nm', `strip', etc.")
4a44e743 348 (license gpl3+)
8f6201a3
LC
349 (home-page "http://www.gnu.org/software/binutils/")))
350
81e57ec5
LC
351(define-public gcc-4.7
352 (let ((stripped? #t)) ; TODO: make this a parameter
353 (package
354 (name "gcc")
8ffae202 355 (version "4.7.2")
81e57ec5 356 (source (origin
87f5d366 357 (method url-fetch)
0db342a5 358 (uri (string-append "mirror://gnu/gcc/gcc-"
81e57ec5
LC
359 version "/gcc-" version ".tar.bz2"))
360 (sha256
361 (base32
8ffae202 362 "115h03hil99ljig8lkrq4qk426awmzh0g99wrrggxf8g07bq74la"))))
81e57ec5 363 (build-system gnu-build-system)
dc0a9729 364 (inputs `(("gmp" ,gmp)
81e57ec5
LC
365 ("mpfr" ,mpfr)
366 ("mpc" ,mpc))) ; TODO: libelf, ppl, cloog, zlib, etc.
367 (arguments
a52e429f
NK
368 (lambda (system)
369 `(#:out-of-source? #t
370 #:strip-binaries? ,stripped?
371 #:configure-flags
372 `("--enable-plugin"
373 "--enable-languages=c,c++"
374 "--disable-multilib"
01d45404
LC
375
376 "--with-local-prefix=/no-gcc-local-prefix"
377
a52e429f
NK
378 ,(let ((libc (assoc-ref %build-inputs "libc")))
379 (if libc
380 (string-append "--with-native-system-header-dir=" libc
381 "/include")
382 "--without-headers")))
383 #:make-flags
384 (let ((libc (assoc-ref %build-inputs "libc")))
385 `(,@(if libc
386 (list (string-append "LDFLAGS_FOR_BUILD="
387 "-L" libc "/lib "
388 "-Wl,-dynamic-linker "
389 "-Wl," libc
390 ,(glibc-dynamic-linker system)))
391 '())
392 ,(string-append "BOOT_CFLAGS=-O2 "
393 ,(if stripped? "-g0" "-g"))))
394
395 #:tests? #f
396 #:phases
397 (alist-cons-before
398 'configure 'pre-configure
399 (lambda* (#:key inputs outputs #:allow-other-keys)
400 (let ((out (assoc-ref outputs "out"))
401 (libc (assoc-ref inputs "libc")))
402 (when libc
403 ;; The following is not performed for `--without-headers'
404 ;; cross-compiler builds.
405
406 ;; Fix the dynamic linker's file name.
fc95fdae
LC
407 (substitute* (find-files "gcc/config"
408 "^linux(64|-elf)?\\.h$")
a52e429f
NK
409 (("#define GLIBC_DYNAMIC_LINKER([^ ]*).*$" _ suffix)
410 (format #f "#define GLIBC_DYNAMIC_LINKER~a \"~a\"~%"
411 suffix
412 (string-append libc ,(glibc-dynamic-linker system)))))
413
414 ;; Tell where to find libstdc++, libc, and `?crt*.o', except
415 ;; `crt{begin,end}.o', which come with GCC.
fc95fdae
LC
416 (substitute* (find-files "gcc/config"
417 "^(gnu-user(64)?|linux-elf)\\.h$")
a52e429f 418 (("#define LIB_SPEC (.*)$" _ suffix)
bca114d5
LC
419 ;; Note that with this "lib" spec, we may still add a
420 ;; RUNPATH to GCC even when `libgcc_s' is not NEEDED.
421 ;; There's not much that can be done to avoid it, though.
422 (format #f "#define LIB_SPEC \"-L~a/lib %{!static:-rpath=~a/lib \
423%{!static-libgcc:-rpath=~a/lib64 -rpath=~a/lib}} \" ~a~%"
a52e429f 424 libc libc out out suffix))
3f8de86d
LC
425 (("#define STARTFILE_SPEC.*$" line)
426 (format #f "#define STANDARD_STARTFILE_PREFIX_1 \"~a/lib\"
427#define STANDARD_STARTFILE_PREFIX_2 \"\"
428~a~%"
429 libc line))))
a52e429f
NK
430
431 ;; Don't retain a dependency on the build-time sed.
432 (substitute* "fixincludes/fixincl.x"
433 (("static char const sed_cmd_z\\[\\] =.*;")
434 "static char const sed_cmd_z[] = \"sed\";"))))
435
436 (alist-cons-after
437 'configure 'post-configure
438 (lambda _
439 ;; Don't store configure flags, to avoid retaining references to
440 ;; build-time dependencies---e.g., `--with-ppl=/nix/store/xxx'.
441 (substitute* "Makefile"
442 (("^TOPLEVEL_CONFIGURE_ARGUMENTS=(.*)$" _ rest)
443 "TOPLEVEL_CONFIGURE_ARGUMENTS=\n")))
444 (alist-replace 'install
445 (lambda* (#:key outputs #:allow-other-keys)
446 (zero?
447 (system* "make"
448 ,(if stripped?
449 "install-strip"
450 "install"))))
451 %standard-phases))))))
81e57ec5
LC
452
453 (properties `((gcc-libc . ,(assoc-ref inputs "libc"))))
d45122f5
LC
454 (synopsis "The GNU Compiler Collection")
455 (description
81e57ec5
LC
456 "The GNU Compiler Collection includes compiler front ends for C, C++,
457Objective-C, Fortran, OpenMP for C/C++/Fortran, Java, and Ada, as well as
458libraries for these languages (libstdc++, libgcj, libgomp,...).
459
460GCC development is a part of the GNU Project, aiming to improve the compiler
461used in the GNU system including the GNU/Linux variant.")
4a44e743 462 (license gpl3+)
81e57ec5
LC
463 (home-page "http://gcc.gnu.org/"))))
464
7cdeac02
LC
465(define-public glibc
466 (package
467 (name "glibc")
468 (version "2.16.0")
469 (source (origin
87f5d366 470 (method url-fetch)
0db342a5 471 (uri (string-append "mirror://gnu/glibc/glibc-"
7cdeac02
LC
472 version ".tar.xz"))
473 (sha256
474 (base32
475 "092rdm49zh6l1pqkxbcpcaawgsgzxhpf1s7wf5wi5dvc5am3dp0y"))))
476 (build-system gnu-build-system)
0a3da5b7
LC
477
478 ;; Glibc's <limits.h> refers to <linux/limit.h>, for instance, so glibc
479 ;; users should automatically pull Linux headers as well.
124b1767 480 (propagated-inputs `(("linux-headers" ,linux-libre-headers)))
0a3da5b7 481
7cdeac02 482 (arguments
8197c978 483 `(#:out-of-source? #t
25608d64 484 #:patches (list (assoc-ref %build-inputs "patch/ld.so.cache"))
7cdeac02
LC
485 #:configure-flags
486 (list "--enable-add-ons"
487 "--sysconfdir=/etc"
488 "--localedir=/var/run/current-system/sw/lib/locale" ; XXX
489 (string-append "--with-headers="
490 (assoc-ref %build-inputs "linux-headers")
491 "/include")
5f456680
LC
492
493 ;; The default is to assume a 2.4 Linux interface, but we'll
494 ;; always use something newer. See "kernel-features.h" in the
495 ;; GNU libc for details.
496 "--enable-kernel=2.6.30"
497
7cdeac02
LC
498 ;; XXX: Work around "undefined reference to `__stack_chk_guard'".
499 "libc_cv_ssp=no")
500 #:tests? #f ; XXX
501 #:phases (alist-cons-before
502 'configure 'pre-configure
503 (lambda* (#:key outputs #:allow-other-keys)
504 (let ((out (assoc-ref outputs "out")))
505 ;; Use `pwd', not `/bin/pwd'.
506 (substitute* "configure"
0a3da5b7 507 (("/bin/pwd") "pwd"))
7cdeac02
LC
508
509 ;; Install the rpc data base file under `$out/etc/rpc'.
8197c978 510 ;; FIXME: Use installFlags = [ "sysconfdir=$(out)/etc" ];
7cdeac02
LC
511 (substitute* "sunrpc/Makefile"
512 (("^\\$\\(inst_sysconfdir\\)/rpc(.*)$" _ suffix)
513 (string-append out "/etc/rpc" suffix "\n"))
514 (("^install-others =.*$")
321b0996
LC
515 (string-append "install-others = " out "/etc/rpc\n")))
516
517 (substitute* "Makeconfig"
518 ;; According to
519 ;; <http://www.linuxfromscratch.org/lfs/view/stable/chapter05/glibc.html>,
520 ;; linking against libgcc_s is not needed with GCC
521 ;; 4.7.1.
522 ((" -lgcc_s") ""))))
7cdeac02 523 %standard-phases)))
25608d64
LC
524 (inputs `(("patch/ld.so.cache"
525 ,(search-patch "glibc-no-ld-so-cache.patch"))))
d45122f5
LC
526 (synopsis "The GNU C Library")
527 (description
7cdeac02
LC
528 "Any Unix-like operating system needs a C library: the library which
529defines the \"system calls\" and other basic facilities such as open, malloc,
530printf, exit...
531
532The GNU C library is used as the C library in the GNU system and most systems
533with the Linux kernel.")
4a44e743 534 (license lgpl2.0+)
7cdeac02
LC
535 (home-page "http://www.gnu.org/software/libc/")))
536
60f984b2
LC
537\f
538;;;
539;;; Bootstrap packages.
540;;;
541
3c0670e6 542(define gnu-make-boot0
d6e87776
LC
543 (package-with-bootstrap-guile
544 (package (inherit gnu-make)
545 (name "make-boot0")
546 (location (source-properties->location (current-source-location)))
ea8fbbf2
LC
547 (arguments
548 `(#:guile ,%bootstrap-guile
549 #:implicit-inputs? #f
550 #:tests? #f ; cannot run "make check"
551 ,@(substitute-keyword-arguments (package-arguments gnu-make)
552 ((#:phases phases)
553 `(alist-replace
554 'build (lambda _
555 (zero? (system* "./build.sh")))
556 (alist-replace
557 'install (lambda* (#:key outputs #:allow-other-keys)
558 (let* ((out (assoc-ref outputs "out"))
559 (bin (string-append out "/bin")))
560 (mkdir-p bin)
561 (copy-file "make"
562 (string-append bin "/make"))))
563 ,phases))))))
d6e87776 564 (inputs %bootstrap-inputs))))
3c0670e6
LC
565
566(define diffutils-boot0
d6e87776
LC
567 (package-with-bootstrap-guile
568 (let ((p (package-with-explicit-inputs diffutils
569 `(("make" ,gnu-make-boot0)
570 ,@%bootstrap-inputs)
571 #:guile %bootstrap-guile)))
572 (package (inherit p)
573 (location (source-properties->location (current-source-location)))
574 (arguments `(#:tests? #f ; the test suite needs diffutils
575 ,@(package-arguments p)))))))
3c0670e6
LC
576
577(define findutils-boot0
d6e87776
LC
578 (package-with-bootstrap-guile
579 (package-with-explicit-inputs findutils
580 `(("make" ,gnu-make-boot0)
581 ("diffutils" ,diffutils-boot0) ; for tests
582 ,@%bootstrap-inputs)
583 (current-source-location)
584 #:guile %bootstrap-guile)))
3c0670e6
LC
585
586
587(define %boot0-inputs
588 `(("make" ,gnu-make-boot0)
589 ("diffutils" ,diffutils-boot0)
590 ("findutils" ,findutils-boot0)
591 ,@%bootstrap-inputs))
592
321b0996
LC
593(define* (nix-system->gnu-triplet system #:optional (vendor "unknown"))
594 "Return an a guess of the GNU triplet corresponding to Nix system
595identifier SYSTEM."
596 (let* ((dash (string-index system #\-))
597 (arch (substring system 0 dash))
598 (os (substring system (+ 1 dash))))
599 (string-append arch
600 "-" vendor "-"
601 (if (string=? os "linux")
602 "linux-gnu"
603 os))))
604
605(define boot-triplet
606 ;; Return the triplet used to create the cross toolchain needed in the
607 ;; first bootstrapping stage.
608 (cut nix-system->gnu-triplet <> "guix"))
609
610;; Following Linux From Scratch, build a cross-toolchain in stage 0. That
611;; toolchain actually targets the same OS and arch, but it has the advantage
612;; of being independent of the libc and tools in %BOOTSTRAP-INPUTS, since
613;; GCC-BOOT0 (below) is built without any reference to the target libc.
614
615(define binutils-boot0
d6e87776
LC
616 (package-with-bootstrap-guile
617 (package (inherit binutils)
618 (name "binutils-cross-boot0")
619 (arguments
620 (lambda (system)
621 `(#:guile ,%bootstrap-guile
622 #:implicit-inputs? #f
623 ,@(substitute-keyword-arguments (package-arguments binutils)
624 ((#:configure-flags cf)
625 `(list ,(string-append "--target=" (boot-triplet system))))))))
626 (inputs %boot0-inputs))))
321b0996 627
60f984b2 628(define gcc-boot0
d6e87776
LC
629 (package-with-bootstrap-guile
630 (package (inherit gcc-4.7)
631 (name "gcc-cross-boot0")
632 (arguments
633 (lambda (system)
634 `(#:guile ,%bootstrap-guile
635 #:implicit-inputs? #f
636 #:modules ((guix build gnu-build-system)
637 (guix build utils)
638 (ice-9 regex)
639 (srfi srfi-1)
640 (srfi srfi-26))
641 ,@(substitute-keyword-arguments ((package-arguments gcc-4.7) system)
642 ((#:configure-flags flags)
643 `(append (list ,(string-append "--target="
644 (boot-triplet system))
645
646 ;; No libc yet.
647 "--without-headers"
648
649 ;; Disable features not needed at this stage.
650 "--disable-shared"
651 "--enable-languages=c"
652 "--disable-libmudflap"
653 "--disable-libgomp"
654 "--disable-libssp"
655 "--disable-libquadmath"
656 "--disable-decimal-float")
657 (remove (cut string-match "--enable-languages.*" <>)
658 ,flags)))
659 ((#:phases phases)
660 `(alist-cons-after
661 'unpack 'unpack-gmp&co
662 (lambda* (#:key inputs #:allow-other-keys)
663 (let ((gmp (assoc-ref %build-inputs "gmp-source"))
664 (mpfr (assoc-ref %build-inputs "mpfr-source"))
665 (mpc (assoc-ref %build-inputs "mpc-source")))
666
667 ;; To reduce the set of pre-built bootstrap inputs, build
668 ;; GMP & co. from GCC.
669 (for-each (lambda (source)
670 (or (zero? (system* "tar" "xvf" source))
671 (error "failed to unpack tarball"
672 source)))
673 (list gmp mpfr mpc))
674
675 ;; Create symlinks like `gmp' -> `gmp-5.0.5'.
676 ,@(map (lambda (lib)
677 `(symlink ,(package-full-name lib)
678 ,(package-name lib)))
679 (list gmp mpfr mpc))
680
681 ;; MPFR headers/lib are found under $(MPFR)/src, but
682 ;; `configure' wrongfully tells MPC too look under
683 ;; $(MPFR), so fix that.
684 (substitute* "configure"
685 (("extra_mpc_mpfr_configure_flags(.+)--with-mpfr-include=([^/]+)/mpfr(.*)--with-mpfr-lib=([^ ]+)/mpfr"
686 _ equals include middle lib)
687 (string-append "extra_mpc_mpfr_configure_flags" equals
688 "--with-mpfr-include=" include
689 "/mpfr/src" middle
690 "--with-mpfr-lib=" lib
691 "/mpfr/src"))
692 (("gmpinc='-I([^ ]+)/mpfr -I([^ ]+)/mpfr" _ a b)
693 (string-append "gmpinc='-I" a "/mpfr/src "
694 "-I" b "/mpfr/src"))
695 (("gmplibs='-L([^ ]+)/mpfr" _ a)
696 (string-append "gmplibs='-L" a "/mpfr/src")))))
697 (alist-cons-after
698 'install 'symlink-libgcc_eh
699 (lambda* (#:key outputs #:allow-other-keys)
700 (let ((out (assoc-ref outputs "out")))
701 ;; Glibc wants to link against libgcc_eh, so provide
702 ;; it.
703 (with-directory-excursion
704 (string-append out "/lib/gcc/"
705 ,(boot-triplet system)
706 "/" ,(package-version gcc-4.7))
707 (symlink "libgcc.a" "libgcc_eh.a"))))
708 ,phases)))))))
709
710 (inputs `(("gmp-source" ,(package-source gmp))
711 ("mpfr-source" ,(package-source mpfr))
712 ("mpc-source" ,(package-source mpc))
713 ("binutils-cross" ,binutils-boot0)
714
715 ;; Call it differently so that the builder can check whether
716 ;; the "libc" input is #f.
717 ("libc-native" ,@(assoc-ref %boot0-inputs "libc"))
718 ,@(alist-delete "libc" %boot0-inputs))))))
60f984b2 719
124b1767 720(define linux-libre-headers-boot0
d6e87776
LC
721 (package-with-bootstrap-guile
722 (package (inherit linux-libre-headers)
723 (arguments `(#:guile ,%bootstrap-guile
724 #:implicit-inputs? #f
725 ,@(package-arguments linux-libre-headers)))
726 (native-inputs
727 (let ((perl (package-with-explicit-inputs perl
728 %boot0-inputs
729 (current-source-location)
730 #:guile %bootstrap-guile)))
731 `(("perl" ,perl)
732 ,@%boot0-inputs))))))
60f984b2
LC
733
734(define %boot1-inputs
735 ;; 2nd stage inputs.
736 `(("gcc" ,gcc-boot0)
321b0996
LC
737 ("binutils-cross" ,binutils-boot0)
738
739 ;; Keep "binutils" here because the cross-gcc invokes `as', not the
740 ;; cross-`as'.
741 ,@%boot0-inputs))
60f984b2
LC
742
743(define-public glibc-final
321b0996
LC
744 ;; The final libc, "cross-built". If everything went well, the resulting
745 ;; store path has no dependencies.
d6e87776
LC
746 (package-with-bootstrap-guile
747 (package (inherit glibc)
748 (arguments
749 (lambda (system)
750 `(#:guile ,%bootstrap-guile
751 #:implicit-inputs? #f
752
753 ;; Leave /bin/sh as the interpreter for `ldd', `sotruss', etc. to
754 ;; avoid keeping a reference to the bootstrap Bash.
755 #:patch-shebangs? #f
756 ,@(substitute-keyword-arguments (package-arguments glibc)
757 ((#:configure-flags flags)
758 `(append (list ,(string-append "--host=" (boot-triplet system))
759 ,(string-append "--build="
760 (nix-system->gnu-triplet system))
761 "BASH_SHELL=/bin/sh"
762
1c702d1e
LC
763 ;; Build Sun/ONC RPC support. In particular,
764 ;; install rpc/*.h.
765 "--enable-obsolete-rpc")
d6e87776
LC
766 ,flags))))))
767 (propagated-inputs `(("linux-headers" ,linux-libre-headers-boot0)))
768 (inputs `( ;; A native GCC is needed to build `cross-rpcgen'.
769 ("native-gcc" ,@(assoc-ref %boot0-inputs "gcc"))
25608d64
LC
770 ,@%boot1-inputs
771 ,@(package-inputs glibc)))))) ; patches
321b0996
LC
772
773(define gcc-boot0-wrapped
774 ;; Make the cross-tools GCC-BOOT0 and BINUTILS-BOOT0 available under the
775 ;; non-cross names.
776 (package (inherit gcc-4.7)
777 (name (string-append (package-name gcc-boot0) "-wrapped"))
d6e87776 778 (source #f)
321b0996
LC
779 (build-system trivial-build-system)
780 (arguments
781 (lambda (system)
2143cf7a
LC
782 `(#:guile ,%bootstrap-guile
783 #:modules ((guix build utils))
321b0996
LC
784 #:builder (begin
785 (use-modules (guix build utils))
786
787 (let* ((binutils (assoc-ref %build-inputs "binutils"))
788 (gcc (assoc-ref %build-inputs "gcc"))
789 (libc (assoc-ref %build-inputs "libc"))
9d1d434c 790 (bash (assoc-ref %build-inputs "bash"))
321b0996
LC
791 (out (assoc-ref %outputs "out"))
792 (bindir (string-append out "/bin"))
793 (triplet ,(boot-triplet system)))
7da95264 794 (mkdir-p bindir)
321b0996
LC
795 (with-directory-excursion bindir
796 (for-each (lambda (tool)
797 (symlink (string-append binutils "/bin/"
798 triplet "-" tool)
799 tool))
800 '("ar" "ranlib"))
801
802 ;; GCC-BOOT0 is a libc-less cross-compiler, so it
803 ;; needs to be told where to find the crt files and
804 ;; the dynamic linker.
805 (call-with-output-file "gcc"
806 (lambda (p)
9d1d434c 807 (format p "#!~a/bin/bash
683d57f4 808exec ~a/bin/~a-gcc -B~a/lib -Wl,-dynamic-linker -Wl,~a/~a \"$@\"~%"
9d1d434c 809 bash
321b0996
LC
810 gcc triplet
811 libc libc
812 ,(glibc-dynamic-linker system))))
813
814 (chmod "gcc" #o555)))))))
815 (native-inputs
816 `(("binutils" ,binutils-boot0)
817 ("gcc" ,gcc-boot0)
9d1d434c 818 ("libc" ,glibc-final)
7f131cf3 819 ,(assoc "bash" %boot1-inputs)))
321b0996 820 (inputs '())))
60f984b2
LC
821
822(define %boot2-inputs
823 ;; 3rd stage inputs.
824 `(("libc" ,glibc-final)
321b0996
LC
825 ("gcc" ,gcc-boot0-wrapped)
826 ,@(fold alist-delete %boot1-inputs '("libc" "gcc"))))
60f984b2 827
8ba60d7b 828(define-public binutils-final
a48dddfe
LC
829 (package-with-bootstrap-guile
830 (package (inherit binutils)
831 (arguments
832 (lambda (system)
833 `(#:guile ,%bootstrap-guile
834 #:implicit-inputs? #f
835 ,@(package-arguments binutils))))
836 (inputs %boot2-inputs))))
60f984b2 837
321b0996
LC
838(define-public gcc-final
839 ;; The final GCC.
840 (package (inherit gcc-boot0)
841 (name "gcc")
60f984b2 842 (arguments
321b0996 843 (lambda (system)
2143cf7a
LC
844 `(#:guile ,%bootstrap-guile
845 #:implicit-inputs? #f
321b0996
LC
846
847 ;; Build again GMP & co. within GCC's build process, because it's hard
848 ;; to do outside (because GCC-BOOT0 is a cross-compiler, and thus
849 ;; doesn't honor $LIBRARY_PATH, which breaks `gnu-build-system'.)
850 ,@(substitute-keyword-arguments ((package-arguments gcc-boot0) system)
851 ((#:configure-flags boot-flags)
a52e429f 852 (let loop ((args ((package-arguments gcc-4.7) system)))
321b0996
LC
853 (match args
854 ((#:configure-flags normal-flags _ ...)
855 normal-flags)
856 ((_ rest ...)
857 (loop rest)))))
858 ((#:phases phases)
859 `(alist-delete 'symlink-libgcc_eh ,phases))))))
860
861 (inputs `(("gmp-source" ,(package-source gmp))
862 ("mpfr-source" ,(package-source mpfr))
863 ("mpc-source" ,(package-source mpc))
864 ("binutils" ,binutils-final)
60f984b2
LC
865 ,@%boot2-inputs))))
866
82dc2b9a
LC
867(define ld-wrapper-boot3
868 ;; A linker wrapper that uses the bootstrap Guile.
869 (package
870 (name "ld-wrapper-boot3")
871 (version "0")
872 (source #f)
873 (build-system trivial-build-system)
874 (inputs `(("binutils" ,binutils-final)
dfb53ee2
LC
875 ("guile" ,%bootstrap-guile)
876 ("bash" ,@(assoc-ref %boot2-inputs "bash"))
877 ("wrapper" ,(search-path %load-path
878 "distro/packages/ld-wrapper.scm"))))
82dc2b9a 879 (arguments
2143cf7a
LC
880 `(#:guile ,%bootstrap-guile
881 #:modules ((guix build utils))
82dc2b9a
LC
882 #:builder (begin
883 (use-modules (guix build utils)
884 (system base compile))
885
886 (let* ((out (assoc-ref %outputs "out"))
887 (bin (string-append out "/bin"))
888 (ld (string-append bin "/ld"))
889 (go (string-append bin "/ld.go")))
890
891 (setvbuf (current-output-port) _IOLBF)
892 (format #t "building ~s/bin/ld wrapper in ~s~%"
893 (assoc-ref %build-inputs "binutils")
894 out)
895
7da95264 896 (mkdir-p bin)
82dc2b9a
LC
897 (copy-file (assoc-ref %build-inputs "wrapper") ld)
898 (substitute* ld
899 (("@GUILE@")
900 (string-append (assoc-ref %build-inputs "guile")
901 "/bin/guile"))
dfb53ee2
LC
902 (("@BASH@")
903 (string-append (assoc-ref %build-inputs "bash")
904 "/bin/bash"))
82dc2b9a
LC
905 (("@LD@")
906 (string-append (assoc-ref %build-inputs "binutils")
907 "/bin/ld")))
908 (chmod ld #o555)
909 (compile-file ld #:output-file go)))))
d45122f5
LC
910 (synopsis "The linker wrapper")
911 (description
82dc2b9a
LC
912 "The linker wrapper (or `ld-wrapper') wraps the linker to add any
913missing `-rpath' flags, and to detect any misuse of libraries outside of the
914store.")
915 (home-page #f)
4a44e743 916 (license gpl3+)))
82dc2b9a 917
60f984b2
LC
918(define %boot3-inputs
919 ;; 4th stage inputs.
60f984b2 920 `(("gcc" ,gcc-final)
82dc2b9a 921 ("ld-wrapper" ,ld-wrapper-boot3)
321b0996 922 ,@(alist-delete "gcc" %boot2-inputs)))
60f984b2 923
82dc2b9a 924(define-public bash-final
ce1ef15b
LC
925 ;; Link with `-static-libgcc' to make sure we don't retain a reference
926 ;; to the bootstrap GCC.
d6e87776 927 (package-with-bootstrap-guile
ce1ef15b
LC
928 (package-with-explicit-inputs (static-libgcc-package bash)
929 %boot3-inputs
d6e87776
LC
930 (current-source-location)
931 #:guile %bootstrap-guile)))
82dc2b9a 932
4033bde8
LC
933(define %boot4-inputs
934 ;; Now use the final Bash.
935 `(("bash" ,bash-final)
936 ,@(alist-delete "bash" %boot3-inputs)))
937
82dc2b9a 938(define-public guile-final
4033bde8
LC
939 ;; FIXME: The Libtool used here, specifically its `bin/libtool' script,
940 ;; holds a dependency on the bootstrap Binutils. Use multiple outputs for
941 ;; Libtool, so that that dependency is isolated in the "bin" output.
d6e87776 942 (package-with-bootstrap-guile
fa29b199 943 (package-with-explicit-inputs guile-2.0/fixed
4033bde8 944 %boot4-inputs
d6e87776
LC
945 (current-source-location)
946 #:guile %bootstrap-guile)))
82dc2b9a
LC
947
948(define-public ld-wrapper
949 ;; The final `ld' wrapper, which uses the final Guile.
950 (package (inherit ld-wrapper-boot3)
951 (name "ld-wrapper")
952 (inputs `(("guile" ,guile-final)
dfb53ee2
LC
953 ("bash" ,bash-final)
954 ,@(fold alist-delete (package-inputs ld-wrapper-boot3)
955 '("guile" "bash"))))))
82dc2b9a 956
60f984b2
LC
957(define-public %final-inputs
958 ;; Final derivations used as implicit inputs by `gnu-build-system'.
4033bde8 959 (let ((finalize (cut package-with-explicit-inputs <> %boot4-inputs
3c0670e6 960 (current-source-location))))
60f984b2
LC
961 `(,@(map (match-lambda
962 ((name package)
963 (list name (finalize package))))
964 `(("tar" ,tar)
965 ("gzip" ,gzip)
6818af7b 966 ("bzip2" ,bzip2)
60f984b2
LC
967 ("xz" ,xz)
968 ("diffutils" ,diffutils)
969 ("patch" ,patch)
970 ("coreutils" ,coreutils)
971 ("sed" ,sed)
972 ("grep" ,grep)
60f984b2
LC
973 ("findutils" ,findutils)
974 ("gawk" ,gawk)
321b0996 975 ("make" ,gnu-make)))
82dc2b9a
LC
976 ("bash" ,bash-final)
977 ("ld-wrapper" ,ld-wrapper)
321b0996 978 ("binutils" ,binutils-final)
60f984b2 979 ("gcc" ,gcc-final)
321b0996 980 ("libc" ,glibc-final))))
60f984b2 981
1722d680 982;;; base.scm ends here