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