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 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>
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 i18n)
56 #:use-module (guix utils)
57 #:use-module (guix packages)
58 #:use-module (guix download)
59 #:use-module (guix git-download)
60 #:use-module (guix build-system gnu)
61 #:use-module (guix build-system trivial)
62 #:use-module (ice-9 format)
63 #:use-module (ice-9 match)
64 #:use-module (ice-9 optargs)
65 #:use-module (srfi srfi-1)
66 #:use-module (srfi srfi-26)
72 ;;; Base packages of the Guix-based GNU user-land software distribution.
82 (uri (string-append "mirror://gnu/hello/hello-" version
86 "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"))))
87 (build-system gnu-build-system)
88 (synopsis "Hello, GNU world: An example GNU package")
90 "GNU Hello prints the message \"Hello, world!\" and then exits. It
91 serves as an example of standard GNU coding practices. As such, it supports
92 command-line arguments, multiple languages, and so on.")
93 (home-page "https://www.gnu.org/software/hello/")
102 (uri (string-append "mirror://gnu/grep/grep-"
106 "1yy33kiwrxrwj2nxa4fg15bvmwyghqbs8qwkdvy5phm784f7brjq"))
107 (patches (search-patches "grep-timing-sensitive-test.patch"))))
108 (build-system gnu-build-system)
109 (native-inputs `(("perl" ,perl))) ;some of the tests require it
110 (inputs `(("pcre" ,pcre)))
113 (modify-phases %standard-phases
114 (add-after 'install 'fix-egrep-and-fgrep
115 ;; Patch 'egrep' and 'fgrep' to execute 'grep' via its
116 ;; absolute file name instead of searching for it in $PATH.
117 (lambda* (#:key outputs #:allow-other-keys)
118 (let* ((out (assoc-ref outputs "out"))
119 (bin (string-append out "/bin")))
120 (substitute* (list (string-append bin "/egrep")
121 (string-append bin "/fgrep"))
123 (string-append "exec " bin "/grep")))
125 (synopsis "Print lines matching a pattern")
127 "grep is a tool for finding text inside files. Text is found by
128 matching a pattern provided by the user in one or many files. The pattern
129 may be provided as a basic or extended regular expression, or as fixed
130 strings. By default, the matching text is simply printed to the screen,
131 however the output can be greatly customized to include, for example, line
132 numbers. GNU grep offers many extensions over the standard utility,
133 including, for example, recursive directory searching.")
135 (home-page "https://www.gnu.org/software/grep/")))
143 (uri (string-append "mirror://gnu/sed/sed-" version
147 "0alqagh0nliymz23kfjg6g9w3cr086k0sfni56gi8fhzqwa3xksk"))))
148 (build-system gnu-build-system)
149 (synopsis "Stream editor")
151 `(("perl" ,perl))) ;for tests
153 "Sed is a non-interactive, text stream editor. It receives a text
154 input from a file or from standard input and it then applies a series of text
155 editing commands to the stream and prints its output to standard output. It
156 is often used for substituting text patterns in a stream. The GNU
157 implementation offers several extensions over the standard utility.")
159 (home-page "https://www.gnu.org/software/sed/")))
167 (uri (string-append "mirror://gnu/tar/tar-"
171 "1n7xy657ii0sa42zx6944v2m4v9qrh6sqgmw17l3nch3y43sxlyh"))
172 (patches (search-patches "tar-skip-unreliable-tests.patch"
173 "tar-remove-wholesparse-check.patch"))))
174 (build-system gnu-build-system)
175 ;; Note: test suite requires ~1GiB of disk space.
177 `(,@(if (hurd-target?)
180 "TESTSUITEFLAGS= -k '"
182 ",!renamed dirs in incrementals"
183 ",!--exclude-tag option in incremental pass"
184 ",!incremental dumps with -C"
185 ",!incremental dumps of nested directories"
186 ",!incremental restores with -C"
187 ",!concatenated incremental archives (renames)"
188 ",!renamed directory containing subdirectories"
189 ",!renamed subdirectories"
192 #:phases (modify-phases %standard-phases
193 (add-before 'build 'set-shell-file-name
194 (lambda* (#:key inputs #:allow-other-keys)
195 ;; Do not use "/bin/sh" to run programs.
196 (let ((bash (assoc-ref inputs "bash")))
197 (substitute* "src/system.c"
199 (string-append bash "/bin/sh")))
202 ;; When cross-compiling, the 'set-shell-file-name' phase needs to be able
203 ;; to refer to the target Bash.
204 (inputs (if (%current-target-system)
208 (synopsis "Managing tar archives")
210 "Tar provides the ability to create tar archives, as well as the
211 ability to extract, update or list files in an existing archive. It is
212 useful for combining many files into one larger file, while maintaining
213 directory structure and file information such as permissions and
214 creation/modification dates. GNU tar offers many extensions over the
217 (home-page "https://www.gnu.org/software/tar/")))
225 (uri (string-append "mirror://gnu/patch/patch-"
229 "1zfqy4rdcy279vwn2z1kbv19dcfw25d2aqy9nzvdkq5bjzd0nqdc"))
230 (patches (search-patches "patch-hurd-path-max.patch"))))
231 (build-system gnu-build-system)
233 ;; Work around a cross-compilation bug whereby libpatch.a would provide
234 ;; '__mktime_internal', which conflicts with the one in libc.a.
235 (if (%current-target-system)
236 `(#:configure-flags '("gl_cv_func_working_mktime=yes"))
238 (native-inputs `(("ed" ,ed)))
239 (synopsis "Apply differences to originals, with optional backups")
241 "Patch is a program that applies changes to files based on differences
242 laid out as by the program \"diff\". The changes may be applied to one or more
243 files depending on the contents of the diff file. It accepts several
244 different diff formats. It may also be used to revert previously applied
247 (home-page "https://savannah.gnu.org/projects/patch/")))
249 (define-public diffutils
255 (uri (string-append "mirror://gnu/diffutils/diffutils-"
259 "09isrg0isjinv8c535nxsi1s86wfdfzml80dbw41dj9x3hiad9xk"))))
260 (build-system gnu-build-system)
261 (native-inputs `(("perl" ,perl)))
262 (synopsis "Comparing and merging files")
264 "GNU Diffutils is a package containing tools for finding the
265 differences between files. The \"diff\" command is used to show how two files
266 differ, while \"cmp\" shows the offsets and line numbers where they differ.
267 \"diff3\" allows you to compare three files. Finally, \"sdiff\" offers an
268 interactive means to merge two files.")
270 (home-page "https://www.gnu.org/software/diffutils/")))
272 (define-public findutils
278 (uri (string-append "mirror://gnu/findutils/findutils-"
282 "16kqz9yz98dasmj70jwf5py7jk558w96w0vgp3zf9xsqk3gzpzn5"))
283 (patches (search-patches "findutils-localstatedir.patch"
284 "findutils-test-rwlock-threads.patch"))))
285 (build-system gnu-build-system)
287 `(#:configure-flags (list
288 ;; Tell 'updatedb' to write to /var.
289 "--localstatedir=/var")
290 #:phases (modify-phases %standard-phases
291 (add-before 'check 'adjust-test-shebangs
293 (substitute* '("tests/xargs/verbose-quote.sh"
294 "tests/find/exec-plus-last-file.sh")
296 (string-append "#!" (which "sh"))))
298 (synopsis "Operating on files matching given criteria")
300 "Findutils supplies the basic file directory searching utilities of the
301 GNU system. It consists of two primary searching utilities: \"find\"
302 recursively searches for files in a directory according to given criteria and
303 \"locate\" lists files in a database that match a query. Two auxiliary tools
304 are included: \"updatedb\" updates the file name database and \"xargs\" may be
305 used to apply commands with arbitrarily long arguments.")
307 (home-page "https://www.gnu.org/software/findutils/")))
309 (define-public coreutils
315 (uri (string-append "mirror://gnu/coreutils/coreutils-"
319 "1yjcrh5hw70c0yn8zw55pd6j51dj90anpq8mmg649ps9g3gdhn24"))
320 (patches (search-patches "coreutils-ls.patch"))))
321 (build-system gnu-build-system)
322 (inputs `(("acl" ,acl) ; TODO: add SELinux
323 ("gmp" ,gmp) ;bignums in 'expr', yay!
325 ;; Do not use libcap when cross-compiling since it's not quite
326 ;; cross-compilable; and use it only for supported systems.
327 ,@(if (and (not (%current-target-system))
328 (member (%current-system)
329 (package-supported-systems libcap)))
330 `(("libcap" ,libcap-2.31)) ;capability support in 'ls', etc.
333 ;; Perl is needed to run tests in native builds, and to run the bundled
334 ;; copy of help2man. However, don't pass it when cross-compiling since
335 ;; that would lead it to try to run programs to get their '--help' output
337 (if (%current-target-system)
340 (outputs '("out" "debug"))
342 `(#:parallel-build? #f ; help2man may be called too early
344 '(#:make-flags ; these tests fail deterministically
345 (list (string-append "XFAIL_TESTS=tests/misc/env-S.pl"
346 " tests/misc/kill.sh"
347 " tests/misc/nice.sh"
348 " tests/misc/pwd-long.sh"
349 " tests/split/fail.sh"
358 #:phases (modify-phases %standard-phases
359 (add-before 'build 'patch-shell-references
361 ;; 'split' uses either $SHELL or /bin/sh. Set $SHELL so
362 ;; that tests pass, since /bin/sh isn't in the chroot.
363 (setenv "SHELL" (which "sh"))
365 (substitute* (find-files "gnulib-tests" "\\.c$")
366 (("/bin/sh") (which "sh")))
367 (substitute* (find-files "tests" "\\.sh$")
368 (("#!/bin/sh") (string-append "#!" (which "sh"))))
371 `((add-after 'unpack 'remove-tests
373 (substitute* "Makefile.in"
375 (("^ *tests/misc/timeout-group.sh.*") ""))
378 (synopsis "Core GNU utilities (file, text, shell)")
380 "GNU Coreutils package includes all of the basic command-line tools that
381 are expected in a POSIX system, excluding shell. This package is the union of
382 the GNU fileutils, sh-utils, and textutils packages. Most of these tools
383 offer extended functionality beyond that which is outlined in the POSIX
386 (home-page "https://www.gnu.org/software/coreutils/")))
388 (define-public coreutils-minimal
389 ;; Coreutils without its optional dependencies.
392 (name "coreutils-minimal")
396 (define-public coreutils-8.30
397 ;; XXX: This version is kept just so we can run PRoot tests.
400 (inherit coreutils-minimal)
404 (uri (string-append "mirror://gnu/coreutils/coreutils-"
408 "0mxhw43d4wpqmvg0l4znk1vm10fy92biyh90lzdnqjcic2lb6cg8"))))
410 (substitute-keyword-arguments (package-arguments coreutils-minimal)
411 ((#:phases phases '%standard-phases)
412 `(modify-phases ,phases
413 (add-before 'check 'disable-broken-test
415 ;; This test hits the 127 character shebang limit in the build
416 ;; environment due to the way "env -S" splits arguments into
417 ;; shebangs. Note that "env-S-script.sh" works around this
418 ;; specific issue, but "env-S.pl" is not adjusted for build
419 ;; environments with long prefixes (/tmp/guix-build-...).
420 (substitute* "Makefile"
421 (("^.*tests/misc/env-S.pl.*$") ""))
424 (define-public gnu-make
430 (uri (string-append "mirror://gnu/make/make-" version
434 "06cfqzpqsvdnsxbysl5p2fgdgxgl9y4p7scpnrfa8z2zgkjdspz0"))
435 (patches (search-patches "make-impure-dirs.patch"))))
436 (build-system gnu-build-system)
437 (native-inputs `(("pkg-config" ,pkg-config))) ; to detect Guile
438 (inputs `(("guile" ,guile-3.0)))
439 (outputs '("out" "debug"))
441 `(,@(if (hurd-target?)
442 '(#:configure-flags '("CFLAGS=-D__alloca=alloca"
443 "ac_cv_func_posix_spawn=no"))
446 (modify-phases %standard-phases
447 (add-before 'build 'set-default-shell
448 (lambda* (#:key inputs #:allow-other-keys)
449 ;; Change the default shell from /bin/sh.
450 (let ((bash (assoc-ref inputs "bash")))
451 (substitute* "src/job.c"
452 (("default_shell =.*$")
453 (format #f "default_shell = \"~a/bin/sh\";\n"
456 (synopsis "Remake files automatically")
458 "Make is a program that is used to control the production of
459 executables or other files from their source files. The process is
460 controlled from a Makefile, in which the developer specifies how each file is
461 generated from its source. It has powerful dependency resolution and the
462 ability to determine when files have to be regenerated after their sources
463 change. GNU make offers many powerful extensions over the standard utility.")
465 (home-page "https://www.gnu.org/software/make/")))
467 (define-public gnu-make-4.2
473 (uri (string-append "mirror://gnu/make/make-" version
477 "12f5zzyq2w56g95nni65hc0g5p7154033y2f3qmjvd016szn5qnn"))))
479 `(#:configure-flags '("CFLAGS=-D__alloca=alloca")
481 (modify-phases %standard-phases
482 (add-before 'build 'set-default-shell
483 (lambda* (#:key inputs #:allow-other-keys)
484 ;; Change the default shell from /bin/sh.
485 (let ((bash (assoc-ref inputs "bash")))
487 (("default_shell =.*$")
488 (format #f "default_shell = \"~a/bin/sh\";\n"
492 (define-public binutils
498 (uri (string-append "mirror://gnu/binutils/binutils-"
502 "1rin1f5c7wm4n3piky6xilcrpf2s0n3dd5vqq8irrxkcic3i1w49"))
503 (patches (search-patches "binutils-loongson-workaround.patch"))))
504 (build-system gnu-build-system)
506 ;; TODO: Add dependency on zlib + those for Gold.
508 `(#:configure-flags '(;; Add `-static-libgcc' to not retain a dependency
509 ;; on GCC when bootstrapping.
510 "LDFLAGS=-static-libgcc"
512 ;; Turn on --enable-new-dtags by default to make the
513 ;; linker set RUNPATH instead of RPATH on binaries.
514 ;; This is important because RUNPATH can be overriden
515 ;; using LD_LIBRARY_PATH at runtime.
518 ;; Don't search under /usr/lib & co.
519 "--with-lib-path=/no-ld-lib-path"
521 ;; Install BFD. It ends up in a hidden directory,
523 "--enable-install-libbfd"
525 ;; Make sure 'ar' and 'ranlib' produce archives in a
526 ;; deterministic fashion.
527 "--enable-deterministic-archives")
529 ;; XXX: binutils 2.34 was mistakenly released without generated manuals:
530 ;; <https://sourceware.org/bugzilla/show_bug.cgi?id=25491>. To avoid a
531 ;; circular dependency on texinfo, prevent the build system from creating
532 ;; the manuals by calling "true" instead of "makeinfo"...
533 #:make-flags '("MAKEINFO=true")))
535 ;; ...and "hide" this package so that users who install binutils get the
536 ;; version with documentation defined below.
537 (properties '((hidden? . #t)))
539 (synopsis "Binary utilities: bfd gas gprof ld")
541 "GNU Binutils is a collection of tools for working with binary files.
542 Perhaps the most notable are \"ld\", a linker, and \"as\", an assembler.
543 Other tools include programs to display binary profiling information, list
544 the strings in a binary file, and utilities for working with archives. The
545 \"bfd\" library for working with executable and object formats is also
548 (home-page "https://www.gnu.org/software/binutils/")))
550 ;; Work around a problem with binutils 2.34 whereby manuals are missing from
551 ;; the release tarball. Remove this and the related code above when updating.
552 (define-public binutils+documentation
556 `(("texinfo" ,texinfo)))
558 (substitute-keyword-arguments (package-arguments binutils)
559 ((#:make-flags _ ''()) ''())))
562 ;; FIXME: ath9k-firmware-htc-binutils.patch do not apply on 2.34 because of a
563 ;; big refactoring of xtensa-modules.c (commit 567607c11fbf7105 upstream).
564 ;; Keep this version around until the patch is updated.
565 (define-public binutils-2.33
570 (inherit (package-source binutils))
571 (uri (string-append "mirror://gnu/binutils/binutils-"
575 "1cmd0riv37bqy9mwbg6n3523qgr8b3bbm5kwj19sjrasl4yq9d0c"))))
577 (substitute-keyword-arguments (package-arguments binutils)
578 ((#:make-flags _ ''()) ''())))
581 (define-public binutils-gold
582 (package/inherit binutils+documentation
583 (name "binutils-gold")
586 (modify-phases %standard-phases
587 (add-after 'patch-source-shebangs 'patch-more-shebangs
589 (substitute* "gold/Makefile.in"
590 (("/bin/sh") (which "sh")))
592 ,@(substitute-keyword-arguments (package-arguments binutils)
593 ; Upstream is aware of unrelocatable test failures on arm*.
595 (if (any (cute string-prefix? <> (or (%current-target-system)
599 ((#:configure-flags flags)
600 `(cons* "--enable-gold=default"
601 (delete "LDFLAGS=-static-libgcc" ,flags))))))
605 `(("gcc:lib" ,(canonical-package gcc) "lib")))))
607 (define* (make-ld-wrapper name #:key
610 (guile (canonical-package guile-3.0))
611 (bash (canonical-package bash))
612 (guile-for-build guile))
613 "Return a package called NAME that contains a wrapper for the 'ld' program
614 of BINUTILS, which adds '-rpath' flags to the actual 'ld' command line. The
615 wrapper uses GUILE and BASH.
617 TARGET must be a one-argument procedure that, given a system type, returns a
618 cross-compilation target triplet or #f. When the result is not #f, make a
619 wrapper for the cross-linker for that target, called 'TARGET-ld'."
620 ;; Note: #:system->target-triplet is a procedure so that the evaluation of
621 ;; its result can be delayed until the 'arguments' field is evaluated, thus
622 ;; in a context where '%current-system' is accurate.
627 (build-system trivial-build-system)
628 (inputs `(("binutils" ,binutils)
631 ("wrapper" ,(search-path %load-path
632 "gnu/packages/ld-wrapper.in"))))
634 (let ((target (target (%current-system))))
635 `(#:guile ,guile-for-build
636 #:modules ((guix build utils))
638 (use-modules (guix build utils)
639 (system base compile))
641 (let* ((out (assoc-ref %outputs "out"))
642 (bin (string-append out "/bin"))
644 `(string-append bin "/" ,target "-ld")
645 '(string-append bin "/ld")))
646 (go (string-append ld ".go")))
648 (setvbuf (current-output-port)
649 (cond-expand (guile-2.0 _IOLBF)
651 (format #t "building ~s/bin/ld wrapper in ~s~%"
652 (assoc-ref %build-inputs "binutils")
656 (copy-file (assoc-ref %build-inputs "wrapper") ld)
661 (string-append (assoc-ref %build-inputs "guile")
664 (string-append (assoc-ref %build-inputs "bash")
667 (string-append (assoc-ref %build-inputs "binutils")
669 (string-append "/bin/"
673 (compile-file ld #:output-file go)
675 (synopsis "The linker wrapper")
677 "The linker wrapper (or @code{ld-wrapper}) wraps the linker to add any
678 missing @code{-rpath} flags, and to detect any misuse of libraries outside of
680 (home-page "https://www.gnu.org/software/guix//")
683 (export make-ld-wrapper)
686 ;; This is the GNU C Library, used on GNU/Linux and GNU/Hurd. Prior to
687 ;; version 2.28, GNU/Hurd used a different glibc branch.
693 (uri (string-append "mirror://gnu/glibc/glibc-" version ".tar.xz"))
696 "05zxkyz9bv3j9h0xyid1rhvh3klhsmrpkf3bcs6frvlgyr2gwilj"))
698 ;; Disable 'ldconfig' and /etc/ld.so.cache. The latter is
699 ;; required on LFS distros to avoid loading the distro's libc.so
702 (substitute* "sysdeps/unix/sysv/linux/configure"
703 (("use_ldconfig=yes")
706 (modules '((guix build utils)))
707 (patches (search-patches "glibc-ldd-x86_64.patch"
708 "glibc-hidden-visibility-ldconfig.patch"
709 "glibc-versioned-locpath.patch"
710 "glibc-allow-kernel-2.6.32.patch"
711 "glibc-reinstate-prlimit64-fallback.patch"
712 "glibc-supported-locales.patch"
713 "glibc-hurd-clock_t_centiseconds.patch"
714 "glibc-hurd-clock_gettime_monotonic.patch"
715 "glibc-hurd-signal-sa-siginfo.patch"))))
716 (build-system gnu-build-system)
718 ;; Glibc's <limits.h> refers to <linux/limit.h>, for instance, so glibc
719 ;; users should automatically pull Linux headers as well. On GNU/Hurd,
720 ;; libc provides <hurd.h>, which includes a bunch of Hurd and Mach headers,
721 ;; so both should be propagated.
724 `(("hurd-core-headers" ,hurd-core-headers))
725 `(("kernel-headers" ,linux-libre-headers))))
727 (outputs '("out" "debug"
728 "static")) ;9 MiB of .a files
731 `(#:out-of-source? #t
733 ;; The libraries have an empty RUNPATH, but some, such as the versioned
734 ;; libraries (libdl-2.24.so, etc.) have ld.so marked as NEEDED. Since
735 ;; these libraries are always going to be found anyway, just skip
737 #:validate-runpath? #f
739 #:modules ((ice-9 ftw)
742 (guix build gnu-build-system))
745 (list "--sysconfdir=/etc"
747 ;; Installing a locale archive with all the locales is to
748 ;; expensive (~100 MiB), so we rely on users to install the
749 ;; locales they really want.
751 ;; Set the default locale path. In practice, $LOCPATH may be
752 ;; defined to point whatever locales users want. However, setuid
753 ;; binaries don't honor $LOCPATH, so they'll instead look into
754 ;; $libc_cv_complocaledir; we choose /run/current-system/locale/X.Y,
755 ;; with the idea that it is going to be populated by the sysadmin.
756 ;; The "X.Y" sub-directory is because locale data formats are
757 ;; incompatible across libc versions; see
758 ;; <https://lists.gnu.org/archive/html/guix-devel/2015-08/msg00737.html>.
760 ;; `--localedir' is not honored, so work around it.
761 ;; See <http://sourceware.org/ml/libc-alpha/2013-03/msg00093.html>.
762 (string-append "libc_cv_complocaledir=/run/current-system/locale/"
763 ,(version-major+minor version))
765 (string-append "--with-headers="
766 (assoc-ref ,(if (%current-target-system)
767 '%build-target-inputs
772 ;; This is the default for most architectures as of GNU libc 2.26,
773 ;; but we specify it explicitly for clarity and consistency. See
774 ;; "kernel-features.h" in the GNU libc for details.
775 "--enable-kernel=3.2.0"
777 ;; Use our Bash instead of /bin/sh.
778 (string-append "BASH_SHELL="
779 (assoc-ref %build-inputs "bash")
782 ;; On GNU/Hurd we get discarded-qualifiers warnings for
783 ;; 'device_write_inband' among other things. Ignore them.
785 '("--disable-werror")
789 #:phases (modify-phases %standard-phases
791 'configure 'pre-configure
792 (lambda* (#:key inputs native-inputs outputs
794 (let* ((out (assoc-ref outputs "out"))
795 (bin (string-append out "/bin"))
796 ;; FIXME: Normally we would look it up only in INPUTS
797 ;; but cross-base uses it as a native input.
798 (bash (or (assoc-ref inputs "static-bash")
799 (assoc-ref native-inputs "static-bash"))))
800 ;; Install the rpc data base file under `$out/etc/rpc'.
801 ;; FIXME: Use installFlags = [ "sysconfdir=$(out)/etc" ];
802 (substitute* "sunrpc/Makefile"
803 (("^\\$\\(inst_sysconfdir\\)/rpc(.*)$" _ suffix)
804 (string-append out "/etc/rpc" suffix "\n"))
805 (("^install-others =.*$")
806 (string-append "install-others = " out "/etc/rpc\n")))
808 (substitute* "Makeconfig"
810 ;; <http://www.linuxfromscratch.org/lfs/view/stable/chapter05/glibc.html>,
811 ;; linking against libgcc_s is not needed with GCC
815 ;; Have `system' use that Bash.
816 (substitute* "sysdeps/posix/system.c"
817 (("#define[[:blank:]]+SHELL_PATH.*$")
818 (format #f "#define SHELL_PATH \"~a/bin/bash\"\n"
822 (substitute* "libio/iopopen.c"
824 (string-append bash "/bin/sh")))
826 ;; Same for the shell used by the 'exec' functions for
827 ;; scripts that lack a shebang.
828 (substitute* (find-files "." "^paths\\.h$")
829 (("#define[[:blank:]]+_PATH_BSHELL[[:blank:]].*$")
830 (string-append "#define _PATH_BSHELL \""
831 bash "/bin/sh\"\n")))
833 ;; Nscd uses __DATE__ and __TIME__ to create a string to
834 ;; make sure the client and server come from the same
835 ;; libc. Use something deterministic instead.
836 (substitute* "nscd/nscd_stat.c"
837 (("static const char compilation\\[21\\] =.*$")
839 "static const char compilation[21] = \""
840 (string-take (basename out) 20) "\";\n")))
842 ;; Make sure we don't retain a reference to the
844 (substitute* "malloc/mtrace.pl"
846 ;; The shebang can be omitted, because there's the
847 ;; "bilingual" eval/exec magic at the top of the file.
854 (add-after 'install 'move-static-libs
855 (lambda* (#:key outputs #:allow-other-keys)
856 ;; Move static libraries to the "static" output.
857 (define (static-library? file)
858 ;; Return true if FILE is a static library. The
859 ;; "_nonshared.a" files are referred to by libc.so,
860 ;; libpthread.so, etc., which are in fact linker
862 (and (string-suffix? ".a" file)
863 (not (string-contains file "_nonshared"))))
865 (define (linker-script? file)
866 ;; Guess whether FILE, a ".a" file, is actually a
868 (and (not (ar-file? file))
869 (not (elf-file? file))))
871 (let* ((out (assoc-ref outputs "out"))
872 (lib (string-append out "/lib"))
873 (files (scandir lib static-library?))
874 (static (assoc-ref outputs "static"))
875 (slib (string-append static "/lib")))
877 (for-each (lambda (base)
878 (rename-file (string-append lib "/" base)
879 (string-append slib "/" base)))
882 ;; Usually libm.a is a linker script so we need to
883 ;; change the file names in there to refer to STATIC
885 (for-each (lambda (ld-script)
886 (substitute* ld-script
888 (filter linker-script?
889 (map (cut string-append slib "/" <>)
894 '((add-after 'install 'augment-libc.so
895 (lambda* (#:key outputs #:allow-other-keys)
896 (let* ((out (assoc-ref outputs "out")))
897 (substitute* (string-append out "/lib/libc.so")
898 (("/[^ ]+/lib/libc.so.0.3")
899 (string-append out "/lib/libc.so.0.3"
900 " libmachuser.so libhurduser.so"))))
904 (inputs `(("static-bash" ,static-bash)))
906 ;; To build the manual, we need Texinfo and Perl. Gettext is needed to
907 ;; install the message catalogs, with 'msgfmt'.
908 (native-inputs `(("texinfo" ,texinfo)
911 ("gettext" ,gettext-minimal)
912 ("python" ,python-minimal)
920 ;; Search path for packages that provide locale data. This is useful
921 ;; primarily in build environments. Use 'GUIX_LOCPATH' rather than
922 ;; 'LOCPATH' to avoid interference with the host system's libc on foreign
924 (list (search-path-specification
925 (variable "GUIX_LOCPATH")
926 (files '("lib/locale")))))
928 (synopsis "The GNU C Library")
930 "Any Unix-like operating system needs a C library: the library which
931 defines the \"system calls\" and other basic facilities such as open, malloc,
934 The GNU C library is used as the C library in the GNU system and most systems
935 with the Linux kernel.")
937 (home-page "https://www.gnu.org/software/libc/")))
939 ;; Below are old libc versions, which we use mostly to build locale data in
940 ;; the old format (which the new libc cannot cope with.)
942 (define-public glibc-2.30
947 (inherit (package-source glibc))
948 (uri (string-append "mirror://gnu/glibc/glibc-" version ".tar.xz"))
951 "1bxqpg91d02qnaz837a5kamm0f43pr1il4r9pknygywsar713i72"))
952 (patches (search-patches "glibc-ldd-x86_64.patch"
953 "glibc-CVE-2019-19126.patch"
954 "glibc-hidden-visibility-ldconfig.patch"
955 "glibc-versioned-locpath.patch"
956 "glibc-allow-kernel-2.6.32.patch"
957 "glibc-reinstate-prlimit64-fallback.patch"
958 "glibc-2.29-supported-locales.patch"))))))
960 (define-public glibc-2.29
965 (inherit (package-source glibc))
966 (uri (string-append "mirror://gnu/glibc/glibc-" version ".tar.xz"))
969 "0jzh58728flfh939a8k9pi1zdyalfzlxmwra7k0rzji5gvavivpk"))
970 (patches (search-patches "glibc-ldd-x86_64.patch"
971 "glibc-CVE-2019-7309.patch"
972 "glibc-CVE-2019-9169.patch"
973 "glibc-2.29-git-updates.patch"
974 "glibc-hidden-visibility-ldconfig.patch"
975 "glibc-versioned-locpath.patch"
976 "glibc-allow-kernel-2.6.32.patch"
977 "glibc-reinstate-prlimit64-fallback.patch"
978 "glibc-2.29-supported-locales.patch"))))))
980 (define-public glibc-2.28
985 (inherit (package-source glibc))
986 (uri (string-append "mirror://gnu/glibc/glibc-" version ".tar.xz"))
989 "10iha5ynvdj5m62vgpgqbq4cwvc2yhyl2w9yyyjgfxmdmx8h145i"))
990 (patches (search-patches "glibc-ldd-x86_64.patch"
991 "glibc-2.28-git-fixes.patch"
992 "glibc-hidden-visibility-ldconfig.patch"
993 "glibc-versioned-locpath.patch"
994 "glibc-allow-kernel-2.6.32.patch"
995 "glibc-reinstate-prlimit64-fallback.patch"
996 "glibc-hurd-magic-pid.patch"
997 "glibc-2.28-supported-locales.patch"))))))
999 (define-public glibc-2.27
1004 (inherit (package-source glibc))
1005 (uri (string-append "mirror://gnu/glibc/glibc-" version ".tar.xz"))
1008 "0wpwq7gsm7sd6ysidv0z575ckqdg13cr2njyfgrbgh4f65adwwji"))
1009 (patches (search-patches "glibc-ldd-x86_64.patch"
1010 "glibc-2.27-git-fixes.patch"
1011 "glibc-hidden-visibility-ldconfig.patch"
1012 "glibc-versioned-locpath.patch"
1013 "glibc-allow-kernel-2.6.32.patch"
1014 "glibc-reinstate-prlimit64-fallback.patch"
1015 "glibc-2.27-supported-locales.patch"
1016 "glibc-CVE-2018-11236.patch"
1017 "glibc-CVE-2018-11237.patch"))))
1018 (properties `((lint-hidden-cve . ("CVE-2017-18269")))))) ; glibc-2.27-git-fixes
1020 (define-public (make-gcc-libc base-gcc libc)
1021 "Return a GCC that targets LIBC."
1022 (package (inherit base-gcc)
1023 (name (string-append (package-name base-gcc) "-"
1024 (package-name libc) "-"
1025 (package-version libc)))
1027 (ensure-keyword-arguments (package-arguments base-gcc)
1028 '(#:implicit-inputs? #f)))
1030 `(,@(package-native-inputs base-gcc)
1031 ,@(append (fold alist-delete (%final-inputs) '("libc" "libc:static")))
1033 ("libc:static" ,libc "static")))))
1035 (define-public (make-glibc-locales glibc)
1038 (name "glibc-locales")
1039 (source (origin (inherit (package-source glibc))
1040 ;; The patch for glibc 2.28 and earlier replaces the same
1041 ;; content, but the context in the patch is different
1042 ;; enough to fail to merge.
1043 (patches (cons (search-patch
1044 (if (version>=? (package-version glibc)
1046 "glibc-locales.patch"
1047 "glibc-locales-2.28.patch"))
1048 (origin-patches (package-source glibc))))))
1049 (synopsis "All the locales supported by the GNU C Library")
1051 "This package provides all the locales supported by the GNU C Library,
1052 more than 400 in total. To use them set the @code{LOCPATH} environment variable
1053 to the @code{share/locale} sub-directory of this package.")
1054 (outputs '("out")) ;110+ MiB
1055 (native-search-paths '())
1057 (let ((args `(#:tests? #f #:strip-binaries? #f
1058 ,@(package-arguments glibc))))
1059 (substitute-keyword-arguments args
1060 ((#:modules modules '((guix build utils)
1061 (guix build gnu-build-system)))
1065 ((#:imported-modules modules '())
1066 `((gnu build locale)
1067 ,@%gnu-build-system-modules))
1069 `(modify-phases ,phases
1072 (invoke "make" "localedata/install-locales"
1073 "-j" (number->string (parallel-job-count)))))
1074 (add-after 'build 'symlink-normalized-codesets
1075 (lambda* (#:key outputs #:allow-other-keys)
1076 ;; The above phase does not install locales with names using
1077 ;; the "normalized codeset." Thus, create symlinks like:
1078 ;; en_US.utf8 -> en_US.UTF-8
1079 (define (locale-directory? file stat)
1080 (and (file-is-directory? file)
1081 (string-index (basename file) #\_)
1082 (string-rindex (basename file) #\.)))
1084 (let* ((out (assoc-ref outputs "out"))
1085 (locales (find-files out locale-directory?
1086 #:directories? #t)))
1087 (for-each (lambda (directory)
1088 (let*-values (((base)
1089 (basename directory))
1091 (locale->name+codeset base))
1093 (normalize-codeset codeset)))
1094 (unless (string=? codeset normalized)
1096 (string-append (dirname directory)
1102 (delete 'move-static-libs)))
1103 ((#:configure-flags flags)
1105 ;; Use $(libdir)/locale/X.Y as is the case by default.
1106 (list (string-append "libc_cv_complocaledir="
1107 (assoc-ref %outputs "out")
1109 ,(version-major+minor
1110 (package-version glibc)))))))))))
1112 (define %default-utf8-locales
1113 ;; These are the locales commonly used for tests---e.g., in Guile's i18n
1115 '("de_DE" "el_GR" "en_US" "fr_FR" "tr_TR"))
1116 (define*-public (make-glibc-utf8-locales glibc #:key
1117 (locales %default-utf8-locales)
1118 (name "glibc-utf8-locales"))
1119 (define default-locales? (equal? locales %default-utf8-locales))
1122 (version (package-version glibc))
1124 (build-system trivial-build-system)
1126 `(#:modules ((guix build utils))
1128 (use-modules (guix build utils))
1130 (let* ((libc (assoc-ref %build-inputs "glibc"))
1131 (gzip (assoc-ref %build-inputs "gzip"))
1132 (out (assoc-ref %outputs "out"))
1133 (localedir (string-append out "/lib/locale/"
1134 ,(version-major+minor version))))
1135 ;; 'localedef' needs 'gzip'.
1136 (setenv "PATH" (string-append libc "/bin:" gzip "/bin"))
1139 (for-each (lambda (locale)
1141 ;; Use the "normalized codeset" by
1142 ;; default--e.g., "en_US.utf8".
1143 (string-append localedir "/" locale ".utf8"))
1145 (invoke "localedef" "--no-archive"
1146 "--prefix" localedir
1150 ;; For backward compatibility with Guix
1151 ;; <= 0.8.3, add "xx_YY.UTF-8".
1152 (symlink (string-append locale ".utf8")
1153 (string-append localedir "/"
1157 (native-inputs `(("glibc" ,glibc)
1159 (synopsis (if default-locales?
1160 (P_ "Small sample of UTF-8 locales")
1161 (P_ "Customized sample of UTF-8 locales")))
1163 (if default-locales?
1164 (P_ "This package provides a small sample of UTF-8 locales mostly useful in
1165 test environments.")
1166 (format #f (P_ "This package provides the following UTF-8 locales:
1171 (home-page (package-home-page glibc))
1172 (license (package-license glibc))))
1174 (define-public glibc-locales
1175 (make-glibc-locales glibc))
1176 (define-public glibc-utf8-locales
1177 (make-glibc-utf8-locales glibc))
1179 ;; Packages provided to ease use of binaries linked against the previous libc.
1180 (define-public glibc-locales-2.29
1181 (package (inherit (make-glibc-locales glibc-2.29))
1182 (name "glibc-locales-2.29")))
1183 (define-public glibc-utf8-locales-2.29
1184 (package (inherit (make-glibc-utf8-locales glibc-2.29))
1185 (name "glibc-utf8-locales-2.29")))
1187 (define-public which
1193 (uri (string-append "mirror://gnu/which/which-"
1197 "1bgafvy3ypbhhfznwjv1lxmd6mci3x1byilnnkc7gcr486wlb8pl"))))
1198 (build-system gnu-build-system)
1199 (home-page "https://gnu.org/software/which/")
1200 (synopsis "Find full path of shell commands")
1202 "The which program finds the location of executables in PATH, with a
1203 variety of options. It is an alternative to the shell \"type\" built-in
1205 (license gpl3+))) ; some files are under GPLv2+
1207 (define-public glibc/hurd-headers
1208 (package (inherit glibc)
1209 (name "glibc-hurd-headers")
1211 (propagated-inputs `(("gnumach-headers" ,gnumach-headers)
1212 ("hurd-headers" ,hurd-headers)))
1214 `(("mig" ,(if (%current-target-system)
1215 ;; XXX: When targeting i586-pc-gnu, we need a 32-bit MiG,
1219 (arguments `(#:system "i686-linux")))
1221 ,@(package-native-inputs glibc)))
1223 (substitute-keyword-arguments (package-arguments glibc)
1224 ;; We just pass the flags really needed to build the headers.
1225 ((#:configure-flags _)
1226 `(list "--enable-add-ons"
1227 "--host=i586-pc-gnu"))
1229 '(modify-phases %standard-phases
1231 (lambda* (#:key outputs #:allow-other-keys)
1232 (invoke "make" "install-headers")
1234 ;; Make an empty stubs.h to work around not being able to
1235 ;; produce a valid stubs.h and causing the build to fail. See
1236 ;; <http://lists.gnu.org/archive/html/guix-devel/2014-04/msg00233.html>.
1237 (let ((out (assoc-ref outputs "out")))
1240 (string-append out "/include/gnu/stubs.h"))))
1242 (delete 'build))))))) ; nothing to build
1244 (define-public tzdata
1251 "https://data.iana.org/time-zones/releases/tzdata"
1255 "1wxskk9mh1x2073n99qna2mq58mgi648mbq5dxlqfcrnvrbkk0cd"))))
1256 (build-system gnu-build-system)
1259 #:make-flags (let ((out (assoc-ref %outputs "out"))
1260 (tmp (getenv "TMPDIR")))
1261 (list (string-append "TOPDIR=" out)
1262 (string-append "TZDIR=" out "/share/zoneinfo")
1263 (string-append "TZDEFAULT=" out
1264 "/share/zoneinfo/localtime")
1266 ;; Likewise for the C library routines.
1267 (string-append "LIBDIR=" tmp "/lib")
1268 (string-append "MANDIR=" tmp "/man")
1270 ;; XXX: tzdata 2020b changed the on-disk format
1271 ;; of the time zone files from 'fat' to 'slim'.
1272 ;; Many packages (particularly evolution-data-server)
1273 ;; can not yet handle the latter, so we stick with
1275 ,@(if (version>=? (package-version this-package)
1277 '("CPPFLAGS=-DZIC_BLOAT_DEFAULT='\"fat\"'")
1282 #:modules ((guix build utils)
1283 (guix build gnu-build-system)
1286 (modify-phases %standard-phases
1288 (lambda* (#:key source inputs #:allow-other-keys)
1289 (invoke "tar" "xvf" source)
1290 (invoke "tar" "xvf" (assoc-ref inputs "tzcode"))))
1291 (add-after 'install 'post-install
1292 (lambda* (#:key outputs #:allow-other-keys)
1293 ;; Move data in the right place.
1294 (let ((out (assoc-ref outputs "out")))
1295 ;; Discard zic, dump, and tzselect, already
1296 ;; provided by glibc.
1297 (delete-file-recursively (string-append out "/usr"))
1298 (symlink (string-append out "/share/zoneinfo")
1299 (string-append out "/share/zoneinfo/posix"))
1300 (delete-file-recursively
1301 (string-append out "/share/zoneinfo-posix"))
1302 (copy-recursively (string-append out "/share/zoneinfo-leaps")
1303 (string-append out "/share/zoneinfo/right"))
1304 (delete-file-recursively
1305 (string-append out "/share/zoneinfo-leaps"))
1307 (delete 'configure))))
1308 (inputs `(("tzcode" ,(origin
1311 "https://data.iana.org/time-zones/releases/tzcode"
1315 "1mgsckixmmk9qxzsflfxnp3999qi3ls72bgksclk01g852x51w3c"))))))
1316 (home-page "https://www.iana.org/time-zones")
1317 (synopsis "Database of current and historical time zones")
1318 (description "The Time Zone Database (often called tz or zoneinfo)
1319 contains code and data that represent the history of local time for many
1320 representative locations around the globe. It is updated periodically to
1321 reflect changes made by political bodies to time zone boundaries, UTC offsets,
1322 and daylight-saving rules.")
1323 (license public-domain)))
1325 ;;; A "fixed" version of tzdata, which is used in the test suites of glib and R
1326 ;;; and a few other places. We can update this whenever we are able to rebuild
1327 ;;; thousands of packages (for example, in a core-updates rebuild). This package
1328 ;;; will typically be obsolete and should never be referred to by a built
1330 (define-public tzdata-for-tests
1338 "https://data.iana.org/time-zones/releases/tzdata"
1342 "0z7w1yv37cfk8yhix2cillam091vgp1j4g8fv84261q9mdnq1ivr"))))
1344 `(("tzcode" ,(origin
1347 "https://data.iana.org/time-zones/releases/tzcode"
1351 "1m3y2rnf1nggxxhxplab5zdd5whvar3ijyrv7lifvm82irkd7szn")))))))))
1353 (define-public libiconv
1359 (uri (string-append "mirror://gnu/libiconv/libiconv-"
1363 "0y1ij745r4p48mxq84rax40p10ln7fc7m243p8k8sia519i3dxfc"))
1364 (modules '((guix build utils)))
1366 ;; Work around "declared gets" error on glibc systems (fixed by
1367 ;; Gnulib commit 66712c23388e93e5c518ebc8515140fa0c807348.)
1369 (substitute* "srclib/stdio.in.h"
1370 (("^#undef gets") "")
1371 (("^_GL_WARN_ON_USE \\(gets.*") ""))
1373 (build-system gnu-build-system)
1374 (synopsis "Character set conversion library")
1376 "libiconv provides an implementation of the iconv function for systems
1377 that lack it. iconv is used to convert between character encodings in a
1378 program. It supports a wide variety of different encodings.")
1379 (home-page "https://www.gnu.org/software/libiconv/")
1382 (define* (libiconv-if-needed #:optional (target (%current-target-system)))
1383 "Return either a libiconv package specification to include in a dependency
1384 list for platforms that have an incomplete libc, or the empty list. If a
1385 package needs iconv ,@(libiconv-if-needed) should be added."
1386 ;; POSIX C libraries provide iconv. Platforms with an incomplete libc
1387 ;; without iconv, such as MinGW, must return the then clause.
1388 (if (target-mingw? target)
1389 `(("libiconv" ,libiconv))
1392 (define-public (canonical-package package)
1393 ;; Avoid circular dependency by lazily resolving 'commencement'.
1394 (let* ((iface (resolve-interface '(gnu packages commencement)))
1395 (proc (module-ref iface 'canonical-package)))
1398 (define-public (%final-inputs)
1399 "Return the list of \"final inputs\"."
1400 ;; Avoid circular dependency by lazily resolving 'commencement'.
1401 (let ((iface (resolve-interface '(gnu packages commencement))))
1402 (module-ref iface '%final-inputs)))
1404 ;;; base.scm ends here