gnu: glibc: Add clock patches for the Hurd.
[jackhill/guix/guix.git] / gnu / packages / base.scm
CommitLineData
233e7676 1;;; GNU Guix --- Functional package management for GNU
2073b55e 2;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
28317d49 3;;; Copyright © 2014, 2019 Andreas Enge <andreas@enge.fr>
233e7676 4;;; Copyright © 2012 Nikita Karetnikov <nikita@karetnikov.org>
4e50f1f2 5;;; Copyright © 2014, 2015, 2016, 2018 Mark H Weaver <mhw@netris.org>
4c8425b7 6;;; Copyright © 2014 Alex Kost <alezost@gmail.com>
21a8fe1b 7;;; Copyright © 2014, 2015 Manolis Fragkiskos Ragkousis <manolis837@gmail.com>
aded68b3 8;;; Copyright © 2016, 2017, 2019, 2020 Efraim Flashner <efraim@flashner.co.il>
11a5ffba 9;;; Copyright © 2016, 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
ad3c9f18 10;;; Copyright © 2016, 2018 Alex Vong <alexvong1995@gmail.com>
b81d11e5 11;;; Copyright © 2017 Rene Saavedra <rennes@openmailbox.org>
02043f36 12;;; Copyright © 2017, 2020 Mathieu Othacehe <m.othacehe@gmail.com>
3e3a37b2 13;;; Copyright © 2017, 2018, 2020 Marius Bakke <mbakke@fastmail.com>
acc2dab7 14;;; Copyright © 2017 Eric Bavier <bavier@member.fsf.org>
c04e5116 15;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
0845999a 16;;; Copyright © 2018, 2019 Ricardo Wurmus <rekado@elephly.net>
2eb39cd2 17;;; Copyright © 2020 Vitaliy Shatrov <D0dyBo0D0dyBo0@protonmail.com>
e3ce5d70 18;;;
233e7676 19;;; This file is part of GNU Guix.
e3ce5d70 20;;;
233e7676 21;;; GNU Guix is free software; you can redistribute it and/or modify it
e3ce5d70
LC
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.
25;;;
233e7676 26;;; GNU Guix is distributed in the hope that it will be useful, but
e3ce5d70
LC
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.
30;;;
31;;; You should have received a copy of the GNU General Public License
233e7676 32;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
e3ce5d70 33
1ffa7090 34(define-module (gnu packages base)
c6d7e299 35 #:use-module ((guix licenses)
7309045c 36 #:select (gpl3+ lgpl2.0+ lgpl3+ public-domain))
59a43334 37 #:use-module (gnu packages)
1ffa7090 38 #:use-module (gnu packages acl)
28317d49 39 #:use-module (gnu packages algebra)
1ffa7090 40 #:use-module (gnu packages bash)
5e8cb5e6 41 #:use-module (gnu packages bison)
b5ef82e0 42 #:use-module (gnu packages ed)
28317d49 43 #:use-module (gnu packages gcc)
1ffa7090
LC
44 #:use-module (gnu packages guile)
45 #:use-module (gnu packages multiprecision)
c9505f3f 46 #:use-module (gnu packages compression)
1ffa7090
LC
47 #:use-module (gnu packages perl)
48 #:use-module (gnu packages linux)
20bf5fce 49 #:use-module (gnu packages pcre)
8fd6487e 50 #:use-module (gnu packages texinfo)
21a8fe1b 51 #:use-module (gnu packages hurd)
aa6b0d6b 52 #:use-module (gnu packages pkg-config)
5f3f7039 53 #:use-module (gnu packages python)
a635ed5c 54 #:use-module (gnu packages gettext)
aee6180c 55 #:use-module (guix utils)
e3ce5d70 56 #:use-module (guix packages)
87f5d366 57 #:use-module (guix download)
21a8fe1b 58 #:use-module (guix git-download)
c9505f3f 59 #:use-module (guix build-system gnu)
b09617da
MR
60 #:use-module (guix build-system trivial)
61 #:use-module (ice-9 match)
28317d49
EF
62 #:use-module (srfi srfi-1)
63 #:use-module (srfi srfi-26)
4dab8c59
JN
64 #:export (glibc
65 libiconv-if-needed))
e3ce5d70
LC
66
67;;; Commentary:
68;;;
1722d680 69;;; Base packages of the Guix-based GNU user-land software distribution.
e3ce5d70
LC
70;;;
71;;; Code:
72
73(define-public hello
74 (package
17d8e33f
ML
75 (name "hello")
76 (version "2.10")
77 (source (origin
78 (method url-fetch)
79 (uri (string-append "mirror://gnu/hello/hello-" version
80 ".tar.gz"))
81 (sha256
82 (base32
83 "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"))))
84 (build-system gnu-build-system)
85 (synopsis "Hello, GNU world: An example GNU package")
86 (description
87 "GNU Hello prints the message \"Hello, world!\" and then exits. It
a22dc0c4
LC
88serves as an example of standard GNU coding practices. As such, it supports
89command-line arguments, multiple languages, and so on.")
6fd52309 90 (home-page "https://www.gnu.org/software/hello/")
17d8e33f 91 (license gpl3+)))
d7672884 92
6794b278
LC
93(define-public grep
94 (package
95 (name "grep")
e8b79cd9 96 (version "3.4")
6794b278 97 (source (origin
87f5d366 98 (method url-fetch)
0db342a5 99 (uri (string-append "mirror://gnu/grep/grep-"
6794b278
LC
100 version ".tar.xz"))
101 (sha256
102 (base32
e8b79cd9 103 "1yy33kiwrxrwj2nxa4fg15bvmwyghqbs8qwkdvy5phm784f7brjq"))
63adf0fd 104 (patches (search-patches "grep-timing-sensitive-test.patch"))))
6794b278 105 (build-system gnu-build-system)
304e4f51 106 (native-inputs `(("perl" ,perl))) ;some of the tests require it
20bf5fce 107 (inputs `(("pcre" ,pcre)))
1063d325
MW
108 (arguments
109 `(#:phases
110 (modify-phases %standard-phases
111 (add-after 'install 'fix-egrep-and-fgrep
112 ;; Patch 'egrep' and 'fgrep' to execute 'grep' via its
113 ;; absolute file name instead of searching for it in $PATH.
114 (lambda* (#:key outputs #:allow-other-keys)
115 (let* ((out (assoc-ref outputs "out"))
116 (bin (string-append out "/bin")))
117 (substitute* (list (string-append bin "/egrep")
118 (string-append bin "/fgrep"))
119 (("^exec grep")
120 (string-append "exec " bin "/grep")))
121 #t))))))
f50d2669 122 (synopsis "Print lines matching a pattern")
d45122f5 123 (description
12bcf94a 124 "grep is a tool for finding text inside files. Text is found by
a22dc0c4 125matching a pattern provided by the user in one or many files. The pattern
79c311b8
LC
126may be provided as a basic or extended regular expression, or as fixed
127strings. By default, the matching text is simply printed to the screen,
128however the output can be greatly customized to include, for example, line
129numbers. GNU grep offers many extensions over the standard utility,
130including, for example, recursive directory searching.")
4a44e743 131 (license gpl3+)
6fd52309 132 (home-page "https://www.gnu.org/software/grep/")))
6794b278 133
8dcad9aa
LC
134(define-public sed
135 (package
136 (name "sed")
aded68b3 137 (version "4.8")
8dcad9aa 138 (source (origin
87f5d366 139 (method url-fetch)
0db342a5 140 (uri (string-append "mirror://gnu/sed/sed-" version
aded68b3 141 ".tar.gz"))
8dcad9aa
LC
142 (sha256
143 (base32
aded68b3 144 "0alqagh0nliymz23kfjg6g9w3cr086k0sfni56gi8fhzqwa3xksk"))))
8dcad9aa 145 (build-system gnu-build-system)
f50d2669 146 (synopsis "Stream editor")
301a4249
LC
147 (native-inputs
148 `(("perl" ,perl))) ;for tests
d45122f5 149 (description
a22dc0c4
LC
150 "Sed is a non-interactive, text stream editor. It receives a text
151input from a file or from standard input and it then applies a series of text
152editing commands to the stream and prints its output to standard output. It
79c311b8
LC
153is often used for substituting text patterns in a stream. The GNU
154implementation offers several extensions over the standard utility.")
4a44e743 155 (license gpl3+)
7d7ea947 156 (home-page "https://www.gnu.org/software/sed/")))
8dcad9aa 157
85240322
LC
158(define-public tar
159 (package
160 (name "tar")
218eb6e6 161 (version "1.32")
85240322 162 (source (origin
87f5d366 163 (method url-fetch)
0db342a5 164 (uri (string-append "mirror://gnu/tar/tar-"
d6535cf1 165 version ".tar.xz"))
85240322
LC
166 (sha256
167 (base32
218eb6e6 168 "1n7xy657ii0sa42zx6944v2m4v9qrh6sqgmw17l3nch3y43sxlyh"))
45413064
MW
169 (patches (search-patches "tar-skip-unreliable-tests.patch"
170 "tar-remove-wholesparse-check.patch"))))
85240322 171 (build-system gnu-build-system)
74d63739
LC
172 ;; Note: test suite requires ~1GiB of disk space.
173 (arguments
c77835db 174 `(#:phases (modify-phases %standard-phases
74d63739
LC
175 (add-before 'build 'set-shell-file-name
176 (lambda* (#:key inputs #:allow-other-keys)
177 ;; Do not use "/bin/sh" to run programs.
178 (let ((bash (assoc-ref inputs "bash")))
179 (substitute* "src/system.c"
180 (("/bin/sh")
181 (string-append bash "/bin/sh")))
218eb6e6 182 #t))))))
bbe03294
LC
183
184 ;; When cross-compiling, the 'set-shell-file-name' phase needs to be able
185 ;; to refer to the target Bash.
186 (inputs (if (%current-target-system)
187 `(("bash" ,bash))
188 '()))
189
f50d2669 190 (synopsis "Managing tar archives")
d45122f5 191 (description
a22dc0c4
LC
192 "Tar provides the ability to create tar archives, as well as the
193ability to extract, update or list files in an existing archive. It is
194useful for combining many files into one larger file, while maintaining
195directory structure and file information such as permissions and
79c311b8
LC
196creation/modification dates. GNU tar offers many extensions over the
197standard utility.")
4a44e743 198 (license gpl3+)
6fd52309 199 (home-page "https://www.gnu.org/software/tar/")))
85240322 200
fbeec3d9
LC
201(define-public patch
202 (package
203 (name "patch")
ec07ba1f 204 (version "2.7.6")
f6408bc5
LC
205 (source (origin
206 (method url-fetch)
207 (uri (string-append "mirror://gnu/patch/patch-"
208 version ".tar.xz"))
209 (sha256
210 (base32
ec07ba1f 211 "1zfqy4rdcy279vwn2z1kbv19dcfw25d2aqy9nzvdkq5bjzd0nqdc"))
fc1adab1 212 (patches (search-patches "patch-hurd-path-max.patch"))))
fbeec3d9 213 (build-system gnu-build-system)
d3878d3d
LC
214 (arguments
215 ;; Work around a cross-compilation bug whereby libpatch.a would provide
216 ;; '__mktime_internal', which conflicts with the one in libc.a.
217 (if (%current-target-system)
218 `(#:configure-flags '("gl_cv_func_working_mktime=yes"))
219 '()))
b3546174 220 (native-inputs `(("ed" ,ed)))
f50d2669 221 (synopsis "Apply differences to originals, with optional backups")
d45122f5 222 (description
a22dc0c4 223 "Patch is a program that applies changes to files based on differences
79c311b8 224laid out as by the program \"diff\". The changes may be applied to one or more
a22dc0c4
LC
225files depending on the contents of the diff file. It accepts several
226different diff formats. It may also be used to revert previously applied
227differences.")
4a44e743 228 (license gpl3+)
6fd52309 229 (home-page "https://savannah.gnu.org/projects/patch/")))
fbeec3d9 230
04a32ee5
LC
231(define-public diffutils
232 (package
233 (name "diffutils")
e992d566 234 (version "3.7")
04a32ee5 235 (source (origin
87f5d366 236 (method url-fetch)
0db342a5 237 (uri (string-append "mirror://gnu/diffutils/diffutils-"
04a32ee5
LC
238 version ".tar.xz"))
239 (sha256
240 (base32
e992d566 241 "09isrg0isjinv8c535nxsi1s86wfdfzml80dbw41dj9x3hiad9xk"))))
04a32ee5 242 (build-system gnu-build-system)
e992d566 243 (native-inputs `(("perl" ,perl)))
f50d2669 244 (synopsis "Comparing and merging files")
d45122f5 245 (description
79c311b8
LC
246 "GNU Diffutils is a package containing tools for finding the
247differences between files. The \"diff\" command is used to show how two files
e881752c 248differ, while \"cmp\" shows the offsets and line numbers where they differ.
79c311b8 249\"diff3\" allows you to compare three files. Finally, \"sdiff\" offers an
a22dc0c4 250interactive means to merge two files.")
4a44e743 251 (license gpl3+)
6fd52309 252 (home-page "https://www.gnu.org/software/diffutils/")))
04a32ee5 253
af5521ca
LC
254(define-public findutils
255 (package
256 (name "findutils")
717867a6 257 (version "4.7.0")
af5521ca 258 (source (origin
87f5d366 259 (method url-fetch)
0db342a5 260 (uri (string-append "mirror://gnu/findutils/findutils-"
717867a6 261 version ".tar.xz"))
af5521ca
LC
262 (sha256
263 (base32
717867a6 264 "16kqz9yz98dasmj70jwf5py7jk558w96w0vgp3zf9xsqk3gzpzn5"))
f87b68a1
MB
265 (patches (search-patches "findutils-localstatedir.patch"
266 "findutils-test-rwlock-threads.patch"))))
af5521ca 267 (build-system gnu-build-system)
af5521ca 268 (arguments
67dfa198
LC
269 `(#:configure-flags (list
270 ;; Tell 'updatedb' to write to /var.
717867a6
MB
271 "--localstatedir=/var")
272 #:phases (modify-phases %standard-phases
273 (add-before 'check 'adjust-test-shebangs
274 (lambda _
275 (substitute* '("tests/xargs/verbose-quote.sh"
276 "tests/find/exec-plus-last-file.sh")
277 (("#!/bin/sh")
278 (string-append "#!" (which "sh"))))
279 #t)))))
f50d2669 280 (synopsis "Operating on files matching given criteria")
d45122f5 281 (description
a22dc0c4
LC
282 "Findutils supplies the basic file directory searching utilities of the
283GNU system. It consists of two primary searching utilities: \"find\"
284recursively searches for files in a directory according to given criteria and
285\"locate\" lists files in a database that match a query. Two auxiliary tools
79c311b8
LC
286are included: \"updatedb\" updates the file name database and \"xargs\" may be
287used to apply commands with arbitrarily long arguments.")
4a44e743 288 (license gpl3+)
6fd52309 289 (home-page "https://www.gnu.org/software/findutils/")))
2c957cd2
LC
290
291(define-public coreutils
292 (package
293 (name "coreutils")
d7ca0f73 294 (version "8.32")
2c957cd2 295 (source (origin
87f5d366 296 (method url-fetch)
0db342a5 297 (uri (string-append "mirror://gnu/coreutils/coreutils-"
2c957cd2
LC
298 version ".tar.xz"))
299 (sha256
300 (base32
02043f36
MO
301 "1yjcrh5hw70c0yn8zw55pd6j51dj90anpq8mmg649ps9g3gdhn24"))
302 (patches (search-patches "coreutils-ls.patch"))))
2c957cd2 303 (build-system gnu-build-system)
de59af4d 304 (inputs `(("acl" ,acl) ; TODO: add SELinux
09cc7729 305 ("gmp" ,gmp) ;bignums in 'expr', yay!
62ea8865 306
11a5ffba
JN
307 ;; Do not use libcap when cross-compiling since it's not quite
308 ;; cross-compilable; and use it only for supported systems.
309 ,@(if (and (not (%current-target-system))
310 (not (member (%current-system)
311 (package-supported-systems libcap))))
312 `(("libcap" ,libcap)) ;capability support in 'ls', etc.
313 '())))
2c1dea85
LC
314 (native-inputs
315 ;; Perl is needed to run tests in native builds, and to run the bundled
7f31c71c
LC
316 ;; copy of help2man. However, don't pass it when cross-compiling since
317 ;; that would lead it to try to run programs to get their '--help' output
318 ;; for help2man.
1cbd63f2
LC
319 (if (%current-target-system)
320 '()
321 `(("perl" ,perl))))
9bf62d9b 322 (outputs '("out" "debug"))
2c957cd2 323 (arguments
8ba8aeb7 324 `(#:parallel-build? #f ; help2man may be called too early
656a5ba0
EF
325 #:phases (modify-phases %standard-phases
326 (add-before 'build 'patch-shell-references
327 (lambda _
328 ;; 'split' uses either $SHELL or /bin/sh. Set $SHELL so
329 ;; that tests pass, since /bin/sh isn't in the chroot.
330 (setenv "SHELL" (which "sh"))
b47b2b52 331
656a5ba0
EF
332 (substitute* (find-files "gnulib-tests" "\\.c$")
333 (("/bin/sh") (which "sh")))
334 (substitute* (find-files "tests" "\\.sh$")
a8dcf6ce 335 (("#!/bin/sh") (string-append "#!" (which "sh"))))
cf826436 336 #t)))))
f50d2669 337 (synopsis "Core GNU utilities (file, text, shell)")
d45122f5 338 (description
2eb39cd2
VS
339 "GNU Coreutils package includes all of the basic command-line tools that
340are expected in a POSIX system, excluding shell. This package is the union of
341the GNU fileutils, sh-utils, and textutils packages. Most of these tools
342offer extended functionality beyond that which is outlined in the POSIX
343standard.")
4a44e743 344 (license gpl3+)
6fd52309 345 (home-page "https://www.gnu.org/software/coreutils/")))
af5521ca 346
d0f74308 347(define-public coreutils-minimal
28cbc587
LC
348 ;; Coreutils without its optional dependencies.
349 (package
350 (inherit coreutils)
d0f74308 351 (name "coreutils-minimal")
28cbc587
LC
352 (outputs '("out"))
353 (inputs '())))
354
ab776865
LC
355(define-public gnu-make
356 (package
357 (name "make")
cdba9148 358 (version "4.3")
ab776865 359 (source (origin
87f5d366 360 (method url-fetch)
0db342a5 361 (uri (string-append "mirror://gnu/make/make-" version
cdba9148 362 ".tar.gz"))
ab776865
LC
363 (sha256
364 (base32
cdba9148
MB
365 "06cfqzpqsvdnsxbysl5p2fgdgxgl9y4p7scpnrfa8z2zgkjdspz0"))
366 (patches (search-patches "make-impure-dirs.patch"))))
ab776865 367 (build-system gnu-build-system)
b3546174 368 (native-inputs `(("pkg-config" ,pkg-config))) ; to detect Guile
cdba9148 369 (inputs `(("guile" ,guile-3.0)))
9bf62d9b 370 (outputs '("out" "debug"))
ea8fbbf2 371 (arguments
cdba9148 372 '(#:phases
6cc83b68
EF
373 (modify-phases %standard-phases
374 (add-before 'build 'set-default-shell
375 (lambda* (#:key inputs #:allow-other-keys)
376 ;; Change the default shell from /bin/sh.
377 (let ((bash (assoc-ref inputs "bash")))
cdba9148 378 (substitute* "src/job.c"
6cc83b68 379 (("default_shell =.*$")
60f3ad8c 380 (format #f "default_shell = \"~a/bin/sh\";\n"
759ad069
MB
381 bash)))
382 #t))))))
f50d2669 383 (synopsis "Remake files automatically")
d45122f5 384 (description
a22dc0c4
LC
385 "Make is a program that is used to control the production of
386executables or other files from their source files. The process is
387controlled from a Makefile, in which the developer specifies how each file is
388generated from its source. It has powerful dependency resolution and the
389ability to determine when files have to be regenerated after their sources
79c311b8 390change. GNU make offers many powerful extensions over the standard utility.")
4a44e743 391 (license gpl3+)
6fd52309 392 (home-page "https://www.gnu.org/software/make/")))
ab776865 393
8f6201a3
LC
394(define-public binutils
395 (package
396 (name "binutils")
3e3a37b2 397 (version "2.34")
8f6201a3 398 (source (origin
87f5d366 399 (method url-fetch)
0db342a5 400 (uri (string-append "mirror://gnu/binutils/binutils-"
8f6201a3
LC
401 version ".tar.bz2"))
402 (sha256
403 (base32
3e3a37b2 404 "1rin1f5c7wm4n3piky6xilcrpf2s0n3dd5vqq8irrxkcic3i1w49"))
ff19532f 405 (patches (search-patches "binutils-loongson-workaround.patch"))))
8f6201a3
LC
406 (build-system gnu-build-system)
407
408 ;; TODO: Add dependency on zlib + those for Gold.
8f6201a3 409 (arguments
de80b504 410 `(#:configure-flags '(;; Add `-static-libgcc' to not retain a dependency
01d45404
LC
411 ;; on GCC when bootstrapping.
412 "LDFLAGS=-static-libgcc"
8f6201a3 413
ff19532f
MB
414 ;; Turn on --enable-new-dtags by default to make the
415 ;; linker set RUNPATH instead of RPATH on binaries.
416 ;; This is important because RUNPATH can be overriden
417 ;; using LD_LIBRARY_PATH at runtime.
418 "--enable-new-dtags"
419
01d45404 420 ;; Don't search under /usr/lib & co.
444c64b0
LC
421 "--with-lib-path=/no-ld-lib-path"
422
6c95f363
LC
423 ;; Install BFD. It ends up in a hidden directory,
424 ;; but it's here.
cc0a1282
LC
425 "--enable-install-libbfd"
426
427 ;; Make sure 'ar' and 'ranlib' produce archives in a
428 ;; deterministic fashion.
3e3a37b2
MB
429 "--enable-deterministic-archives")
430
431 ;; XXX: binutils 2.34 was mistakenly released without generated manuals:
432 ;; <https://sourceware.org/bugzilla/show_bug.cgi?id=25491>. To avoid a
433 ;; circular dependency on texinfo, prevent the build system from creating
434 ;; the manuals by calling "true" instead of "makeinfo"...
435 #:make-flags '("MAKEINFO=true")))
436
437 ;; ...and "hide" this package so that users who install binutils get the
438 ;; version with documentation defined below.
439 (properties '((hidden? . #t)))
8f6201a3 440
f50d2669 441 (synopsis "Binary utilities: bfd gas gprof ld")
d45122f5 442 (description
a22dc0c4 443 "GNU Binutils is a collection of tools for working with binary files.
c5779c93
LC
444Perhaps the most notable are \"ld\", a linker, and \"as\", an assembler.
445Other tools include programs to display binary profiling information, list
446the strings in a binary file, and utilities for working with archives. The
447\"bfd\" library for working with executable and object formats is also
448included.")
4a44e743 449 (license gpl3+)
6fd52309 450 (home-page "https://www.gnu.org/software/binutils/")))
8f6201a3 451
3e3a37b2
MB
452;; Work around a problem with binutils 2.34 whereby manuals are missing from
453;; the release tarball. Remove this and the related code above when updating.
454(define-public binutils+documentation
455 (package/inherit
456 binutils
457 (native-inputs
458 `(("texinfo" ,texinfo)))
459 (arguments
460 (substitute-keyword-arguments (package-arguments binutils)
461 ((#:make-flags _ ''()) ''())))
462 (properties '())))
463
a493a526
MB
464;; FIXME: ath9k-firmware-htc-binutils.patch do not apply on 2.34 because of a
465;; big refactoring of xtensa-modules.c (commit 567607c11fbf7105 upstream).
466;; Keep this version around until the patch is updated.
467(define-public binutils-2.33
468 (package/inherit
469 binutils
470 (version "2.33.1")
471 (source (origin
472 (inherit (package-source binutils))
473 (uri (string-append "mirror://gnu/binutils/binutils-"
474 version ".tar.bz2"))
475 (sha256
476 (base32
477 "1cmd0riv37bqy9mwbg6n3523qgr8b3bbm5kwj19sjrasl4yq9d0c"))))
478 (arguments
479 (substitute-keyword-arguments (package-arguments binutils)
480 ((#:make-flags _ ''()) ''())))
481 (properties '())))
482
28317d49
EF
483(define-public binutils-gold
484 (package
485 (inherit binutils)
486 (name "binutils-gold")
487 (arguments
488 `(#:phases
489 (modify-phases %standard-phases
490 (add-after 'patch-source-shebangs 'patch-more-shebangs
491 (lambda _
492 (substitute* "gold/Makefile.in"
493 (("/bin/sh") (which "sh")))
494 #t)))
495 ,@(substitute-keyword-arguments (package-arguments binutils)
496 ; Upstream is aware of unrelocatable test failures on arm*.
497 ((#:tests? _ #f)
498 (if (any (cute string-prefix? <> (or (%current-target-system)
499 (%current-system)))
500 '("i686" "x86_64"))
501 '#t '#f))
502 ((#:configure-flags flags)
503 `(cons* "--enable-gold=default"
504 (delete "LDFLAGS=-static-libgcc" ,flags))))))
505 (native-inputs
506 `(("bc" ,bc)))
507 (inputs
508 `(("gcc:lib" ,gcc "lib")))))
509
5bde4503
LC
510(define* (make-ld-wrapper name #:key
511 (target (const #f))
512 binutils
1b709954 513 (guile (canonical-package guile-3.0))
5bde4503 514 (bash (canonical-package bash))
8fdd4101
LC
515 (guile-for-build guile))
516 "Return a package called NAME that contains a wrapper for the 'ld' program
5bde4503
LC
517of BINUTILS, which adds '-rpath' flags to the actual 'ld' command line. The
518wrapper uses GUILE and BASH.
519
520TARGET must be a one-argument procedure that, given a system type, returns a
521cross-compilation target triplet or #f. When the result is not #f, make a
522wrapper for the cross-linker for that target, called 'TARGET-ld'."
523 ;; Note: #:system->target-triplet is a procedure so that the evaluation of
524 ;; its result can be delayed until the 'arguments' field is evaluated, thus
525 ;; in a context where '%current-system' is accurate.
8fdd4101
LC
526 (package
527 (name name)
528 (version "0")
529 (source #f)
530 (build-system trivial-build-system)
531 (inputs `(("binutils" ,binutils)
532 ("guile" ,guile)
533 ("bash" ,bash)
534 ("wrapper" ,(search-path %load-path
c8bfa5b4 535 "gnu/packages/ld-wrapper.in"))))
8fdd4101 536 (arguments
5bde4503
LC
537 (let ((target (target (%current-system))))
538 `(#:guile ,guile-for-build
539 #:modules ((guix build utils))
540 #:builder (begin
541 (use-modules (guix build utils)
542 (system base compile))
8fdd4101 543
5bde4503
LC
544 (let* ((out (assoc-ref %outputs "out"))
545 (bin (string-append out "/bin"))
546 (ld ,(if target
547 `(string-append bin "/" ,target "-ld")
548 '(string-append bin "/ld")))
549 (go (string-append ld ".go")))
8fdd4101 550
d8f78f54
LC
551 (setvbuf (current-output-port)
552 (cond-expand (guile-2.0 _IOLBF)
553 (else 'line)))
5bde4503
LC
554 (format #t "building ~s/bin/ld wrapper in ~s~%"
555 (assoc-ref %build-inputs "binutils")
556 out)
8fdd4101 557
5bde4503
LC
558 (mkdir-p bin)
559 (copy-file (assoc-ref %build-inputs "wrapper") ld)
560 (substitute* ld
561 (("@SELF@")
562 ld)
563 (("@GUILE@")
564 (string-append (assoc-ref %build-inputs "guile")
565 "/bin/guile"))
566 (("@BASH@")
567 (string-append (assoc-ref %build-inputs "bash")
568 "/bin/bash"))
569 (("@LD@")
570 (string-append (assoc-ref %build-inputs "binutils")
571 ,(if target
572 (string-append "/bin/"
573 target "-ld")
574 "/bin/ld"))))
575 (chmod ld #o555)
e3cfef22
MW
576 (compile-file ld #:output-file go)
577 #t)))))
8fdd4101
LC
578 (synopsis "The linker wrapper")
579 (description
36a4366d
EF
580 "The linker wrapper (or @code{ld-wrapper}) wraps the linker to add any
581missing @code{-rpath} flags, and to detect any misuse of libraries outside of
582the store.")
6fd52309 583 (home-page "https://www.gnu.org/software/guix//")
8fdd4101
LC
584 (license gpl3+)))
585
586(export make-ld-wrapper)
587
2d546858
LC
588(define-public glibc
589 ;; This is the GNU C Library, used on GNU/Linux and GNU/Hurd. Prior to
590 ;; version 2.28, GNU/Hurd used a different glibc branch.
7cdeac02
LC
591 (package
592 (name "glibc")
a33eac03 593 (version "2.31")
7cdeac02 594 (source (origin
87f5d366 595 (method url-fetch)
5e8cb5e6 596 (uri (string-append "mirror://gnu/glibc/glibc-" version ".tar.xz"))
7cdeac02
LC
597 (sha256
598 (base32
a33eac03 599 "05zxkyz9bv3j9h0xyid1rhvh3klhsmrpkf3bcs6frvlgyr2gwilj"))
13990c73
LC
600 (snippet
601 ;; Disable 'ldconfig' and /etc/ld.so.cache. The latter is
602 ;; required on LFS distros to avoid loading the distro's libc.so
603 ;; instead of ours.
6cbee49d
MW
604 '(begin
605 (substitute* "sysdeps/unix/sysv/linux/configure"
606 (("use_ldconfig=yes")
607 "use_ldconfig=no"))
608 #t))
1faca892 609 (modules '((guix build utils)))
c3052d6b 610 (patches (search-patches "glibc-ldd-x86_64.patch"
5e8cb5e6 611 "glibc-hidden-visibility-ldconfig.patch"
c3052d6b 612 "glibc-versioned-locpath.patch"
6422bde9 613 "glibc-allow-kernel-2.6.32.patch"
1b9fb043 614 "glibc-reinstate-prlimit64-fallback.patch"
974c42a7
JN
615 "glibc-supported-locales.patch"
616 "glibc-hurd-clock_t_centiseconds.patch"
617 "glibc-hurd-clock_gettime_monotonic.patch"))))
7cdeac02 618 (build-system gnu-build-system)
0a3da5b7
LC
619
620 ;; Glibc's <limits.h> refers to <linux/limit.h>, for instance, so glibc
2d546858
LC
621 ;; users should automatically pull Linux headers as well. On GNU/Hurd,
622 ;; libc provides <hurd.h>, which includes a bunch of Hurd and Mach headers,
623 ;; so both should be propagated.
624 (propagated-inputs
625 (if (hurd-target?)
626 `(("hurd-core-headers" ,hurd-core-headers))
627 `(("kernel-headers" ,linux-libre-headers))))
0a3da5b7 628
6dff905e
LC
629 (outputs '("out" "debug"
630 "static")) ;9 MiB of .a files
7f614e49 631
7cdeac02 632 (arguments
8197c978 633 `(#:out-of-source? #t
211db2f6 634
112da588 635 ;; The libraries have an empty RUNPATH, but some, such as the versioned
67fcf235 636 ;; libraries (libdl-2.24.so, etc.) have ld.so marked as NEEDED. Since
112da588
LC
637 ;; these libraries are always going to be found anyway, just skip
638 ;; RUNPATH checks.
639 #:validate-runpath? #f
640
6dff905e
LC
641 #:modules ((ice-9 ftw)
642 (srfi srfi-26)
643 (guix build utils)
644 (guix build gnu-build-system))
645
7cdeac02 646 #:configure-flags
5e8cb5e6 647 (list "--sysconfdir=/etc"
7f614e49 648
97e11209
LC
649 ;; Installing a locale archive with all the locales is to
650 ;; expensive (~100 MiB), so we rely on users to install the
651 ;; locales they really want.
652 ;;
653 ;; Set the default locale path. In practice, $LOCPATH may be
654 ;; defined to point whatever locales users want. However, setuid
655 ;; binaries don't honor $LOCPATH, so they'll instead look into
9f58fe3d 656 ;; $libc_cv_complocaledir; we choose /run/current-system/locale/X.Y,
46bd6edd
LC
657 ;; with the idea that it is going to be populated by the sysadmin.
658 ;; The "X.Y" sub-directory is because locale data formats are
659 ;; incompatible across libc versions; see
660 ;; <https://lists.gnu.org/archive/html/guix-devel/2015-08/msg00737.html>.
97e11209 661 ;;
7f614e49
LC
662 ;; `--localedir' is not honored, so work around it.
663 ;; See <http://sourceware.org/ml/libc-alpha/2013-03/msg00093.html>.
9f58fe3d 664 (string-append "libc_cv_complocaledir=/run/current-system/locale/"
c6bc8e22 665 ,(version-major+minor version))
7f614e49 666
7cdeac02 667 (string-append "--with-headers="
28dc10a4
LC
668 (assoc-ref ,(if (%current-target-system)
669 '%build-target-inputs
670 '%build-inputs)
aeafff53 671 "kernel-headers")
7cdeac02 672 "/include")
5f456680 673
67d527e3 674 ;; This is the default for most architectures as of GNU libc 2.26,
39ccbfad
MW
675 ;; but we specify it explicitly for clarity and consistency. See
676 ;; "kernel-features.h" in the GNU libc for details.
67d527e3 677 "--enable-kernel=3.2.0"
5f456680 678
6e32f6c0 679 ;; Use our Bash instead of /bin/sh.
8cd8e97c 680 (string-append "BASH_SHELL="
6e32f6c0 681 (assoc-ref %build-inputs "bash")
2d546858
LC
682 "/bin/bash")
683
684 ;; On GNU/Hurd we get discarded-qualifiers warnings for
685 ;; 'device_write_inband' among other things. Ignore them.
686 ,@(if (hurd-target?)
687 '("--disable-werror")
688 '()))
6e32f6c0 689
7cdeac02 690 #:tests? #f ; XXX
57f65bcc
LC
691 #:phases (modify-phases %standard-phases
692 (add-before
693 'configure 'pre-configure
694 (lambda* (#:key inputs native-inputs outputs
695 #:allow-other-keys)
696 (let* ((out (assoc-ref outputs "out"))
697 (bin (string-append out "/bin"))
698 ;; FIXME: Normally we would look it up only in INPUTS
699 ;; but cross-base uses it as a native input.
700 (bash (or (assoc-ref inputs "static-bash")
701 (assoc-ref native-inputs "static-bash"))))
57f65bcc
LC
702 ;; Install the rpc data base file under `$out/etc/rpc'.
703 ;; FIXME: Use installFlags = [ "sysconfdir=$(out)/etc" ];
704 (substitute* "sunrpc/Makefile"
705 (("^\\$\\(inst_sysconfdir\\)/rpc(.*)$" _ suffix)
706 (string-append out "/etc/rpc" suffix "\n"))
707 (("^install-others =.*$")
708 (string-append "install-others = " out "/etc/rpc\n")))
709
710 (substitute* "Makeconfig"
711 ;; According to
712 ;; <http://www.linuxfromscratch.org/lfs/view/stable/chapter05/glibc.html>,
713 ;; linking against libgcc_s is not needed with GCC
714 ;; 4.7.1.
715 ((" -lgcc_s") ""))
716
717 ;; Have `system' use that Bash.
718 (substitute* "sysdeps/posix/system.c"
719 (("#define[[:blank:]]+SHELL_PATH.*$")
720 (format #f "#define SHELL_PATH \"~a/bin/bash\"\n"
721 bash)))
722
723 ;; Same for `popen'.
724 (substitute* "libio/iopopen.c"
725 (("/bin/sh")
11b66876 726 (string-append bash "/bin/sh")))
57f65bcc 727
d56f8d5e
LC
728 ;; Same for the shell used by the 'exec' functions for
729 ;; scripts that lack a shebang.
730 (substitute* (find-files "." "^paths\\.h$")
731 (("#define[[:blank:]]+_PATH_BSHELL[[:blank:]].*$")
732 (string-append "#define _PATH_BSHELL \""
e4831391 733 bash "/bin/sh\"\n")))
d56f8d5e 734
c5b65f7e
LC
735 ;; Nscd uses __DATE__ and __TIME__ to create a string to
736 ;; make sure the client and server come from the same
737 ;; libc. Use something deterministic instead.
738 (substitute* "nscd/nscd_stat.c"
739 (("static const char compilation\\[21\\] =.*$")
740 (string-append
741 "static const char compilation[21] = \""
742 (string-take (basename out) 20) "\";\n")))
743
57f65bcc
LC
744 ;; Make sure we don't retain a reference to the
745 ;; bootstrap Perl.
746 (substitute* "malloc/mtrace.pl"
747 (("^#!.*")
748 ;; The shebang can be omitted, because there's the
749 ;; "bilingual" eval/exec magic at the top of the file.
750 "")
751 (("exec @PERL@")
ab6e5690
MW
752 "exec perl"))
753
754 #t)))
6dff905e
LC
755
756 (add-after 'install 'move-static-libs
757 (lambda* (#:key outputs #:allow-other-keys)
758 ;; Move static libraries to the "static" output.
759 (define (static-library? file)
760 ;; Return true if FILE is a static library. The
761 ;; "_nonshared.a" files are referred to by libc.so,
762 ;; libpthread.so, etc., which are in fact linker
763 ;; scripts.
764 (and (string-suffix? ".a" file)
765 (not (string-contains file "_nonshared"))))
766
767 (define (linker-script? file)
768 ;; Guess whether FILE, a ".a" file, is actually a
769 ;; linker script.
770 (and (not (ar-file? file))
771 (not (elf-file? file))))
772
773 (let* ((out (assoc-ref outputs "out"))
774 (lib (string-append out "/lib"))
775 (files (scandir lib static-library?))
776 (static (assoc-ref outputs "static"))
777 (slib (string-append static "/lib")))
778 (mkdir-p slib)
779 (for-each (lambda (base)
780 (rename-file (string-append lib "/" base)
781 (string-append slib "/" base)))
782 files)
783
784 ;; Usually libm.a is a linker script so we need to
785 ;; change the file names in there to refer to STATIC
786 ;; instead of OUT.
787 (for-each (lambda (ld-script)
788 (substitute* ld-script
789 ((out) static)))
790 (filter linker-script?
791 (map (cut string-append slib "/" <>)
792 files)))
2d546858
LC
793 #t)))
794
795 ,@(if (hurd-target?)
796 '((add-after 'install 'augment-libc.so
797 (lambda* (#:key outputs #:allow-other-keys)
798 (let* ((out (assoc-ref outputs "out")))
799 (substitute* (string-append out "/lib/libc.so")
800 (("/[^ ]+/lib/libc.so.0.3")
801 (string-append out "/lib/libc.so.0.3"
802 " libmachuser.so libhurduser.so"))))
803 #t)))
804 '()))))
7f614e49 805
90d891fc 806 (inputs `(("static-bash" ,static-bash)))
8fd6487e 807
6162b95d
LC
808 ;; To build the manual, we need Texinfo and Perl. Gettext is needed to
809 ;; install the message catalogs, with 'msgfmt'.
8fd6487e 810 (native-inputs `(("texinfo" ,texinfo)
6162b95d 811 ("perl" ,perl)
5e8cb5e6 812 ("bison" ,bison)
2d546858 813 ("gettext" ,gettext-minimal)
5f3f7039 814 ("python" ,python-minimal)
2d546858
LC
815
816 ,@(if (hurd-target?)
817 `(("mig" ,mig)
ef582109 818 ("perl" ,perl))
2d546858 819 '())))
8fd6487e 820
d6718df4
LC
821 (native-search-paths
822 ;; Search path for packages that provide locale data. This is useful
85e57214
LC
823 ;; primarily in build environments. Use 'GUIX_LOCPATH' rather than
824 ;; 'LOCPATH' to avoid interference with the host system's libc on foreign
825 ;; distros.
d6718df4 826 (list (search-path-specification
fbb909ac 827 (variable "GUIX_LOCPATH")
f211b2af 828 (files '("lib/locale")))))
d6718df4 829
d45122f5
LC
830 (synopsis "The GNU C Library")
831 (description
7cdeac02
LC
832 "Any Unix-like operating system needs a C library: the library which
833defines the \"system calls\" and other basic facilities such as open, malloc,
834printf, exit...
835
836The GNU C library is used as the C library in the GNU system and most systems
837with the Linux kernel.")
4a44e743 838 (license lgpl2.0+)
6fd52309 839 (home-page "https://www.gnu.org/software/libc/")))
7cdeac02 840
e13b5474
MB
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.)
843
a33eac03
MB
844(define-public glibc-2.30
845 (package
846 (inherit glibc)
847 (version "2.30")
848 (source (origin
849 (inherit (package-source glibc))
850 (uri (string-append "mirror://gnu/glibc/glibc-" version ".tar.xz"))
851 (sha256
852 (base32
853 "1bxqpg91d02qnaz837a5kamm0f43pr1il4r9pknygywsar713i72"))
854 (patches (search-patches "glibc-ldd-x86_64.patch"
855 "glibc-CVE-2019-19126.patch"
856 "glibc-hidden-visibility-ldconfig.patch"
857 "glibc-versioned-locpath.patch"
858 "glibc-allow-kernel-2.6.32.patch"
859 "glibc-reinstate-prlimit64-fallback.patch"
860 "glibc-2.29-supported-locales.patch"))))))
861
0b3df5c9
MB
862(define-public glibc-2.29
863 (package
864 (inherit glibc)
865 (version "2.29")
866 (source (origin
867 (inherit (package-source glibc))
868 (uri (string-append "mirror://gnu/glibc/glibc-" version ".tar.xz"))
869 (sha256
870 (base32
871 "0jzh58728flfh939a8k9pi1zdyalfzlxmwra7k0rzji5gvavivpk"))
872 (patches (search-patches "glibc-ldd-x86_64.patch"
873 "glibc-CVE-2019-7309.patch"
874 "glibc-CVE-2019-9169.patch"
875 "glibc-2.29-git-updates.patch"
876 "glibc-hidden-visibility-ldconfig.patch"
877 "glibc-versioned-locpath.patch"
878 "glibc-allow-kernel-2.6.32.patch"
879 "glibc-reinstate-prlimit64-fallback.patch"
a33eac03 880 "glibc-2.29-supported-locales.patch"))))))
0b3df5c9 881
5f3f7039
MB
882(define-public glibc-2.28
883 (package
884 (inherit glibc)
885 (version "2.28")
886 (source (origin
887 (inherit (package-source glibc))
888 (uri (string-append "mirror://gnu/glibc/glibc-" version ".tar.xz"))
889 (sha256
890 (base32
891 "10iha5ynvdj5m62vgpgqbq4cwvc2yhyl2w9yyyjgfxmdmx8h145i"))
892 (patches (search-patches "glibc-ldd-x86_64.patch"
893 "glibc-2.28-git-fixes.patch"
894 "glibc-hidden-visibility-ldconfig.patch"
895 "glibc-versioned-locpath.patch"
896 "glibc-allow-kernel-2.6.32.patch"
897 "glibc-reinstate-prlimit64-fallback.patch"
898 "glibc-hurd-magic-pid.patch"
899 "glibc-2.28-supported-locales.patch"))))))
900
e13b5474 901(define-public glibc-2.27
ae66fdaf
MB
902 (package
903 (inherit glibc)
e13b5474 904 (version "2.27")
ae66fdaf
MB
905 (source (origin
906 (inherit (package-source glibc))
907 (uri (string-append "mirror://gnu/glibc/glibc-" version ".tar.xz"))
908 (sha256
909 (base32
e13b5474
MB
910 "0wpwq7gsm7sd6ysidv0z575ckqdg13cr2njyfgrbgh4f65adwwji"))
911 (patches (search-patches "glibc-ldd-x86_64.patch"
912 "glibc-2.27-git-fixes.patch"
ae66fdaf 913 "glibc-hidden-visibility-ldconfig.patch"
e13b5474
MB
914 "glibc-versioned-locpath.patch"
915 "glibc-allow-kernel-2.6.32.patch"
1b9fb043 916 "glibc-reinstate-prlimit64-fallback.patch"
ca3757e1 917 "glibc-2.27-supported-locales.patch"
c86b5f1b
EF
918 "glibc-CVE-2018-11236.patch"
919 "glibc-CVE-2018-11237.patch"))))
920 (properties `((lint-hidden-cve . ("CVE-2017-18269")))))) ; glibc-2.27-git-fixes
19ac2ba8 921
5e8cb5e6
MB
922(define-public glibc-2.26
923 (package
924 (inherit glibc)
925 ;; This version number corresponds to the output of `git describe` and the
926 ;; archive can be generated by checking out the commit ID and running:
927 ;; git archive --prefix=$(git describe)/ HEAD | xz > $(git describe).tar.xz
928 ;; See <https://bugs.gnu.org/29406> for why this was necessary.
929 (version "2.26.105-g0890d5379c")
930 (source (origin
931 (inherit (package-source glibc))
932 (uri (string-append "https://alpha.gnu.org/gnu/guix/mirror/"
933 "glibc-" (version-major+minor version) "-"
934 (caddr (string-split version #\.)) ".tar.xz"))
935 (sha256
936 (base32
937 "1jck0c1i248sn02rvsfjykk77qncma34bjq89dyy2irwm50d7s3g"))
938 (patches (search-patches "glibc-ldd-x86_64.patch"
939 "glibc-versioned-locpath.patch"
940 "glibc-allow-kernel-2.6.32.patch"))))))
941
67d527e3
MB
942(define-public glibc-2.25
943 (package
944 (inherit glibc)
945 (version "2.25")
946 (source (origin
947 (inherit (package-source glibc))
948 (uri (string-append "mirror://gnu/glibc/glibc-"
949 version ".tar.xz"))
950 (sha256
951 (base32
952 "1813dzkgw6v8q8q1m4v96yfis7vjqc9pslqib6j9mrwh6fxxjyq6"))
953 (patches (search-patches "glibc-ldd-x86_64.patch"
954 "glibc-versioned-locpath.patch"
67d527e3 955 "glibc-vectorized-strcspn-guards.patch"
67d527e3
MB
956 "glibc-CVE-2017-1000366-pt1.patch"
957 "glibc-CVE-2017-1000366-pt2.patch"
958 "glibc-CVE-2017-1000366-pt3.patch"))))))
959
7ca72ec4
EF
960(define-public glibc-2.24
961 (package
962 (inherit glibc)
963 (version "2.24")
964 (source (origin
965 (inherit (package-source glibc))
966 (uri (string-append "mirror://gnu/glibc/glibc-"
967 version ".tar.xz"))
968 (sha256
969 (base32
665d6a59
EF
970 "1lxmprg9gm73gvafxd503x70z32phwjzcy74i0adfi6ixzla7m4r"))
971 (patches (search-patches "glibc-ldd-x86_64.patch"
972 "glibc-versioned-locpath.patch"
ffc015be 973 "glibc-vectorized-strcspn-guards.patch"
575e5e4e 974 "glibc-CVE-2015-5180.patch"
665d6a59
EF
975 "glibc-CVE-2017-1000366-pt1.patch"
976 "glibc-CVE-2017-1000366-pt2.patch"
977 "glibc-CVE-2017-1000366-pt3.patch"))))))
7ca72ec4 978
19ac2ba8
LC
979(define-public glibc-2.23
980 (package
981 (inherit glibc)
982 (version "2.23")
983 (source (origin
984 (inherit (package-source glibc))
985 (uri (string-append "mirror://gnu/glibc/glibc-"
986 version ".tar.xz"))
987 (sha256
988 (base32
665d6a59
EF
989 "1s8krs3y2n6pzav7ic59dz41alqalphv7vww4138ag30wh0fpvwl"))
990 (patches (search-patches "glibc-ldd-x86_64.patch"
991 "glibc-versioned-locpath.patch"
ffc015be 992 "glibc-vectorized-strcspn-guards.patch"
a0ae64a3
EF
993 "glibc-CVE-2015-5180.patch"
994 "glibc-CVE-2016-3075.patch"
995 "glibc-CVE-2016-3706.patch"
996 "glibc-CVE-2016-4429.patch"
665d6a59
EF
997 "glibc-CVE-2017-1000366-pt1.patch"
998 "glibc-CVE-2017-1000366-pt2.patch"
999 "glibc-CVE-2017-1000366-pt3.patch"))))))
19ac2ba8 1000
c2c54ebd 1001(define-public glibc-2.22
455859a5 1002 (package
0832787e 1003 (inherit glibc)
c2c54ebd 1004 (version "2.22")
137d957e
LC
1005 (source (origin
1006 (inherit (package-source glibc))
1007 (uri (string-append "mirror://gnu/glibc/glibc-"
1008 version ".tar.xz"))
1009 (sha256
1010 (base32
c2c54ebd 1011 "0j49682pm2nh4qbdw35bas82p1pgfnz4d2l7iwfyzvrvj0318wzb"))
665d6a59 1012 (patches (search-patches "glibc-ldd-x86_64.patch"
ca331eb8 1013 "glibc-o-largefile.patch"
ffc015be 1014 "glibc-vectorized-strcspn-guards.patch"
edd08fb7
EF
1015 "glibc-CVE-2015-5180.patch"
1016 "glibc-CVE-2015-7547.patch"
1017 "glibc-CVE-2016-3075.patch"
1018 "glibc-CVE-2016-3706.patch"
1019 "glibc-CVE-2016-4429.patch"
665d6a59
EF
1020 "glibc-CVE-2017-1000366-pt1.patch"
1021 "glibc-CVE-2017-1000366-pt2.patch"
1022 "glibc-CVE-2017-1000366-pt3.patch"))))
38e9373b
EF
1023 (arguments
1024 (substitute-keyword-arguments (package-arguments glibc)
1025 ((#:phases phases)
1026 `(modify-phases ,phases
1027 (add-before 'configure 'fix-pwd
1028 (lambda _
6d833b13 1029 ;; Use `pwd' instead of `/bin/pwd' for glibc-2.22.
38e9373b 1030 (substitute* "configure"
56ed97c8
MW
1031 (("/bin/pwd") "pwd"))
1032 #t))))))))
137d957e 1033
6869b663 1034(define-public (make-gcc-libc base-gcc libc)
3ed497d4
CD
1035 "Return a GCC that targets LIBC."
1036 (package (inherit base-gcc)
1037 (name (string-append (package-name base-gcc) "-"
1038 (package-name libc) "-"
1039 (package-version libc)))
1040 (arguments
2073b55e
LC
1041 (ensure-keyword-arguments (package-arguments base-gcc)
1042 '(#:implicit-inputs? #f)))
3ed497d4 1043 (native-inputs
2b1d7082
CD
1044 `(,@(package-native-inputs base-gcc)
1045 ,@(append (fold alist-delete (%final-inputs) '("libc" "libc:static")))
1046 ("libc" ,libc)
1047 ("libc:static" ,libc "static")))))
3ed497d4 1048
0845999a 1049(define-public (make-glibc-locales glibc)
aee6180c
LC
1050 (package
1051 (inherit glibc)
1052 (name "glibc-locales")
1053 (source (origin (inherit (package-source glibc))
d4137d84
KK
1054 ;; The patch for glibc 2.28 and earlier replaces the same
1055 ;; content, but the context in the patch is different
1056 ;; enough to fail to merge.
1057 (patches (cons (search-patch
1058 (if (version>=? (package-version glibc)
1059 "2.29")
1060 "glibc-locales.patch"
1061 "glibc-locales-2.28.patch"))
aee6180c
LC
1062 (origin-patches (package-source glibc))))))
1063 (synopsis "All the locales supported by the GNU C Library")
1064 (description
1065 "This package provides all the locales supported by the GNU C Library,
36a4366d
EF
1066more than 400 in total. To use them set the @code{LOCPATH} environment variable
1067to the @code{share/locale} sub-directory of this package.")
aee6180c 1068 (outputs '("out")) ;110+ MiB
605217be 1069 (native-search-paths '())
aee6180c
LC
1070 (arguments
1071 (let ((args `(#:tests? #f #:strip-binaries? #f
1072 ,@(package-arguments glibc))))
1073 (substitute-keyword-arguments args
0e6cee21
LC
1074 ((#:modules modules '((guix build utils)
1075 (guix build gnu-build-system)))
1076 `((srfi srfi-11)
1077 (gnu build locale)
1078 ,@modules))
1079 ((#:imported-modules modules '())
1080 `((gnu build locale)
1081 ,@%gnu-build-system-modules))
aee6180c 1082 ((#:phases phases)
2320d4f0
EF
1083 `(modify-phases ,phases
1084 (replace 'build
1085 (lambda _
bf8e8a74
MW
1086 (invoke "make" "localedata/install-locales"
1087 "-j" (number->string (parallel-job-count)))))
0e6cee21
LC
1088 (add-after 'build 'symlink-normalized-codesets
1089 (lambda* (#:key outputs #:allow-other-keys)
1090 ;; The above phase does not install locales with names using
1091 ;; the "normalized codeset." Thus, create symlinks like:
1092 ;; en_US.utf8 -> en_US.UTF-8
1093 (define (locale-directory? file stat)
1094 (and (file-is-directory? file)
1095 (string-index (basename file) #\_)
1096 (string-rindex (basename file) #\.)))
1097
1098 (let* ((out (assoc-ref outputs "out"))
1099 (locales (find-files out locale-directory?
1100 #:directories? #t)))
1101 (for-each (lambda (directory)
1102 (let*-values (((base)
1103 (basename directory))
1104 ((name codeset)
1105 (locale->name+codeset base))
1106 ((normalized)
1107 (normalize-codeset codeset)))
1108 (unless (string=? codeset normalized)
1109 (symlink base
1110 (string-append (dirname directory)
1111 "/" name "."
1112 normalized)))))
1113 locales)
1114 #t)))
2bbd674b
MB
1115 (delete 'install)
1116 (delete 'move-static-libs)))
aee6180c
LC
1117 ((#:configure-flags flags)
1118 `(append ,flags
85e57214 1119 ;; Use $(libdir)/locale/X.Y as is the case by default.
85860fdf 1120 (list (string-append "libc_cv_complocaledir="
aee6180c 1121 (assoc-ref %outputs "out")
f2d7bbb5 1122 "/lib/locale/"
c6bc8e22
MB
1123 ,(version-major+minor
1124 (package-version glibc)))))))))))
aee6180c 1125
0845999a 1126(define-public (make-glibc-utf8-locales glibc)
c9505f3f
LC
1127 (package
1128 (name "glibc-utf8-locales")
1129 (version (package-version glibc))
1130 (source #f)
1131 (build-system trivial-build-system)
1132 (arguments
f2d7bbb5 1133 `(#:modules ((guix build utils))
c9505f3f 1134 #:builder (begin
44161fe1 1135 (use-modules (guix build utils))
c9505f3f
LC
1136
1137 (let* ((libc (assoc-ref %build-inputs "glibc"))
1138 (gzip (assoc-ref %build-inputs "gzip"))
1139 (out (assoc-ref %outputs "out"))
f2d7bbb5 1140 (localedir (string-append out "/lib/locale/"
c6bc8e22 1141 ,(version-major+minor version))))
c9505f3f
LC
1142 ;; 'localedef' needs 'gzip'.
1143 (setenv "PATH" (string-append libc "/bin:" gzip "/bin"))
1144
1145 (mkdir-p localedir)
44161fe1
MW
1146 (for-each (lambda (locale)
1147 (define file
1148 ;; Use the "normalized codeset" by
1149 ;; default--e.g., "en_US.utf8".
1150 (string-append localedir "/" locale ".utf8"))
1151
1152 (invoke "localedef" "--no-archive"
1153 "--prefix" localedir
1154 "-i" locale
1155 "-f" "UTF-8" file)
1156
1157 ;; For backward compatibility with Guix
1158 ;; <= 0.8.3, add "xx_YY.UTF-8".
1159 (symlink (string-append locale ".utf8")
1160 (string-append localedir "/"
1161 locale ".UTF-8")))
1162
1163 ;; These are the locales commonly used for
1164 ;; tests---e.g., in Guile's i18n tests.
1165 '("de_DE" "el_GR" "en_US" "fr_FR" "tr_TR"))
1166 #t))))
58a75996
MO
1167 (native-inputs `(("glibc" ,glibc)
1168 ("gzip" ,gzip)))
c9505f3f
LC
1169 (synopsis "Small sample of UTF-8 locales")
1170 (description
1171 "This package provides a small sample of UTF-8 locales mostly useful in
1172test environments.")
1173 (home-page (package-home-page glibc))
1174 (license (package-license glibc))))
aee6180c 1175
0845999a
RW
1176(define-public glibc-locales
1177 (make-glibc-locales glibc))
1178(define-public glibc-utf8-locales
1179 (make-glibc-utf8-locales glibc))
1180
f77993bb
LC
1181;; Packages provided to ease use of binaries linked against the previous libc.
1182(define-public glibc-locales-2.28
1183 (package (inherit (make-glibc-locales glibc-2.28))
1184 (name "glibc-locales-2.28")))
1185(define-public glibc-utf8-locales-2.28
1186 (package (inherit (make-glibc-utf8-locales glibc-2.28))
1187 (name "glibc-utf8-locales-2.28")))
1188
1189;; These should no longer be needed.
0845999a 1190(define-public glibc-utf8-locales-2.27
f77993bb
LC
1191 (deprecated-package "glibc-utf8-locales-2.27" glibc-utf8-locales-2.28))
1192(define-public glibc-locales-2.27
1193 (deprecated-package "glibc-locales-2.27" glibc-locales-2.28))
0845999a 1194
ce0614dd
LC
1195(define-public which
1196 (package
1197 (name "which")
70ca2e94 1198 (version "2.21")
ce0614dd
LC
1199 (source (origin
1200 (method url-fetch)
1201 (uri (string-append "mirror://gnu/which/which-"
1202 version ".tar.gz"))
1203 (sha256
1204 (base32
70ca2e94 1205 "1bgafvy3ypbhhfznwjv1lxmd6mci3x1byilnnkc7gcr486wlb8pl"))))
ce0614dd
LC
1206 (build-system gnu-build-system)
1207 (home-page "https://gnu.org/software/which/")
1208 (synopsis "Find full path of shell commands")
1209 (description
1210 "The which program finds the location of executables in PATH, with a
1211variety of options. It is an alternative to the shell \"type\" built-in
1212command.")
1213 (license gpl3+))) ; some files are under GPLv2+
1214
21a8fe1b 1215(define-public glibc/hurd-headers
2d546858 1216 (package (inherit glibc)
21a8fe1b
MR
1217 (name "glibc-hurd-headers")
1218 (outputs '("out"))
1219 (propagated-inputs `(("gnumach-headers" ,gnumach-headers)
1220 ("hurd-headers" ,hurd-headers)))
1221 (arguments
2d546858 1222 (substitute-keyword-arguments (package-arguments glibc)
21a8fe1b
MR
1223 ;; We just pass the flags really needed to build the headers.
1224 ((#:configure-flags _)
1225 `(list "--enable-add-ons"
2d546858 1226 "--host=i586-pc-gnu"))
21a8fe1b 1227 ((#:phases _)
c04e5116
TGR
1228 '(modify-phases %standard-phases
1229 (replace 'install
1230 (lambda* (#:key outputs #:allow-other-keys)
1231 (invoke "make" "install-headers")
1232
1233 ;; Make an empty stubs.h to work around not being able to
1234 ;; produce a valid stubs.h and causing the build to fail. See
1235 ;; <http://lists.gnu.org/archive/html/guix-devel/2014-04/msg00233.html>.
1236 (let ((out (assoc-ref outputs "out")))
1237 (close-port
1238 (open-output-file
b4c4f339
MW
1239 (string-append out "/include/gnu/stubs.h"))))
1240 #t))
2d546858 1241 (delete 'build))))))) ; nothing to build
21a8fe1b 1242
e789d9a8
LC
1243(define-public tzdata
1244 (package
1245 (name "tzdata")
a5cd5c91 1246 (version "2019c")
e789d9a8
LC
1247 (source (origin
1248 (method url-fetch)
1249 (uri (string-append
27b3568b 1250 "https://data.iana.org/time-zones/releases/tzdata"
e789d9a8
LC
1251 version ".tar.gz"))
1252 (sha256
1253 (base32
a5cd5c91 1254 "0z7w1yv37cfk8yhix2cillam091vgp1j4g8fv84261q9mdnq1ivr"))))
e789d9a8
LC
1255 (build-system gnu-build-system)
1256 (arguments
1257 '(#:tests? #f
1258 #:make-flags (let ((out (assoc-ref %outputs "out"))
1259 (tmp (getenv "TMPDIR")))
1260 (list (string-append "TOPDIR=" out)
1261 (string-append "TZDIR=" out "/share/zoneinfo")
62868f12
LF
1262 (string-append "TZDEFAULT=" out
1263 "/share/zoneinfo/localtime")
e789d9a8
LC
1264
1265 ;; Likewise for the C library routines.
1266 (string-append "LIBDIR=" tmp "/lib")
1267 (string-append "MANDIR=" tmp "/man")
1268
1269 "AWK=awk"
1270 "CC=gcc"))
1271 #:modules ((guix build utils)
1272 (guix build gnu-build-system)
1273 (srfi srfi-1))
1274 #:phases
c8f35458
JD
1275 (modify-phases %standard-phases
1276 (replace 'unpack
1277 (lambda* (#:key source inputs #:allow-other-keys)
408fcff6
MW
1278 (invoke "tar" "xvf" source)
1279 (invoke "tar" "xvf" (assoc-ref inputs "tzcode"))))
c8f35458
JD
1280 (add-after 'install 'post-install
1281 (lambda* (#:key outputs #:allow-other-keys)
1282 ;; Move data in the right place.
1283 (let ((out (assoc-ref outputs "out")))
62868f12
LF
1284 ;; Discard zic, dump, and tzselect, already
1285 ;; provided by glibc.
1286 (delete-file-recursively (string-append out "/usr"))
c8f35458
JD
1287 (symlink (string-append out "/share/zoneinfo")
1288 (string-append out "/share/zoneinfo/posix"))
1289 (delete-file-recursively
1290 (string-append out "/share/zoneinfo-posix"))
1291 (copy-recursively (string-append out "/share/zoneinfo-leaps")
1292 (string-append out "/share/zoneinfo/right"))
1293 (delete-file-recursively
408fcff6
MW
1294 (string-append out "/share/zoneinfo-leaps"))
1295 #t)))
c8f35458 1296 (delete 'configure))))
e789d9a8
LC
1297 (inputs `(("tzcode" ,(origin
1298 (method url-fetch)
1299 (uri (string-append
27b3568b 1300 "https://data.iana.org/time-zones/releases/tzcode"
e789d9a8
LC
1301 version ".tar.gz"))
1302 (sha256
1303 (base32
a5cd5c91 1304 "1m3y2rnf1nggxxhxplab5zdd5whvar3ijyrv7lifvm82irkd7szn"))))))
80b63e67 1305 (home-page "https://www.iana.org/time-zones")
e789d9a8
LC
1306 (synopsis "Database of current and historical time zones")
1307 (description "The Time Zone Database (often called tz or zoneinfo)
1308contains code and data that represent the history of local time for many
35b9e423 1309representative locations around the globe. It is updated periodically to
e789d9a8
LC
1310reflect changes made by political bodies to time zone boundaries, UTC offsets,
1311and daylight-saving rules.")
1312 (license public-domain)))
1313
75aea16f
LF
1314;;; A "fixed" version of tzdata, which is used in the test suites of glib and R
1315;;; and a few other places. We can update this whenever we are able to rebuild
1316;;; thousands of packages (for example, in a core-updates rebuild). This package
1317;;; will typically be obsolete and should never be referred to by a built
1318;;; package.
f9c3bd2e 1319(define-public tzdata-for-tests
cd50b9f0 1320 (hidden-package
e3ca10ab 1321 (package/inherit tzdata)))
3ffaec13 1322
7309045c
JN
1323(define-public libiconv
1324 (package
1325 (name "libiconv")
a55fbab7 1326 (version "1.15")
7309045c
JN
1327 (source (origin
1328 (method url-fetch)
1329 (uri (string-append "mirror://gnu/libiconv/libiconv-"
1330 version ".tar.gz"))
1331 (sha256
1332 (base32
5c6b6827 1333 "0y1ij745r4p48mxq84rax40p10ln7fc7m243p8k8sia519i3dxfc"))
7309045c
JN
1334 (modules '((guix build utils)))
1335 (snippet
1336 ;; Work around "declared gets" error on glibc systems (fixed by
1337 ;; Gnulib commit 66712c23388e93e5c518ebc8515140fa0c807348.)
6cbee49d
MW
1338 '(begin
1339 (substitute* "srclib/stdio.in.h"
1340 (("^#undef gets") "")
1341 (("^_GL_WARN_ON_USE \\(gets.*") ""))
1342 #t))))
7309045c
JN
1343 (build-system gnu-build-system)
1344 (synopsis "Character set conversion library")
1345 (description
1346 "libiconv provides an implementation of the iconv function for systems
1347that lack it. iconv is used to convert between character encodings in a
1348program. It supports a wide variety of different encodings.")
6fd52309 1349 (home-page "https://www.gnu.org/software/libiconv/")
7309045c
JN
1350 (license lgpl3+)))
1351
4dab8c59
JN
1352(define* (libiconv-if-needed #:optional (target (%current-target-system)))
1353 "Return either a libiconv package specification to include in a dependency
1354list for platforms that have an incomplete libc, or the empty list. If a
1355package needs iconv ,@(libiconv-if-needed) should be added."
1356 ;; POSIX C libraries provide iconv. Platforms with an incomplete libc
1357 ;; without iconv, such as MinGW, must return the then clause.
1358 (if (target-mingw? target)
1359 `(("libiconv" ,libiconv))
1360 '()))
1361
bdb36958
LC
1362(define-public (canonical-package package)
1363 ;; Avoid circular dependency by lazily resolving 'commencement'.
1364 (let* ((iface (resolve-interface '(gnu packages commencement)))
1365 (proc (module-ref iface 'canonical-package)))
1366 (proc package)))
571aa6cd 1367
fb77c614
LC
1368(define-public (%final-inputs)
1369 "Return the list of \"final inputs\"."
1370 ;; Avoid circular dependency by lazily resolving 'commencement'.
1371 (let ((iface (resolve-interface '(gnu packages commencement))))
1372 (module-ref iface '%final-inputs)))
1373
1722d680 1374;;; base.scm ends here