gnu: glibc: Incorporate grafted changes.
[jackhill/guix/guix.git] / gnu / packages / base.scm
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, 2016 Mark H Weaver <mhw@netris.org>
6 ;;; Copyright © 2014 Alex Kost <alezost@gmail.com>
7 ;;; Copyright © 2014, 2015 Manolis Fragkiskos Ragkousis <manolis837@gmail.com>
8 ;;; Copyright © 2016, 2017 Efraim Flashner <efraim@flashner.co.il>
9 ;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
10 ;;; Copyright © 2017 Rene Saavedra <rennes@openmailbox.org>
11 ;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
12 ;;; Copyright © 2017 Marius Bakke <mbakke@fastmail.com>
13 ;;;
14 ;;; This file is part of GNU Guix.
15 ;;;
16 ;;; GNU Guix is free software; you can redistribute it and/or modify it
17 ;;; under the terms of the GNU General Public License as published by
18 ;;; the Free Software Foundation; either version 3 of the License, or (at
19 ;;; your option) any later version.
20 ;;;
21 ;;; GNU Guix is distributed in the hope that it will be useful, but
22 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
23 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 ;;; GNU General Public License for more details.
25 ;;;
26 ;;; You should have received a copy of the GNU General Public License
27 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
28
29 (define-module (gnu packages base)
30 #:use-module ((guix licenses)
31 #:select (gpl3+ lgpl2.0+ lgpl3+ public-domain))
32 #:use-module (gnu packages)
33 #:use-module (gnu packages acl)
34 #:use-module (gnu packages bash)
35 #:use-module (gnu packages ed)
36 #:use-module (gnu packages guile)
37 #:use-module (gnu packages multiprecision)
38 #:use-module (gnu packages compression)
39 #:use-module (gnu packages perl)
40 #:use-module (gnu packages linux)
41 #:use-module (gnu packages texinfo)
42 #:use-module (gnu packages hurd)
43 #:use-module (gnu packages pkg-config)
44 #:use-module (gnu packages gettext)
45 #:use-module (guix utils)
46 #:use-module (guix packages)
47 #:use-module (guix download)
48 #:use-module (guix git-download)
49 #:use-module (guix build-system gnu)
50 #:use-module (guix build-system trivial)
51 #:use-module (ice-9 match)
52 #:export (glibc
53 libiconv-if-needed))
54
55 ;;; Commentary:
56 ;;;
57 ;;; Base packages of the Guix-based GNU user-land software distribution.
58 ;;;
59 ;;; Code:
60
61 (define-public hello
62 (package
63 (name "hello")
64 (version "2.10")
65 (source (origin
66 (method url-fetch)
67 (uri (string-append "mirror://gnu/hello/hello-" version
68 ".tar.gz"))
69 (sha256
70 (base32
71 "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"))))
72 (build-system gnu-build-system)
73 (synopsis "Hello, GNU world: An example GNU package")
74 (description
75 "GNU Hello prints the message \"Hello, world!\" and then exits. It
76 serves as an example of standard GNU coding practices. As such, it supports
77 command-line arguments, multiple languages, and so on.")
78 (home-page "https://www.gnu.org/software/hello/")
79 (license gpl3+)))
80
81 (define-public grep
82 (package
83 (name "grep")
84 (version "3.1")
85 (source (origin
86 (method url-fetch)
87 (uri (string-append "mirror://gnu/grep/grep-"
88 version ".tar.xz"))
89 (sha256
90 (base32
91 "0zm0ywmyz9g8vn1plw14mn8kj74yipx5qsljndbyfgmvndx5qqnv"))
92 (patches (search-patches "grep-timing-sensitive-test.patch"))))
93 (build-system gnu-build-system)
94 (native-inputs `(("perl" ,perl))) ;some of the tests require it
95 (arguments
96 `(#:phases
97 (modify-phases %standard-phases
98 (add-after 'install 'fix-egrep-and-fgrep
99 ;; Patch 'egrep' and 'fgrep' to execute 'grep' via its
100 ;; absolute file name instead of searching for it in $PATH.
101 (lambda* (#:key outputs #:allow-other-keys)
102 (let* ((out (assoc-ref outputs "out"))
103 (bin (string-append out "/bin")))
104 (substitute* (list (string-append bin "/egrep")
105 (string-append bin "/fgrep"))
106 (("^exec grep")
107 (string-append "exec " bin "/grep")))
108 #t))))))
109 (synopsis "Print lines matching a pattern")
110 (description
111 "grep is a tool for finding text inside files. Text is found by
112 matching a pattern provided by the user in one or many files. The pattern
113 may be provided as a basic or extended regular expression, or as fixed
114 strings. By default, the matching text is simply printed to the screen,
115 however the output can be greatly customized to include, for example, line
116 numbers. GNU grep offers many extensions over the standard utility,
117 including, for example, recursive directory searching.")
118 (license gpl3+)
119 (home-page "https://www.gnu.org/software/grep/")))
120
121 (define-public sed
122 (package
123 (name "sed")
124 (version "4.4")
125 (source (origin
126 (method url-fetch)
127 (uri (string-append "mirror://gnu/sed/sed-" version
128 ".tar.xz"))
129 (sha256
130 (base32
131 "0fv88bcnraixc8jvpacvxshi30p5x9m7yb8ns1hfv07hmb2ypmnb"))))
132 (build-system gnu-build-system)
133 (synopsis "Stream editor")
134 (arguments
135 `(#:phases
136 (modify-phases %standard-phases
137 (add-after 'unpack 'dont-rebuild-sed.1
138 (lambda _
139 ;; Make sure we do not attempt to rebuild 'doc/sed.1', which does
140 ;; not work when cross-compiling because we cannot run 'sed'.
141 ;; This is fixed upstream as commit a0a25e3.
142 (substitute* "Makefile.in"
143 (("^doc/sed\\.1:.*")
144 "doc/sed.1:\n"))
145 #t))
146 (add-before 'patch-source-shebangs 'patch-test-suite
147 (lambda* (#:key inputs #:allow-other-keys)
148 (patch-makefile-SHELL "testsuite/Makefile.tests")
149 (substitute* '("testsuite/bsd.sh"
150 "testsuite/bug-regex9.c")
151 (("/bin/sh")
152 (which "sh")))
153 #t)))))
154 (description
155 "Sed is a non-interactive, text stream editor. It receives a text
156 input from a file or from standard input and it then applies a series of text
157 editing commands to the stream and prints its output to standard output. It
158 is often used for substituting text patterns in a stream. The GNU
159 implementation offers several extensions over the standard utility.")
160 (license gpl3+)
161 (home-page "https://www.gnu.org/software/sed/")))
162
163 (define-public tar
164 (package
165 (name "tar")
166 (version "1.29")
167 (source (origin
168 (method url-fetch)
169 (uri (string-append "mirror://gnu/tar/tar-"
170 version ".tar.xz"))
171 (sha256
172 (base32
173 "097hx7sbzp8qirl4m930lw84kn0wmxhmq7v1qpra3mrg0b8cyba0"))
174 (patches (search-patches "tar-CVE-2016-6321.patch"
175 "tar-skip-unreliable-tests.patch"))))
176 (build-system gnu-build-system)
177 ;; Note: test suite requires ~1GiB of disk space.
178 (arguments
179 '(#:phases (modify-phases %standard-phases
180 (add-before 'build 'set-shell-file-name
181 (lambda* (#:key inputs #:allow-other-keys)
182 ;; Do not use "/bin/sh" to run programs.
183 (let ((bash (assoc-ref inputs "bash")))
184 (substitute* "src/system.c"
185 (("/bin/sh")
186 (string-append bash "/bin/sh")))
187 #t))))))
188
189 ;; When cross-compiling, the 'set-shell-file-name' phase needs to be able
190 ;; to refer to the target Bash.
191 (inputs (if (%current-target-system)
192 `(("bash" ,bash))
193 '()))
194
195 (synopsis "Managing tar archives")
196 (description
197 "Tar provides the ability to create tar archives, as well as the
198 ability to extract, update or list files in an existing archive. It is
199 useful for combining many files into one larger file, while maintaining
200 directory structure and file information such as permissions and
201 creation/modification dates. GNU tar offers many extensions over the
202 standard utility.")
203 (license gpl3+)
204 (home-page "https://www.gnu.org/software/tar/")))
205
206 (define-public patch
207 (package
208 (name "patch")
209 (version "2.7.5")
210 (source (origin
211 (method url-fetch)
212 (uri (string-append "mirror://gnu/patch/patch-"
213 version ".tar.xz"))
214 (sha256
215 (base32
216 "16d2r9kpivaak948mxzc0bai45mqfw73m113wrkmbffnalv1b5gx"))
217 (patches (search-patches "patch-hurd-path-max.patch"))))
218 (build-system gnu-build-system)
219 (native-inputs `(("ed" ,ed)))
220 (synopsis "Apply differences to originals, with optional backups")
221 (description
222 "Patch is a program that applies changes to files based on differences
223 laid out as by the program \"diff\". The changes may be applied to one or more
224 files depending on the contents of the diff file. It accepts several
225 different diff formats. It may also be used to revert previously applied
226 differences.")
227 (license gpl3+)
228 (home-page "https://savannah.gnu.org/projects/patch/")))
229
230 (define-public diffutils
231 (package
232 (name "diffutils")
233 (version "3.6")
234 (source (origin
235 (method url-fetch)
236 (uri (string-append "mirror://gnu/diffutils/diffutils-"
237 version ".tar.xz"))
238 (sha256
239 (base32
240 "1mivg0fy3a6fcn535ln8nkgfj6vxh5hsxxs5h6692wxmsjyyh8fn"))))
241 (build-system gnu-build-system)
242 (synopsis "Comparing and merging files")
243 (description
244 "GNU Diffutils is a package containing tools for finding the
245 differences between files. The \"diff\" command is used to show how two files
246 differ, while \"cmp\" shows the offsets and line numbers where they differ.
247 \"diff3\" allows you to compare three files. Finally, \"sdiff\" offers an
248 interactive means to merge two files.")
249 (license gpl3+)
250 (home-page "https://www.gnu.org/software/diffutils/")))
251
252 (define-public findutils
253 (package
254 (name "findutils")
255 (version "4.6.0")
256 (source (origin
257 (method url-fetch)
258 (uri (string-append "mirror://gnu/findutils/findutils-"
259 version ".tar.gz"))
260 (sha256
261 (base32
262 "178nn4dl7wbcw499czikirnkniwnx36argdnqgz4ik9i6zvwkm6y"))
263 (patches (search-patches
264 "findutils-localstatedir.patch"
265 "findutils-test-xargs.patch"
266 ;; test-lock has performance issues on multi-core
267 ;; machines, it hangs or takes a long time to complete.
268 ;; This is a commit from gnulib to fix this issue.
269 "findutils-gnulib-multi-core.patch"))))
270 (build-system gnu-build-system)
271 (arguments
272 `(#:configure-flags (list
273 ;; Tell 'updatedb' to write to /var.
274 "--localstatedir=/var"
275
276 ;; Work around cross-compilation failure. See
277 ;; <http://savannah.gnu.org/bugs/?27299#comment1>.
278 ,@(if (%current-target-system)
279 '("gl_cv_func_wcwidth_works=yes")
280 '()))))
281 (synopsis "Operating on files matching given criteria")
282 (description
283 "Findutils supplies the basic file directory searching utilities of the
284 GNU system. It consists of two primary searching utilities: \"find\"
285 recursively searches for files in a directory according to given criteria and
286 \"locate\" lists files in a database that match a query. Two auxiliary tools
287 are included: \"updatedb\" updates the file name database and \"xargs\" may be
288 used to apply commands with arbitrarily long arguments.")
289 (license gpl3+)
290 (home-page "https://www.gnu.org/software/findutils/")))
291
292 (define-public coreutils
293 (package
294 (name "coreutils")
295 (version "8.28")
296 (source (origin
297 (method url-fetch)
298 (uri (string-append "mirror://gnu/coreutils/coreutils-"
299 version ".tar.xz"))
300 (sha256
301 (base32
302 "0r8c1bgm68kl70j1lgd0rv12iykw6143k4m9a56xip9rc2hv25qi"))))
303 (build-system gnu-build-system)
304 (inputs `(("acl" ,acl) ; TODO: add SELinux
305 ("gmp" ,gmp) ;bignums in 'expr', yay!
306
307 ;; Drop the dependency on libcap when cross-compiling since it's
308 ;; not quite cross-compilable.
309 ,@(if (%current-target-system)
310 '()
311 `(("libcap" ,libcap))))) ;capability support is 'ls', etc.
312 (native-inputs
313 ;; Perl is needed to run tests in native builds, and to run the bundled
314 ;; copy of help2man. However, don't pass it when cross-compiling since
315 ;; that would lead it to try to run programs to get their '--help' output
316 ;; for help2man.
317 (if (%current-target-system)
318 '()
319 `(("perl" ,perl))))
320 (outputs '("out" "debug"))
321 (arguments
322 `(#:parallel-build? #f ; help2man may be called too early
323 #:phases (modify-phases %standard-phases
324 (add-before 'build 'patch-shell-references
325 (lambda _
326 ;; 'split' uses either $SHELL or /bin/sh. Set $SHELL so
327 ;; that tests pass, since /bin/sh isn't in the chroot.
328 (setenv "SHELL" (which "sh"))
329
330 (substitute* (find-files "gnulib-tests" "\\.c$")
331 (("/bin/sh") (which "sh")))
332 (substitute* (find-files "tests" "\\.sh$")
333 (("#!/bin/sh") (which "sh")))
334 #t)))))
335 (synopsis "Core GNU utilities (file, text, shell)")
336 (description
337 "GNU Coreutils includes all of the basic command-line tools that are
338 expected in a POSIX system. These provide the basic file, shell and text
339 manipulation functions of the GNU system. Most of these tools offer extended
340 functionality beyond that which is outlined in the POSIX standard.")
341 (license gpl3+)
342 (home-page "https://www.gnu.org/software/coreutils/")))
343
344 (define-public coreutils-minimal
345 ;; Coreutils without its optional dependencies.
346 (package
347 (inherit coreutils)
348 (name "coreutils-minimal")
349 (outputs '("out"))
350 (inputs '())))
351
352 (define-public gnu-make
353 (package
354 (name "make")
355 (version "4.2.1")
356 (source (origin
357 (method url-fetch)
358 (uri (string-append "mirror://gnu/make/make-" version
359 ".tar.bz2"))
360 (sha256
361 (base32
362 "12f5zzyq2w56g95nni65hc0g5p7154033y2f3qmjvd016szn5qnn"))
363 (patches (search-patches "make-impure-dirs.patch"))))
364 (build-system gnu-build-system)
365 (native-inputs `(("pkg-config" ,pkg-config))) ; to detect Guile
366 (inputs `(("guile" ,guile-2.0)))
367 (outputs '("out" "debug"))
368 (arguments
369 '(#:phases
370 (modify-phases %standard-phases
371 (add-before 'build 'set-default-shell
372 (lambda* (#:key inputs #:allow-other-keys)
373 ;; Change the default shell from /bin/sh.
374 (let ((bash (assoc-ref inputs "bash")))
375 (substitute* "job.c"
376 (("default_shell =.*$")
377 (format #f "default_shell = \"~a/bin/sh\";\n"
378 bash)))))))))
379 (synopsis "Remake files automatically")
380 (description
381 "Make is a program that is used to control the production of
382 executables or other files from their source files. The process is
383 controlled from a Makefile, in which the developer specifies how each file is
384 generated from its source. It has powerful dependency resolution and the
385 ability to determine when files have to be regenerated after their sources
386 change. GNU make offers many powerful extensions over the standard utility.")
387 (license gpl3+)
388 (home-page "https://www.gnu.org/software/make/")))
389
390 (define-public binutils
391 (package
392 (name "binutils")
393 (version "2.28.1")
394 (source (origin
395 (method url-fetch)
396 (uri (string-append "mirror://gnu/binutils/binutils-"
397 version ".tar.bz2"))
398 (sha256
399 (base32
400 "1sj234nd05cdgga1r36zalvvdkvpfbr12g5mir2n8i1dwsdrj939"))
401 (patches (search-patches "binutils-ld-new-dtags.patch"
402 "binutils-loongson-workaround.patch"))))
403 (build-system gnu-build-system)
404
405 ;; TODO: Add dependency on zlib + those for Gold.
406 (arguments
407 `(#:configure-flags '(;; Add `-static-libgcc' to not retain a dependency
408 ;; on GCC when bootstrapping.
409 "LDFLAGS=-static-libgcc"
410
411 ;; Don't search under /usr/lib & co.
412 "--with-lib-path=/no-ld-lib-path"
413
414 ;; Install BFD. It ends up in a hidden directory,
415 ;; but it's here.
416 "--enable-install-libbfd"
417
418 ;; Make sure 'ar' and 'ranlib' produce archives in a
419 ;; deterministic fashion.
420 "--enable-deterministic-archives")))
421
422 (synopsis "Binary utilities: bfd gas gprof ld")
423 (description
424 "GNU Binutils is a collection of tools for working with binary files.
425 Perhaps the most notable are \"ld\", a linker, and \"as\", an assembler.
426 Other tools include programs to display binary profiling information, list
427 the strings in a binary file, and utilities for working with archives. The
428 \"bfd\" library for working with executable and object formats is also
429 included.")
430 (license gpl3+)
431 (home-page "https://www.gnu.org/software/binutils/")))
432
433 (define* (make-ld-wrapper name #:key
434 (target (const #f))
435 binutils
436 (guile (canonical-package guile-2.2))
437 (bash (canonical-package bash))
438 (guile-for-build guile))
439 "Return a package called NAME that contains a wrapper for the 'ld' program
440 of BINUTILS, which adds '-rpath' flags to the actual 'ld' command line. The
441 wrapper uses GUILE and BASH.
442
443 TARGET must be a one-argument procedure that, given a system type, returns a
444 cross-compilation target triplet or #f. When the result is not #f, make a
445 wrapper for the cross-linker for that target, called 'TARGET-ld'."
446 ;; Note: #:system->target-triplet is a procedure so that the evaluation of
447 ;; its result can be delayed until the 'arguments' field is evaluated, thus
448 ;; in a context where '%current-system' is accurate.
449 (package
450 (name name)
451 (version "0")
452 (source #f)
453 (build-system trivial-build-system)
454 (inputs `(("binutils" ,binutils)
455 ("guile" ,guile)
456 ("bash" ,bash)
457 ("wrapper" ,(search-path %load-path
458 "gnu/packages/ld-wrapper.in"))))
459 (arguments
460 (let ((target (target (%current-system))))
461 `(#:guile ,guile-for-build
462 #:modules ((guix build utils))
463 #:builder (begin
464 (use-modules (guix build utils)
465 (system base compile))
466
467 (let* ((out (assoc-ref %outputs "out"))
468 (bin (string-append out "/bin"))
469 (ld ,(if target
470 `(string-append bin "/" ,target "-ld")
471 '(string-append bin "/ld")))
472 (go (string-append ld ".go")))
473
474 (setvbuf (current-output-port) _IOLBF)
475 (format #t "building ~s/bin/ld wrapper in ~s~%"
476 (assoc-ref %build-inputs "binutils")
477 out)
478
479 (mkdir-p bin)
480 (copy-file (assoc-ref %build-inputs "wrapper") ld)
481 (substitute* ld
482 (("@SELF@")
483 ld)
484 (("@GUILE@")
485 (string-append (assoc-ref %build-inputs "guile")
486 "/bin/guile"))
487 (("@BASH@")
488 (string-append (assoc-ref %build-inputs "bash")
489 "/bin/bash"))
490 (("@LD@")
491 (string-append (assoc-ref %build-inputs "binutils")
492 ,(if target
493 (string-append "/bin/"
494 target "-ld")
495 "/bin/ld"))))
496 (chmod ld #o555)
497 (compile-file ld #:output-file go))))))
498 (synopsis "The linker wrapper")
499 (description
500 "The linker wrapper (or 'ld-wrapper') wraps the linker to add any
501 missing '-rpath' flags, and to detect any misuse of libraries outside of the
502 store.")
503 (home-page "https://www.gnu.org/software/guix//")
504 (license gpl3+)))
505
506 (export make-ld-wrapper)
507
508 (define-public glibc/linux
509 (package
510 (name "glibc")
511 (version "2.25")
512 (source (origin
513 (method url-fetch)
514 (uri (string-append "mirror://gnu/glibc/glibc-"
515 version ".tar.xz"))
516 (sha256
517 (base32
518 "1813dzkgw6v8q8q1m4v96yfis7vjqc9pslqib6j9mrwh6fxxjyq6"))
519 (snippet
520 ;; Disable 'ldconfig' and /etc/ld.so.cache. The latter is
521 ;; required on LFS distros to avoid loading the distro's libc.so
522 ;; instead of ours.
523 '(substitute* "sysdeps/unix/sysv/linux/configure"
524 (("use_ldconfig=yes")
525 "use_ldconfig=no")))
526 (modules '((guix build utils)))
527 (patches (search-patches "glibc-ldd-x86_64.patch"
528 "glibc-versioned-locpath.patch"
529 "glibc-o-largefile.patch"
530 "glibc-memchr-overflow-i686.patch"
531 "glibc-vectorized-strcspn-guards.patch"
532 "glibc-CVE-2017-15670-15671.patch"
533 "glibc-CVE-2017-1000366-pt1.patch"
534 "glibc-CVE-2017-1000366-pt2.patch"
535 "glibc-CVE-2017-1000366-pt3.patch"))))
536 (build-system gnu-build-system)
537
538 ;; Glibc's <limits.h> refers to <linux/limit.h>, for instance, so glibc
539 ;; users should automatically pull Linux headers as well.
540 (propagated-inputs `(("kernel-headers" ,linux-libre-headers)))
541
542 (outputs '("out" "debug"
543 "static")) ;9 MiB of .a files
544
545 (arguments
546 `(#:out-of-source? #t
547
548 ;; The libraries have an empty RUNPATH, but some, such as the versioned
549 ;; libraries (libdl-2.24.so, etc.) have ld.so marked as NEEDED. Since
550 ;; these libraries are always going to be found anyway, just skip
551 ;; RUNPATH checks.
552 #:validate-runpath? #f
553
554 #:modules ((ice-9 ftw)
555 (srfi srfi-26)
556 (guix build utils)
557 (guix build gnu-build-system))
558
559 #:configure-flags
560 (list "--enable-add-ons"
561 "--sysconfdir=/etc"
562
563 ;; Installing a locale archive with all the locales is to
564 ;; expensive (~100 MiB), so we rely on users to install the
565 ;; locales they really want.
566 ;;
567 ;; Set the default locale path. In practice, $LOCPATH may be
568 ;; defined to point whatever locales users want. However, setuid
569 ;; binaries don't honor $LOCPATH, so they'll instead look into
570 ;; $libc_cv_complocaledir; we choose /run/current-system/locale/X.Y,
571 ;; with the idea that it is going to be populated by the sysadmin.
572 ;; The "X.Y" sub-directory is because locale data formats are
573 ;; incompatible across libc versions; see
574 ;; <https://lists.gnu.org/archive/html/guix-devel/2015-08/msg00737.html>.
575 ;;
576 ;; `--localedir' is not honored, so work around it.
577 ;; See <http://sourceware.org/ml/libc-alpha/2013-03/msg00093.html>.
578 (string-append "libc_cv_complocaledir=/run/current-system/locale/"
579 ,version)
580
581 (string-append "--with-headers="
582 (assoc-ref ,(if (%current-target-system)
583 '%build-target-inputs
584 '%build-inputs)
585 "kernel-headers")
586 "/include")
587
588 ;; This is the default for most architectures as of GNU libc 2.21,
589 ;; but we specify it explicitly for clarity and consistency. See
590 ;; "kernel-features.h" in the GNU libc for details.
591 "--enable-kernel=2.6.32"
592
593 ;; Use our Bash instead of /bin/sh.
594 (string-append "BASH_SHELL="
595 (assoc-ref %build-inputs "bash")
596 "/bin/bash")
597
598 ;; XXX: Work around "undefined reference to `__stack_chk_guard'".
599 "libc_cv_ssp=no" "libc_cv_ssp_strong=no")
600
601 #:tests? #f ; XXX
602 #:phases (modify-phases %standard-phases
603 (add-before
604 'configure 'pre-configure
605 (lambda* (#:key inputs native-inputs outputs
606 #:allow-other-keys)
607 (let* ((out (assoc-ref outputs "out"))
608 (bin (string-append out "/bin"))
609 ;; FIXME: Normally we would look it up only in INPUTS
610 ;; but cross-base uses it as a native input.
611 (bash (or (assoc-ref inputs "static-bash")
612 (assoc-ref native-inputs "static-bash"))))
613 ;; Install the rpc data base file under `$out/etc/rpc'.
614 ;; FIXME: Use installFlags = [ "sysconfdir=$(out)/etc" ];
615 (substitute* "sunrpc/Makefile"
616 (("^\\$\\(inst_sysconfdir\\)/rpc(.*)$" _ suffix)
617 (string-append out "/etc/rpc" suffix "\n"))
618 (("^install-others =.*$")
619 (string-append "install-others = " out "/etc/rpc\n")))
620
621 (substitute* "Makeconfig"
622 ;; According to
623 ;; <http://www.linuxfromscratch.org/lfs/view/stable/chapter05/glibc.html>,
624 ;; linking against libgcc_s is not needed with GCC
625 ;; 4.7.1.
626 ((" -lgcc_s") ""))
627
628 ;; Have `system' use that Bash.
629 (substitute* "sysdeps/posix/system.c"
630 (("#define[[:blank:]]+SHELL_PATH.*$")
631 (format #f "#define SHELL_PATH \"~a/bin/bash\"\n"
632 bash)))
633
634 ;; Same for `popen'.
635 (substitute* "libio/iopopen.c"
636 (("/bin/sh")
637 (string-append bash "/bin/sh")))
638
639 ;; Same for the shell used by the 'exec' functions for
640 ;; scripts that lack a shebang.
641 (substitute* (find-files "." "^paths\\.h$")
642 (("#define[[:blank:]]+_PATH_BSHELL[[:blank:]].*$")
643 (string-append "#define _PATH_BSHELL \""
644 bash "/bin/sh\"\n")))
645
646 ;; Nscd uses __DATE__ and __TIME__ to create a string to
647 ;; make sure the client and server come from the same
648 ;; libc. Use something deterministic instead.
649 (substitute* "nscd/nscd_stat.c"
650 (("static const char compilation\\[21\\] =.*$")
651 (string-append
652 "static const char compilation[21] = \""
653 (string-take (basename out) 20) "\";\n")))
654
655 ;; Make sure we don't retain a reference to the
656 ;; bootstrap Perl.
657 (substitute* "malloc/mtrace.pl"
658 (("^#!.*")
659 ;; The shebang can be omitted, because there's the
660 ;; "bilingual" eval/exec magic at the top of the file.
661 "")
662 (("exec @PERL@")
663 "exec perl")))))
664
665 (add-after 'install 'move-static-libs
666 (lambda* (#:key outputs #:allow-other-keys)
667 ;; Move static libraries to the "static" output.
668 (define (static-library? file)
669 ;; Return true if FILE is a static library. The
670 ;; "_nonshared.a" files are referred to by libc.so,
671 ;; libpthread.so, etc., which are in fact linker
672 ;; scripts.
673 (and (string-suffix? ".a" file)
674 (not (string-contains file "_nonshared"))))
675
676 (define (linker-script? file)
677 ;; Guess whether FILE, a ".a" file, is actually a
678 ;; linker script.
679 (and (not (ar-file? file))
680 (not (elf-file? file))))
681
682 (let* ((out (assoc-ref outputs "out"))
683 (lib (string-append out "/lib"))
684 (files (scandir lib static-library?))
685 (static (assoc-ref outputs "static"))
686 (slib (string-append static "/lib")))
687 (mkdir-p slib)
688 (for-each (lambda (base)
689 (rename-file (string-append lib "/" base)
690 (string-append slib "/" base)))
691 files)
692
693 ;; Usually libm.a is a linker script so we need to
694 ;; change the file names in there to refer to STATIC
695 ;; instead of OUT.
696 (for-each (lambda (ld-script)
697 (substitute* ld-script
698 ((out) static)))
699 (filter linker-script?
700 (map (cut string-append slib "/" <>)
701 files)))
702 #t))))))
703
704 (inputs `(("static-bash" ,static-bash)))
705
706 ;; To build the manual, we need Texinfo and Perl. Gettext is needed to
707 ;; install the message catalogs, with 'msgfmt'.
708 (native-inputs `(("texinfo" ,texinfo)
709 ("perl" ,perl)
710 ("gettext" ,gettext-minimal)))
711
712 (native-search-paths
713 ;; Search path for packages that provide locale data. This is useful
714 ;; primarily in build environments. Use 'GUIX_LOCPATH' rather than
715 ;; 'LOCPATH' to avoid interference with the host system's libc on foreign
716 ;; distros.
717 (list (search-path-specification
718 (variable "GUIX_LOCPATH")
719 (files '("lib/locale")))))
720
721 (synopsis "The GNU C Library")
722 (description
723 "Any Unix-like operating system needs a C library: the library which
724 defines the \"system calls\" and other basic facilities such as open, malloc,
725 printf, exit...
726
727 The GNU C library is used as the C library in the GNU system and most systems
728 with the Linux kernel.")
729 (license lgpl2.0+)
730 (home-page "https://www.gnu.org/software/libc/")))
731
732 (define-public glibc/hurd
733 ;; The Hurd's libc variant.
734 (package (inherit glibc/linux)
735 (name "glibc-hurd")
736 (version "2.23")
737 (source (origin
738 (method url-fetch)
739 (uri (string-append "http://alpha.gnu.org/gnu/hurd/glibc-"
740 version "-hurd+libpthread-20161218" ".tar.gz"))
741 (sha256
742 (base32
743 "0vpdv05j6j3ria5bw8gp468i64gij94cslxkxj9xkfgi6p615b8p"))))
744
745 ;; Libc provides <hurd.h>, which includes a bunch of Hurd and Mach headers,
746 ;; so both should be propagated.
747 (propagated-inputs `(("hurd-core-headers" ,hurd-core-headers)))
748 (native-inputs
749 `(,@(package-native-inputs glibc/linux)
750 ("mig" ,mig)
751 ("perl" ,perl)))
752
753 (arguments
754 (substitute-keyword-arguments (package-arguments glibc/linux)
755 ((#:phases original-phases)
756 ;; Add libmachuser.so and libhurduser.so to libc.so's search path.
757 ;; See <http://lists.gnu.org/archive/html/bug-hurd/2015-07/msg00051.html>.
758 `(modify-phases ,original-phases
759 (add-after 'install 'augment-libc.so
760 (lambda* (#:key outputs #:allow-other-keys)
761 (let* ((out (assoc-ref outputs "out")))
762 (substitute* (string-append out "/lib/libc.so")
763 (("/[^ ]+/lib/libc.so.0.3")
764 (string-append out "/lib/libc.so.0.3" " libmachuser.so" " libhurduser.so"))))
765 #t))
766 (add-after 'pre-configure 'pre-configure-set-pwd
767 (lambda _
768 ;; Use the right 'pwd'.
769 (substitute* "configure"
770 (("/bin/pwd") "pwd"))
771 #t))
772 (replace 'build
773 (lambda _
774 ;; Force mach/hurd/libpthread subdirs to build first in order to avoid
775 ;; linking errors.
776 ;; See <https://lists.gnu.org/archive/html/bug-hurd/2016-11/msg00045.html>
777 (let ((-j (list "-j" (number->string (parallel-job-count)))))
778 (let-syntax ((make (syntax-rules ()
779 ((_ target)
780 (zero? (apply system* "make" target -j))))))
781 (and (make "mach/subdir_lib")
782 (make "hurd/subdir_lib")
783 (make "libpthread/subdir_lib")
784 (zero? (apply system* "make" -j)))))))))
785 ((#:configure-flags original-configure-flags)
786 `(append (list "--host=i586-pc-gnu"
787
788 ;; We need this to get a working openpty() function.
789 "--enable-pt_chown"
790
791 ;; <https://lists.gnu.org/archive/html/bug-hurd/2016-10/msg00033.html>
792 "--disable-werror"
793
794 ;; nscd fails to build for GNU/Hurd:
795 ;; <https://lists.gnu.org/archive/html/bug-hurd/2014-07/msg00006.html>.
796 ;; Disable it.
797 "--disable-nscd")
798 (filter (lambda (flag)
799 (not (string-prefix? "--enable-kernel=" flag)))
800 ,original-configure-flags)))))
801 (synopsis "The GNU C Library (GNU Hurd variant)")
802 (supported-systems %hurd-systems)))
803
804 (define* (glibc-for-target #:optional
805 (target (or (%current-target-system)
806 (%current-system))))
807 "Return the glibc for TARGET, GLIBC/LINUX for a Linux host or
808 GLIBC/HURD for a Hurd host"
809 (match target
810 ((or "i586-pc-gnu" "i586-gnu") glibc/hurd)
811 (_ glibc/linux)))
812
813 (define-syntax glibc
814 (identifier-syntax (glibc-for-target)))
815
816 ;; Below are old libc versions, which we use mostly to build locale data in
817 ;; the old format (which the new libc cannot cope with.)
818
819 (define-public glibc-2.24
820 (package
821 (inherit glibc)
822 (version "2.24")
823 (source (origin
824 (inherit (package-source glibc))
825 (uri (string-append "mirror://gnu/glibc/glibc-"
826 version ".tar.xz"))
827 (sha256
828 (base32
829 "1lxmprg9gm73gvafxd503x70z32phwjzcy74i0adfi6ixzla7m4r"))
830 (patches (search-patches "glibc-ldd-x86_64.patch"
831 "glibc-versioned-locpath.patch"
832 "glibc-o-largefile.patch"
833 "glibc-vectorized-strcspn-guards.patch"
834 "glibc-CVE-2015-5180.patch"
835 "glibc-CVE-2017-15670-15671.patch"
836 "glibc-CVE-2017-1000366-pt1.patch"
837 "glibc-CVE-2017-1000366-pt2.patch"
838 "glibc-CVE-2017-1000366-pt3.patch"))))))
839
840 (define-public glibc-2.23
841 (package
842 (inherit glibc)
843 (version "2.23")
844 (source (origin
845 (inherit (package-source glibc))
846 (uri (string-append "mirror://gnu/glibc/glibc-"
847 version ".tar.xz"))
848 (sha256
849 (base32
850 "1s8krs3y2n6pzav7ic59dz41alqalphv7vww4138ag30wh0fpvwl"))
851 (patches (search-patches "glibc-ldd-x86_64.patch"
852 "glibc-versioned-locpath.patch"
853 "glibc-o-largefile.patch"
854 "glibc-vectorized-strcspn-guards.patch"
855 "glibc-CVE-2015-5180.patch"
856 "glibc-CVE-2016-3075.patch"
857 "glibc-CVE-2016-3706.patch"
858 "glibc-CVE-2016-4429.patch"
859 "glibc-CVE-2017-15670-15671.patch"
860 "glibc-CVE-2017-1000366-pt1.patch"
861 "glibc-CVE-2017-1000366-pt2.patch"
862 "glibc-CVE-2017-1000366-pt3.patch"))))))
863
864 (define-public glibc-2.22
865 (package
866 (inherit glibc)
867 (version "2.22")
868 (source (origin
869 (inherit (package-source glibc))
870 (uri (string-append "mirror://gnu/glibc/glibc-"
871 version ".tar.xz"))
872 (sha256
873 (base32
874 "0j49682pm2nh4qbdw35bas82p1pgfnz4d2l7iwfyzvrvj0318wzb"))
875 (patches (search-patches "glibc-ldd-x86_64.patch"
876 "glibc-vectorized-strcspn-guards.patch"
877 "glibc-CVE-2015-5180.patch"
878 "glibc-CVE-2015-7547.patch"
879 "glibc-CVE-2016-3075.patch"
880 "glibc-CVE-2016-3706.patch"
881 "glibc-CVE-2016-4429.patch"
882 "glibc-CVE-2017-15670-15671.patch"
883 "glibc-CVE-2017-1000366-pt1.patch"
884 "glibc-CVE-2017-1000366-pt2.patch"
885 "glibc-CVE-2017-1000366-pt3.patch"))))
886 (arguments
887 (substitute-keyword-arguments (package-arguments glibc)
888 ((#:phases phases)
889 `(modify-phases ,phases
890 (add-before 'configure 'fix-pwd
891 (lambda _
892 ;; Use `pwd' instead of `/bin/pwd' for glibc-2.22.
893 (substitute* "configure"
894 (("/bin/pwd") "pwd"))
895 #t))))))))
896
897 (define-public glibc-locales
898 (package
899 (inherit glibc)
900 (name "glibc-locales")
901 (source (origin (inherit (package-source glibc))
902 (patches (cons (search-patch "glibc-locales.patch")
903 (origin-patches (package-source glibc))))))
904 (synopsis "All the locales supported by the GNU C Library")
905 (description
906 "This package provides all the locales supported by the GNU C Library,
907 more than 400 in total. To use them set the 'LOCPATH' environment variable to
908 the 'share/locale' sub-directory of this package.")
909 (outputs '("out")) ;110+ MiB
910 (native-search-paths '())
911 (arguments
912 (let ((args `(#:tests? #f #:strip-binaries? #f
913 ,@(package-arguments glibc))))
914 (substitute-keyword-arguments args
915 ((#:phases phases)
916 `(modify-phases ,phases
917 (replace 'build
918 (lambda _
919 (zero? (system* "make" "localedata/install-locales"
920 "-j" (number->string (parallel-job-count))))))
921 (delete 'install)))
922 ((#:configure-flags flags)
923 `(append ,flags
924 ;; Use $(libdir)/locale/X.Y as is the case by default.
925 (list (string-append "libc_cv_complocaledir="
926 (assoc-ref %outputs "out")
927 "/lib/locale/"
928 ,(package-version glibc))))))))))
929
930 (define-public glibc-utf8-locales
931 (package
932 (name "glibc-utf8-locales")
933 (version (package-version glibc))
934 (source #f)
935 (build-system trivial-build-system)
936 (arguments
937 `(#:modules ((guix build utils))
938 #:builder (begin
939 (use-modules (srfi srfi-1)
940 (guix build utils))
941
942 (let* ((libc (assoc-ref %build-inputs "glibc"))
943 (gzip (assoc-ref %build-inputs "gzip"))
944 (out (assoc-ref %outputs "out"))
945 (localedir (string-append out "/lib/locale/"
946 ,version)))
947 ;; 'localedef' needs 'gzip'.
948 (setenv "PATH" (string-append libc "/bin:" gzip "/bin"))
949
950 (mkdir-p localedir)
951 (every (lambda (locale)
952 (define file
953 ;; Use the "normalized codeset" by
954 ;; default--e.g., "en_US.utf8".
955 (string-append localedir "/" locale ".utf8"))
956
957 (and (zero? (system* "localedef" "--no-archive"
958 "--prefix" localedir
959 "-i" locale
960 "-f" "UTF-8" file))
961 (begin
962 ;; For backward compatibility with Guix
963 ;; <= 0.8.3, add "xx_YY.UTF-8".
964 (symlink (string-append locale ".utf8")
965 (string-append localedir "/"
966 locale ".UTF-8"))
967 #t)))
968
969 ;; These are the locales commonly used for
970 ;; tests---e.g., in Guile's i18n tests.
971 '("de_DE" "el_GR" "en_US" "fr_FR" "tr_TR"))))))
972 (inputs `(("glibc" ,glibc)
973 ("gzip" ,gzip)))
974 (synopsis "Small sample of UTF-8 locales")
975 (description
976 "This package provides a small sample of UTF-8 locales mostly useful in
977 test environments.")
978 (home-page (package-home-page glibc))
979 (license (package-license glibc))))
980
981 (define-public which
982 (package
983 (name "which")
984 (version "2.21")
985 (source (origin
986 (method url-fetch)
987 (uri (string-append "mirror://gnu/which/which-"
988 version ".tar.gz"))
989 (sha256
990 (base32
991 "1bgafvy3ypbhhfznwjv1lxmd6mci3x1byilnnkc7gcr486wlb8pl"))))
992 (build-system gnu-build-system)
993 (home-page "https://gnu.org/software/which/")
994 (synopsis "Find full path of shell commands")
995 (description
996 "The which program finds the location of executables in PATH, with a
997 variety of options. It is an alternative to the shell \"type\" built-in
998 command.")
999 (license gpl3+))) ; some files are under GPLv2+
1000
1001 (define-public glibc/hurd-headers
1002 (package (inherit glibc/hurd)
1003 (name "glibc-hurd-headers")
1004 (outputs '("out"))
1005 (propagated-inputs `(("gnumach-headers" ,gnumach-headers)
1006 ("hurd-headers" ,hurd-headers)))
1007 (arguments
1008 (substitute-keyword-arguments (package-arguments glibc/hurd)
1009 ;; We just pass the flags really needed to build the headers.
1010 ((#:configure-flags _)
1011 `(list "--enable-add-ons"
1012 "--host=i586-pc-gnu"
1013 "--enable-obsolete-rpc"))
1014 ((#:phases _)
1015 '(alist-replace
1016 'install
1017 (lambda* (#:key outputs #:allow-other-keys)
1018 (and (zero? (system* "make" "install-headers"))
1019
1020 ;; Make an empty stubs.h to work around not being able to
1021 ;; produce a valid stubs.h and causing the build to fail. See
1022 ;; <http://lists.gnu.org/archive/html/guix-devel/2014-04/msg00233.html>.
1023 (let ((out (assoc-ref outputs "out")))
1024 (close-port
1025 (open-output-file
1026 (string-append out "/include/gnu/stubs.h"))))))
1027
1028 ;; Nothing to build.
1029 (alist-delete
1030 'build
1031
1032 (alist-cons-before
1033 'configure 'pre-configure
1034 (lambda _
1035 ;; Use the right 'pwd'.
1036 (substitute* "configure"
1037 (("/bin/pwd") "pwd")))
1038 %standard-phases))))))))
1039
1040 (define-public tzdata
1041 (package
1042 (name "tzdata")
1043 (version "2017b")
1044 (source (origin
1045 (method url-fetch)
1046 (uri (string-append
1047 "https://www.iana.org/time-zones/repository/releases/tzdata"
1048 version ".tar.gz"))
1049 (sha256
1050 (base32
1051 "11l0s43vx33dcs78p80122i8s5s9l1sjwkzzwh66njd35r92l97q"))))
1052 (build-system gnu-build-system)
1053 (arguments
1054 '(#:tests? #f
1055 #:make-flags (let ((out (assoc-ref %outputs "out"))
1056 (tmp (getenv "TMPDIR")))
1057 (list (string-append "TOPDIR=" out)
1058 (string-append "TZDIR=" out "/share/zoneinfo")
1059
1060 ;; Discard zic, dump, and tzselect, already
1061 ;; provided by glibc.
1062 (string-append "ETCDIR=" tmp "/etc")
1063
1064 ;; Likewise for the C library routines.
1065 (string-append "LIBDIR=" tmp "/lib")
1066 (string-append "MANDIR=" tmp "/man")
1067
1068 "AWK=awk"
1069 "CC=gcc"))
1070 #:modules ((guix build utils)
1071 (guix build gnu-build-system)
1072 (srfi srfi-1))
1073 #:phases
1074 (modify-phases %standard-phases
1075 (replace 'unpack
1076 (lambda* (#:key source inputs #:allow-other-keys)
1077 (and (zero? (system* "tar" "xvf" source))
1078 (zero? (system* "tar" "xvf" (assoc-ref inputs "tzcode"))))))
1079 (add-after 'install 'post-install
1080 (lambda* (#:key outputs #:allow-other-keys)
1081 ;; Move data in the right place.
1082 (let ((out (assoc-ref outputs "out")))
1083 (symlink (string-append out "/share/zoneinfo")
1084 (string-append out "/share/zoneinfo/posix"))
1085 (delete-file-recursively
1086 (string-append out "/share/zoneinfo-posix"))
1087 (copy-recursively (string-append out "/share/zoneinfo-leaps")
1088 (string-append out "/share/zoneinfo/right"))
1089 (delete-file-recursively
1090 (string-append out "/share/zoneinfo-leaps")))))
1091 (delete 'configure))))
1092 (inputs `(("tzcode" ,(origin
1093 (method url-fetch)
1094 (uri (string-append
1095 "http://www.iana.org/time-zones/repository/releases/tzcode"
1096 version ".tar.gz"))
1097 (sha256
1098 (base32
1099 "0h1d567gn8l3iqgyadcswwdy2yh07nhz3lfl8ds8saz2ajxka5sd"))))))
1100 (home-page "https://www.iana.org/time-zones")
1101 (synopsis "Database of current and historical time zones")
1102 (description "The Time Zone Database (often called tz or zoneinfo)
1103 contains code and data that represent the history of local time for many
1104 representative locations around the globe. It is updated periodically to
1105 reflect changes made by political bodies to time zone boundaries, UTC offsets,
1106 and daylight-saving rules.")
1107 (license public-domain)))
1108
1109 ;;; A "fixed" version of tzdata, which is used in the test suites of
1110 ;;; glib and R. We can update this whenever we are able to rebuild
1111 ;;; thousands of packages (for example, in a core-updates rebuild).
1112 (define-public tzdata-2017a
1113 (package
1114 (inherit tzdata)
1115 (version "2017a")
1116 (source
1117 (origin
1118 (method url-fetch)
1119 (uri (string-append "https://www.iana.org/time-zones/repository"
1120 "/releases/tzdata" version ".tar.gz"))
1121 (sha256
1122 (base32
1123 "1mmv4rvcs12lrvgghw4fidczvb69yv69cmzknghcvw1c196mqfnz"))))
1124 (inputs `(("tzcode" ,(origin
1125 (method url-fetch)
1126 (uri (string-append
1127 "http://www.iana.org/time-zones/repository/releases/tzcode"
1128 version ".tar.gz"))
1129 (sha256
1130 (base32
1131 "1b1q7gnlsh5hjgs5065pvajd37rmbc3k9b8cgzad1vcrifswdwh2"))))))))
1132
1133
1134 (define-public libiconv
1135 (package
1136 (name "libiconv")
1137 (version "1.15")
1138 (source (origin
1139 (method url-fetch)
1140 (uri (string-append "mirror://gnu/libiconv/libiconv-"
1141 version ".tar.gz"))
1142 (sha256
1143 (base32
1144 "0y1ij745r4p48mxq84rax40p10ln7fc7m243p8k8sia519i3dxfc"))
1145 (modules '((guix build utils)))
1146 (snippet
1147 ;; Work around "declared gets" error on glibc systems (fixed by
1148 ;; Gnulib commit 66712c23388e93e5c518ebc8515140fa0c807348.)
1149 '(substitute* "srclib/stdio.in.h"
1150 (("^#undef gets") "")
1151 (("^_GL_WARN_ON_USE \\(gets.*") "")))))
1152 (build-system gnu-build-system)
1153 (synopsis "Character set conversion library")
1154 (description
1155 "libiconv provides an implementation of the iconv function for systems
1156 that lack it. iconv is used to convert between character encodings in a
1157 program. It supports a wide variety of different encodings.")
1158 (home-page "https://www.gnu.org/software/libiconv/")
1159 (license lgpl3+)))
1160
1161 (define* (libiconv-if-needed #:optional (target (%current-target-system)))
1162 "Return either a libiconv package specification to include in a dependency
1163 list for platforms that have an incomplete libc, or the empty list. If a
1164 package needs iconv ,@(libiconv-if-needed) should be added."
1165 ;; POSIX C libraries provide iconv. Platforms with an incomplete libc
1166 ;; without iconv, such as MinGW, must return the then clause.
1167 (if (target-mingw? target)
1168 `(("libiconv" ,libiconv))
1169 '()))
1170
1171 (define-public (canonical-package package)
1172 ;; Avoid circular dependency by lazily resolving 'commencement'.
1173 (let* ((iface (resolve-interface '(gnu packages commencement)))
1174 (proc (module-ref iface 'canonical-package)))
1175 (proc package)))
1176
1177 (define-public (%final-inputs)
1178 "Return the list of \"final inputs\"."
1179 ;; Avoid circular dependency by lazily resolving 'commencement'.
1180 (let ((iface (resolve-interface '(gnu packages commencement))))
1181 (module-ref iface '%final-inputs)))
1182
1183 ;;; base.scm ends here