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