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