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 ;;; Copyright © 2020 Vitaliy Shatrov <D0dyBo0D0dyBo0@protonmail.com>
19 ;;; This file is part of GNU Guix.
21 ;;; GNU Guix is free software; you can redistribute it and/or modify it
22 ;;; under the terms of the GNU General Public License as published by
23 ;;; the Free Software Foundation; either version 3 of the License, or (at
24 ;;; your option) any later version.
26 ;;; GNU Guix is distributed in the hope that it will be useful, but
27 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
28 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 ;;; GNU General Public License for more details.
31 ;;; You should have received a copy of the GNU General Public License
32 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
34 (define-module (gnu packages base)
35 #:use-module ((guix licenses)
36 #:select (gpl3+ lgpl2.0+ lgpl3+ public-domain))
37 #:use-module (gnu packages)
38 #:use-module (gnu packages acl)
39 #:use-module (gnu packages algebra)
40 #:use-module (gnu packages bash)
41 #:use-module (gnu packages bison)
42 #:use-module (gnu packages ed)
43 #:use-module (gnu packages gcc)
44 #:use-module (gnu packages guile)
45 #:use-module (gnu packages multiprecision)
46 #:use-module (gnu packages compression)
47 #:use-module (gnu packages perl)
48 #:use-module (gnu packages linux)
49 #:use-module (gnu packages pcre)
50 #:use-module (gnu packages texinfo)
51 #:use-module (gnu packages hurd)
52 #:use-module (gnu packages pkg-config)
53 #:use-module (gnu packages python)
54 #:use-module (gnu packages gettext)
55 #:use-module (guix utils)
56 #:use-module (guix packages)
57 #:use-module (guix download)
58 #:use-module (guix git-download)
59 #:use-module (guix build-system gnu)
60 #:use-module (guix build-system trivial)
61 #:use-module (ice-9 match)
62 #:use-module (srfi srfi-1)
63 #:use-module (srfi srfi-26)
69 ;;; Base packages of the Guix-based GNU user-land software distribution.
79 (uri (string-append "mirror://gnu/hello/hello-" version
83 "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"))))
84 (build-system gnu-build-system)
85 (synopsis "Hello, GNU world: An example GNU package")
87 "GNU Hello prints the message \"Hello, world!\" and then exits. It
88 serves as an example of standard GNU coding practices. As such, it supports
89 command-line arguments, multiple languages, and so on.")
90 (home-page "https://www.gnu.org/software/hello/")
99 (uri (string-append "mirror://gnu/grep/grep-"
103 "055mqp6vrd0brkygmygb2673qwz409a7kyp1mzbfy6cn94f58q5r"))
104 (patches (search-patches "grep-timing-sensitive-test.patch"))))
105 (build-system gnu-build-system)
106 (native-inputs `(("perl" ,perl))) ;some of the tests require it
107 (inputs `(("pcre" ,pcre)))
110 (modify-phases %standard-phases
111 (add-after 'install 'fix-egrep-and-fgrep
112 ;; Patch 'egrep' and 'fgrep' to execute 'grep' via its
113 ;; absolute file name instead of searching for it in $PATH.
114 (lambda* (#:key outputs #:allow-other-keys)
115 (let* ((out (assoc-ref outputs "out"))
116 (bin (string-append out "/bin")))
117 (substitute* (list (string-append bin "/egrep")
118 (string-append bin "/fgrep"))
120 (string-append "exec " bin "/grep")))
122 (synopsis "Print lines matching a pattern")
124 "grep is a tool for finding text inside files. Text is found by
125 matching a pattern provided by the user in one or many files. The pattern
126 may be provided as a basic or extended regular expression, or as fixed
127 strings. By default, the matching text is simply printed to the screen,
128 however the output can be greatly customized to include, for example, line
129 numbers. GNU grep offers many extensions over the standard utility,
130 including, for example, recursive directory searching.")
132 (home-page "https://www.gnu.org/software/grep/")))
140 (uri (string-append "mirror://gnu/sed/sed-" version
144 "0smxcx66vx29djzb542nxcynl7qnzxqa5032ibazi7x2s267d198"))))
145 (build-system gnu-build-system)
146 (synopsis "Stream editor")
148 `(("perl" ,perl))) ;for tests
150 "Sed is a non-interactive, text stream editor. It receives a text
151 input from a file or from standard input and it then applies a series of text
152 editing commands to the stream and prints its output to standard output. It
153 is often used for substituting text patterns in a stream. The GNU
154 implementation offers several extensions over the standard utility.")
156 (home-page "https://www.gnu.org/software/sed/")))
164 (uri (string-append "mirror://gnu/tar/tar-"
168 "1n7xy657ii0sa42zx6944v2m4v9qrh6sqgmw17l3nch3y43sxlyh"))
169 (patches (search-patches "tar-skip-unreliable-tests.patch"
170 "tar-remove-wholesparse-check.patch"))))
171 (build-system gnu-build-system)
172 ;; Note: test suite requires ~1GiB of disk space.
174 `(#:phases (modify-phases %standard-phases
175 (add-before 'build 'set-shell-file-name
176 (lambda* (#:key inputs #:allow-other-keys)
177 ;; Do not use "/bin/sh" to run programs.
178 (let ((bash (assoc-ref inputs "bash")))
179 (substitute* "src/system.c"
181 (string-append bash "/bin/sh")))
184 ;; When cross-compiling, the 'set-shell-file-name' phase needs to be able
185 ;; to refer to the target Bash.
186 (inputs (if (%current-target-system)
190 (synopsis "Managing tar archives")
192 "Tar provides the ability to create tar archives, as well as the
193 ability to extract, update or list files in an existing archive. It is
194 useful for combining many files into one larger file, while maintaining
195 directory structure and file information such as permissions and
196 creation/modification dates. GNU tar offers many extensions over the
199 (home-page "https://www.gnu.org/software/tar/")))
207 (uri (string-append "mirror://gnu/patch/patch-"
211 "1zfqy4rdcy279vwn2z1kbv19dcfw25d2aqy9nzvdkq5bjzd0nqdc"))
212 (patches (search-patches "patch-hurd-path-max.patch"))))
213 (build-system gnu-build-system)
215 ;; Work around a cross-compilation bug whereby libpatch.a would provide
216 ;; '__mktime_internal', which conflicts with the one in libc.a.
217 (if (%current-target-system)
218 `(#:configure-flags '("gl_cv_func_working_mktime=yes"))
220 (native-inputs `(("ed" ,ed)))
221 (synopsis "Apply differences to originals, with optional backups")
223 "Patch is a program that applies changes to files based on differences
224 laid out as by the program \"diff\". The changes may be applied to one or more
225 files depending on the contents of the diff file. It accepts several
226 different diff formats. It may also be used to revert previously applied
229 (home-page "https://savannah.gnu.org/projects/patch/")))
231 (define-public diffutils
237 (uri (string-append "mirror://gnu/diffutils/diffutils-"
241 "09isrg0isjinv8c535nxsi1s86wfdfzml80dbw41dj9x3hiad9xk"))))
242 (build-system gnu-build-system)
243 (native-inputs `(("perl" ,perl)))
244 (synopsis "Comparing and merging files")
246 "GNU Diffutils is a package containing tools for finding the
247 differences between files. The \"diff\" command is used to show how two files
248 differ, while \"cmp\" shows the offsets and line numbers where they differ.
249 \"diff3\" allows you to compare three files. Finally, \"sdiff\" offers an
250 interactive means to merge two files.")
252 (home-page "https://www.gnu.org/software/diffutils/")))
254 (define-public findutils
260 (uri (string-append "mirror://gnu/findutils/findutils-"
264 "178nn4dl7wbcw499czikirnkniwnx36argdnqgz4ik9i6zvwkm6y"))
265 (patches (search-patches
266 "findutils-gnulib-libio.patch"
267 "findutils-localstatedir.patch"
268 "findutils-makedev.patch"
269 "findutils-test-xargs.patch"))
270 (modules '((guix build utils)))
273 ;; The gnulib test-lock test is prone to writer starvation
274 ;; with our glibc@2.25, which prefers readers, so disable it.
275 ;; The gnulib commit b20e8afb0b2 should fix this once
276 ;; incorporated here.
277 (substitute* "tests/Makefile.in"
278 (("test-lock\\$\\(EXEEXT\\) ") ""))
280 (build-system gnu-build-system)
282 `(#:configure-flags (list
283 ;; Tell 'updatedb' to write to /var.
284 "--localstatedir=/var"
286 ;; Work around cross-compilation failure. See
287 ;; <http://savannah.gnu.org/bugs/?27299#comment1>.
288 ,@(if (%current-target-system)
289 '("gl_cv_func_wcwidth_works=yes")
291 (synopsis "Operating on files matching given criteria")
293 "Findutils supplies the basic file directory searching utilities of the
294 GNU system. It consists of two primary searching utilities: \"find\"
295 recursively searches for files in a directory according to given criteria and
296 \"locate\" lists files in a database that match a query. Two auxiliary tools
297 are included: \"updatedb\" updates the file name database and \"xargs\" may be
298 used to apply commands with arbitrarily long arguments.")
300 (home-page "https://www.gnu.org/software/findutils/")))
302 (define-public coreutils
308 (uri (string-append "mirror://gnu/coreutils/coreutils-"
312 "1zg9m79x1i2nifj4kb0waf9x3i5h6ydkypkjnbsb9rnwis8rqypz"))))
313 (build-system gnu-build-system)
314 (inputs `(("acl" ,acl) ; TODO: add SELinux
315 ("gmp" ,gmp) ;bignums in 'expr', yay!
317 ;; Drop the dependency on libcap when cross-compiling since it's
318 ;; not quite cross-compilable.
319 ,@(if (%current-target-system)
321 `(("libcap" ,libcap))))) ;capability support is 'ls', etc.
323 ;; Perl is needed to run tests in native builds, and to run the bundled
324 ;; copy of help2man. However, don't pass it when cross-compiling since
325 ;; that would lead it to try to run programs to get their '--help' output
327 (if (%current-target-system)
330 (outputs '("out" "debug"))
332 `(#:parallel-build? #f ; help2man may be called too early
333 #:phases (modify-phases %standard-phases
334 (add-before 'build 'patch-shell-references
336 ;; 'split' uses either $SHELL or /bin/sh. Set $SHELL so
337 ;; that tests pass, since /bin/sh isn't in the chroot.
338 (setenv "SHELL" (which "sh"))
340 (substitute* (find-files "gnulib-tests" "\\.c$")
341 (("/bin/sh") (which "sh")))
342 (substitute* (find-files "tests" "\\.sh$")
343 (("#!/bin/sh") (string-append "#!" (which "sh"))))
345 (add-before 'check 'disable-broken-test
347 ;; This test hits the 127 character shebang limit in the build
348 ;; environment due to the way "env -S" splits arguments into
349 ;; shebangs. Note that "env-S-script.sh" works around this
350 ;; specific issue, but "env-S.pl" is not adjusted for build
351 ;; environments with long prefixes (/tmp/guix-build-...).
352 (substitute* "Makefile"
353 (("^.*tests/misc/env-S.pl.*$") ""))
355 (synopsis "Core GNU utilities (file, text, shell)")
357 "GNU Coreutils package includes all of the basic command-line tools that
358 are expected in a POSIX system, excluding shell. This package is the union of
359 the GNU fileutils, sh-utils, and textutils packages. Most of these tools
360 offer extended functionality beyond that which is outlined in the POSIX
363 (home-page "https://www.gnu.org/software/coreutils/")))
365 (define-public coreutils-minimal
366 ;; Coreutils without its optional dependencies.
369 (name "coreutils-minimal")
373 (define-public gnu-make
379 (uri (string-append "mirror://gnu/make/make-" version
383 "12f5zzyq2w56g95nni65hc0g5p7154033y2f3qmjvd016szn5qnn"))
384 (patches (search-patches "make-impure-dirs.patch"
385 "make-glibc-compat.patch"))))
386 (build-system gnu-build-system)
387 (native-inputs `(("pkg-config" ,pkg-config))) ; to detect Guile
388 (inputs `(("guile" ,guile-2.0)))
389 (outputs '("out" "debug"))
391 '(;; Work around faulty glob detection with glibc 2.27. See
392 ;; <https://lists.nongnu.org/archive/html/bug-make/2017-11/msg00027.html>.
393 #:configure-flags '("make_cv_sys_gnu_glob=yes")
395 (modify-phases %standard-phases
396 (add-before 'build 'set-default-shell
397 (lambda* (#:key inputs #:allow-other-keys)
398 ;; Change the default shell from /bin/sh.
399 (let ((bash (assoc-ref inputs "bash")))
401 (("default_shell =.*$")
402 (format #f "default_shell = \"~a/bin/sh\";\n"
405 (synopsis "Remake files automatically")
407 "Make is a program that is used to control the production of
408 executables or other files from their source files. The process is
409 controlled from a Makefile, in which the developer specifies how each file is
410 generated from its source. It has powerful dependency resolution and the
411 ability to determine when files have to be regenerated after their sources
412 change. GNU make offers many powerful extensions over the standard utility.")
414 (home-page "https://www.gnu.org/software/make/")))
416 (define-public binutils
422 (uri (string-append "mirror://gnu/binutils/binutils-"
426 "0b8767nyal1bc4cyzg5h9iis8kpkln1i3wkamig75cifj1fb2f6y"))
427 (patches (search-patches "binutils-loongson-workaround.patch"))))
428 (build-system gnu-build-system)
430 ;; TODO: Add dependency on zlib + those for Gold.
432 `(#:configure-flags '(;; Add `-static-libgcc' to not retain a dependency
433 ;; on GCC when bootstrapping.
434 "LDFLAGS=-static-libgcc"
436 ;; Turn on --enable-new-dtags by default to make the
437 ;; linker set RUNPATH instead of RPATH on binaries.
438 ;; This is important because RUNPATH can be overriden
439 ;; using LD_LIBRARY_PATH at runtime.
442 ;; Don't search under /usr/lib & co.
443 "--with-lib-path=/no-ld-lib-path"
445 ;; Install BFD. It ends up in a hidden directory,
447 "--enable-install-libbfd"
449 ;; Make sure 'ar' and 'ranlib' produce archives in a
450 ;; deterministic fashion.
451 "--enable-deterministic-archives")))
453 (synopsis "Binary utilities: bfd gas gprof ld")
455 "GNU Binutils is a collection of tools for working with binary files.
456 Perhaps the most notable are \"ld\", a linker, and \"as\", an assembler.
457 Other tools include programs to display binary profiling information, list
458 the strings in a binary file, and utilities for working with archives. The
459 \"bfd\" library for working with executable and object formats is also
462 (home-page "https://www.gnu.org/software/binutils/")))
464 (define-public binutils-gold
467 (name "binutils-gold")
470 (modify-phases %standard-phases
471 (add-after 'patch-source-shebangs 'patch-more-shebangs
473 (substitute* "gold/Makefile.in"
474 (("/bin/sh") (which "sh")))
476 ,@(substitute-keyword-arguments (package-arguments binutils)
477 ; Upstream is aware of unrelocatable test failures on arm*.
479 (if (any (cute string-prefix? <> (or (%current-target-system)
483 ((#:configure-flags flags)
484 `(cons* "--enable-gold=default"
485 (delete "LDFLAGS=-static-libgcc" ,flags))))))
489 `(("gcc:lib" ,gcc "lib")))))
491 (define* (make-ld-wrapper name #:key
494 (guile (canonical-package guile-2.2))
495 (bash (canonical-package bash))
496 (guile-for-build guile))
497 "Return a package called NAME that contains a wrapper for the 'ld' program
498 of BINUTILS, which adds '-rpath' flags to the actual 'ld' command line. The
499 wrapper uses GUILE and BASH.
501 TARGET must be a one-argument procedure that, given a system type, returns a
502 cross-compilation target triplet or #f. When the result is not #f, make a
503 wrapper for the cross-linker for that target, called 'TARGET-ld'."
504 ;; Note: #:system->target-triplet is a procedure so that the evaluation of
505 ;; its result can be delayed until the 'arguments' field is evaluated, thus
506 ;; in a context where '%current-system' is accurate.
511 (build-system trivial-build-system)
512 (inputs `(("binutils" ,binutils)
515 ("wrapper" ,(search-path %load-path
516 "gnu/packages/ld-wrapper.in"))))
518 (let ((target (target (%current-system))))
519 `(#:guile ,guile-for-build
520 #:modules ((guix build utils))
522 (use-modules (guix build utils)
523 (system base compile))
525 (let* ((out (assoc-ref %outputs "out"))
526 (bin (string-append out "/bin"))
528 `(string-append bin "/" ,target "-ld")
529 '(string-append bin "/ld")))
530 (go (string-append ld ".go")))
532 (setvbuf (current-output-port) _IOLBF)
533 (format #t "building ~s/bin/ld wrapper in ~s~%"
534 (assoc-ref %build-inputs "binutils")
538 (copy-file (assoc-ref %build-inputs "wrapper") ld)
543 (string-append (assoc-ref %build-inputs "guile")
546 (string-append (assoc-ref %build-inputs "bash")
549 (string-append (assoc-ref %build-inputs "binutils")
551 (string-append "/bin/"
555 (compile-file ld #:output-file go)
557 (synopsis "The linker wrapper")
559 "The linker wrapper (or @code{ld-wrapper}) wraps the linker to add any
560 missing @code{-rpath} flags, and to detect any misuse of libraries outside of
562 (home-page "https://www.gnu.org/software/guix//")
565 (export make-ld-wrapper)
568 ;; This is the GNU C Library, used on GNU/Linux and GNU/Hurd. Prior to
569 ;; version 2.28, GNU/Hurd used a different glibc branch.
575 (uri (string-append "mirror://gnu/glibc/glibc-" version ".tar.xz"))
578 "0jzh58728flfh939a8k9pi1zdyalfzlxmwra7k0rzji5gvavivpk"))
580 ;; Disable 'ldconfig' and /etc/ld.so.cache. The latter is
581 ;; required on LFS distros to avoid loading the distro's libc.so
584 (substitute* "sysdeps/unix/sysv/linux/configure"
585 (("use_ldconfig=yes")
588 (modules '((guix build utils)))
589 (patches (search-patches "glibc-ldd-x86_64.patch"
590 "glibc-CVE-2019-7309.patch"
591 "glibc-CVE-2019-9169.patch"
592 "glibc-2.29-git-updates.patch"
593 "glibc-hidden-visibility-ldconfig.patch"
594 "glibc-versioned-locpath.patch"
595 "glibc-allow-kernel-2.6.32.patch"
596 "glibc-reinstate-prlimit64-fallback.patch"
597 "glibc-supported-locales.patch"))))
598 (build-system gnu-build-system)
600 ;; Glibc's <limits.h> refers to <linux/limit.h>, for instance, so glibc
601 ;; users should automatically pull Linux headers as well. On GNU/Hurd,
602 ;; libc provides <hurd.h>, which includes a bunch of Hurd and Mach headers,
603 ;; so both should be propagated.
606 `(("hurd-core-headers" ,hurd-core-headers))
607 `(("kernel-headers" ,linux-libre-headers))))
609 (outputs '("out" "debug"
610 "static")) ;9 MiB of .a files
613 `(#:out-of-source? #t
615 ;; The libraries have an empty RUNPATH, but some, such as the versioned
616 ;; libraries (libdl-2.24.so, etc.) have ld.so marked as NEEDED. Since
617 ;; these libraries are always going to be found anyway, just skip
619 #:validate-runpath? #f
621 #:modules ((ice-9 ftw)
624 (guix build gnu-build-system))
627 (list "--sysconfdir=/etc"
629 ;; Installing a locale archive with all the locales is to
630 ;; expensive (~100 MiB), so we rely on users to install the
631 ;; locales they really want.
633 ;; Set the default locale path. In practice, $LOCPATH may be
634 ;; defined to point whatever locales users want. However, setuid
635 ;; binaries don't honor $LOCPATH, so they'll instead look into
636 ;; $libc_cv_complocaledir; we choose /run/current-system/locale/X.Y,
637 ;; with the idea that it is going to be populated by the sysadmin.
638 ;; The "X.Y" sub-directory is because locale data formats are
639 ;; incompatible across libc versions; see
640 ;; <https://lists.gnu.org/archive/html/guix-devel/2015-08/msg00737.html>.
642 ;; `--localedir' is not honored, so work around it.
643 ;; See <http://sourceware.org/ml/libc-alpha/2013-03/msg00093.html>.
644 (string-append "libc_cv_complocaledir=/run/current-system/locale/"
645 ,(version-major+minor version))
647 (string-append "--with-headers="
648 (assoc-ref ,(if (%current-target-system)
649 '%build-target-inputs
654 ;; This is the default for most architectures as of GNU libc 2.26,
655 ;; but we specify it explicitly for clarity and consistency. See
656 ;; "kernel-features.h" in the GNU libc for details.
657 "--enable-kernel=3.2.0"
659 ;; Use our Bash instead of /bin/sh.
660 (string-append "BASH_SHELL="
661 (assoc-ref %build-inputs "bash")
664 ;; On GNU/Hurd we get discarded-qualifiers warnings for
665 ;; 'device_write_inband' among other things. Ignore them.
667 '("--disable-werror")
671 #:phases (modify-phases %standard-phases
673 'configure 'pre-configure
674 (lambda* (#:key inputs native-inputs outputs
676 (let* ((out (assoc-ref outputs "out"))
677 (bin (string-append out "/bin"))
678 ;; FIXME: Normally we would look it up only in INPUTS
679 ;; but cross-base uses it as a native input.
680 (bash (or (assoc-ref inputs "static-bash")
681 (assoc-ref native-inputs "static-bash"))))
682 ;; Install the rpc data base file under `$out/etc/rpc'.
683 ;; FIXME: Use installFlags = [ "sysconfdir=$(out)/etc" ];
684 (substitute* "sunrpc/Makefile"
685 (("^\\$\\(inst_sysconfdir\\)/rpc(.*)$" _ suffix)
686 (string-append out "/etc/rpc" suffix "\n"))
687 (("^install-others =.*$")
688 (string-append "install-others = " out "/etc/rpc\n")))
690 (substitute* "Makeconfig"
692 ;; <http://www.linuxfromscratch.org/lfs/view/stable/chapter05/glibc.html>,
693 ;; linking against libgcc_s is not needed with GCC
697 ;; Have `system' use that Bash.
698 (substitute* "sysdeps/posix/system.c"
699 (("#define[[:blank:]]+SHELL_PATH.*$")
700 (format #f "#define SHELL_PATH \"~a/bin/bash\"\n"
704 (substitute* "libio/iopopen.c"
706 (string-append bash "/bin/sh")))
708 ;; Same for the shell used by the 'exec' functions for
709 ;; scripts that lack a shebang.
710 (substitute* (find-files "." "^paths\\.h$")
711 (("#define[[:blank:]]+_PATH_BSHELL[[:blank:]].*$")
712 (string-append "#define _PATH_BSHELL \""
713 bash "/bin/sh\"\n")))
715 ;; Nscd uses __DATE__ and __TIME__ to create a string to
716 ;; make sure the client and server come from the same
717 ;; libc. Use something deterministic instead.
718 (substitute* "nscd/nscd_stat.c"
719 (("static const char compilation\\[21\\] =.*$")
721 "static const char compilation[21] = \""
722 (string-take (basename out) 20) "\";\n")))
724 ;; Make sure we don't retain a reference to the
726 (substitute* "malloc/mtrace.pl"
728 ;; The shebang can be omitted, because there's the
729 ;; "bilingual" eval/exec magic at the top of the file.
736 (add-after 'install 'move-static-libs
737 (lambda* (#:key outputs #:allow-other-keys)
738 ;; Move static libraries to the "static" output.
739 (define (static-library? file)
740 ;; Return true if FILE is a static library. The
741 ;; "_nonshared.a" files are referred to by libc.so,
742 ;; libpthread.so, etc., which are in fact linker
744 (and (string-suffix? ".a" file)
745 (not (string-contains file "_nonshared"))))
747 (define (linker-script? file)
748 ;; Guess whether FILE, a ".a" file, is actually a
750 (and (not (ar-file? file))
751 (not (elf-file? file))))
753 (let* ((out (assoc-ref outputs "out"))
754 (lib (string-append out "/lib"))
755 (files (scandir lib static-library?))
756 (static (assoc-ref outputs "static"))
757 (slib (string-append static "/lib")))
759 (for-each (lambda (base)
760 (rename-file (string-append lib "/" base)
761 (string-append slib "/" base)))
764 ;; Usually libm.a is a linker script so we need to
765 ;; change the file names in there to refer to STATIC
767 (for-each (lambda (ld-script)
768 (substitute* ld-script
770 (filter linker-script?
771 (map (cut string-append slib "/" <>)
776 '((add-after 'install 'augment-libc.so
777 (lambda* (#:key outputs #:allow-other-keys)
778 (let* ((out (assoc-ref outputs "out")))
779 (substitute* (string-append out "/lib/libc.so")
780 (("/[^ ]+/lib/libc.so.0.3")
781 (string-append out "/lib/libc.so.0.3"
782 " libmachuser.so libhurduser.so"))))
786 (inputs `(("static-bash" ,static-bash)))
788 ;; To build the manual, we need Texinfo and Perl. Gettext is needed to
789 ;; install the message catalogs, with 'msgfmt'.
790 (native-inputs `(("texinfo" ,texinfo)
793 ("gettext" ,gettext-minimal)
794 ("python" ,python-minimal)
802 ;; Search path for packages that provide locale data. This is useful
803 ;; primarily in build environments. Use 'GUIX_LOCPATH' rather than
804 ;; 'LOCPATH' to avoid interference with the host system's libc on foreign
806 (list (search-path-specification
807 (variable "GUIX_LOCPATH")
808 (files '("lib/locale")))))
810 (synopsis "The GNU C Library")
812 "Any Unix-like operating system needs a C library: the library which
813 defines the \"system calls\" and other basic facilities such as open, malloc,
816 The GNU C library is used as the C library in the GNU system and most systems
817 with the Linux kernel.")
819 (home-page "https://www.gnu.org/software/libc/")))
821 ;; Below are old libc versions, which we use mostly to build locale data in
822 ;; the old format (which the new libc cannot cope with.)
824 (define-public glibc-2.28
829 (inherit (package-source glibc))
830 (uri (string-append "mirror://gnu/glibc/glibc-" version ".tar.xz"))
833 "10iha5ynvdj5m62vgpgqbq4cwvc2yhyl2w9yyyjgfxmdmx8h145i"))
834 (patches (search-patches "glibc-ldd-x86_64.patch"
835 "glibc-2.28-git-fixes.patch"
836 "glibc-hidden-visibility-ldconfig.patch"
837 "glibc-versioned-locpath.patch"
838 "glibc-allow-kernel-2.6.32.patch"
839 "glibc-reinstate-prlimit64-fallback.patch"
840 "glibc-hurd-magic-pid.patch"
841 "glibc-2.28-supported-locales.patch"))))))
843 (define-public glibc-2.27
848 (inherit (package-source glibc))
849 (uri (string-append "mirror://gnu/glibc/glibc-" version ".tar.xz"))
852 "0wpwq7gsm7sd6ysidv0z575ckqdg13cr2njyfgrbgh4f65adwwji"))
853 (patches (search-patches "glibc-ldd-x86_64.patch"
854 "glibc-2.27-git-fixes.patch"
855 "glibc-hidden-visibility-ldconfig.patch"
856 "glibc-versioned-locpath.patch"
857 "glibc-allow-kernel-2.6.32.patch"
858 "glibc-reinstate-prlimit64-fallback.patch"
859 "glibc-2.27-supported-locales.patch"
860 "glibc-CVE-2018-11236.patch"
861 "glibc-CVE-2018-11237.patch"))))
862 (properties `((lint-hidden-cve . ("CVE-2017-18269")))))) ; glibc-2.27-git-fixes
864 (define-public glibc-2.26
867 ;; This version number corresponds to the output of `git describe` and the
868 ;; archive can be generated by checking out the commit ID and running:
869 ;; git archive --prefix=$(git describe)/ HEAD | xz > $(git describe).tar.xz
870 ;; See <https://bugs.gnu.org/29406> for why this was necessary.
871 (version "2.26.105-g0890d5379c")
873 (inherit (package-source glibc))
874 (uri (string-append "https://alpha.gnu.org/gnu/guix/mirror/"
875 "glibc-" (version-major+minor version) "-"
876 (caddr (string-split version #\.)) ".tar.xz"))
879 "1jck0c1i248sn02rvsfjykk77qncma34bjq89dyy2irwm50d7s3g"))
880 (patches (search-patches "glibc-ldd-x86_64.patch"
881 "glibc-versioned-locpath.patch"
882 "glibc-allow-kernel-2.6.32.patch"))))))
884 (define-public glibc-2.25
889 (inherit (package-source glibc))
890 (uri (string-append "mirror://gnu/glibc/glibc-"
894 "1813dzkgw6v8q8q1m4v96yfis7vjqc9pslqib6j9mrwh6fxxjyq6"))
895 (patches (search-patches "glibc-ldd-x86_64.patch"
896 "glibc-versioned-locpath.patch"
897 "glibc-vectorized-strcspn-guards.patch"
898 "glibc-CVE-2017-1000366-pt1.patch"
899 "glibc-CVE-2017-1000366-pt2.patch"
900 "glibc-CVE-2017-1000366-pt3.patch"))))))
902 (define-public glibc-2.24
907 (inherit (package-source glibc))
908 (uri (string-append "mirror://gnu/glibc/glibc-"
912 "1lxmprg9gm73gvafxd503x70z32phwjzcy74i0adfi6ixzla7m4r"))
913 (patches (search-patches "glibc-ldd-x86_64.patch"
914 "glibc-versioned-locpath.patch"
915 "glibc-vectorized-strcspn-guards.patch"
916 "glibc-CVE-2015-5180.patch"
917 "glibc-CVE-2017-1000366-pt1.patch"
918 "glibc-CVE-2017-1000366-pt2.patch"
919 "glibc-CVE-2017-1000366-pt3.patch"))))))
921 (define-public glibc-2.23
926 (inherit (package-source glibc))
927 (uri (string-append "mirror://gnu/glibc/glibc-"
931 "1s8krs3y2n6pzav7ic59dz41alqalphv7vww4138ag30wh0fpvwl"))
932 (patches (search-patches "glibc-ldd-x86_64.patch"
933 "glibc-versioned-locpath.patch"
934 "glibc-vectorized-strcspn-guards.patch"
935 "glibc-CVE-2015-5180.patch"
936 "glibc-CVE-2016-3075.patch"
937 "glibc-CVE-2016-3706.patch"
938 "glibc-CVE-2016-4429.patch"
939 "glibc-CVE-2017-1000366-pt1.patch"
940 "glibc-CVE-2017-1000366-pt2.patch"
941 "glibc-CVE-2017-1000366-pt3.patch"))))))
943 (define-public glibc-2.22
948 (inherit (package-source glibc))
949 (uri (string-append "mirror://gnu/glibc/glibc-"
953 "0j49682pm2nh4qbdw35bas82p1pgfnz4d2l7iwfyzvrvj0318wzb"))
954 (patches (search-patches "glibc-ldd-x86_64.patch"
955 "glibc-o-largefile.patch"
956 "glibc-vectorized-strcspn-guards.patch"
957 "glibc-CVE-2015-5180.patch"
958 "glibc-CVE-2015-7547.patch"
959 "glibc-CVE-2016-3075.patch"
960 "glibc-CVE-2016-3706.patch"
961 "glibc-CVE-2016-4429.patch"
962 "glibc-CVE-2017-1000366-pt1.patch"
963 "glibc-CVE-2017-1000366-pt2.patch"
964 "glibc-CVE-2017-1000366-pt3.patch"))))
966 (substitute-keyword-arguments (package-arguments glibc)
968 `(modify-phases ,phases
969 (add-before 'configure 'fix-pwd
971 ;; Use `pwd' instead of `/bin/pwd' for glibc-2.22.
972 (substitute* "configure"
973 (("/bin/pwd") "pwd"))
976 (define-public (make-gcc-libc base-gcc libc)
977 "Return a GCC that targets LIBC."
978 (package (inherit base-gcc)
979 (name (string-append (package-name base-gcc) "-"
980 (package-name libc) "-"
981 (package-version libc)))
983 (substitute-keyword-arguments
984 (ensure-keyword-arguments (package-arguments base-gcc)
985 '(#:implicit-inputs? #f))
987 `(modify-phases ,phases
988 (add-before 'configure 'treat-glibc-as-system-header
990 (let ((libc (assoc-ref %build-inputs "libc")))
991 ;; GCCs build processes requires that the libc
992 ;; we're building against is on the system header
994 (for-each (lambda (var)
995 (setenv var (string-append libc "/include")))
996 '("C_INCLUDE_PATH" "CPLUS_INCLUDE_PATH"))
999 `(,@(package-native-inputs base-gcc)
1000 ,@(append (fold alist-delete (%final-inputs) '("libc" "libc:static")))
1002 ("libc:static" ,libc "static")))))
1004 (define-public (make-glibc-locales glibc)
1007 (name "glibc-locales")
1008 (source (origin (inherit (package-source glibc))
1009 ;; The patch for glibc 2.28 and earlier replaces the same
1010 ;; content, but the context in the patch is different
1011 ;; enough to fail to merge.
1012 (patches (cons (search-patch
1013 (if (version>=? (package-version glibc)
1015 "glibc-locales.patch"
1016 "glibc-locales-2.28.patch"))
1017 (origin-patches (package-source glibc))))))
1018 (synopsis "All the locales supported by the GNU C Library")
1020 "This package provides all the locales supported by the GNU C Library,
1021 more than 400 in total. To use them set the @code{LOCPATH} environment variable
1022 to the @code{share/locale} sub-directory of this package.")
1023 (outputs '("out")) ;110+ MiB
1024 (native-search-paths '())
1026 (let ((args `(#:tests? #f #:strip-binaries? #f
1027 ,@(package-arguments glibc))))
1028 (substitute-keyword-arguments args
1029 ((#:modules modules '((guix build utils)
1030 (guix build gnu-build-system)))
1034 ((#:imported-modules modules '())
1035 `((gnu build locale)
1036 ,@%gnu-build-system-modules))
1038 `(modify-phases ,phases
1041 (invoke "make" "localedata/install-locales"
1042 "-j" (number->string (parallel-job-count)))))
1043 (add-after 'build 'symlink-normalized-codesets
1044 (lambda* (#:key outputs #:allow-other-keys)
1045 ;; The above phase does not install locales with names using
1046 ;; the "normalized codeset." Thus, create symlinks like:
1047 ;; en_US.utf8 -> en_US.UTF-8
1048 (define (locale-directory? file stat)
1049 (and (file-is-directory? file)
1050 (string-index (basename file) #\_)
1051 (string-rindex (basename file) #\.)))
1053 (let* ((out (assoc-ref outputs "out"))
1054 (locales (find-files out locale-directory?
1055 #:directories? #t)))
1056 (for-each (lambda (directory)
1057 (let*-values (((base)
1058 (basename directory))
1060 (locale->name+codeset base))
1062 (normalize-codeset codeset)))
1063 (unless (string=? codeset normalized)
1065 (string-append (dirname directory)
1071 (delete 'move-static-libs)))
1072 ((#:configure-flags flags)
1074 ;; Use $(libdir)/locale/X.Y as is the case by default.
1075 (list (string-append "libc_cv_complocaledir="
1076 (assoc-ref %outputs "out")
1078 ,(version-major+minor
1079 (package-version glibc)))))))))))
1081 (define-public (make-glibc-utf8-locales glibc)
1083 (name "glibc-utf8-locales")
1084 (version (package-version glibc))
1086 (build-system trivial-build-system)
1088 `(#:modules ((guix build utils))
1090 (use-modules (guix build utils))
1092 (let* ((libc (assoc-ref %build-inputs "glibc"))
1093 (gzip (assoc-ref %build-inputs "gzip"))
1094 (out (assoc-ref %outputs "out"))
1095 (localedir (string-append out "/lib/locale/"
1096 ,(version-major+minor version))))
1097 ;; 'localedef' needs 'gzip'.
1098 (setenv "PATH" (string-append libc "/bin:" gzip "/bin"))
1101 (for-each (lambda (locale)
1103 ;; Use the "normalized codeset" by
1104 ;; default--e.g., "en_US.utf8".
1105 (string-append localedir "/" locale ".utf8"))
1107 (invoke "localedef" "--no-archive"
1108 "--prefix" localedir
1112 ;; For backward compatibility with Guix
1113 ;; <= 0.8.3, add "xx_YY.UTF-8".
1114 (symlink (string-append locale ".utf8")
1115 (string-append localedir "/"
1118 ;; These are the locales commonly used for
1119 ;; tests---e.g., in Guile's i18n tests.
1120 '("de_DE" "el_GR" "en_US" "fr_FR" "tr_TR"))
1122 (native-inputs `(("glibc" ,glibc)
1124 (synopsis "Small sample of UTF-8 locales")
1126 "This package provides a small sample of UTF-8 locales mostly useful in
1127 test environments.")
1128 (home-page (package-home-page glibc))
1129 (license (package-license glibc))))
1131 (define-public glibc-locales
1132 (make-glibc-locales glibc))
1133 (define-public glibc-utf8-locales
1134 (make-glibc-utf8-locales glibc))
1136 ;; Packages provided to ease use of binaries linked against the previous libc.
1137 (define-public glibc-locales-2.28
1138 (package (inherit (make-glibc-locales glibc-2.28))
1139 (name "glibc-locales-2.28")))
1140 (define-public glibc-utf8-locales-2.28
1141 (package (inherit (make-glibc-utf8-locales glibc-2.28))
1142 (name "glibc-utf8-locales-2.28")))
1144 ;; These should no longer be needed.
1145 (define-public glibc-utf8-locales-2.27
1146 (deprecated-package "glibc-utf8-locales-2.27" glibc-utf8-locales-2.28))
1147 (define-public glibc-locales-2.27
1148 (deprecated-package "glibc-locales-2.27" glibc-locales-2.28))
1150 (define-public which
1156 (uri (string-append "mirror://gnu/which/which-"
1160 "1bgafvy3ypbhhfznwjv1lxmd6mci3x1byilnnkc7gcr486wlb8pl"))))
1161 (build-system gnu-build-system)
1162 (home-page "https://gnu.org/software/which/")
1163 (synopsis "Find full path of shell commands")
1165 "The which program finds the location of executables in PATH, with a
1166 variety of options. It is an alternative to the shell \"type\" built-in
1168 (license gpl3+))) ; some files are under GPLv2+
1170 (define-public glibc/hurd-headers
1171 (package (inherit glibc)
1172 (name "glibc-hurd-headers")
1174 (propagated-inputs `(("gnumach-headers" ,gnumach-headers)
1175 ("hurd-headers" ,hurd-headers)))
1177 (substitute-keyword-arguments (package-arguments glibc)
1178 ;; We just pass the flags really needed to build the headers.
1179 ((#:configure-flags _)
1180 `(list "--enable-add-ons"
1181 "--host=i586-pc-gnu"))
1183 '(modify-phases %standard-phases
1185 (lambda* (#:key outputs #:allow-other-keys)
1186 (invoke "make" "install-headers")
1188 ;; Make an empty stubs.h to work around not being able to
1189 ;; produce a valid stubs.h and causing the build to fail. See
1190 ;; <http://lists.gnu.org/archive/html/guix-devel/2014-04/msg00233.html>.
1191 (let ((out (assoc-ref outputs "out")))
1194 (string-append out "/include/gnu/stubs.h"))))
1196 (delete 'build))))))) ; nothing to build
1198 (define-public tzdata
1205 "https://data.iana.org/time-zones/releases/tzdata"
1209 "0z7w1yv37cfk8yhix2cillam091vgp1j4g8fv84261q9mdnq1ivr"))))
1210 (build-system gnu-build-system)
1213 #:make-flags (let ((out (assoc-ref %outputs "out"))
1214 (tmp (getenv "TMPDIR")))
1215 (list (string-append "TOPDIR=" out)
1216 (string-append "TZDIR=" out "/share/zoneinfo")
1217 (string-append "TZDEFAULT=" out
1218 "/share/zoneinfo/localtime")
1220 ;; Likewise for the C library routines.
1221 (string-append "LIBDIR=" tmp "/lib")
1222 (string-append "MANDIR=" tmp "/man")
1226 #:modules ((guix build utils)
1227 (guix build gnu-build-system)
1230 (modify-phases %standard-phases
1232 (lambda* (#:key source inputs #:allow-other-keys)
1233 (invoke "tar" "xvf" source)
1234 (invoke "tar" "xvf" (assoc-ref inputs "tzcode"))))
1235 (add-after 'install 'post-install
1236 (lambda* (#:key outputs #:allow-other-keys)
1237 ;; Move data in the right place.
1238 (let ((out (assoc-ref outputs "out")))
1239 ;; Discard zic, dump, and tzselect, already
1240 ;; provided by glibc.
1241 (delete-file-recursively (string-append out "/usr"))
1242 (symlink (string-append out "/share/zoneinfo")
1243 (string-append out "/share/zoneinfo/posix"))
1244 (delete-file-recursively
1245 (string-append out "/share/zoneinfo-posix"))
1246 (copy-recursively (string-append out "/share/zoneinfo-leaps")
1247 (string-append out "/share/zoneinfo/right"))
1248 (delete-file-recursively
1249 (string-append out "/share/zoneinfo-leaps"))
1251 (delete 'configure))))
1252 (inputs `(("tzcode" ,(origin
1255 "https://data.iana.org/time-zones/releases/tzcode"
1259 "1m3y2rnf1nggxxhxplab5zdd5whvar3ijyrv7lifvm82irkd7szn"))))))
1260 (home-page "https://www.iana.org/time-zones")
1261 (synopsis "Database of current and historical time zones")
1262 (description "The Time Zone Database (often called tz or zoneinfo)
1263 contains code and data that represent the history of local time for many
1264 representative locations around the globe. It is updated periodically to
1265 reflect changes made by political bodies to time zone boundaries, UTC offsets,
1266 and daylight-saving rules.")
1267 (license public-domain)))
1269 ;;; A "fixed" version of tzdata, which is used in the test suites of glib and R
1270 ;;; and a few other places. We can update this whenever we are able to rebuild
1271 ;;; thousands of packages (for example, in a core-updates rebuild). This package
1272 ;;; will typically be obsolete and should never be referred to by a built
1274 (define-public tzdata-for-tests
1282 "https://data.iana.org/time-zones/releases/tzdata"
1286 "0r0clnlslwm15m1c61dinf1fi9ffgl6aipng7i7yryfwj0n0kn85"))))
1288 `(("tzcode" ,(origin
1291 "https://data.iana.org/time-zones/releases/tzcode"
1295 "0vbmswvv3li25s31shyllq5v24449lxnrki9hr043nipjd09sirf")))))))))
1297 (define-public libiconv
1303 (uri (string-append "mirror://gnu/libiconv/libiconv-"
1307 "0y1ij745r4p48mxq84rax40p10ln7fc7m243p8k8sia519i3dxfc"))
1308 (modules '((guix build utils)))
1310 ;; Work around "declared gets" error on glibc systems (fixed by
1311 ;; Gnulib commit 66712c23388e93e5c518ebc8515140fa0c807348.)
1313 (substitute* "srclib/stdio.in.h"
1314 (("^#undef gets") "")
1315 (("^_GL_WARN_ON_USE \\(gets.*") ""))
1317 (build-system gnu-build-system)
1318 (synopsis "Character set conversion library")
1320 "libiconv provides an implementation of the iconv function for systems
1321 that lack it. iconv is used to convert between character encodings in a
1322 program. It supports a wide variety of different encodings.")
1323 (home-page "https://www.gnu.org/software/libiconv/")
1326 (define* (libiconv-if-needed #:optional (target (%current-target-system)))
1327 "Return either a libiconv package specification to include in a dependency
1328 list for platforms that have an incomplete libc, or the empty list. If a
1329 package needs iconv ,@(libiconv-if-needed) should be added."
1330 ;; POSIX C libraries provide iconv. Platforms with an incomplete libc
1331 ;; without iconv, such as MinGW, must return the then clause.
1332 (if (target-mingw? target)
1333 `(("libiconv" ,libiconv))
1336 (define-public (canonical-package package)
1337 ;; Avoid circular dependency by lazily resolving 'commencement'.
1338 (let* ((iface (resolve-interface '(gnu packages commencement)))
1339 (proc (module-ref iface 'canonical-package)))
1342 (define-public (%final-inputs)
1343 "Return the list of \"final inputs\"."
1344 ;; Avoid circular dependency by lazily resolving 'commencement'.
1345 (let ((iface (resolve-interface '(gnu packages commencement))))
1346 (module-ref iface '%final-inputs)))
1348 ;;; base.scm ends here