1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 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, 2020, 2021 Efraim Flashner <efraim@flashner.co.il>
9 ;;; Copyright © 2016, 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
10 ;;; Copyright © 2016, 2018 Alex Vong <alexvong1995@gmail.com>
11 ;;; Copyright © 2017 Rene Saavedra <rennes@openmailbox.org>
12 ;;; Copyright © 2017, 2020 Mathieu Othacehe <m.othacehe@gmail.com>
13 ;;; Copyright © 2017, 2018, 2020 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>
18 ;;; Copyright © 2020 Chris Marusich <cmmarusich@gmail.com>
19 ;;; Copyright © 2021 Leo Le Bouter <lle-bout@zaclys.net>
21 ;;; This file is part of GNU Guix.
23 ;;; GNU Guix is free software; you can redistribute it and/or modify it
24 ;;; under the terms of the GNU General Public License as published by
25 ;;; the Free Software Foundation; either version 3 of the License, or (at
26 ;;; your option) any later version.
28 ;;; GNU Guix is distributed in the hope that it will be useful, but
29 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
30 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31 ;;; GNU General Public License for more details.
33 ;;; You should have received a copy of the GNU General Public License
34 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
36 (define-module (gnu packages base)
37 #:use-module ((guix licenses)
38 #:select (gpl3+ lgpl2.0+ lgpl3+ public-domain))
39 #:use-module (gnu packages)
40 #:use-module (gnu packages acl)
41 #:use-module (gnu packages algebra)
42 #:use-module (gnu packages bash)
43 #:use-module (gnu packages bison)
44 #:use-module (gnu packages ed)
45 #:use-module (gnu packages gcc)
46 #:use-module (gnu packages guile)
47 #:use-module (gnu packages multiprecision)
48 #:use-module (gnu packages compression)
49 #:use-module (gnu packages perl)
50 #:use-module (gnu packages linux)
51 #:use-module (gnu packages pcre)
52 #:use-module (gnu packages texinfo)
53 #:use-module (gnu packages hurd)
54 #:use-module (gnu packages pkg-config)
55 #:use-module (gnu packages python)
56 #:use-module (gnu packages gettext)
57 #:use-module (guix i18n)
58 #:use-module (guix utils)
59 #:use-module (guix packages)
60 #:use-module (guix download)
61 #:use-module (guix git-download)
62 #:use-module (guix build-system gnu)
63 #:use-module (guix build-system trivial)
64 #:use-module (ice-9 format)
65 #:use-module (ice-9 match)
66 #:use-module (ice-9 optargs)
67 #:use-module (srfi srfi-1)
68 #:use-module (srfi srfi-26)
74 ;;; Base packages of the Guix-based GNU user-land software distribution.
84 (uri (string-append "mirror://gnu/hello/hello-" version
88 "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"))))
89 (build-system gnu-build-system)
90 (synopsis "Hello, GNU world: An example GNU package")
92 "GNU Hello prints the message \"Hello, world!\" and then exits. It
93 serves as an example of standard GNU coding practices. As such, it supports
94 command-line arguments, multiple languages, and so on.")
95 (home-page "https://www.gnu.org/software/hello/")
104 (uri (string-append "mirror://gnu/grep/grep-"
108 "1yy33kiwrxrwj2nxa4fg15bvmwyghqbs8qwkdvy5phm784f7brjq"))
109 (patches (search-patches "grep-timing-sensitive-test.patch"))))
110 (build-system gnu-build-system)
111 (native-inputs `(("perl" ,perl))) ;some of the tests require it
112 (inputs `(("pcre" ,pcre)))
115 (modify-phases %standard-phases
116 (add-after 'install 'fix-egrep-and-fgrep
117 ;; Patch 'egrep' and 'fgrep' to execute 'grep' via its
118 ;; absolute file name instead of searching for it in $PATH.
119 (lambda* (#:key outputs #:allow-other-keys)
120 (let* ((out (assoc-ref outputs "out"))
121 (bin (string-append out "/bin")))
122 (substitute* (list (string-append bin "/egrep")
123 (string-append bin "/fgrep"))
125 (string-append "exec " bin "/grep")))
127 (synopsis "Print lines matching a pattern")
129 "grep is a tool for finding text inside files. Text is found by
130 matching a pattern provided by the user in one or many files. The pattern
131 may be provided as a basic or extended regular expression, or as fixed
132 strings. By default, the matching text is simply printed to the screen,
133 however the output can be greatly customized to include, for example, line
134 numbers. GNU grep offers many extensions over the standard utility,
135 including, for example, recursive directory searching.")
137 (home-page "https://www.gnu.org/software/grep/")))
145 (uri (string-append "mirror://gnu/sed/sed-" version
149 "0alqagh0nliymz23kfjg6g9w3cr086k0sfni56gi8fhzqwa3xksk"))))
150 (build-system gnu-build-system)
152 ;; TODO: When merging this into core-updates, keep the version of
153 ;; this code (with comment!) applied as a snippet.
154 `(,@(if (string-prefix? "powerpc64le" (or (%current-target-system)
157 (modify-phases %standard-phases
158 (add-after 'unpack 'allow-building-on-selinux-systems
160 (substitute* "Makefile.in"
161 (("^ abs_srcdir='\\$\\(abs_srcdir\\)'.*" previous-line)
164 " CONFIG_HEADER='$(CONFIG_HEADER)'\t\t\\\n")))
167 (synopsis "Stream editor")
169 `(("perl" ,perl))) ;for tests
171 "Sed is a non-interactive, text stream editor. It receives a text
172 input from a file or from standard input and it then applies a series of text
173 editing commands to the stream and prints its output to standard output. It
174 is often used for substituting text patterns in a stream. The GNU
175 implementation offers several extensions over the standard utility.")
177 (home-page "https://www.gnu.org/software/sed/")))
185 (uri (string-append "mirror://gnu/tar/tar-"
189 "1n7xy657ii0sa42zx6944v2m4v9qrh6sqgmw17l3nch3y43sxlyh"))
190 (patches (search-patches "tar-skip-unreliable-tests.patch"
191 "tar-remove-wholesparse-check.patch"))))
192 (build-system gnu-build-system)
193 ;; Note: test suite requires ~1GiB of disk space.
195 `(,@(if (hurd-target?)
198 "TESTSUITEFLAGS= -k '"
200 ",!renamed dirs in incrementals"
201 ",!--exclude-tag option in incremental pass"
202 ",!incremental dumps with -C"
203 ",!incremental dumps of nested directories"
204 ",!incremental restores with -C"
205 ",!concatenated incremental archives (renames)"
206 ",!renamed directory containing subdirectories"
207 ",!renamed subdirectories"
210 #:phases (modify-phases %standard-phases
211 (add-before 'build 'set-shell-file-name
212 (lambda* (#:key inputs #:allow-other-keys)
213 ;; Do not use "/bin/sh" to run programs.
214 (let ((bash (assoc-ref inputs "bash")))
215 (substitute* "src/system.c"
217 (string-append bash "/bin/sh")))
220 ;; When cross-compiling, the 'set-shell-file-name' phase needs to be able
221 ;; to refer to the target Bash.
222 (inputs (if (%current-target-system)
226 (synopsis "Managing tar archives")
228 "Tar provides the ability to create tar archives, as well as the
229 ability to extract, update or list files in an existing archive. It is
230 useful for combining many files into one larger file, while maintaining
231 directory structure and file information such as permissions and
232 creation/modification dates. GNU tar offers many extensions over the
235 (home-page "https://www.gnu.org/software/tar/")))
243 (uri (string-append "mirror://gnu/patch/patch-"
247 "1zfqy4rdcy279vwn2z1kbv19dcfw25d2aqy9nzvdkq5bjzd0nqdc"))
248 (patches (search-patches "patch-hurd-path-max.patch"))))
249 (build-system gnu-build-system)
251 ;; Work around a cross-compilation bug whereby libpatch.a would provide
252 ;; '__mktime_internal', which conflicts with the one in libc.a.
253 (if (%current-target-system)
254 `(#:configure-flags '("gl_cv_func_working_mktime=yes"))
256 (native-inputs `(("ed" ,ed)))
257 (synopsis "Apply differences to originals, with optional backups")
259 "Patch is a program that applies changes to files based on differences
260 laid out as by the program \"diff\". The changes may be applied to one or more
261 files depending on the contents of the diff file. It accepts several
262 different diff formats. It may also be used to revert previously applied
265 (home-page "https://savannah.gnu.org/projects/patch/")))
267 (define-public diffutils
273 (uri (string-append "mirror://gnu/diffutils/diffutils-"
277 "09isrg0isjinv8c535nxsi1s86wfdfzml80dbw41dj9x3hiad9xk"))))
278 (build-system gnu-build-system)
279 (native-inputs `(("perl" ,perl)))
280 (synopsis "Comparing and merging files")
282 "GNU Diffutils is a package containing tools for finding the
283 differences between files. The \"diff\" command is used to show how two files
284 differ, while \"cmp\" shows the offsets and line numbers where they differ.
285 \"diff3\" allows you to compare three files. Finally, \"sdiff\" offers an
286 interactive means to merge two files.")
288 (home-page "https://www.gnu.org/software/diffutils/")))
290 (define-public findutils
296 (uri (string-append "mirror://gnu/findutils/findutils-"
300 "16kqz9yz98dasmj70jwf5py7jk558w96w0vgp3zf9xsqk3gzpzn5"))
301 (patches (search-patches "findutils-localstatedir.patch"
302 "findutils-test-rwlock-threads.patch"))))
303 (build-system gnu-build-system)
305 `(#:configure-flags (list
306 ;; Tell 'updatedb' to write to /var.
307 "--localstatedir=/var")
308 #:phases (modify-phases %standard-phases
309 (add-before 'check 'adjust-test-shebangs
311 (substitute* '("tests/xargs/verbose-quote.sh"
312 "tests/find/exec-plus-last-file.sh")
314 (string-append "#!" (which "sh"))))
316 (synopsis "Operating on files matching given criteria")
318 "Findutils supplies the basic file directory searching utilities of the
319 GNU system. It consists of two primary searching utilities: \"find\"
320 recursively searches for files in a directory according to given criteria and
321 \"locate\" lists files in a database that match a query. Two auxiliary tools
322 are included: \"updatedb\" updates the file name database and \"xargs\" may be
323 used to apply commands with arbitrarily long arguments.")
325 (home-page "https://www.gnu.org/software/findutils/")))
327 (define-public coreutils
333 (uri (string-append "mirror://gnu/coreutils/coreutils-"
337 "1yjcrh5hw70c0yn8zw55pd6j51dj90anpq8mmg649ps9g3gdhn24"))
338 (patches (search-patches "coreutils-ls.patch"))))
339 (build-system gnu-build-system)
340 (inputs `(("acl" ,acl) ; TODO: add SELinux
341 ("gmp" ,gmp) ;bignums in 'expr', yay!
343 ;; Do not use libcap when cross-compiling since it's not quite
344 ;; cross-compilable; and use it only for supported systems.
345 ,@(if (and (not (%current-target-system))
346 (member (%current-system)
347 (package-supported-systems libcap)))
348 `(("libcap" ,libcap-2.31)) ;capability support in 'ls', etc.
351 ;; Perl is needed to run tests in native builds, and to run the bundled
352 ;; copy of help2man. However, don't pass it when cross-compiling since
353 ;; that would lead it to try to run programs to get their '--help' output
355 (if (%current-target-system)
358 (outputs '("out" "debug"))
360 `(#:parallel-build? #f ; help2man may be called too early
362 '(#:make-flags ; these tests fail deterministically
363 (list (string-append "XFAIL_TESTS=tests/misc/env-S.pl"
364 " tests/misc/kill.sh"
365 " tests/misc/nice.sh"
366 " tests/misc/pwd-long.sh"
367 " tests/split/fail.sh"
376 #:phases (modify-phases %standard-phases
377 (add-before 'build 'patch-shell-references
379 ;; 'split' uses either $SHELL or /bin/sh. Set $SHELL so
380 ;; that tests pass, since /bin/sh isn't in the chroot.
381 (setenv "SHELL" (which "sh"))
383 (substitute* (find-files "gnulib-tests" "\\.c$")
384 (("/bin/sh") (which "sh")))
385 (substitute* (find-files "tests" "\\.sh$")
386 (("#!/bin/sh") (string-append "#!" (which "sh"))))
389 `((add-after 'unpack 'remove-tests
391 (substitute* "Makefile.in"
393 (("^ *tests/misc/timeout-group.sh.*") ""))
396 (synopsis "Core GNU utilities (file, text, shell)")
398 "GNU Coreutils package includes all of the basic command-line tools that
399 are expected in a POSIX system, excluding shell. This package is the union of
400 the GNU fileutils, sh-utils, and textutils packages. Most of these tools
401 offer extended functionality beyond that which is outlined in the POSIX
404 (home-page "https://www.gnu.org/software/coreutils/")))
406 (define-public coreutils-minimal
407 ;; Coreutils without its optional dependencies.
410 (name "coreutils-minimal")
414 (define-public coreutils-8.30
415 ;; XXX: This version is kept just so we can run PRoot tests.
418 (inherit coreutils-minimal)
422 (uri (string-append "mirror://gnu/coreutils/coreutils-"
426 "0mxhw43d4wpqmvg0l4znk1vm10fy92biyh90lzdnqjcic2lb6cg8"))))
428 (substitute-keyword-arguments (package-arguments coreutils-minimal)
429 ((#:phases phases '%standard-phases)
430 `(modify-phases ,phases
431 (add-before 'check 'disable-broken-test
433 ;; This test hits the 127 character shebang limit in the build
434 ;; environment due to the way "env -S" splits arguments into
435 ;; shebangs. Note that "env-S-script.sh" works around this
436 ;; specific issue, but "env-S.pl" is not adjusted for build
437 ;; environments with long prefixes (/tmp/guix-build-...).
438 (substitute* "Makefile"
439 (("^.*tests/misc/env-S.pl.*$") ""))
442 (define-public gnu-make
448 (uri (string-append "mirror://gnu/make/make-" version
452 "06cfqzpqsvdnsxbysl5p2fgdgxgl9y4p7scpnrfa8z2zgkjdspz0"))
453 (patches (search-patches "make-impure-dirs.patch"))))
454 (build-system gnu-build-system)
455 (native-inputs `(("pkg-config" ,pkg-config))) ; to detect Guile
456 (inputs `(("guile" ,guile-3.0)))
457 (outputs '("out" "debug"))
459 `(,@(if (hurd-target?)
460 '(#:configure-flags '("CFLAGS=-D__alloca=alloca"
461 "ac_cv_func_posix_spawn=no"))
464 (modify-phases %standard-phases
465 (add-before 'build 'set-default-shell
466 (lambda* (#:key inputs #:allow-other-keys)
467 ;; Change the default shell from /bin/sh.
468 (let ((bash (assoc-ref inputs "bash")))
469 (substitute* "src/job.c"
470 (("default_shell =.*$")
471 (format #f "default_shell = \"~a/bin/sh\";\n"
474 (synopsis "Remake files automatically")
476 "Make is a program that is used to control the production of
477 executables or other files from their source files. The process is
478 controlled from a Makefile, in which the developer specifies how each file is
479 generated from its source. It has powerful dependency resolution and the
480 ability to determine when files have to be regenerated after their sources
481 change. GNU make offers many powerful extensions over the standard utility.")
483 (home-page "https://www.gnu.org/software/make/")))
485 (define-public gnu-make-4.2
491 (uri (string-append "mirror://gnu/make/make-" version
495 "12f5zzyq2w56g95nni65hc0g5p7154033y2f3qmjvd016szn5qnn"))))
497 `(#:configure-flags '("CFLAGS=-D__alloca=alloca")
499 (modify-phases %standard-phases
500 (add-before 'build 'set-default-shell
501 (lambda* (#:key inputs #:allow-other-keys)
502 ;; Change the default shell from /bin/sh.
503 (let ((bash (assoc-ref inputs "bash")))
505 (("default_shell =.*$")
506 (format #f "default_shell = \"~a/bin/sh\";\n"
510 (define-public binutils
516 (uri (string-append "mirror://gnu/binutils/binutils-"
520 "1rin1f5c7wm4n3piky6xilcrpf2s0n3dd5vqq8irrxkcic3i1w49"))
521 (patches (search-patches "binutils-loongson-workaround.patch"))))
522 (build-system gnu-build-system)
524 ;; TODO: Add dependency on zlib + those for Gold.
526 `(#:configure-flags '(;; Add `-static-libgcc' to not retain a dependency
527 ;; on GCC when bootstrapping.
528 "LDFLAGS=-static-libgcc"
530 ;; Turn on --enable-new-dtags by default to make the
531 ;; linker set RUNPATH instead of RPATH on binaries.
532 ;; This is important because RUNPATH can be overriden
533 ;; using LD_LIBRARY_PATH at runtime.
536 ;; Don't search under /usr/lib & co.
537 "--with-lib-path=/no-ld-lib-path"
539 ;; Install BFD. It ends up in a hidden directory,
541 "--enable-install-libbfd"
543 ;; Make sure 'ar' and 'ranlib' produce archives in a
544 ;; deterministic fashion.
545 "--enable-deterministic-archives")
547 ;; XXX: binutils 2.34 was mistakenly released without generated manuals:
548 ;; <https://sourceware.org/bugzilla/show_bug.cgi?id=25491>. To avoid a
549 ;; circular dependency on texinfo, prevent the build system from creating
550 ;; the manuals by calling "true" instead of "makeinfo"...
551 #:make-flags '("MAKEINFO=true")))
553 ;; ...and "hide" this package so that users who install binutils get the
554 ;; version with documentation defined below.
555 (properties '((hidden? . #t)))
557 (synopsis "Binary utilities: bfd gas gprof ld")
559 "GNU Binutils is a collection of tools for working with binary files.
560 Perhaps the most notable are \"ld\", a linker, and \"as\", an assembler.
561 Other tools include programs to display binary profiling information, list
562 the strings in a binary file, and utilities for working with archives. The
563 \"bfd\" library for working with executable and object formats is also
566 (home-page "https://www.gnu.org/software/binutils/")))
568 ;; Work around a problem with binutils 2.34 whereby manuals are missing from
569 ;; the release tarball. Remove this and the related code above when updating.
570 (define-public binutils+documentation
574 `(("texinfo" ,texinfo)))
576 (substitute-keyword-arguments (package-arguments binutils)
577 ((#:make-flags _ ''()) ''())))
580 ;; FIXME: ath9k-firmware-htc-binutils.patch do not apply on 2.34 because of a
581 ;; big refactoring of xtensa-modules.c (commit 567607c11fbf7105 upstream).
582 ;; Keep this version around until the patch is updated.
583 (define-public binutils-2.33
588 (inherit (package-source binutils))
589 (uri (string-append "mirror://gnu/binutils/binutils-"
593 "1cmd0riv37bqy9mwbg6n3523qgr8b3bbm5kwj19sjrasl4yq9d0c"))))
595 (substitute-keyword-arguments (package-arguments binutils)
596 ((#:make-flags _ ''()) ''())))
599 (define-public binutils-gold
600 (package/inherit binutils+documentation
601 (name "binutils-gold")
604 (modify-phases %standard-phases
605 (add-after 'patch-source-shebangs 'patch-more-shebangs
607 (substitute* "gold/Makefile.in"
608 (("/bin/sh") (which "sh")))
610 ,@(substitute-keyword-arguments (package-arguments binutils)
611 ; Upstream is aware of unrelocatable test failures on arm*.
613 (if (any (cute string-prefix? <> (or (%current-target-system)
617 ((#:configure-flags flags)
618 `(cons* "--enable-gold=default"
619 (delete "LDFLAGS=-static-libgcc" ,flags))))))
623 `(("gcc:lib" ,(canonical-package gcc) "lib")))))
625 (define* (make-ld-wrapper name #:key
628 (guile (canonical-package guile-3.0))
629 (bash (canonical-package bash))
630 (guile-for-build guile))
631 "Return a package called NAME that contains a wrapper for the 'ld' program
632 of BINUTILS, which adds '-rpath' flags to the actual 'ld' command line. The
633 wrapper uses GUILE and BASH.
635 TARGET must be a one-argument procedure that, given a system type, returns a
636 cross-compilation target triplet or #f. When the result is not #f, make a
637 wrapper for the cross-linker for that target, called 'TARGET-ld'."
638 ;; Note: #:system->target-triplet is a procedure so that the evaluation of
639 ;; its result can be delayed until the 'arguments' field is evaluated, thus
640 ;; in a context where '%current-system' is accurate.
645 (build-system trivial-build-system)
646 (inputs `(("binutils" ,binutils)
649 ("wrapper" ,(search-path %load-path
650 "gnu/packages/ld-wrapper.in"))))
652 (let ((target (target (%current-system))))
653 `(#:guile ,guile-for-build
654 #:modules ((guix build utils))
656 (use-modules (guix build utils)
657 (system base compile))
659 (let* ((out (assoc-ref %outputs "out"))
660 (bin (string-append out "/bin"))
662 `(string-append bin "/" ,target "-ld")
663 '(string-append bin "/ld")))
664 (go (string-append ld ".go")))
666 (setvbuf (current-output-port)
667 (cond-expand (guile-2.0 _IOLBF)
669 (format #t "building ~s/bin/ld wrapper in ~s~%"
670 (assoc-ref %build-inputs "binutils")
674 (copy-file (assoc-ref %build-inputs "wrapper") ld)
679 (string-append (assoc-ref %build-inputs "guile")
682 (string-append (assoc-ref %build-inputs "bash")
685 (string-append (assoc-ref %build-inputs "binutils")
687 (string-append "/bin/"
691 (compile-file ld #:output-file go)
693 (synopsis "The linker wrapper")
695 "The linker wrapper (or @code{ld-wrapper}) wraps the linker to add any
696 missing @code{-rpath} flags, and to detect any misuse of libraries outside of
698 (home-page "https://www.gnu.org/software/guix//")
701 (export make-ld-wrapper)
704 ;; This is the GNU C Library, used on GNU/Linux and GNU/Hurd. Prior to
705 ;; version 2.28, GNU/Hurd used a different glibc branch.
711 (uri (string-append "mirror://gnu/glibc/glibc-" version ".tar.xz"))
714 "05zxkyz9bv3j9h0xyid1rhvh3klhsmrpkf3bcs6frvlgyr2gwilj"))
716 ;; Disable 'ldconfig' and /etc/ld.so.cache. The latter is
717 ;; required on LFS distros to avoid loading the distro's libc.so
720 (substitute* "sysdeps/unix/sysv/linux/configure"
721 (("use_ldconfig=yes")
724 (modules '((guix build utils)))
725 (patches (search-patches "glibc-ldd-x86_64.patch"
726 "glibc-hidden-visibility-ldconfig.patch"
727 "glibc-versioned-locpath.patch"
728 "glibc-allow-kernel-2.6.32.patch"
729 "glibc-reinstate-prlimit64-fallback.patch"
730 "glibc-supported-locales.patch"
731 "glibc-hurd-clock_t_centiseconds.patch"
732 "glibc-hurd-clock_gettime_monotonic.patch"
733 "glibc-hurd-signal-sa-siginfo.patch"))))
734 (build-system gnu-build-system)
736 ;; Glibc's <limits.h> refers to <linux/limit.h>, for instance, so glibc
737 ;; users should automatically pull Linux headers as well. On GNU/Hurd,
738 ;; libc provides <hurd.h>, which includes a bunch of Hurd and Mach headers,
739 ;; so both should be propagated.
742 `(("hurd-core-headers" ,hurd-core-headers))
743 `(("kernel-headers" ,linux-libre-headers))))
745 (outputs '("out" "debug"
746 "static")) ;9 MiB of .a files
749 `(#:out-of-source? #t
751 ;; The libraries have an empty RUNPATH, but some, such as the versioned
752 ;; libraries (libdl-2.24.so, etc.) have ld.so marked as NEEDED. Since
753 ;; these libraries are always going to be found anyway, just skip
755 #:validate-runpath? #f
757 #:modules ((ice-9 ftw)
760 (guix build gnu-build-system))
763 (list "--sysconfdir=/etc"
765 ;; Installing a locale archive with all the locales is to
766 ;; expensive (~100 MiB), so we rely on users to install the
767 ;; locales they really want.
769 ;; Set the default locale path. In practice, $LOCPATH may be
770 ;; defined to point whatever locales users want. However, setuid
771 ;; binaries don't honor $LOCPATH, so they'll instead look into
772 ;; $libc_cv_complocaledir; we choose /run/current-system/locale/X.Y,
773 ;; with the idea that it is going to be populated by the sysadmin.
774 ;; The "X.Y" sub-directory is because locale data formats are
775 ;; incompatible across libc versions; see
776 ;; <https://lists.gnu.org/archive/html/guix-devel/2015-08/msg00737.html>.
778 ;; `--localedir' is not honored, so work around it.
779 ;; See <http://sourceware.org/ml/libc-alpha/2013-03/msg00093.html>.
780 (string-append "libc_cv_complocaledir=/run/current-system/locale/"
781 ,(version-major+minor version))
783 (string-append "--with-headers="
784 (assoc-ref ,(if (%current-target-system)
785 '%build-target-inputs
790 ;; This is the default for most architectures as of GNU libc 2.26,
791 ;; but we specify it explicitly for clarity and consistency. See
792 ;; "kernel-features.h" in the GNU libc for details.
793 "--enable-kernel=3.2.0"
795 ;; Use our Bash instead of /bin/sh.
796 (string-append "BASH_SHELL="
797 (assoc-ref %build-inputs "bash")
800 ;; On GNU/Hurd we get discarded-qualifiers warnings for
801 ;; 'device_write_inband' among other things. Ignore them.
803 '("--disable-werror")
807 #:phases (modify-phases %standard-phases
809 'configure 'pre-configure
810 (lambda* (#:key inputs native-inputs outputs
812 (let* ((out (assoc-ref outputs "out"))
813 (bin (string-append out "/bin"))
814 ;; FIXME: Normally we would look it up only in INPUTS
815 ;; but cross-base uses it as a native input.
816 (bash (or (assoc-ref inputs "static-bash")
817 (assoc-ref native-inputs "static-bash"))))
818 ;; Install the rpc data base file under `$out/etc/rpc'.
819 ;; FIXME: Use installFlags = [ "sysconfdir=$(out)/etc" ];
820 (substitute* "sunrpc/Makefile"
821 (("^\\$\\(inst_sysconfdir\\)/rpc(.*)$" _ suffix)
822 (string-append out "/etc/rpc" suffix "\n"))
823 (("^install-others =.*$")
824 (string-append "install-others = " out "/etc/rpc\n")))
826 (substitute* "Makeconfig"
828 ;; <http://www.linuxfromscratch.org/lfs/view/stable/chapter05/glibc.html>,
829 ;; linking against libgcc_s is not needed with GCC
833 ;; Have `system' use that Bash.
834 (substitute* "sysdeps/posix/system.c"
835 (("#define[[:blank:]]+SHELL_PATH.*$")
836 (format #f "#define SHELL_PATH \"~a/bin/bash\"\n"
840 (substitute* "libio/iopopen.c"
842 (string-append bash "/bin/sh")))
844 ;; Same for the shell used by the 'exec' functions for
845 ;; scripts that lack a shebang.
846 (substitute* (find-files "." "^paths\\.h$")
847 (("#define[[:blank:]]+_PATH_BSHELL[[:blank:]].*$")
848 (string-append "#define _PATH_BSHELL \""
849 bash "/bin/sh\"\n")))
851 ;; Nscd uses __DATE__ and __TIME__ to create a string to
852 ;; make sure the client and server come from the same
853 ;; libc. Use something deterministic instead.
854 (substitute* "nscd/nscd_stat.c"
855 (("static const char compilation\\[21\\] =.*$")
857 "static const char compilation[21] = \""
858 (string-take (basename out) 20) "\";\n")))
860 ;; Make sure we don't retain a reference to the
862 (substitute* "malloc/mtrace.pl"
864 ;; The shebang can be omitted, because there's the
865 ;; "bilingual" eval/exec magic at the top of the file.
872 (add-after 'install 'move-static-libs
873 (lambda* (#:key outputs #:allow-other-keys)
874 ;; Move static libraries to the "static" output.
875 (define (static-library? file)
876 ;; Return true if FILE is a static library. The
877 ;; "_nonshared.a" files are referred to by libc.so,
878 ;; libpthread.so, etc., which are in fact linker
880 (and (string-suffix? ".a" file)
881 (not (string-contains file "_nonshared"))))
883 (define (linker-script? file)
884 ;; Guess whether FILE, a ".a" file, is actually a
886 (and (not (ar-file? file))
887 (not (elf-file? file))))
889 (let* ((out (assoc-ref outputs "out"))
890 (lib (string-append out "/lib"))
891 (files (scandir lib static-library?))
892 (static (assoc-ref outputs "static"))
893 (slib (string-append static "/lib")))
895 (for-each (lambda (base)
896 (rename-file (string-append lib "/" base)
897 (string-append slib "/" base)))
900 ;; Usually libm.a is a linker script so we need to
901 ;; change the file names in there to refer to STATIC
903 (for-each (lambda (ld-script)
904 (substitute* ld-script
906 (filter linker-script?
907 (map (cut string-append slib "/" <>)
911 ,@(if (target-powerpc?)
912 '((add-after 'unpack 'apply-patch
913 (lambda* (#:key inputs #:allow-other-keys)
914 (let ((patch (assoc-ref inputs
915 "powerpc64le-patch")))
916 (invoke "patch" "--force" "-p1"
920 '((add-after 'install 'augment-libc.so
921 (lambda* (#:key outputs #:allow-other-keys)
922 (let* ((out (assoc-ref outputs "out")))
923 (substitute* (string-append out "/lib/libc.so")
924 (("/[^ ]+/lib/libc.so.0.3")
925 (string-append out "/lib/libc.so.0.3"
926 " libmachuser.so libhurduser.so"))))
930 (inputs `(("static-bash" ,static-bash)))
932 ;; To build the manual, we need Texinfo and Perl. Gettext is needed to
933 ;; install the message catalogs, with 'msgfmt'.
934 (native-inputs `(("texinfo" ,texinfo)
937 ("gettext" ,gettext-minimal)
938 ("python" ,python-minimal)
940 ,@(if (target-powerpc?)
941 `(("powerpc64le-patch" ,@(search-patches
942 "glibc-ldd-powerpc.patch")))
950 ;; Search path for packages that provide locale data. This is useful
951 ;; primarily in build environments. Use 'GUIX_LOCPATH' rather than
952 ;; 'LOCPATH' to avoid interference with the host system's libc on foreign
954 (list (search-path-specification
955 (variable "GUIX_LOCPATH")
956 (files '("lib/locale")))))
958 (synopsis "The GNU C Library")
960 "Any Unix-like operating system needs a C library: the library which
961 defines the \"system calls\" and other basic facilities such as open, malloc,
964 The GNU C library is used as the C library in the GNU system and most systems
965 with the Linux kernel.")
967 (home-page "https://www.gnu.org/software/libc/")))
969 ;; Below are old libc versions, which we use mostly to build locale data in
970 ;; the old format (which the new libc cannot cope with.)
972 (define-public glibc-2.30
977 (inherit (package-source glibc))
978 (uri (string-append "mirror://gnu/glibc/glibc-" version ".tar.xz"))
981 "1bxqpg91d02qnaz837a5kamm0f43pr1il4r9pknygywsar713i72"))
982 (patches (search-patches "glibc-ldd-x86_64.patch"
983 "glibc-CVE-2019-19126.patch"
984 "glibc-hidden-visibility-ldconfig.patch"
985 "glibc-versioned-locpath.patch"
986 "glibc-allow-kernel-2.6.32.patch"
987 "glibc-reinstate-prlimit64-fallback.patch"
988 "glibc-2.29-supported-locales.patch"))))))
990 (define-public glibc-2.29
995 (inherit (package-source glibc))
996 (uri (string-append "mirror://gnu/glibc/glibc-" version ".tar.xz"))
999 "0jzh58728flfh939a8k9pi1zdyalfzlxmwra7k0rzji5gvavivpk"))
1000 (patches (search-patches "glibc-ldd-x86_64.patch"
1001 "glibc-CVE-2019-7309.patch"
1002 "glibc-CVE-2019-9169.patch"
1003 "glibc-2.29-git-updates.patch"
1004 "glibc-hidden-visibility-ldconfig.patch"
1005 "glibc-versioned-locpath.patch"
1006 "glibc-allow-kernel-2.6.32.patch"
1007 "glibc-reinstate-prlimit64-fallback.patch"
1008 "glibc-2.29-supported-locales.patch"))))))
1010 (define-public glibc-2.28
1015 (inherit (package-source glibc))
1016 (uri (string-append "mirror://gnu/glibc/glibc-" version ".tar.xz"))
1019 "10iha5ynvdj5m62vgpgqbq4cwvc2yhyl2w9yyyjgfxmdmx8h145i"))
1020 (patches (search-patches "glibc-ldd-x86_64.patch"
1021 "glibc-2.28-git-fixes.patch"
1022 "glibc-hidden-visibility-ldconfig.patch"
1023 "glibc-versioned-locpath.patch"
1024 "glibc-allow-kernel-2.6.32.patch"
1025 "glibc-reinstate-prlimit64-fallback.patch"
1026 "glibc-hurd-magic-pid.patch"
1027 "glibc-2.28-supported-locales.patch"))))))
1029 (define-public glibc-2.27
1034 (inherit (package-source glibc))
1035 (uri (string-append "mirror://gnu/glibc/glibc-" version ".tar.xz"))
1038 "0wpwq7gsm7sd6ysidv0z575ckqdg13cr2njyfgrbgh4f65adwwji"))
1039 (patches (search-patches "glibc-ldd-x86_64.patch"
1040 "glibc-2.27-git-fixes.patch"
1041 "glibc-hidden-visibility-ldconfig.patch"
1042 "glibc-versioned-locpath.patch"
1043 "glibc-allow-kernel-2.6.32.patch"
1044 "glibc-reinstate-prlimit64-fallback.patch"
1045 "glibc-2.27-supported-locales.patch"
1046 "glibc-CVE-2018-11236.patch"
1047 "glibc-CVE-2018-11237.patch"))))
1048 (properties `((lint-hidden-cve . ("CVE-2017-18269")))))) ; glibc-2.27-git-fixes
1050 (define-public (make-gcc-libc base-gcc libc)
1051 "Return a GCC that targets LIBC."
1052 (package (inherit base-gcc)
1053 (name (string-append (package-name base-gcc) "-"
1054 (package-name libc) "-"
1055 (package-version libc)))
1057 (ensure-keyword-arguments (package-arguments base-gcc)
1058 '(#:implicit-inputs? #f)))
1060 `(,@(package-native-inputs base-gcc)
1061 ,@(append (fold alist-delete (%final-inputs) '("libc" "libc:static")))
1063 ("libc:static" ,libc "static")))))
1065 (define-public (make-glibc-locales glibc)
1068 (name "glibc-locales")
1069 (source (origin (inherit (package-source glibc))
1070 ;; The patch for glibc 2.28 and earlier replaces the same
1071 ;; content, but the context in the patch is different
1072 ;; enough to fail to merge.
1073 (patches (cons (search-patch
1074 (if (version>=? (package-version glibc)
1076 "glibc-locales.patch"
1077 "glibc-locales-2.28.patch"))
1078 (origin-patches (package-source glibc))))))
1079 (synopsis "All the locales supported by the GNU C Library")
1081 "This package provides all the locales supported by the GNU C Library,
1082 more than 400 in total. To use them set the @code{LOCPATH} environment variable
1083 to the @code{share/locale} sub-directory of this package.")
1084 (outputs '("out")) ;110+ MiB
1085 (native-search-paths '())
1087 (let ((args `(#:tests? #f #:strip-binaries? #f
1088 ,@(package-arguments glibc))))
1089 (substitute-keyword-arguments args
1090 ((#:modules modules '((guix build utils)
1091 (guix build gnu-build-system)))
1095 ((#:imported-modules modules '())
1096 `((gnu build locale)
1097 ,@%gnu-build-system-modules))
1099 `(modify-phases ,phases
1102 (invoke "make" "localedata/install-locales"
1103 "-j" (number->string (parallel-job-count)))))
1104 (add-after 'build 'symlink-normalized-codesets
1105 (lambda* (#:key outputs #:allow-other-keys)
1106 ;; The above phase does not install locales with names using
1107 ;; the "normalized codeset." Thus, create symlinks like:
1108 ;; en_US.utf8 -> en_US.UTF-8
1109 (define (locale-directory? file stat)
1110 (and (file-is-directory? file)
1111 (string-index (basename file) #\_)
1112 (string-rindex (basename file) #\.)))
1114 (let* ((out (assoc-ref outputs "out"))
1115 (locales (find-files out locale-directory?
1116 #:directories? #t)))
1117 (for-each (lambda (directory)
1118 (let*-values (((base)
1119 (basename directory))
1121 (locale->name+codeset base))
1123 (normalize-codeset codeset)))
1124 (unless (string=? codeset normalized)
1126 (string-append (dirname directory)
1132 (delete 'move-static-libs)))
1133 ((#:configure-flags flags)
1135 ;; Use $(libdir)/locale/X.Y as is the case by default.
1136 (list (string-append "libc_cv_complocaledir="
1137 (assoc-ref %outputs "out")
1139 ,(version-major+minor
1140 (package-version glibc)))))))))))
1142 (define %default-utf8-locales
1143 ;; These are the locales commonly used for tests---e.g., in Guile's i18n
1145 '("de_DE" "el_GR" "en_US" "fr_FR" "tr_TR"))
1146 (define*-public (make-glibc-utf8-locales glibc #:key
1147 (locales %default-utf8-locales)
1148 (name "glibc-utf8-locales"))
1149 (define default-locales? (equal? locales %default-utf8-locales))
1152 (version (package-version glibc))
1154 (build-system trivial-build-system)
1156 `(#:modules ((guix build utils))
1158 (use-modules (guix build utils))
1160 (let* ((libc (assoc-ref %build-inputs "glibc"))
1161 (gzip (assoc-ref %build-inputs "gzip"))
1162 (out (assoc-ref %outputs "out"))
1163 (localedir (string-append out "/lib/locale/"
1164 ,(version-major+minor version))))
1165 ;; 'localedef' needs 'gzip'.
1166 (setenv "PATH" (string-append libc "/bin:" gzip "/bin"))
1169 (for-each (lambda (locale)
1171 ;; Use the "normalized codeset" by
1172 ;; default--e.g., "en_US.utf8".
1173 (string-append localedir "/" locale ".utf8"))
1175 (invoke "localedef" "--no-archive"
1176 "--prefix" localedir
1180 ;; For backward compatibility with Guix
1181 ;; <= 0.8.3, add "xx_YY.UTF-8".
1182 (symlink (string-append locale ".utf8")
1183 (string-append localedir "/"
1187 (native-inputs `(("glibc" ,glibc)
1189 (synopsis (if default-locales?
1190 (P_ "Small sample of UTF-8 locales")
1191 (P_ "Customized sample of UTF-8 locales")))
1193 (if default-locales?
1194 (P_ "This package provides a small sample of UTF-8 locales mostly useful in
1195 test environments.")
1196 (format #f (P_ "This package provides the following UTF-8 locales:
1201 (home-page (package-home-page glibc))
1202 (license (package-license glibc))))
1204 (define-public glibc-locales
1205 (make-glibc-locales glibc))
1206 (define-public glibc-utf8-locales
1207 (make-glibc-utf8-locales glibc))
1209 ;; Packages provided to ease use of binaries linked against the previous libc.
1210 (define-public glibc-locales-2.29
1211 (package (inherit (make-glibc-locales glibc-2.29))
1212 (name "glibc-locales-2.29")))
1213 (define-public glibc-utf8-locales-2.29
1214 (package (inherit (make-glibc-utf8-locales glibc-2.29))
1215 (name "glibc-utf8-locales-2.29")))
1217 (define-public which
1223 (uri (string-append "mirror://gnu/which/which-"
1227 "1bgafvy3ypbhhfznwjv1lxmd6mci3x1byilnnkc7gcr486wlb8pl"))))
1228 (build-system gnu-build-system)
1229 (home-page "https://gnu.org/software/which/")
1230 (synopsis "Find full path of shell commands")
1232 "The which program finds the location of executables in PATH, with a
1233 variety of options. It is an alternative to the shell \"type\" built-in
1235 (license gpl3+))) ; some files are under GPLv2+
1237 (define-public glibc/hurd-headers
1238 (package (inherit glibc)
1239 (name "glibc-hurd-headers")
1241 (propagated-inputs `(("gnumach-headers" ,gnumach-headers)
1242 ("hurd-headers" ,hurd-headers)))
1244 `(("mig" ,(if (%current-target-system)
1245 ;; XXX: When targeting i586-pc-gnu, we need a 32-bit MiG,
1249 (arguments `(#:system "i686-linux")))
1251 ,@(package-native-inputs glibc)))
1253 (substitute-keyword-arguments (package-arguments glibc)
1254 ;; We just pass the flags really needed to build the headers.
1255 ((#:configure-flags _)
1256 `(list "--enable-add-ons"
1257 "--host=i586-pc-gnu"))
1259 '(modify-phases %standard-phases
1261 (lambda* (#:key outputs #:allow-other-keys)
1262 (invoke "make" "install-headers")
1264 ;; Make an empty stubs.h to work around not being able to
1265 ;; produce a valid stubs.h and causing the build to fail. See
1266 ;; <http://lists.gnu.org/archive/html/guix-devel/2014-04/msg00233.html>.
1267 (let ((out (assoc-ref outputs "out")))
1270 (string-append out "/include/gnu/stubs.h"))))
1272 (delete 'build))))))) ; nothing to build
1274 (define-public tzdata
1277 ;; This package should be kept in sync with python-pytz in (gnu packages
1283 "https://data.iana.org/time-zones/releases/tzdata"
1287 "022fn6gkmp7pamlgab04x0dm5hnyn2m2fcnyr3pvm36612xd5rrr"))))
1288 (build-system gnu-build-system)
1291 #:make-flags (let ((out (assoc-ref %outputs "out"))
1292 (tmp (getenv "TMPDIR")))
1293 (list (string-append "TOPDIR=" out)
1294 (string-append "TZDIR=" out "/share/zoneinfo")
1295 (string-append "TZDEFAULT=" out
1296 "/share/zoneinfo/localtime")
1298 ;; Likewise for the C library routines.
1299 (string-append "LIBDIR=" tmp "/lib")
1300 (string-append "MANDIR=" tmp "/man")
1302 ;; XXX: tzdata 2020b changed the on-disk format
1303 ;; of the time zone files from 'fat' to 'slim'.
1304 ;; Many packages (particularly evolution-data-server)
1305 ;; can not yet handle the latter, so we stick with
1307 ,@(if (version>=? (package-version this-package)
1309 '("CPPFLAGS=-DZIC_BLOAT_DEFAULT='\"fat\"'")
1314 #:modules ((guix build utils)
1315 (guix build gnu-build-system)
1318 (modify-phases %standard-phases
1320 (lambda* (#:key source inputs #:allow-other-keys)
1321 (invoke "tar" "xvf" source)
1322 (invoke "tar" "xvf" (assoc-ref inputs "tzcode"))))
1323 (add-after 'install 'post-install
1324 (lambda* (#:key outputs #:allow-other-keys)
1325 ;; Move data in the right place.
1326 (let ((out (assoc-ref outputs "out")))
1327 ;; Discard zic, dump, and tzselect, already
1328 ;; provided by glibc.
1329 (delete-file-recursively (string-append out "/usr"))
1330 (symlink (string-append out "/share/zoneinfo")
1331 (string-append out "/share/zoneinfo/posix"))
1332 (delete-file-recursively
1333 (string-append out "/share/zoneinfo-posix"))
1334 (copy-recursively (string-append out "/share/zoneinfo-leaps")
1335 (string-append out "/share/zoneinfo/right"))
1336 (delete-file-recursively
1337 (string-append out "/share/zoneinfo-leaps"))
1339 (delete 'configure))))
1340 (inputs `(("tzcode" ,(origin
1343 "https://data.iana.org/time-zones/releases/tzcode"
1347 "1l02b0jiwp3fl0xd6227i69d26rmx3yrnq0ssq9vvdmm4jhvyipb"))))))
1348 (home-page "https://www.iana.org/time-zones")
1349 (synopsis "Database of current and historical time zones")
1350 (description "The Time Zone Database (often called tz or zoneinfo)
1351 contains code and data that represent the history of local time for many
1352 representative locations around the globe. It is updated periodically to
1353 reflect changes made by political bodies to time zone boundaries, UTC offsets,
1354 and daylight-saving rules.")
1355 (license public-domain)))
1357 ;;; A "fixed" version of tzdata, which is used in the test suites of glib and R
1358 ;;; and a few other places. We can update this whenever we are able to rebuild
1359 ;;; thousands of packages (for example, in a core-updates rebuild). This package
1360 ;;; will typically be obsolete and should never be referred to by a built
1362 (define-public tzdata-for-tests
1370 "https://data.iana.org/time-zones/releases/tzdata"
1374 "0z7w1yv37cfk8yhix2cillam091vgp1j4g8fv84261q9mdnq1ivr"))))
1376 `(("tzcode" ,(origin
1379 "https://data.iana.org/time-zones/releases/tzcode"
1383 "1m3y2rnf1nggxxhxplab5zdd5whvar3ijyrv7lifvm82irkd7szn")))))))))
1385 (define-public libiconv
1391 (uri (string-append "mirror://gnu/libiconv/libiconv-"
1395 "0y1ij745r4p48mxq84rax40p10ln7fc7m243p8k8sia519i3dxfc"))
1396 (modules '((guix build utils)))
1398 ;; Work around "declared gets" error on glibc systems (fixed by
1399 ;; Gnulib commit 66712c23388e93e5c518ebc8515140fa0c807348.)
1401 (substitute* "srclib/stdio.in.h"
1402 (("^#undef gets") "")
1403 (("^_GL_WARN_ON_USE \\(gets.*") ""))
1405 (build-system gnu-build-system)
1406 (synopsis "Character set conversion library")
1408 "libiconv provides an implementation of the iconv function for systems
1409 that lack it. iconv is used to convert between character encodings in a
1410 program. It supports a wide variety of different encodings.")
1411 (home-page "https://www.gnu.org/software/libiconv/")
1414 (define* (libiconv-if-needed #:optional (target (%current-target-system)))
1415 "Return either a libiconv package specification to include in a dependency
1416 list for platforms that have an incomplete libc, or the empty list. If a
1417 package needs iconv ,@(libiconv-if-needed) should be added."
1418 ;; POSIX C libraries provide iconv. Platforms with an incomplete libc
1419 ;; without iconv, such as MinGW, must return the then clause.
1420 (if (target-mingw? target)
1421 `(("libiconv" ,libiconv))
1424 (define-public (canonical-package package)
1425 ;; Avoid circular dependency by lazily resolving 'commencement'.
1426 (let* ((iface (resolve-interface '(gnu packages commencement)))
1427 (proc (module-ref iface 'canonical-package)))
1430 (define-public (%final-inputs)
1431 "Return the list of \"final inputs\"."
1432 ;; Avoid circular dependency by lazily resolving 'commencement'.
1433 (let ((iface (resolve-interface '(gnu packages commencement))))
1434 (module-ref iface '%final-inputs)))
1436 ;;; base.scm ends here