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