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 Andreas Enge <andreas@enge.fr>
4 ;;; Copyright © 2012 Nikita Karetnikov <nikita@karetnikov.org>
5 ;;; Copyright © 2014, 2015, 2016 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 Efraim Flashner <efraim@flashner.co.il>
9 ;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
10 ;;; Copyright © 2016 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 Marius Bakke <mbakke@fastmail.com>
14 ;;; Copyright © 2017 Eric Bavier <bavier@member.fsf.org>
15 ;;; Copyright © 2018 Ricardo Wurmus <rekado@elephly.net>
17 ;;; This file is part of GNU Guix.
19 ;;; GNU Guix is free software; you can redistribute it and/or modify it
20 ;;; under the terms of the GNU General Public License as published by
21 ;;; the Free Software Foundation; either version 3 of the License, or (at
22 ;;; your option) any later version.
24 ;;; GNU Guix is distributed in the hope that it will be useful, but
25 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
26 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 ;;; GNU General Public License for more details.
29 ;;; You should have received a copy of the GNU General Public License
30 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
32 (define-module (gnu packages base)
33 #:use-module ((guix licenses)
34 #:select (gpl3+ lgpl2.0+ lgpl3+ public-domain))
35 #:use-module (gnu packages)
36 #:use-module (gnu packages acl)
37 #:use-module (gnu packages bash)
38 #:use-module (gnu packages ed)
39 #:use-module (gnu packages guile)
40 #:use-module (gnu packages multiprecision)
41 #:use-module (gnu packages compression)
42 #:use-module (gnu packages perl)
43 #:use-module (gnu packages linux)
44 #:use-module (gnu packages pcre)
45 #:use-module (gnu packages texinfo)
46 #:use-module (gnu packages hurd)
47 #:use-module (gnu packages pkg-config)
48 #:use-module (gnu packages gettext)
49 #:use-module (guix utils)
50 #:use-module (guix packages)
51 #:use-module (guix download)
52 #:use-module (guix git-download)
53 #:use-module (guix build-system gnu)
54 #:use-module (guix build-system trivial)
55 #:use-module (ice-9 match)
61 ;;; Base packages of the Guix-based GNU user-land software distribution.
71 (uri (string-append "mirror://gnu/hello/hello-" version
75 "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"))))
76 (build-system gnu-build-system)
77 (synopsis "Hello, GNU world: An example GNU package")
79 "GNU Hello prints the message \"Hello, world!\" and then exits. It
80 serves as an example of standard GNU coding practices. As such, it supports
81 command-line arguments, multiple languages, and so on.")
82 (home-page "https://www.gnu.org/software/hello/")
91 (uri (string-append "mirror://gnu/grep/grep-"
95 "0zm0ywmyz9g8vn1plw14mn8kj74yipx5qsljndbyfgmvndx5qqnv"))
96 (patches (search-patches "grep-timing-sensitive-test.patch"))))
97 (build-system gnu-build-system)
98 (native-inputs `(("perl" ,perl))) ;some of the tests require it
99 (inputs `(("pcre" ,pcre)))
102 (modify-phases %standard-phases
103 (add-after 'install 'fix-egrep-and-fgrep
104 ;; Patch 'egrep' and 'fgrep' to execute 'grep' via its
105 ;; absolute file name instead of searching for it in $PATH.
106 (lambda* (#:key outputs #:allow-other-keys)
107 (let* ((out (assoc-ref outputs "out"))
108 (bin (string-append out "/bin")))
109 (substitute* (list (string-append bin "/egrep")
110 (string-append bin "/fgrep"))
112 (string-append "exec " bin "/grep")))
114 (synopsis "Print lines matching a pattern")
116 "grep is a tool for finding text inside files. Text is found by
117 matching a pattern provided by the user in one or many files. The pattern
118 may be provided as a basic or extended regular expression, or as fixed
119 strings. By default, the matching text is simply printed to the screen,
120 however the output can be greatly customized to include, for example, line
121 numbers. GNU grep offers many extensions over the standard utility,
122 including, for example, recursive directory searching.")
124 (home-page "https://www.gnu.org/software/grep/")))
132 (uri (string-append "mirror://gnu/sed/sed-" version
136 "0fv88bcnraixc8jvpacvxshi30p5x9m7yb8ns1hfv07hmb2ypmnb"))))
137 (build-system gnu-build-system)
138 (synopsis "Stream editor")
141 (modify-phases %standard-phases
142 (add-after 'unpack 'dont-rebuild-sed.1
144 ;; Make sure we do not attempt to rebuild 'doc/sed.1', which does
145 ;; not work when cross-compiling because we cannot run 'sed'.
146 ;; This is fixed upstream as commit a0a25e3.
147 (substitute* "Makefile.in"
151 (add-before 'patch-source-shebangs 'patch-test-suite
152 (lambda* (#:key inputs #:allow-other-keys)
153 (patch-makefile-SHELL "testsuite/Makefile.tests")
154 (substitute* '("testsuite/bsd.sh"
155 "testsuite/bug-regex9.c")
160 "Sed is a non-interactive, text stream editor. It receives a text
161 input from a file or from standard input and it then applies a series of text
162 editing commands to the stream and prints its output to standard output. It
163 is often used for substituting text patterns in a stream. The GNU
164 implementation offers several extensions over the standard utility.")
166 (home-page "https://www.gnu.org/software/sed/")))
174 (uri (string-append "mirror://gnu/tar/tar-"
178 "097hx7sbzp8qirl4m930lw84kn0wmxhmq7v1qpra3mrg0b8cyba0"))
179 (patches (search-patches "tar-CVE-2016-6321.patch"
180 "tar-skip-unreliable-tests.patch"))))
181 (build-system gnu-build-system)
182 ;; Note: test suite requires ~1GiB of disk space.
184 '(#:phases (modify-phases %standard-phases
185 (add-before 'build 'set-shell-file-name
186 (lambda* (#:key inputs #:allow-other-keys)
187 ;; Do not use "/bin/sh" to run programs.
188 (let ((bash (assoc-ref inputs "bash")))
189 (substitute* "src/system.c"
191 (string-append bash "/bin/sh")))
194 ;; When cross-compiling, the 'set-shell-file-name' phase needs to be able
195 ;; to refer to the target Bash.
196 (inputs (if (%current-target-system)
200 (synopsis "Managing tar archives")
202 "Tar provides the ability to create tar archives, as well as the
203 ability to extract, update or list files in an existing archive. It is
204 useful for combining many files into one larger file, while maintaining
205 directory structure and file information such as permissions and
206 creation/modification dates. GNU tar offers many extensions over the
209 (home-page "https://www.gnu.org/software/tar/")))
217 (uri (string-append "mirror://gnu/patch/patch-"
221 "16d2r9kpivaak948mxzc0bai45mqfw73m113wrkmbffnalv1b5gx"))
222 (patches (search-patches "patch-hurd-path-max.patch"))))
223 (build-system gnu-build-system)
224 (native-inputs `(("ed" ,ed)))
225 (synopsis "Apply differences to originals, with optional backups")
227 "Patch is a program that applies changes to files based on differences
228 laid out as by the program \"diff\". The changes may be applied to one or more
229 files depending on the contents of the diff file. It accepts several
230 different diff formats. It may also be used to revert previously applied
233 (home-page "https://savannah.gnu.org/projects/patch/")))
235 (define-public diffutils
241 (uri (string-append "mirror://gnu/diffutils/diffutils-"
245 "1mivg0fy3a6fcn535ln8nkgfj6vxh5hsxxs5h6692wxmsjyyh8fn"))
246 (patches (search-patches "diffutils-getopt.patch"))))
247 (build-system gnu-build-system)
248 (synopsis "Comparing and merging files")
250 "GNU Diffutils is a package containing tools for finding the
251 differences between files. The \"diff\" command is used to show how two files
252 differ, while \"cmp\" shows the offsets and line numbers where they differ.
253 \"diff3\" allows you to compare three files. Finally, \"sdiff\" offers an
254 interactive means to merge two files.")
256 (home-page "https://www.gnu.org/software/diffutils/")))
258 (define-public findutils
264 (uri (string-append "mirror://gnu/findutils/findutils-"
268 "178nn4dl7wbcw499czikirnkniwnx36argdnqgz4ik9i6zvwkm6y"))
269 (patches (search-patches
270 "findutils-localstatedir.patch"
271 "findutils-test-xargs.patch"))
272 (modules '((guix build utils)))
275 ;; The gnulib test-lock test is prone to writer starvation
276 ;; with our glibc@2.25, which prefers readers, so disable it.
277 ;; The gnulib commit b20e8afb0b2 should fix this once
278 ;; incorporated here.
279 (substitute* "tests/Makefile.in"
280 (("test-lock\\$\\(EXEEXT\\) ") ""))
282 (build-system gnu-build-system)
284 `(#:configure-flags (list
285 ;; Tell 'updatedb' to write to /var.
286 "--localstatedir=/var"
288 ;; Work around cross-compilation failure. See
289 ;; <http://savannah.gnu.org/bugs/?27299#comment1>.
290 ,@(if (%current-target-system)
291 '("gl_cv_func_wcwidth_works=yes")
293 (synopsis "Operating on files matching given criteria")
295 "Findutils supplies the basic file directory searching utilities of the
296 GNU system. It consists of two primary searching utilities: \"find\"
297 recursively searches for files in a directory according to given criteria and
298 \"locate\" lists files in a database that match a query. Two auxiliary tools
299 are included: \"updatedb\" updates the file name database and \"xargs\" may be
300 used to apply commands with arbitrarily long arguments.")
302 (home-page "https://www.gnu.org/software/findutils/")))
304 (define-public coreutils
310 (uri (string-append "mirror://gnu/coreutils/coreutils-"
314 "0r8c1bgm68kl70j1lgd0rv12iykw6143k4m9a56xip9rc2hv25qi"))))
315 (build-system gnu-build-system)
316 (inputs `(("acl" ,acl) ; TODO: add SELinux
317 ("gmp" ,gmp) ;bignums in 'expr', yay!
319 ;; Drop the dependency on libcap when cross-compiling since it's
320 ;; not quite cross-compilable.
321 ,@(if (%current-target-system)
323 `(("libcap" ,libcap))))) ;capability support is 'ls', etc.
325 ;; Perl is needed to run tests in native builds, and to run the bundled
326 ;; copy of help2man. However, don't pass it when cross-compiling since
327 ;; that would lead it to try to run programs to get their '--help' output
329 (if (%current-target-system)
332 (outputs '("out" "debug"))
334 `(#:parallel-build? #f ; help2man may be called too early
335 #:phases (modify-phases %standard-phases
336 (add-before 'build 'patch-shell-references
338 ;; 'split' uses either $SHELL or /bin/sh. Set $SHELL so
339 ;; that tests pass, since /bin/sh isn't in the chroot.
340 (setenv "SHELL" (which "sh"))
342 (substitute* (find-files "gnulib-tests" "\\.c$")
343 (("/bin/sh") (which "sh")))
344 (substitute* (find-files "tests" "\\.sh$")
345 (("#!/bin/sh") (which "sh")))
348 ;; Work around a cross-compilation bug whereby libcoreutils.a would
349 ;; provide '__mktime_internal', which conflicts with the one in libc.a.
350 ,@(if (%current-target-system)
351 `(#:configure-flags '("gl_cv_func_working_mktime=yes"))
353 (synopsis "Core GNU utilities (file, text, shell)")
355 "GNU Coreutils includes all of the basic command-line tools that are
356 expected in a POSIX system. These provide the basic file, shell and text
357 manipulation functions of the GNU system. Most of these tools offer extended
358 functionality beyond that which is outlined in the POSIX standard.")
360 (home-page "https://www.gnu.org/software/coreutils/")))
362 (define-public coreutils-minimal
363 ;; Coreutils without its optional dependencies.
366 (name "coreutils-minimal")
370 (define-public gnu-make
376 (uri (string-append "mirror://gnu/make/make-" version
380 "12f5zzyq2w56g95nni65hc0g5p7154033y2f3qmjvd016szn5qnn"))
381 (patches (search-patches "make-impure-dirs.patch"))))
382 (build-system gnu-build-system)
383 (native-inputs `(("pkg-config" ,pkg-config))) ; to detect Guile
384 (inputs `(("guile" ,guile-2.0)))
385 (outputs '("out" "debug"))
388 (modify-phases %standard-phases
389 (add-before 'build 'set-default-shell
390 (lambda* (#:key inputs #:allow-other-keys)
391 ;; Change the default shell from /bin/sh.
392 (let ((bash (assoc-ref inputs "bash")))
394 (("default_shell =.*$")
395 (format #f "default_shell = \"~a/bin/sh\";\n"
397 (synopsis "Remake files automatically")
399 "Make is a program that is used to control the production of
400 executables or other files from their source files. The process is
401 controlled from a Makefile, in which the developer specifies how each file is
402 generated from its source. It has powerful dependency resolution and the
403 ability to determine when files have to be regenerated after their sources
404 change. GNU make offers many powerful extensions over the standard utility.")
406 (home-page "https://www.gnu.org/software/make/")))
408 (define-public binutils
414 (uri (string-append "mirror://gnu/binutils/binutils-"
418 "1sj234nd05cdgga1r36zalvvdkvpfbr12g5mir2n8i1dwsdrj939"))
419 (patches (search-patches "binutils-ld-new-dtags.patch"
420 "binutils-loongson-workaround.patch"))))
421 (build-system gnu-build-system)
423 ;; TODO: Add dependency on zlib + those for Gold.
425 `(#:configure-flags '(;; Add `-static-libgcc' to not retain a dependency
426 ;; on GCC when bootstrapping.
427 "LDFLAGS=-static-libgcc"
429 ;; Don't search under /usr/lib & co.
430 "--with-lib-path=/no-ld-lib-path"
432 ;; Install BFD. It ends up in a hidden directory,
434 "--enable-install-libbfd"
436 ;; Make sure 'ar' and 'ranlib' produce archives in a
437 ;; deterministic fashion.
438 "--enable-deterministic-archives")))
440 (synopsis "Binary utilities: bfd gas gprof ld")
442 "GNU Binutils is a collection of tools for working with binary files.
443 Perhaps the most notable are \"ld\", a linker, and \"as\", an assembler.
444 Other tools include programs to display binary profiling information, list
445 the strings in a binary file, and utilities for working with archives. The
446 \"bfd\" library for working with executable and object formats is also
449 (home-page "https://www.gnu.org/software/binutils/")))
451 (define* (make-ld-wrapper name #:key
454 (guile (canonical-package guile-2.2))
455 (bash (canonical-package bash))
456 (guile-for-build guile))
457 "Return a package called NAME that contains a wrapper for the 'ld' program
458 of BINUTILS, which adds '-rpath' flags to the actual 'ld' command line. The
459 wrapper uses GUILE and BASH.
461 TARGET must be a one-argument procedure that, given a system type, returns a
462 cross-compilation target triplet or #f. When the result is not #f, make a
463 wrapper for the cross-linker for that target, called 'TARGET-ld'."
464 ;; Note: #:system->target-triplet is a procedure so that the evaluation of
465 ;; its result can be delayed until the 'arguments' field is evaluated, thus
466 ;; in a context where '%current-system' is accurate.
471 (build-system trivial-build-system)
472 (inputs `(("binutils" ,binutils)
475 ("wrapper" ,(search-path %load-path
476 "gnu/packages/ld-wrapper.in"))))
478 (let ((target (target (%current-system))))
479 `(#:guile ,guile-for-build
480 #:modules ((guix build utils))
482 (use-modules (guix build utils)
483 (system base compile))
485 (let* ((out (assoc-ref %outputs "out"))
486 (bin (string-append out "/bin"))
488 `(string-append bin "/" ,target "-ld")
489 '(string-append bin "/ld")))
490 (go (string-append ld ".go")))
492 (setvbuf (current-output-port) _IOLBF)
493 (format #t "building ~s/bin/ld wrapper in ~s~%"
494 (assoc-ref %build-inputs "binutils")
498 (copy-file (assoc-ref %build-inputs "wrapper") ld)
503 (string-append (assoc-ref %build-inputs "guile")
506 (string-append (assoc-ref %build-inputs "bash")
509 (string-append (assoc-ref %build-inputs "binutils")
511 (string-append "/bin/"
515 (compile-file ld #:output-file go))))))
516 (synopsis "The linker wrapper")
518 "The linker wrapper (or 'ld-wrapper') wraps the linker to add any
519 missing '-rpath' flags, and to detect any misuse of libraries outside of the
521 (home-page "https://www.gnu.org/software/guix//")
524 (export make-ld-wrapper)
526 (define-public glibc/linux
529 ;; Glibc has stable branches that continuously pick fixes for each supported
530 ;; release. Unfortunately they do not do point-releases, so we are stuck
531 ;; with copying almost all patches, or use a snapshot of the release branch.
533 ;; This version number corresponds to the output of `git describe` and the
534 ;; archive can be generated by checking out the commit ID and running:
535 ;; git archive --prefix=$(git describe)/ HEAD | xz > $(git describe).tar.xz
536 ;; See <https://bugs.gnu.org/29406> for details.
538 ;; Note: Always use a dot after the minor version since various places rely
539 ;; on "version-major+minor" to determine where locales are found.
540 (version "2.26.105-g0890d5379c")
541 (replacement glibc-2.26-patched)
544 (uri (string-append "https://alpha.gnu.org/gnu/guix/mirror/"
545 "glibc-" (version-major+minor version) "-"
546 (caddr (string-split version #\.)) ".tar.xz"))
549 "1jck0c1i248sn02rvsfjykk77qncma34bjq89dyy2irwm50d7s3g"))
551 ;; Disable 'ldconfig' and /etc/ld.so.cache. The latter is
552 ;; required on LFS distros to avoid loading the distro's libc.so
554 '(substitute* "sysdeps/unix/sysv/linux/configure"
555 (("use_ldconfig=yes")
557 (modules '((guix build utils)))
558 (patches (search-patches "glibc-ldd-x86_64.patch"
559 "glibc-versioned-locpath.patch"
560 "glibc-o-largefile.patch"))))
561 (build-system gnu-build-system)
563 ;; Glibc's <limits.h> refers to <linux/limit.h>, for instance, so glibc
564 ;; users should automatically pull Linux headers as well.
565 (propagated-inputs `(("kernel-headers" ,linux-libre-headers)))
567 (outputs '("out" "debug"
568 "static")) ;9 MiB of .a files
571 `(#:out-of-source? #t
573 ;; The libraries have an empty RUNPATH, but some, such as the versioned
574 ;; libraries (libdl-2.24.so, etc.) have ld.so marked as NEEDED. Since
575 ;; these libraries are always going to be found anyway, just skip
577 #:validate-runpath? #f
579 #:modules ((ice-9 ftw)
582 (guix build gnu-build-system))
585 (list "--enable-add-ons"
588 ;; Installing a locale archive with all the locales is to
589 ;; expensive (~100 MiB), so we rely on users to install the
590 ;; locales they really want.
592 ;; Set the default locale path. In practice, $LOCPATH may be
593 ;; defined to point whatever locales users want. However, setuid
594 ;; binaries don't honor $LOCPATH, so they'll instead look into
595 ;; $libc_cv_complocaledir; we choose /run/current-system/locale/X.Y,
596 ;; with the idea that it is going to be populated by the sysadmin.
597 ;; The "X.Y" sub-directory is because locale data formats are
598 ;; incompatible across libc versions; see
599 ;; <https://lists.gnu.org/archive/html/guix-devel/2015-08/msg00737.html>.
601 ;; `--localedir' is not honored, so work around it.
602 ;; See <http://sourceware.org/ml/libc-alpha/2013-03/msg00093.html>.
603 (string-append "libc_cv_complocaledir=/run/current-system/locale/"
604 ,(version-major+minor version))
606 (string-append "--with-headers="
607 (assoc-ref ,(if (%current-target-system)
608 '%build-target-inputs
613 ;; This is the default for most architectures as of GNU libc 2.26,
614 ;; but we specify it explicitly for clarity and consistency. See
615 ;; "kernel-features.h" in the GNU libc for details.
616 "--enable-kernel=3.2.0"
618 ;; Use our Bash instead of /bin/sh.
619 (string-append "BASH_SHELL="
620 (assoc-ref %build-inputs "bash")
623 ;; XXX: Work around "undefined reference to `__stack_chk_guard'".
624 "libc_cv_ssp=no" "libc_cv_ssp_strong=no")
627 #:phases (modify-phases %standard-phases
629 'configure 'pre-configure
630 (lambda* (#:key inputs native-inputs outputs
632 (let* ((out (assoc-ref outputs "out"))
633 (bin (string-append out "/bin"))
634 ;; FIXME: Normally we would look it up only in INPUTS
635 ;; but cross-base uses it as a native input.
636 (bash (or (assoc-ref inputs "static-bash")
637 (assoc-ref native-inputs "static-bash"))))
638 ;; Install the rpc data base file under `$out/etc/rpc'.
639 ;; FIXME: Use installFlags = [ "sysconfdir=$(out)/etc" ];
640 (substitute* "sunrpc/Makefile"
641 (("^\\$\\(inst_sysconfdir\\)/rpc(.*)$" _ suffix)
642 (string-append out "/etc/rpc" suffix "\n"))
643 (("^install-others =.*$")
644 (string-append "install-others = " out "/etc/rpc\n")))
646 (substitute* "Makeconfig"
648 ;; <http://www.linuxfromscratch.org/lfs/view/stable/chapter05/glibc.html>,
649 ;; linking against libgcc_s is not needed with GCC
653 ;; Have `system' use that Bash.
654 (substitute* "sysdeps/posix/system.c"
655 (("#define[[:blank:]]+SHELL_PATH.*$")
656 (format #f "#define SHELL_PATH \"~a/bin/bash\"\n"
660 (substitute* "libio/iopopen.c"
662 (string-append bash "/bin/sh")))
664 ;; Same for the shell used by the 'exec' functions for
665 ;; scripts that lack a shebang.
666 (substitute* (find-files "." "^paths\\.h$")
667 (("#define[[:blank:]]+_PATH_BSHELL[[:blank:]].*$")
668 (string-append "#define _PATH_BSHELL \""
669 bash "/bin/sh\"\n")))
671 ;; Nscd uses __DATE__ and __TIME__ to create a string to
672 ;; make sure the client and server come from the same
673 ;; libc. Use something deterministic instead.
674 (substitute* "nscd/nscd_stat.c"
675 (("static const char compilation\\[21\\] =.*$")
677 "static const char compilation[21] = \""
678 (string-take (basename out) 20) "\";\n")))
680 ;; Make sure we don't retain a reference to the
682 (substitute* "malloc/mtrace.pl"
684 ;; The shebang can be omitted, because there's the
685 ;; "bilingual" eval/exec magic at the top of the file.
690 (add-after 'install 'move-static-libs
691 (lambda* (#:key outputs #:allow-other-keys)
692 ;; Move static libraries to the "static" output.
693 (define (static-library? file)
694 ;; Return true if FILE is a static library. The
695 ;; "_nonshared.a" files are referred to by libc.so,
696 ;; libpthread.so, etc., which are in fact linker
698 (and (string-suffix? ".a" file)
699 (not (string-contains file "_nonshared"))))
701 (define (linker-script? file)
702 ;; Guess whether FILE, a ".a" file, is actually a
704 (and (not (ar-file? file))
705 (not (elf-file? file))))
707 (let* ((out (assoc-ref outputs "out"))
708 (lib (string-append out "/lib"))
709 (files (scandir lib static-library?))
710 (static (assoc-ref outputs "static"))
711 (slib (string-append static "/lib")))
713 (for-each (lambda (base)
714 (rename-file (string-append lib "/" base)
715 (string-append slib "/" base)))
718 ;; Usually libm.a is a linker script so we need to
719 ;; change the file names in there to refer to STATIC
721 (for-each (lambda (ld-script)
722 (substitute* ld-script
724 (filter linker-script?
725 (map (cut string-append slib "/" <>)
729 (inputs `(("static-bash" ,static-bash)))
731 ;; To build the manual, we need Texinfo and Perl. Gettext is needed to
732 ;; install the message catalogs, with 'msgfmt'.
733 (native-inputs `(("texinfo" ,texinfo)
735 ("gettext" ,gettext-minimal)))
738 ;; Search path for packages that provide locale data. This is useful
739 ;; primarily in build environments. Use 'GUIX_LOCPATH' rather than
740 ;; 'LOCPATH' to avoid interference with the host system's libc on foreign
742 (list (search-path-specification
743 (variable "GUIX_LOCPATH")
744 (files '("lib/locale")))))
746 (synopsis "The GNU C Library")
748 "Any Unix-like operating system needs a C library: the library which
749 defines the \"system calls\" and other basic facilities such as open, malloc,
752 The GNU C library is used as the C library in the GNU system and most systems
753 with the Linux kernel.")
755 (home-page "https://www.gnu.org/software/libc/")))
757 (define-public glibc/hurd
758 ;; The Hurd's libc variant.
759 (package (inherit glibc/linux)
764 (uri (string-append "http://alpha.gnu.org/gnu/hurd/glibc-"
765 version "-hurd+libpthread-20161218" ".tar.gz"))
768 "0vpdv05j6j3ria5bw8gp468i64gij94cslxkxj9xkfgi6p615b8p"))))
770 ;; Libc provides <hurd.h>, which includes a bunch of Hurd and Mach headers,
771 ;; so both should be propagated.
772 (propagated-inputs `(("hurd-core-headers" ,hurd-core-headers)))
774 `(,@(package-native-inputs glibc/linux)
779 (substitute-keyword-arguments (package-arguments glibc/linux)
780 ((#:phases original-phases)
781 ;; Add libmachuser.so and libhurduser.so to libc.so's search path.
782 ;; See <http://lists.gnu.org/archive/html/bug-hurd/2015-07/msg00051.html>.
783 `(modify-phases ,original-phases
784 (add-after 'install 'augment-libc.so
785 (lambda* (#:key outputs #:allow-other-keys)
786 (let* ((out (assoc-ref outputs "out")))
787 (substitute* (string-append out "/lib/libc.so")
788 (("/[^ ]+/lib/libc.so.0.3")
789 (string-append out "/lib/libc.so.0.3" " libmachuser.so" " libhurduser.so"))))
791 (add-after 'pre-configure 'pre-configure-set-pwd
793 ;; Use the right 'pwd'.
794 (substitute* "configure"
795 (("/bin/pwd") "pwd"))
799 ;; Force mach/hurd/libpthread subdirs to build first in order to avoid
801 ;; See <https://lists.gnu.org/archive/html/bug-hurd/2016-11/msg00045.html>
802 (let ((-j (list "-j" (number->string (parallel-job-count)))))
803 (let-syntax ((make (syntax-rules ()
805 (zero? (apply system* "make" target -j))))))
806 (and (make "mach/subdir_lib")
807 (make "hurd/subdir_lib")
808 (make "libpthread/subdir_lib")
809 (zero? (apply system* "make" -j)))))))))
810 ((#:configure-flags original-configure-flags)
811 `(append (list "--host=i586-pc-gnu"
813 ;; We need this to get a working openpty() function.
816 ;; <https://lists.gnu.org/archive/html/bug-hurd/2016-10/msg00033.html>
819 ;; nscd fails to build for GNU/Hurd:
820 ;; <https://lists.gnu.org/archive/html/bug-hurd/2014-07/msg00006.html>.
823 (filter (lambda (flag)
824 (not (string-prefix? "--enable-kernel=" flag)))
825 ,original-configure-flags)))))
826 (synopsis "The GNU C Library (GNU Hurd variant)")
827 (supported-systems %hurd-systems)))
829 (define* (glibc-for-target #:optional
830 (target (or (%current-target-system)
832 "Return the glibc for TARGET, GLIBC/LINUX for a Linux host or
833 GLIBC/HURD for a Hurd host"
835 ((or "i586-pc-gnu" "i586-gnu") glibc/hurd)
839 (identifier-syntax (glibc-for-target)))
841 ;; Below are old libc versions, which we use mostly to build locale data in
842 ;; the old format (which the new libc cannot cope with.)
844 (define glibc-2.26-patched
848 (inherit (package-source glibc))
849 (patches (cons (search-patch "glibc-allow-kernel-2.6.32.patch")
850 (origin-patches (package-source glibc))))))))
852 (define-public glibc-2.25
857 (inherit (package-source glibc))
858 (uri (string-append "mirror://gnu/glibc/glibc-"
862 "1813dzkgw6v8q8q1m4v96yfis7vjqc9pslqib6j9mrwh6fxxjyq6"))
863 (patches (search-patches "glibc-ldd-x86_64.patch"
864 "glibc-versioned-locpath.patch"
865 "glibc-o-largefile.patch"
866 "glibc-vectorized-strcspn-guards.patch"
867 "glibc-CVE-2017-1000366-pt1.patch"
868 "glibc-CVE-2017-1000366-pt2.patch"
869 "glibc-CVE-2017-1000366-pt3.patch"))))))
871 (define-public glibc-2.24
876 (inherit (package-source glibc))
877 (uri (string-append "mirror://gnu/glibc/glibc-"
881 "1lxmprg9gm73gvafxd503x70z32phwjzcy74i0adfi6ixzla7m4r"))
882 (patches (search-patches "glibc-ldd-x86_64.patch"
883 "glibc-versioned-locpath.patch"
884 "glibc-o-largefile.patch"
885 "glibc-vectorized-strcspn-guards.patch"
886 "glibc-CVE-2015-5180.patch"
887 "glibc-CVE-2017-1000366-pt1.patch"
888 "glibc-CVE-2017-1000366-pt2.patch"
889 "glibc-CVE-2017-1000366-pt3.patch"))))))
891 (define-public glibc-2.23
896 (inherit (package-source glibc))
897 (uri (string-append "mirror://gnu/glibc/glibc-"
901 "1s8krs3y2n6pzav7ic59dz41alqalphv7vww4138ag30wh0fpvwl"))
902 (patches (search-patches "glibc-ldd-x86_64.patch"
903 "glibc-versioned-locpath.patch"
904 "glibc-o-largefile.patch"
905 "glibc-vectorized-strcspn-guards.patch"
906 "glibc-CVE-2015-5180.patch"
907 "glibc-CVE-2016-3075.patch"
908 "glibc-CVE-2016-3706.patch"
909 "glibc-CVE-2016-4429.patch"
910 "glibc-CVE-2017-1000366-pt1.patch"
911 "glibc-CVE-2017-1000366-pt2.patch"
912 "glibc-CVE-2017-1000366-pt3.patch"))))))
914 (define-public glibc-2.22
919 (inherit (package-source glibc))
920 (uri (string-append "mirror://gnu/glibc/glibc-"
924 "0j49682pm2nh4qbdw35bas82p1pgfnz4d2l7iwfyzvrvj0318wzb"))
925 (patches (search-patches "glibc-ldd-x86_64.patch"
926 "glibc-vectorized-strcspn-guards.patch"
927 "glibc-CVE-2015-5180.patch"
928 "glibc-CVE-2015-7547.patch"
929 "glibc-CVE-2016-3075.patch"
930 "glibc-CVE-2016-3706.patch"
931 "glibc-CVE-2016-4429.patch"
932 "glibc-CVE-2017-1000366-pt1.patch"
933 "glibc-CVE-2017-1000366-pt2.patch"
934 "glibc-CVE-2017-1000366-pt3.patch"))))
936 (substitute-keyword-arguments (package-arguments glibc)
938 `(modify-phases ,phases
939 (add-before 'configure 'fix-pwd
941 ;; Use `pwd' instead of `/bin/pwd' for glibc-2.22.
942 (substitute* "configure"
943 (("/bin/pwd") "pwd"))
946 (define-public glibc-locales
949 (name "glibc-locales")
950 (source (origin (inherit (package-source glibc))
951 (patches (cons (search-patch "glibc-locales.patch")
952 (origin-patches (package-source glibc))))))
953 (synopsis "All the locales supported by the GNU C Library")
955 "This package provides all the locales supported by the GNU C Library,
956 more than 400 in total. To use them set the 'LOCPATH' environment variable to
957 the 'share/locale' sub-directory of this package.")
958 (outputs '("out")) ;110+ MiB
959 (native-search-paths '())
961 (let ((args `(#:tests? #f #:strip-binaries? #f
962 ,@(package-arguments glibc))))
963 (substitute-keyword-arguments args
965 `(modify-phases ,phases
968 (zero? (system* "make" "localedata/install-locales"
969 "-j" (number->string (parallel-job-count))))))
971 (delete 'move-static-libs)))
972 ((#:configure-flags flags)
974 ;; Use $(libdir)/locale/X.Y as is the case by default.
975 (list (string-append "libc_cv_complocaledir="
976 (assoc-ref %outputs "out")
978 ,(version-major+minor
979 (package-version glibc)))))))))))
981 (define-public glibc-utf8-locales
983 (name "glibc-utf8-locales")
984 (version (package-version glibc))
986 (build-system trivial-build-system)
988 `(#:modules ((guix build utils))
990 (use-modules (srfi srfi-1)
993 (let* ((libc (assoc-ref %build-inputs "glibc"))
994 (gzip (assoc-ref %build-inputs "gzip"))
995 (out (assoc-ref %outputs "out"))
996 (localedir (string-append out "/lib/locale/"
997 ,(version-major+minor version))))
998 ;; 'localedef' needs 'gzip'.
999 (setenv "PATH" (string-append libc "/bin:" gzip "/bin"))
1002 (every (lambda (locale)
1004 ;; Use the "normalized codeset" by
1005 ;; default--e.g., "en_US.utf8".
1006 (string-append localedir "/" locale ".utf8"))
1008 (and (zero? (system* "localedef" "--no-archive"
1009 "--prefix" localedir
1013 ;; For backward compatibility with Guix
1014 ;; <= 0.8.3, add "xx_YY.UTF-8".
1015 (symlink (string-append locale ".utf8")
1016 (string-append localedir "/"
1020 ;; These are the locales commonly used for
1021 ;; tests---e.g., in Guile's i18n tests.
1022 '("de_DE" "el_GR" "en_US" "fr_FR" "tr_TR"))))))
1023 (inputs `(("glibc" ,glibc)
1025 (synopsis "Small sample of UTF-8 locales")
1027 "This package provides a small sample of UTF-8 locales mostly useful in
1028 test environments.")
1029 (home-page (package-home-page glibc))
1030 (license (package-license glibc))))
1032 (define-public which
1038 (uri (string-append "mirror://gnu/which/which-"
1042 "1bgafvy3ypbhhfznwjv1lxmd6mci3x1byilnnkc7gcr486wlb8pl"))))
1043 (build-system gnu-build-system)
1044 (home-page "https://gnu.org/software/which/")
1045 (synopsis "Find full path of shell commands")
1047 "The which program finds the location of executables in PATH, with a
1048 variety of options. It is an alternative to the shell \"type\" built-in
1050 (license gpl3+))) ; some files are under GPLv2+
1052 (define-public glibc/hurd-headers
1053 (package (inherit glibc/hurd)
1054 (name "glibc-hurd-headers")
1056 (propagated-inputs `(("gnumach-headers" ,gnumach-headers)
1057 ("hurd-headers" ,hurd-headers)))
1059 (substitute-keyword-arguments (package-arguments glibc/hurd)
1060 ;; We just pass the flags really needed to build the headers.
1061 ((#:configure-flags _)
1062 `(list "--enable-add-ons"
1063 "--host=i586-pc-gnu"
1064 "--enable-obsolete-rpc"))
1068 (lambda* (#:key outputs #:allow-other-keys)
1069 (and (zero? (system* "make" "install-headers"))
1071 ;; Make an empty stubs.h to work around not being able to
1072 ;; produce a valid stubs.h and causing the build to fail. See
1073 ;; <http://lists.gnu.org/archive/html/guix-devel/2014-04/msg00233.html>.
1074 (let ((out (assoc-ref outputs "out")))
1077 (string-append out "/include/gnu/stubs.h"))))))
1079 ;; Nothing to build.
1084 'configure 'pre-configure
1086 ;; Use the right 'pwd'.
1087 (substitute* "configure"
1088 (("/bin/pwd") "pwd")))
1089 %standard-phases))))))))
1091 (define-public tzdata
1098 "https://www.iana.org/time-zones/repository/releases/tzdata"
1102 "1xik57rdi7kqa0wb5jbz7vyjyxpr88lw1g4kscj0ylpgnzjc6998"))))
1103 (build-system gnu-build-system)
1106 #:make-flags (let ((out (assoc-ref %outputs "out"))
1107 (tmp (getenv "TMPDIR")))
1108 (list (string-append "TOPDIR=" out)
1109 (string-append "TZDIR=" out "/share/zoneinfo")
1110 (string-append "TZDEFAULT=" out
1111 "/share/zoneinfo/localtime")
1113 ;; Likewise for the C library routines.
1114 (string-append "LIBDIR=" tmp "/lib")
1115 (string-append "MANDIR=" tmp "/man")
1119 #:modules ((guix build utils)
1120 (guix build gnu-build-system)
1123 (modify-phases %standard-phases
1125 (lambda* (#:key source inputs #:allow-other-keys)
1126 (and (zero? (system* "tar" "xvf" source))
1127 (zero? (system* "tar" "xvf" (assoc-ref inputs "tzcode"))))))
1128 (add-after 'install 'post-install
1129 (lambda* (#:key outputs #:allow-other-keys)
1130 ;; Move data in the right place.
1131 (let ((out (assoc-ref outputs "out")))
1132 ;; Discard zic, dump, and tzselect, already
1133 ;; provided by glibc.
1134 (delete-file-recursively (string-append out "/usr"))
1135 (symlink (string-append out "/share/zoneinfo")
1136 (string-append out "/share/zoneinfo/posix"))
1137 (delete-file-recursively
1138 (string-append out "/share/zoneinfo-posix"))
1139 (copy-recursively (string-append out "/share/zoneinfo-leaps")
1140 (string-append out "/share/zoneinfo/right"))
1141 (delete-file-recursively
1142 (string-append out "/share/zoneinfo-leaps")))))
1143 (delete 'configure))))
1144 (inputs `(("tzcode" ,(origin
1147 "http://www.iana.org/time-zones/repository/releases/tzcode"
1151 "0rg6s1vlgwd8sjhla55hx2h5m2xbx0shm347pkbg4vsaz707zyii"))))))
1152 (home-page "https://www.iana.org/time-zones")
1153 (synopsis "Database of current and historical time zones")
1154 (description "The Time Zone Database (often called tz or zoneinfo)
1155 contains code and data that represent the history of local time for many
1156 representative locations around the globe. It is updated periodically to
1157 reflect changes made by political bodies to time zone boundaries, UTC offsets,
1158 and daylight-saving rules.")
1159 (license public-domain)))
1161 ;;; A "fixed" version of tzdata, which is used in the test suites of glib and R
1162 ;;; and a few other places. We can update this whenever we are able to rebuild
1163 ;;; thousands of packages (for example, in a core-updates rebuild). This package
1164 ;;; will typically be obsolete and should never be referred to by a built
1166 (define-public tzdata-for-tests
1167 (hidden-package (package (inherit tzdata)
1172 (uri (string-append "https://www.iana.org/time-zones/repository"
1173 "/releases/tzdata" version ".tar.gz"))
1176 "02yrrfj0p7ar885ja41ylijzbr8wc6kz6kzlw8c670i9m693ym6n"))))
1179 #:make-flags (let ((out (assoc-ref %outputs "out"))
1180 (tmp (getenv "TMPDIR")))
1181 (list (string-append "TOPDIR=" out)
1182 (string-append "TZDIR=" out "/share/zoneinfo")
1184 ;; Discard zic, dump, and tzselect, already
1185 ;; provided by glibc.
1186 (string-append "ETCDIR=" tmp "/etc")
1188 ;; Likewise for the C library routines.
1189 (string-append "LIBDIR=" tmp "/lib")
1190 (string-append "MANDIR=" tmp "/man")
1194 #:modules ((guix build utils)
1195 (guix build gnu-build-system)
1198 (modify-phases %standard-phases
1200 (lambda* (#:key source inputs #:allow-other-keys)
1201 (and (zero? (system* "tar" "xvf" source))
1202 (zero? (system* "tar" "xvf" (assoc-ref inputs "tzcode"))))))
1203 (add-after 'install 'post-install
1204 (lambda* (#:key outputs #:allow-other-keys)
1205 ;; Move data in the right place.
1206 (let ((out (assoc-ref outputs "out")))
1207 (symlink (string-append out "/share/zoneinfo")
1208 (string-append out "/share/zoneinfo/posix"))
1209 (delete-file-recursively
1210 (string-append out "/share/zoneinfo-posix"))
1211 (copy-recursively (string-append out "/share/zoneinfo-leaps")
1212 (string-append out "/share/zoneinfo/right"))
1213 (delete-file-recursively
1214 (string-append out "/share/zoneinfo-leaps")))))
1215 (delete 'configure))))
1216 (inputs `(("tzcode" ,(origin
1219 "http://www.iana.org/time-zones/repository/releases/tzcode"
1223 "1dvrq0b2hz7cjqdyd7x21wpy4qcng3rvysr61ij0c2g64fyb9s41")))))))))
1225 (define-public libiconv
1231 (uri (string-append "mirror://gnu/libiconv/libiconv-"
1235 "0y1ij745r4p48mxq84rax40p10ln7fc7m243p8k8sia519i3dxfc"))
1236 (modules '((guix build utils)))
1238 ;; Work around "declared gets" error on glibc systems (fixed by
1239 ;; Gnulib commit 66712c23388e93e5c518ebc8515140fa0c807348.)
1240 '(substitute* "srclib/stdio.in.h"
1241 (("^#undef gets") "")
1242 (("^_GL_WARN_ON_USE \\(gets.*") "")))))
1243 (build-system gnu-build-system)
1244 (synopsis "Character set conversion library")
1246 "libiconv provides an implementation of the iconv function for systems
1247 that lack it. iconv is used to convert between character encodings in a
1248 program. It supports a wide variety of different encodings.")
1249 (home-page "https://www.gnu.org/software/libiconv/")
1252 (define* (libiconv-if-needed #:optional (target (%current-target-system)))
1253 "Return either a libiconv package specification to include in a dependency
1254 list for platforms that have an incomplete libc, or the empty list. If a
1255 package needs iconv ,@(libiconv-if-needed) should be added."
1256 ;; POSIX C libraries provide iconv. Platforms with an incomplete libc
1257 ;; without iconv, such as MinGW, must return the then clause.
1258 (if (target-mingw? target)
1259 `(("libiconv" ,libiconv))
1262 (define-public (canonical-package package)
1263 ;; Avoid circular dependency by lazily resolving 'commencement'.
1264 (let* ((iface (resolve-interface '(gnu packages commencement)))
1265 (proc (module-ref iface 'canonical-package)))
1268 (define-public (%final-inputs)
1269 "Return the list of \"final inputs\"."
1270 ;; Avoid circular dependency by lazily resolving 'commencement'.
1271 (let ((iface (resolve-interface '(gnu packages commencement))))
1272 (module-ref iface '%final-inputs)))
1274 ;;; base.scm ends here