1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018 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>
18 ;;; This file is part of GNU Guix.
20 ;;; GNU Guix is free software; you can redistribute it and/or modify it
21 ;;; under the terms of the GNU General Public License as published by
22 ;;; the Free Software Foundation; either version 3 of the License, or (at
23 ;;; your option) any later version.
25 ;;; GNU Guix is distributed in the hope that it will be useful, but
26 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
27 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 ;;; GNU General Public License for more details.
30 ;;; You should have received a copy of the GNU General Public License
31 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
33 (define-module (gnu packages base)
34 #:use-module ((guix licenses)
35 #:select (gpl3+ lgpl2.0+ lgpl3+ public-domain))
36 #:use-module (gnu packages)
37 #:use-module (gnu packages acl)
38 #:use-module (gnu packages algebra)
39 #:use-module (gnu packages bash)
40 #:use-module (gnu packages bison)
41 #:use-module (gnu packages ed)
42 #:use-module (gnu packages gcc)
43 #:use-module (gnu packages guile)
44 #:use-module (gnu packages multiprecision)
45 #:use-module (gnu packages compression)
46 #:use-module (gnu packages perl)
47 #:use-module (gnu packages linux)
48 #:use-module (gnu packages pcre)
49 #:use-module (gnu packages texinfo)
50 #:use-module (gnu packages hurd)
51 #:use-module (gnu packages pkg-config)
52 #:use-module (gnu packages gettext)
53 #:use-module (guix utils)
54 #:use-module (guix packages)
55 #:use-module (guix download)
56 #:use-module (guix git-download)
57 #:use-module (guix build-system gnu)
58 #:use-module (guix build-system trivial)
59 #:use-module (ice-9 match)
60 #:use-module (srfi srfi-1)
61 #:use-module (srfi srfi-26)
67 ;;; Base packages of the Guix-based GNU user-land software distribution.
77 (uri (string-append "mirror://gnu/hello/hello-" version
81 "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"))))
82 (build-system gnu-build-system)
83 (synopsis "Hello, GNU world: An example GNU package")
85 "GNU Hello prints the message \"Hello, world!\" and then exits. It
86 serves as an example of standard GNU coding practices. As such, it supports
87 command-line arguments, multiple languages, and so on.")
88 (home-page "https://www.gnu.org/software/hello/")
97 (uri (string-append "mirror://gnu/grep/grep-"
101 "0zm0ywmyz9g8vn1plw14mn8kj74yipx5qsljndbyfgmvndx5qqnv"))
102 (patches (search-patches "grep-timing-sensitive-test.patch"))))
103 (build-system gnu-build-system)
104 (native-inputs `(("perl" ,perl))) ;some of the tests require it
105 (inputs `(("pcre" ,pcre)))
108 (modify-phases %standard-phases
109 (add-before 'check 'disable-failing-tests
111 ;; These tests are expected to fail due to a glibc bug which has
112 ;; been fixed in 2.28, so they are unexpectedly passing. They
113 ;; should be fixed for grep versions > 3.1.
114 (substitute* "tests/Makefile.in"
115 (("^[[:blank:]]+backref-alt[[:blank:]]+\\\\") "\\")
116 (("^[[:blank:]]+triple-backref[[:blank:]]+\\\\") "\\"))
118 (add-after 'install 'fix-egrep-and-fgrep
119 ;; Patch 'egrep' and 'fgrep' to execute 'grep' via its
120 ;; absolute file name instead of searching for it in $PATH.
121 (lambda* (#:key outputs #:allow-other-keys)
122 (let* ((out (assoc-ref outputs "out"))
123 (bin (string-append out "/bin")))
124 (substitute* (list (string-append bin "/egrep")
125 (string-append bin "/fgrep"))
127 (string-append "exec " bin "/grep")))
129 (synopsis "Print lines matching a pattern")
131 "grep is a tool for finding text inside files. Text is found by
132 matching a pattern provided by the user in one or many files. The pattern
133 may be provided as a basic or extended regular expression, or as fixed
134 strings. By default, the matching text is simply printed to the screen,
135 however the output can be greatly customized to include, for example, line
136 numbers. GNU grep offers many extensions over the standard utility,
137 including, for example, recursive directory searching.")
139 (home-page "https://www.gnu.org/software/grep/")))
147 (uri (string-append "mirror://gnu/sed/sed-" version
151 "0h3b2jfj57wmz680vkbyavlsrkak556qhvs7m7fdlawwhg477bbs"))))
152 (build-system gnu-build-system)
153 (synopsis "Stream editor")
156 (modify-phases %standard-phases
157 (add-after 'unpack 'dont-rebuild-sed.1
159 ;; Make sure we do not attempt to rebuild 'doc/sed.1', which does
160 ;; not work when cross-compiling because we cannot run 'sed'.
161 ;; This is fixed upstream as commit a0a25e3.
162 (substitute* "Makefile.in"
167 `(("perl" ,perl))) ;for tests
169 "Sed is a non-interactive, text stream editor. It receives a text
170 input from a file or from standard input and it then applies a series of text
171 editing commands to the stream and prints its output to standard output. It
172 is often used for substituting text patterns in a stream. The GNU
173 implementation offers several extensions over the standard utility.")
175 (home-page "https://www.gnu.org/software/sed/")))
183 (uri (string-append "mirror://gnu/tar/tar-"
187 "1lyjyk8z8hdddsxw0ikchrsfg3i0x3fsh7l63a8jgaz1n7dr5gzi"))
188 (patches (search-patches "tar-skip-unreliable-tests.patch"
189 "tar-remove-wholesparse-check.patch"))))
190 (build-system gnu-build-system)
191 ;; Note: test suite requires ~1GiB of disk space.
193 `(#:phases (modify-phases %standard-phases
194 (add-before 'build 'set-shell-file-name
195 (lambda* (#:key inputs #:allow-other-keys)
196 ;; Do not use "/bin/sh" to run programs.
197 (let ((bash (assoc-ref inputs "bash")))
198 (substitute* "src/system.c"
200 (string-append bash "/bin/sh")))
203 ;; Work around a cross-compilation bug whereby libgnu.a would provide
204 ;; '__mktime_internal', which conflicts with the one in libc.a.
205 ,@(if (%current-target-system)
206 `(#:configure-flags '("gl_cv_func_working_mktime=yes"))
209 ;; Test #92 "link mismatch" expects "a/z: Not linked to a/y" but gets
210 ;; "a/y: Not linked to a/z" and fails, presumably due to differences in
211 ;; the order in which 'diff' traverses directories. That leads to a
212 ;; test failure even though conceptually the test passes. Skip it.
213 ;; Test 117 and 118 are prone to race conditions too, particularly
214 ;; when cross-compiling, so we skip those as well. All issues have
215 ;; been fixed upstream in these commits:
216 ;; <https://git.savannah.gnu.org/cgit/tar.git/commit/?id=847a36f>
217 ;; <https://git.savannah.gnu.org/cgit/tar.git/commit/?id=64b43fd>
218 #:make-flags (list (string-append
219 "TESTSUITEFLAGS= -k '!link mismatch,"
220 "!directory removed before reading,"
221 "!explicitly named directory removed before reading'"))))
223 ;; When cross-compiling, the 'set-shell-file-name' phase needs to be able
224 ;; to refer to the target Bash.
225 (inputs (if (%current-target-system)
229 (synopsis "Managing tar archives")
231 "Tar provides the ability to create tar archives, as well as the
232 ability to extract, update or list files in an existing archive. It is
233 useful for combining many files into one larger file, while maintaining
234 directory structure and file information such as permissions and
235 creation/modification dates. GNU tar offers many extensions over the
238 (home-page "https://www.gnu.org/software/tar/")))
246 (uri (string-append "mirror://gnu/patch/patch-"
250 "1zfqy4rdcy279vwn2z1kbv19dcfw25d2aqy9nzvdkq5bjzd0nqdc"))
251 (patches (search-patches "patch-hurd-path-max.patch"))))
252 (build-system gnu-build-system)
254 ;; Work around a cross-compilation bug whereby libpatch.a would provide
255 ;; '__mktime_internal', which conflicts with the one in libc.a.
256 (if (%current-target-system)
257 `(#:configure-flags '("gl_cv_func_working_mktime=yes"))
259 (native-inputs `(("ed" ,ed)))
260 (synopsis "Apply differences to originals, with optional backups")
262 "Patch is a program that applies changes to files based on differences
263 laid out as by the program \"diff\". The changes may be applied to one or more
264 files depending on the contents of the diff file. It accepts several
265 different diff formats. It may also be used to revert previously applied
268 (home-page "https://savannah.gnu.org/projects/patch/")))
270 (define-public diffutils
276 (uri (string-append "mirror://gnu/diffutils/diffutils-"
280 "1mivg0fy3a6fcn535ln8nkgfj6vxh5hsxxs5h6692wxmsjyyh8fn"))
281 (patches (search-patches "diffutils-getopt.patch"))))
282 (build-system gnu-build-system)
283 (synopsis "Comparing and merging files")
285 "GNU Diffutils is a package containing tools for finding the
286 differences between files. The \"diff\" command is used to show how two files
287 differ, while \"cmp\" shows the offsets and line numbers where they differ.
288 \"diff3\" allows you to compare three files. Finally, \"sdiff\" offers an
289 interactive means to merge two files.")
291 (home-page "https://www.gnu.org/software/diffutils/")))
293 (define-public findutils
299 (uri (string-append "mirror://gnu/findutils/findutils-"
303 "178nn4dl7wbcw499czikirnkniwnx36argdnqgz4ik9i6zvwkm6y"))
304 (patches (search-patches
305 "findutils-gnulib-libio.patch"
306 "findutils-localstatedir.patch"
307 "findutils-makedev.patch"
308 "findutils-test-xargs.patch"))
309 (modules '((guix build utils)))
312 ;; The gnulib test-lock test is prone to writer starvation
313 ;; with our glibc@2.25, which prefers readers, so disable it.
314 ;; The gnulib commit b20e8afb0b2 should fix this once
315 ;; incorporated here.
316 (substitute* "tests/Makefile.in"
317 (("test-lock\\$\\(EXEEXT\\) ") ""))
319 (build-system gnu-build-system)
321 `(#:configure-flags (list
322 ;; Tell 'updatedb' to write to /var.
323 "--localstatedir=/var"
325 ;; Work around cross-compilation failure. See
326 ;; <http://savannah.gnu.org/bugs/?27299#comment1>.
327 ,@(if (%current-target-system)
328 '("gl_cv_func_wcwidth_works=yes")
330 (synopsis "Operating on files matching given criteria")
332 "Findutils supplies the basic file directory searching utilities of the
333 GNU system. It consists of two primary searching utilities: \"find\"
334 recursively searches for files in a directory according to given criteria and
335 \"locate\" lists files in a database that match a query. Two auxiliary tools
336 are included: \"updatedb\" updates the file name database and \"xargs\" may be
337 used to apply commands with arbitrarily long arguments.")
339 (home-page "https://www.gnu.org/software/findutils/")))
341 (define-public coreutils
347 (uri (string-append "mirror://gnu/coreutils/coreutils-"
351 "0mxhw43d4wpqmvg0l4znk1vm10fy92biyh90lzdnqjcic2lb6cg8"))))
352 (build-system gnu-build-system)
353 (inputs `(("acl" ,acl) ; TODO: add SELinux
354 ("gmp" ,gmp) ;bignums in 'expr', yay!
356 ;; Drop the dependency on libcap when cross-compiling since it's
357 ;; not quite cross-compilable.
358 ,@(if (%current-target-system)
360 `(("libcap" ,libcap))))) ;capability support is 'ls', etc.
362 ;; Perl is needed to run tests in native builds, and to run the bundled
363 ;; copy of help2man. However, don't pass it when cross-compiling since
364 ;; that would lead it to try to run programs to get their '--help' output
366 (if (%current-target-system)
369 (outputs '("out" "debug"))
371 `(#:parallel-build? #f ; help2man may be called too early
372 #:phases (modify-phases %standard-phases
373 (add-before 'build 'patch-shell-references
375 ;; 'split' uses either $SHELL or /bin/sh. Set $SHELL so
376 ;; that tests pass, since /bin/sh isn't in the chroot.
377 (setenv "SHELL" (which "sh"))
379 (substitute* (find-files "gnulib-tests" "\\.c$")
380 (("/bin/sh") (which "sh")))
381 (substitute* (find-files "tests" "\\.sh$")
382 (("#!/bin/sh") (string-append "#!" (which "sh"))))
384 (add-before 'check 'disable-broken-test
386 ;; This test hits the 127 character shebang limit in the build
387 ;; environment due to the way "env -S" splits arguments into
388 ;; shebangs. Note that "env-S-script.sh" works around this
389 ;; specific issue, but "env-S.pl" is not adjusted for build
390 ;; environments with long prefixes (/tmp/guix-build-...).
391 (substitute* "Makefile"
392 (("^.*tests/misc/env-S.pl.*$") ""))
395 ;; Work around a cross-compilation bug whereby libcoreutils.a would
396 ;; provide '__mktime_internal', which conflicts with the one in libc.a.
397 ,@(if (%current-target-system)
398 `(#:configure-flags '("gl_cv_func_working_mktime=yes"))
400 (synopsis "Core GNU utilities (file, text, shell)")
402 "GNU Coreutils includes all of the basic command-line tools that are
403 expected in a POSIX system. These provide the basic file, shell and text
404 manipulation functions of the GNU system. Most of these tools offer extended
405 functionality beyond that which is outlined in the POSIX standard.")
407 (home-page "https://www.gnu.org/software/coreutils/")))
409 (define-public coreutils-minimal
410 ;; Coreutils without its optional dependencies.
413 (name "coreutils-minimal")
417 (define-public gnu-make
423 (uri (string-append "mirror://gnu/make/make-" version
427 "12f5zzyq2w56g95nni65hc0g5p7154033y2f3qmjvd016szn5qnn"))
428 (patches (search-patches "make-impure-dirs.patch"
429 "make-glibc-compat.patch"))))
430 (build-system gnu-build-system)
431 (native-inputs `(("pkg-config" ,pkg-config))) ; to detect Guile
432 (inputs `(("guile" ,guile-2.0)))
433 (outputs '("out" "debug"))
435 '(;; Work around faulty glob detection with glibc 2.27. See
436 ;; <https://lists.nongnu.org/archive/html/bug-make/2017-11/msg00027.html>.
437 #:configure-flags '("make_cv_sys_gnu_glob=yes")
439 (modify-phases %standard-phases
440 (add-before 'build 'set-default-shell
441 (lambda* (#:key inputs #:allow-other-keys)
442 ;; Change the default shell from /bin/sh.
443 (let ((bash (assoc-ref inputs "bash")))
445 (("default_shell =.*$")
446 (format #f "default_shell = \"~a/bin/sh\";\n"
449 (synopsis "Remake files automatically")
451 "Make is a program that is used to control the production of
452 executables or other files from their source files. The process is
453 controlled from a Makefile, in which the developer specifies how each file is
454 generated from its source. It has powerful dependency resolution and the
455 ability to determine when files have to be regenerated after their sources
456 change. GNU make offers many powerful extensions over the standard utility.")
458 (home-page "https://www.gnu.org/software/make/")))
460 (define-public binutils
466 (uri (string-append "mirror://gnu/binutils/binutils-"
470 "1l34hn1zkmhr1wcrgf0d4z7r3najxnw3cx2y2fk7v55zjlk3ik7z"))
471 (patches (search-patches "binutils-loongson-workaround.patch"))))
472 (build-system gnu-build-system)
474 ;; TODO: Add dependency on zlib + those for Gold.
476 `(#:configure-flags '(;; Add `-static-libgcc' to not retain a dependency
477 ;; on GCC when bootstrapping.
478 "LDFLAGS=-static-libgcc"
480 ;; Turn on --enable-new-dtags by default to make the
481 ;; linker set RUNPATH instead of RPATH on binaries.
482 ;; This is important because RUNPATH can be overriden
483 ;; using LD_LIBRARY_PATH at runtime.
486 ;; Don't search under /usr/lib & co.
487 "--with-lib-path=/no-ld-lib-path"
489 ;; Install BFD. It ends up in a hidden directory,
491 "--enable-install-libbfd"
493 ;; Make sure 'ar' and 'ranlib' produce archives in a
494 ;; deterministic fashion.
495 "--enable-deterministic-archives")))
497 (synopsis "Binary utilities: bfd gas gprof ld")
499 "GNU Binutils is a collection of tools for working with binary files.
500 Perhaps the most notable are \"ld\", a linker, and \"as\", an assembler.
501 Other tools include programs to display binary profiling information, list
502 the strings in a binary file, and utilities for working with archives. The
503 \"bfd\" library for working with executable and object formats is also
506 (home-page "https://www.gnu.org/software/binutils/")))
508 (define-public binutils-gold
511 (name "binutils-gold")
514 (modify-phases %standard-phases
515 (add-after 'patch-source-shebangs 'patch-more-shebangs
517 (substitute* "gold/Makefile.in"
518 (("/bin/sh") (which "sh")))
520 ,@(substitute-keyword-arguments (package-arguments binutils)
521 ; Upstream is aware of unrelocatable test failures on arm*.
523 (if (any (cute string-prefix? <> (or (%current-target-system)
527 ((#:configure-flags flags)
528 `(cons* "--enable-gold=default"
529 (delete "LDFLAGS=-static-libgcc" ,flags))))))
533 `(("gcc:lib" ,gcc "lib")))))
535 (define* (make-ld-wrapper name #:key
538 (guile (canonical-package guile-2.2))
539 (bash (canonical-package bash))
540 (guile-for-build guile))
541 "Return a package called NAME that contains a wrapper for the 'ld' program
542 of BINUTILS, which adds '-rpath' flags to the actual 'ld' command line. The
543 wrapper uses GUILE and BASH.
545 TARGET must be a one-argument procedure that, given a system type, returns a
546 cross-compilation target triplet or #f. When the result is not #f, make a
547 wrapper for the cross-linker for that target, called 'TARGET-ld'."
548 ;; Note: #:system->target-triplet is a procedure so that the evaluation of
549 ;; its result can be delayed until the 'arguments' field is evaluated, thus
550 ;; in a context where '%current-system' is accurate.
555 (build-system trivial-build-system)
556 (inputs `(("binutils" ,binutils)
559 ("wrapper" ,(search-path %load-path
560 "gnu/packages/ld-wrapper.in"))))
562 (let ((target (target (%current-system))))
563 `(#:guile ,guile-for-build
564 #:modules ((guix build utils))
566 (use-modules (guix build utils)
567 (system base compile))
569 (let* ((out (assoc-ref %outputs "out"))
570 (bin (string-append out "/bin"))
572 `(string-append bin "/" ,target "-ld")
573 '(string-append bin "/ld")))
574 (go (string-append ld ".go")))
576 (setvbuf (current-output-port) _IOLBF)
577 (format #t "building ~s/bin/ld wrapper in ~s~%"
578 (assoc-ref %build-inputs "binutils")
582 (copy-file (assoc-ref %build-inputs "wrapper") ld)
587 (string-append (assoc-ref %build-inputs "guile")
590 (string-append (assoc-ref %build-inputs "bash")
593 (string-append (assoc-ref %build-inputs "binutils")
595 (string-append "/bin/"
599 (compile-file ld #:output-file go)
601 (synopsis "The linker wrapper")
603 "The linker wrapper (or @code{ld-wrapper}) wraps the linker to add any
604 missing @code{-rpath} flags, and to detect any misuse of libraries outside of
606 (home-page "https://www.gnu.org/software/guix//")
609 (export make-ld-wrapper)
612 ;; This is the GNU C Library, used on GNU/Linux and GNU/Hurd. Prior to
613 ;; version 2.28, GNU/Hurd used a different glibc branch.
616 ;; Note: Always use a dot after the minor version since various places rely
617 ;; on "version-major+minor" to determine where locales are found.
621 (uri (string-append "mirror://gnu/glibc/glibc-" version ".tar.xz"))
624 "10iha5ynvdj5m62vgpgqbq4cwvc2yhyl2w9yyyjgfxmdmx8h145i"))
626 ;; Disable 'ldconfig' and /etc/ld.so.cache. The latter is
627 ;; required on LFS distros to avoid loading the distro's libc.so
630 (substitute* "sysdeps/unix/sysv/linux/configure"
631 (("use_ldconfig=yes")
634 (modules '((guix build utils)))
635 (patches (search-patches "glibc-ldd-x86_64.patch"
636 "glibc-2.28-git-fixes.patch"
637 "glibc-hidden-visibility-ldconfig.patch"
638 "glibc-versioned-locpath.patch"
639 "glibc-allow-kernel-2.6.32.patch"
640 "glibc-reinstate-prlimit64-fallback.patch"))))
641 (build-system gnu-build-system)
643 ;; Glibc's <limits.h> refers to <linux/limit.h>, for instance, so glibc
644 ;; users should automatically pull Linux headers as well. On GNU/Hurd,
645 ;; libc provides <hurd.h>, which includes a bunch of Hurd and Mach headers,
646 ;; so both should be propagated.
649 `(("hurd-core-headers" ,hurd-core-headers))
650 `(("kernel-headers" ,linux-libre-headers))))
652 (outputs '("out" "debug"
653 "static")) ;9 MiB of .a files
656 `(#:out-of-source? #t
658 ;; The libraries have an empty RUNPATH, but some, such as the versioned
659 ;; libraries (libdl-2.24.so, etc.) have ld.so marked as NEEDED. Since
660 ;; these libraries are always going to be found anyway, just skip
662 #:validate-runpath? #f
664 #:modules ((ice-9 ftw)
667 (guix build gnu-build-system))
670 (list "--sysconfdir=/etc"
672 ;; Installing a locale archive with all the locales is to
673 ;; expensive (~100 MiB), so we rely on users to install the
674 ;; locales they really want.
676 ;; Set the default locale path. In practice, $LOCPATH may be
677 ;; defined to point whatever locales users want. However, setuid
678 ;; binaries don't honor $LOCPATH, so they'll instead look into
679 ;; $libc_cv_complocaledir; we choose /run/current-system/locale/X.Y,
680 ;; with the idea that it is going to be populated by the sysadmin.
681 ;; The "X.Y" sub-directory is because locale data formats are
682 ;; incompatible across libc versions; see
683 ;; <https://lists.gnu.org/archive/html/guix-devel/2015-08/msg00737.html>.
685 ;; `--localedir' is not honored, so work around it.
686 ;; See <http://sourceware.org/ml/libc-alpha/2013-03/msg00093.html>.
687 (string-append "libc_cv_complocaledir=/run/current-system/locale/"
688 ,(version-major+minor version))
690 (string-append "--with-headers="
691 (assoc-ref ,(if (%current-target-system)
692 '%build-target-inputs
697 ;; This is the default for most architectures as of GNU libc 2.26,
698 ;; but we specify it explicitly for clarity and consistency. See
699 ;; "kernel-features.h" in the GNU libc for details.
700 "--enable-kernel=3.2.0"
702 ;; Use our Bash instead of /bin/sh.
703 (string-append "BASH_SHELL="
704 (assoc-ref %build-inputs "bash")
707 ;; On GNU/Hurd we get discarded-qualifiers warnings for
708 ;; 'device_write_inband' among other things. Ignore them.
710 '("--disable-werror")
714 #:phases (modify-phases %standard-phases
716 `((add-after 'unpack 'apply-hurd-patch
717 (lambda* (#:key inputs native-inputs
719 ;; TODO: Move this to 'patches' field.
720 (let ((patch (or (assoc-ref native-inputs
721 "hurd-magic-pid-patch")
723 "hurd-magic-pid-patch"))))
724 (invoke "patch" "-p1" "--force" "--input"
728 'configure 'pre-configure
729 (lambda* (#:key inputs native-inputs outputs
731 (let* ((out (assoc-ref outputs "out"))
732 (bin (string-append out "/bin"))
733 ;; FIXME: Normally we would look it up only in INPUTS
734 ;; but cross-base uses it as a native input.
735 (bash (or (assoc-ref inputs "static-bash")
736 (assoc-ref native-inputs "static-bash"))))
737 ;; Install the rpc data base file under `$out/etc/rpc'.
738 ;; FIXME: Use installFlags = [ "sysconfdir=$(out)/etc" ];
739 (substitute* "sunrpc/Makefile"
740 (("^\\$\\(inst_sysconfdir\\)/rpc(.*)$" _ suffix)
741 (string-append out "/etc/rpc" suffix "\n"))
742 (("^install-others =.*$")
743 (string-append "install-others = " out "/etc/rpc\n")))
745 (substitute* "Makeconfig"
747 ;; <http://www.linuxfromscratch.org/lfs/view/stable/chapter05/glibc.html>,
748 ;; linking against libgcc_s is not needed with GCC
752 ;; Have `system' use that Bash.
753 (substitute* "sysdeps/posix/system.c"
754 (("#define[[:blank:]]+SHELL_PATH.*$")
755 (format #f "#define SHELL_PATH \"~a/bin/bash\"\n"
759 (substitute* "libio/iopopen.c"
761 (string-append bash "/bin/sh")))
763 ;; Same for the shell used by the 'exec' functions for
764 ;; scripts that lack a shebang.
765 (substitute* (find-files "." "^paths\\.h$")
766 (("#define[[:blank:]]+_PATH_BSHELL[[:blank:]].*$")
767 (string-append "#define _PATH_BSHELL \""
768 bash "/bin/sh\"\n")))
770 ;; Nscd uses __DATE__ and __TIME__ to create a string to
771 ;; make sure the client and server come from the same
772 ;; libc. Use something deterministic instead.
773 (substitute* "nscd/nscd_stat.c"
774 (("static const char compilation\\[21\\] =.*$")
776 "static const char compilation[21] = \""
777 (string-take (basename out) 20) "\";\n")))
779 ;; Make sure we don't retain a reference to the
781 (substitute* "malloc/mtrace.pl"
783 ;; The shebang can be omitted, because there's the
784 ;; "bilingual" eval/exec magic at the top of the file.
791 (add-after 'install 'move-static-libs
792 (lambda* (#:key outputs #:allow-other-keys)
793 ;; Move static libraries to the "static" output.
794 (define (static-library? file)
795 ;; Return true if FILE is a static library. The
796 ;; "_nonshared.a" files are referred to by libc.so,
797 ;; libpthread.so, etc., which are in fact linker
799 (and (string-suffix? ".a" file)
800 (not (string-contains file "_nonshared"))))
802 (define (linker-script? file)
803 ;; Guess whether FILE, a ".a" file, is actually a
805 (and (not (ar-file? file))
806 (not (elf-file? file))))
808 (let* ((out (assoc-ref outputs "out"))
809 (lib (string-append out "/lib"))
810 (files (scandir lib static-library?))
811 (static (assoc-ref outputs "static"))
812 (slib (string-append static "/lib")))
814 (for-each (lambda (base)
815 (rename-file (string-append lib "/" base)
816 (string-append slib "/" base)))
819 ;; Usually libm.a is a linker script so we need to
820 ;; change the file names in there to refer to STATIC
822 (for-each (lambda (ld-script)
823 (substitute* ld-script
825 (filter linker-script?
826 (map (cut string-append slib "/" <>)
831 '((add-after 'install 'augment-libc.so
832 (lambda* (#:key outputs #:allow-other-keys)
833 (let* ((out (assoc-ref outputs "out")))
834 (substitute* (string-append out "/lib/libc.so")
835 (("/[^ ]+/lib/libc.so.0.3")
836 (string-append out "/lib/libc.so.0.3"
837 " libmachuser.so libhurduser.so"))))
841 (inputs `(("static-bash" ,static-bash)))
843 ;; To build the manual, we need Texinfo and Perl. Gettext is needed to
844 ;; install the message catalogs, with 'msgfmt'.
845 (native-inputs `(("texinfo" ,texinfo)
848 ("gettext" ,gettext-minimal)
853 ("hurd-magic-pid-patch"
854 ,(search-patch "glibc-hurd-magic-pid.patch")))
858 ;; Search path for packages that provide locale data. This is useful
859 ;; primarily in build environments. Use 'GUIX_LOCPATH' rather than
860 ;; 'LOCPATH' to avoid interference with the host system's libc on foreign
862 (list (search-path-specification
863 (variable "GUIX_LOCPATH")
864 (files '("lib/locale")))))
866 (synopsis "The GNU C Library")
868 "Any Unix-like operating system needs a C library: the library which
869 defines the \"system calls\" and other basic facilities such as open, malloc,
872 The GNU C library is used as the C library in the GNU system and most systems
873 with the Linux kernel.")
875 (home-page "https://www.gnu.org/software/libc/")))
877 ;; Below are old libc versions, which we use mostly to build locale data in
878 ;; the old format (which the new libc cannot cope with.)
880 (define-public glibc-2.27
885 (inherit (package-source glibc))
886 (uri (string-append "mirror://gnu/glibc/glibc-" version ".tar.xz"))
889 "0wpwq7gsm7sd6ysidv0z575ckqdg13cr2njyfgrbgh4f65adwwji"))
890 (patches (search-patches "glibc-ldd-x86_64.patch"
891 "glibc-2.27-git-fixes.patch"
892 "glibc-hidden-visibility-ldconfig.patch"
893 "glibc-versioned-locpath.patch"
894 "glibc-allow-kernel-2.6.32.patch"
895 "glibc-reinstate-prlimit64-fallback.patch"
896 "glibc-CVE-2018-11236.patch"
897 "glibc-CVE-2018-11237.patch"))))
898 (properties `((lint-hidden-cve . ("CVE-2017-18269")))))) ; glibc-2.27-git-fixes
900 (define-public glibc-2.26
903 ;; This version number corresponds to the output of `git describe` and the
904 ;; archive can be generated by checking out the commit ID and running:
905 ;; git archive --prefix=$(git describe)/ HEAD | xz > $(git describe).tar.xz
906 ;; See <https://bugs.gnu.org/29406> for why this was necessary.
907 (version "2.26.105-g0890d5379c")
909 (inherit (package-source glibc))
910 (uri (string-append "https://alpha.gnu.org/gnu/guix/mirror/"
911 "glibc-" (version-major+minor version) "-"
912 (caddr (string-split version #\.)) ".tar.xz"))
915 "1jck0c1i248sn02rvsfjykk77qncma34bjq89dyy2irwm50d7s3g"))
916 (patches (search-patches "glibc-ldd-x86_64.patch"
917 "glibc-versioned-locpath.patch"
918 "glibc-allow-kernel-2.6.32.patch"))))))
920 (define-public glibc-2.25
925 (inherit (package-source glibc))
926 (uri (string-append "mirror://gnu/glibc/glibc-"
930 "1813dzkgw6v8q8q1m4v96yfis7vjqc9pslqib6j9mrwh6fxxjyq6"))
931 (patches (search-patches "glibc-ldd-x86_64.patch"
932 "glibc-versioned-locpath.patch"
933 "glibc-vectorized-strcspn-guards.patch"
934 "glibc-CVE-2017-1000366-pt1.patch"
935 "glibc-CVE-2017-1000366-pt2.patch"
936 "glibc-CVE-2017-1000366-pt3.patch"))))))
938 (define-public glibc-2.24
943 (inherit (package-source glibc))
944 (uri (string-append "mirror://gnu/glibc/glibc-"
948 "1lxmprg9gm73gvafxd503x70z32phwjzcy74i0adfi6ixzla7m4r"))
949 (patches (search-patches "glibc-ldd-x86_64.patch"
950 "glibc-versioned-locpath.patch"
951 "glibc-vectorized-strcspn-guards.patch"
952 "glibc-CVE-2015-5180.patch"
953 "glibc-CVE-2017-1000366-pt1.patch"
954 "glibc-CVE-2017-1000366-pt2.patch"
955 "glibc-CVE-2017-1000366-pt3.patch"))))))
957 (define-public glibc-2.23
962 (inherit (package-source glibc))
963 (uri (string-append "mirror://gnu/glibc/glibc-"
967 "1s8krs3y2n6pzav7ic59dz41alqalphv7vww4138ag30wh0fpvwl"))
968 (patches (search-patches "glibc-ldd-x86_64.patch"
969 "glibc-versioned-locpath.patch"
970 "glibc-vectorized-strcspn-guards.patch"
971 "glibc-CVE-2015-5180.patch"
972 "glibc-CVE-2016-3075.patch"
973 "glibc-CVE-2016-3706.patch"
974 "glibc-CVE-2016-4429.patch"
975 "glibc-CVE-2017-1000366-pt1.patch"
976 "glibc-CVE-2017-1000366-pt2.patch"
977 "glibc-CVE-2017-1000366-pt3.patch"))))))
979 (define-public glibc-2.22
984 (inherit (package-source glibc))
985 (uri (string-append "mirror://gnu/glibc/glibc-"
989 "0j49682pm2nh4qbdw35bas82p1pgfnz4d2l7iwfyzvrvj0318wzb"))
990 (patches (search-patches "glibc-ldd-x86_64.patch"
991 "glibc-o-largefile.patch"
992 "glibc-vectorized-strcspn-guards.patch"
993 "glibc-CVE-2015-5180.patch"
994 "glibc-CVE-2015-7547.patch"
995 "glibc-CVE-2016-3075.patch"
996 "glibc-CVE-2016-3706.patch"
997 "glibc-CVE-2016-4429.patch"
998 "glibc-CVE-2017-1000366-pt1.patch"
999 "glibc-CVE-2017-1000366-pt2.patch"
1000 "glibc-CVE-2017-1000366-pt3.patch"))))
1002 (substitute-keyword-arguments (package-arguments glibc)
1004 `(modify-phases ,phases
1005 (add-before 'configure 'fix-pwd
1007 ;; Use `pwd' instead of `/bin/pwd' for glibc-2.22.
1008 (substitute* "configure"
1009 (("/bin/pwd") "pwd"))
1012 (define (make-gcc-libc base-gcc libc)
1013 "Return a GCC that targets LIBC."
1014 (package (inherit base-gcc)
1015 (name (string-append (package-name base-gcc) "-"
1016 (package-name libc) "-"
1017 (package-version libc)))
1019 (substitute-keyword-arguments
1020 (ensure-keyword-arguments (package-arguments base-gcc)
1021 '(#:implicit-inputs? #f))
1022 ((#:make-flags flags)
1023 `(let ((libc (assoc-ref %build-inputs "libc")))
1024 ;; FLAGS_FOR_TARGET are needed for the target libraries to receive
1025 ;; the -Bxxx for the startfiles.
1026 (cons (string-append "FLAGS_FOR_TARGET=-B" libc "/lib")
1030 ("libc:static" ,libc "static")
1031 ,@(append (package-inputs base-gcc)
1032 (fold alist-delete (%final-inputs) '("libc" "libc:static")))))
1035 (define-public (make-glibc-locales glibc)
1038 (name "glibc-locales")
1039 (source (origin (inherit (package-source glibc))
1040 (patches (cons (search-patch "glibc-locales.patch")
1041 (origin-patches (package-source glibc))))))
1042 (synopsis "All the locales supported by the GNU C Library")
1044 "This package provides all the locales supported by the GNU C Library,
1045 more than 400 in total. To use them set the @code{LOCPATH} environment variable
1046 to the @code{share/locale} sub-directory of this package.")
1047 (outputs '("out")) ;110+ MiB
1048 (native-search-paths '())
1050 (let ((args `(#:tests? #f #:strip-binaries? #f
1051 ,@(package-arguments glibc))))
1052 (substitute-keyword-arguments args
1054 `(modify-phases ,phases
1057 (invoke "make" "localedata/install-locales"
1058 "-j" (number->string (parallel-job-count)))))
1060 (delete 'move-static-libs)))
1061 ((#:configure-flags flags)
1063 ;; Use $(libdir)/locale/X.Y as is the case by default.
1064 (list (string-append "libc_cv_complocaledir="
1065 (assoc-ref %outputs "out")
1067 ,(version-major+minor
1068 (package-version glibc)))))))))))
1070 (define-public (make-glibc-utf8-locales glibc)
1072 (name "glibc-utf8-locales")
1073 (version (package-version glibc))
1075 (build-system trivial-build-system)
1077 `(#:modules ((guix build utils))
1079 (use-modules (guix build utils))
1081 (let* ((libc (assoc-ref %build-inputs "glibc"))
1082 (gzip (assoc-ref %build-inputs "gzip"))
1083 (out (assoc-ref %outputs "out"))
1084 (localedir (string-append out "/lib/locale/"
1085 ,(version-major+minor version))))
1086 ;; 'localedef' needs 'gzip'.
1087 (setenv "PATH" (string-append libc "/bin:" gzip "/bin"))
1090 (for-each (lambda (locale)
1092 ;; Use the "normalized codeset" by
1093 ;; default--e.g., "en_US.utf8".
1094 (string-append localedir "/" locale ".utf8"))
1096 (invoke "localedef" "--no-archive"
1097 "--prefix" localedir
1101 ;; For backward compatibility with Guix
1102 ;; <= 0.8.3, add "xx_YY.UTF-8".
1103 (symlink (string-append locale ".utf8")
1104 (string-append localedir "/"
1107 ;; These are the locales commonly used for
1108 ;; tests---e.g., in Guile's i18n tests.
1109 '("de_DE" "el_GR" "en_US" "fr_FR" "tr_TR"))
1111 (inputs `(("glibc" ,glibc)
1113 (synopsis "Small sample of UTF-8 locales")
1115 "This package provides a small sample of UTF-8 locales mostly useful in
1116 test environments.")
1117 (home-page (package-home-page glibc))
1118 (license (package-license glibc))))
1120 (define-public glibc-locales
1121 (make-glibc-locales glibc))
1122 (define-public glibc-utf8-locales
1123 (make-glibc-utf8-locales glibc))
1125 (define-public glibc-locales-2.27
1126 (package (inherit (make-glibc-locales glibc-2.27))
1127 (name "glibc-locales-2.27")))
1128 (define-public glibc-utf8-locales-2.27
1129 (package (inherit (make-glibc-utf8-locales glibc-2.27))
1130 (name "glibc-utf8-locales-2.27")))
1132 (define-public which
1138 (uri (string-append "mirror://gnu/which/which-"
1142 "1bgafvy3ypbhhfznwjv1lxmd6mci3x1byilnnkc7gcr486wlb8pl"))))
1143 (build-system gnu-build-system)
1144 (home-page "https://gnu.org/software/which/")
1145 (synopsis "Find full path of shell commands")
1147 "The which program finds the location of executables in PATH, with a
1148 variety of options. It is an alternative to the shell \"type\" built-in
1150 (license gpl3+))) ; some files are under GPLv2+
1152 (define-public glibc/hurd-headers
1153 (package (inherit glibc)
1154 (name "glibc-hurd-headers")
1156 (propagated-inputs `(("gnumach-headers" ,gnumach-headers)
1157 ("hurd-headers" ,hurd-headers)))
1159 (substitute-keyword-arguments (package-arguments glibc)
1160 ;; We just pass the flags really needed to build the headers.
1161 ((#:configure-flags _)
1162 `(list "--enable-add-ons"
1163 "--host=i586-pc-gnu"))
1165 '(modify-phases %standard-phases
1167 (lambda* (#:key outputs #:allow-other-keys)
1168 (invoke "make" "install-headers")
1170 ;; Make an empty stubs.h to work around not being able to
1171 ;; produce a valid stubs.h and causing the build to fail. See
1172 ;; <http://lists.gnu.org/archive/html/guix-devel/2014-04/msg00233.html>.
1173 (let ((out (assoc-ref outputs "out")))
1176 (string-append out "/include/gnu/stubs.h"))))
1178 (delete 'build))))))) ; nothing to build
1180 (define-public tzdata
1187 "https://www.iana.org/time-zones/repository/releases/tzdata"
1191 "0wlpqm4asvi0waaz24xj20iq40gqfypmb4nldjhkfgm09bgnsdlh"))))
1192 (build-system gnu-build-system)
1195 #:make-flags (let ((out (assoc-ref %outputs "out"))
1196 (tmp (getenv "TMPDIR")))
1197 (list (string-append "TOPDIR=" out)
1198 (string-append "TZDIR=" out "/share/zoneinfo")
1199 (string-append "TZDEFAULT=" out
1200 "/share/zoneinfo/localtime")
1202 ;; Likewise for the C library routines.
1203 (string-append "LIBDIR=" tmp "/lib")
1204 (string-append "MANDIR=" tmp "/man")
1208 #:modules ((guix build utils)
1209 (guix build gnu-build-system)
1212 (modify-phases %standard-phases
1214 (lambda* (#:key source inputs #:allow-other-keys)
1215 (invoke "tar" "xvf" source)
1216 (invoke "tar" "xvf" (assoc-ref inputs "tzcode"))))
1217 (add-after 'install 'post-install
1218 (lambda* (#:key outputs #:allow-other-keys)
1219 ;; Move data in the right place.
1220 (let ((out (assoc-ref outputs "out")))
1221 ;; Discard zic, dump, and tzselect, already
1222 ;; provided by glibc.
1223 (delete-file-recursively (string-append out "/usr"))
1224 (symlink (string-append out "/share/zoneinfo")
1225 (string-append out "/share/zoneinfo/posix"))
1226 (delete-file-recursively
1227 (string-append out "/share/zoneinfo-posix"))
1228 (copy-recursively (string-append out "/share/zoneinfo-leaps")
1229 (string-append out "/share/zoneinfo/right"))
1230 (delete-file-recursively
1231 (string-append out "/share/zoneinfo-leaps"))
1233 (delete 'configure))))
1234 (inputs `(("tzcode" ,(origin
1237 "http://www.iana.org/time-zones/repository/releases/tzcode"
1241 "1x9z8fpgnhzlsnps0hamb54ymaskjab7ys9m4i4gpk9hpiig2fc7"))))))
1242 (home-page "https://www.iana.org/time-zones")
1243 (synopsis "Database of current and historical time zones")
1244 (description "The Time Zone Database (often called tz or zoneinfo)
1245 contains code and data that represent the history of local time for many
1246 representative locations around the globe. It is updated periodically to
1247 reflect changes made by political bodies to time zone boundaries, UTC offsets,
1248 and daylight-saving rules.")
1249 (license public-domain)))
1251 ;;; A "fixed" version of tzdata, which is used in the test suites of glib and R
1252 ;;; and a few other places. We can update this whenever we are able to rebuild
1253 ;;; thousands of packages (for example, in a core-updates rebuild). This package
1254 ;;; will typically be obsolete and should never be referred to by a built
1256 (define-public tzdata-for-tests
1264 "https://www.iana.org/time-zones/repository/releases/tzdata"
1268 "05kayi3w9pvhj6ljx1hvwd0r8mxfzn436fjmwhx53xkj919xxpq2"))))
1270 `(("tzcode" ,(origin
1273 "http://www.iana.org/time-zones/repository/releases/tzcode"
1277 "09y44fzcdq3c06saa8iqqa0a59cyw6ni3p31ps0j1w3hcpxz8lxa")))))))))
1279 (define-public libiconv
1285 (uri (string-append "mirror://gnu/libiconv/libiconv-"
1289 "0y1ij745r4p48mxq84rax40p10ln7fc7m243p8k8sia519i3dxfc"))
1290 (modules '((guix build utils)))
1292 ;; Work around "declared gets" error on glibc systems (fixed by
1293 ;; Gnulib commit 66712c23388e93e5c518ebc8515140fa0c807348.)
1295 (substitute* "srclib/stdio.in.h"
1296 (("^#undef gets") "")
1297 (("^_GL_WARN_ON_USE \\(gets.*") ""))
1299 (build-system gnu-build-system)
1300 (synopsis "Character set conversion library")
1302 "libiconv provides an implementation of the iconv function for systems
1303 that lack it. iconv is used to convert between character encodings in a
1304 program. It supports a wide variety of different encodings.")
1305 (home-page "https://www.gnu.org/software/libiconv/")
1308 (define* (libiconv-if-needed #:optional (target (%current-target-system)))
1309 "Return either a libiconv package specification to include in a dependency
1310 list for platforms that have an incomplete libc, or the empty list. If a
1311 package needs iconv ,@(libiconv-if-needed) should be added."
1312 ;; POSIX C libraries provide iconv. Platforms with an incomplete libc
1313 ;; without iconv, such as MinGW, must return the then clause.
1314 (if (target-mingw? target)
1315 `(("libiconv" ,libiconv))
1318 (define-public (canonical-package package)
1319 ;; Avoid circular dependency by lazily resolving 'commencement'.
1320 (let* ((iface (resolve-interface '(gnu packages commencement)))
1321 (proc (module-ref iface 'canonical-package)))
1324 (define-public (%final-inputs)
1325 "Return the list of \"final inputs\"."
1326 ;; Avoid circular dependency by lazily resolving 'commencement'.
1327 (let ((iface (resolve-interface '(gnu packages commencement))))
1328 (module-ref iface '%final-inputs)))
1330 ;;; base.scm ends here