gnu: findutils: Skip failing test on GNU/Hurd.
[jackhill/guix/guix.git] / gnu / packages / base.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2012-2022 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2014, 2019 Andreas Enge <andreas@enge.fr>
4 ;;; Copyright © 2012 Nikita Karetnikov <nikita@karetnikov.org>
5 ;;; Copyright © 2014, 2015, 2016, 2018 Mark H Weaver <mhw@netris.org>
6 ;;; Copyright © 2014 Alex Kost <alezost@gmail.com>
7 ;;; Copyright © 2014, 2015 Manolis Fragkiskos Ragkousis <manolis837@gmail.com>
8 ;;; Copyright © 2016, 2017, 2019, 2020, 2021 Efraim Flashner <efraim@flashner.co.il>
9 ;;; Copyright © 2016, 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
10 ;;; Copyright © 2016, 2018 Alex Vong <alexvong1995@gmail.com>
11 ;;; Copyright © 2017 Rene Saavedra <rennes@openmailbox.org>
12 ;;; Copyright © 2017, 2020 Mathieu Othacehe <m.othacehe@gmail.com>
13 ;;; Copyright © 2017, 2018, 2020 Marius Bakke <mbakke@fastmail.com>
14 ;;; Copyright © 2017 Eric Bavier <bavier@member.fsf.org>
15 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
16 ;;; Copyright © 2018, 2019, 2022 Ricardo Wurmus <rekado@elephly.net>
17 ;;; Copyright © 2020 Vitaliy Shatrov <D0dyBo0D0dyBo0@protonmail.com>
18 ;;; Copyright © 2020 Chris Marusich <cmmarusich@gmail.com>
19 ;;; Copyright © 2021 Leo Le Bouter <lle-bout@zaclys.net>
20 ;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
21 ;;; Copyright © 2021 Guillaume Le Vaillant <glv@posteo.net>
22 ;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
23 ;;; Copyright © 2022 John Kehayias <john.kehayias@protonmail.com>
24 ;;;
25 ;;; This file is part of GNU Guix.
26 ;;;
27 ;;; GNU Guix is free software; you can redistribute it and/or modify it
28 ;;; under the terms of the GNU General Public License as published by
29 ;;; the Free Software Foundation; either version 3 of the License, or (at
30 ;;; your option) any later version.
31 ;;;
32 ;;; GNU Guix is distributed in the hope that it will be useful, but
33 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
34 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
35 ;;; GNU General Public License for more details.
36 ;;;
37 ;;; You should have received a copy of the GNU General Public License
38 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
39
40 (define-module (gnu packages base)
41 #:use-module ((guix licenses)
42 #:select (gpl3+ lgpl2.0+ lgpl3+ public-domain))
43 #:use-module (gnu packages)
44 #:use-module (gnu packages acl)
45 #:use-module (gnu packages algebra)
46 #:use-module (gnu packages attr)
47 #:use-module (gnu packages bash)
48 #:use-module (gnu packages bison)
49 #:use-module (gnu packages ed)
50 #:use-module (gnu packages gawk)
51 #:use-module (gnu packages gcc)
52 #:use-module (gnu packages guile)
53 #:use-module (gnu packages multiprecision)
54 #:use-module (gnu packages compression)
55 #:use-module (gnu packages perl)
56 #:use-module (gnu packages linux)
57 #:use-module (gnu packages pcre)
58 #:use-module (gnu packages texinfo)
59 #:use-module (gnu packages hurd)
60 #:use-module (gnu packages pkg-config)
61 #:use-module (gnu packages python)
62 #:use-module (gnu packages gettext)
63 #:use-module (guix i18n)
64 #:use-module (guix utils)
65 #:use-module (guix gexp)
66 #:use-module (guix packages)
67 #:use-module (guix download)
68 #:use-module (guix git-download)
69 #:use-module (guix build-system gnu)
70 #:use-module (guix build-system trivial)
71 #:use-module (ice-9 format)
72 #:use-module (ice-9 match)
73 #:use-module (ice-9 optargs)
74 #:use-module (srfi srfi-1)
75 #:use-module (srfi srfi-26)
76 #:export (glibc
77 make-ld-wrapper
78 libiconv-if-needed))
79
80 ;;; Commentary:
81 ;;;
82 ;;; Base packages of the Guix-based GNU user-land software distribution.
83 ;;;
84 ;;; Code:
85
86 (define-public hello
87 (package
88 (name "hello")
89 (version "2.12.1")
90 (source (origin
91 (method url-fetch)
92 (uri (string-append "mirror://gnu/hello/hello-" version
93 ".tar.gz"))
94 (sha256
95 (base32
96 "086vqwk2wl8zfs47sq2xpjc9k066ilmb8z6dn0q6ymwjzlm196cd"))))
97 (build-system gnu-build-system)
98 (synopsis "Hello, GNU world: An example GNU package")
99 (description
100 "GNU Hello prints the message \"Hello, world!\" and then exits. It
101 serves as an example of standard GNU coding practices. As such, it supports
102 command-line arguments, multiple languages, and so on.")
103 (home-page "https://www.gnu.org/software/hello/")
104 (license gpl3+)))
105
106 (define-public grep
107 (package
108 (name "grep")
109 (version "3.6")
110 (source (origin
111 (method url-fetch)
112 (uri (string-append "mirror://gnu/grep/grep-"
113 version ".tar.xz"))
114 (sha256
115 (base32
116 "0gipv6bzkm1aihj0ncqpyh164xrzgcxcv9r1kwzyk2g1mzl1azk6"))
117 (patches (search-patches "grep-timing-sensitive-test.patch"))))
118 (build-system gnu-build-system)
119 (native-inputs (list perl)) ;some of the tests require it
120 (inputs (list pcre))
121 (arguments
122 `(#:phases
123 (modify-phases %standard-phases
124 (add-after 'install 'fix-egrep-and-fgrep
125 ;; Patch 'egrep' and 'fgrep' to execute 'grep' via its
126 ;; absolute file name instead of searching for it in $PATH.
127 (lambda* (#:key outputs #:allow-other-keys)
128 (let* ((out (assoc-ref outputs "out"))
129 (bin (string-append out "/bin")))
130 (substitute* (list (string-append bin "/egrep")
131 (string-append bin "/fgrep"))
132 (("^exec grep")
133 (string-append "exec " bin "/grep")))))))
134 #:make-flags ,(if (hurd-target?)
135 ''("XFAIL_TESTS=test-perror2 equiv-classes") ;XXX
136 ''())))
137 (synopsis "Print lines matching a pattern")
138 (description
139 "grep is a tool for finding text inside files. Text is found by
140 matching a pattern provided by the user in one or many files. The pattern
141 may be provided as a basic or extended regular expression, or as fixed
142 strings. By default, the matching text is simply printed to the screen,
143 however the output can be greatly customized to include, for example, line
144 numbers. GNU grep offers many extensions over the standard utility,
145 including, for example, recursive directory searching.")
146 (license gpl3+)
147 (home-page "https://www.gnu.org/software/grep/")))
148
149 (define-public sed
150 (package
151 (name "sed")
152 (version "4.8")
153 (source (origin
154 (method url-fetch)
155 (uri (string-append "mirror://gnu/sed/sed-" version
156 ".tar.gz"))
157 (sha256
158 (base32
159 "0alqagh0nliymz23kfjg6g9w3cr086k0sfni56gi8fhzqwa3xksk"))
160 (patches (search-patches "coreutils-gnulib-tests.patch"))
161
162 ;; Remove this snippet once upstream releases a fixed version.
163 ;; This snippet changes Makefile.in, even though the upstream
164 ;; patch changes testsuite/local.mk, since we build sed from a
165 ;; release tarball. See: https://bugs.gnu.org/36150
166 (snippet
167 '(begin
168 (substitute* "Makefile.in"
169 (("^ abs_srcdir='\\$\\(abs_srcdir\\)'.*" previous-line)
170 (string-append
171 previous-line
172 " CONFIG_HEADER='$(CONFIG_HEADER)'\t\t\\\n")))))
173 (modules '((guix build utils)))))
174 (build-system gnu-build-system)
175 (synopsis "Stream editor")
176 (native-inputs (list perl)) ;for tests
177 (description
178 "Sed is a non-interactive, text stream editor. It receives a text
179 input from a file or from standard input and it then applies a series of text
180 editing commands to the stream and prints its output to standard output. It
181 is often used for substituting text patterns in a stream. The GNU
182 implementation offers several extensions over the standard utility.")
183 (license gpl3+)
184 (home-page "https://www.gnu.org/software/sed/")))
185
186 (define-public tar
187 (package
188 (name "tar")
189 (version "1.34")
190 (source (origin
191 (method url-fetch)
192 (uri (string-append "mirror://gnu/tar/tar-"
193 version ".tar.xz"))
194 (sha256
195 (base32
196 "0a0x87anh9chbi2cgcyy7pmnm5hzk4yd1w2j8gm1wplwhwkbvgk3"))
197 (patches (search-patches "tar-skip-unreliable-tests.patch"
198 "tar-remove-wholesparse-check.patch"))))
199 (build-system gnu-build-system)
200 ;; Note: test suite requires ~1GiB of disk space.
201 (arguments
202 `(,@(if (hurd-target?)
203 '(#:make-flags
204 (list (string-append
205 "TESTSUITEFLAGS= -k '"
206 "!sparse"
207 ",!renamed dirs in incrementals"
208 ",!--exclude-tag option in incremental pass"
209 ",!incremental dumps with -C"
210 ",!incremental dumps of nested directories"
211 ",!incremental restores with -C"
212 ",!concatenated incremental archives (renames)"
213 ",!renamed directory containing subdirectories"
214 ",!renamed subdirectories"
215 "'")))
216 '())
217 #:phases (modify-phases %standard-phases
218 (add-before 'build 'set-shell-file-name
219 (lambda* (#:key inputs #:allow-other-keys)
220 ;; Do not use "/bin/sh" to run programs.
221 (let ((bash (assoc-ref inputs "bash")))
222 (substitute* "src/system.c"
223 (("/bin/sh")
224 (string-append bash "/bin/sh")))))))))
225
226 ;; When cross-compiling, the 'set-shell-file-name' phase needs to be able
227 ;; to refer to the target Bash.
228 (inputs (if (%current-target-system)
229 (list bash)
230 '()))
231
232 (synopsis "Managing tar archives")
233 (description
234 "Tar provides the ability to create tar archives, as well as the
235 ability to extract, update or list files in an existing archive. It is
236 useful for combining many files into one larger file, while maintaining
237 directory structure and file information such as permissions and
238 creation/modification dates. GNU tar offers many extensions over the
239 standard utility.")
240 (license gpl3+)
241 (home-page "https://www.gnu.org/software/tar/")))
242
243 (define-public patch
244 (package
245 (name "patch")
246 (version "2.7.6")
247 (source (origin
248 (method url-fetch)
249 (uri (string-append "mirror://gnu/patch/patch-"
250 version ".tar.xz"))
251 (sha256
252 (base32
253 "1zfqy4rdcy279vwn2z1kbv19dcfw25d2aqy9nzvdkq5bjzd0nqdc"))
254 (patches (search-patches "patch-hurd-path-max.patch"))))
255 (build-system gnu-build-system)
256 (arguments
257 ;; Work around a cross-compilation bug whereby libpatch.a would provide
258 ;; '__mktime_internal', which conflicts with the one in libc.a.
259 (if (%current-target-system)
260 `(#:configure-flags '("gl_cv_func_working_mktime=yes"))
261 '()))
262 (native-inputs (list ed))
263 (synopsis "Apply differences to originals, with optional backups")
264 (description
265 "Patch is a program that applies changes to files based on differences
266 laid out as by the program \"diff\". The changes may be applied to one or more
267 files depending on the contents of the diff file. It accepts several
268 different diff formats. It may also be used to revert previously applied
269 differences.")
270 (license gpl3+)
271 (home-page "https://savannah.gnu.org/projects/patch/")))
272
273 (define-public diffutils
274 (package
275 (name "diffutils")
276 (version "3.8")
277 (source (origin
278 (method url-fetch)
279 (uri (string-append "mirror://gnu/diffutils/diffutils-"
280 version ".tar.xz"))
281 (sha256
282 (base32
283 "1v4g8gi0lgakqa7iix8s4fq7lq6l92vw3rjd9wfd2rhjng8xggd6"))
284 (patches (search-patches "diffutils-fix-signal-processing.patch"))))
285 (build-system gnu-build-system)
286 (native-inputs (list perl))
287 (synopsis "Comparing and merging files")
288 (description
289 "GNU Diffutils is a package containing tools for finding the
290 differences between files. The \"diff\" command is used to show how two files
291 differ, while \"cmp\" shows the offsets and line numbers where they differ.
292 \"diff3\" allows you to compare three files. Finally, \"sdiff\" offers an
293 interactive means to merge two files.")
294 (license gpl3+)
295 (home-page "https://www.gnu.org/software/diffutils/")))
296
297 (define-public findutils
298 (package
299 (name "findutils")
300 (version "4.8.0")
301 (source (origin
302 (method url-fetch)
303 (uri (string-append "mirror://gnu/findutils/findutils-"
304 version ".tar.xz"))
305 (sha256
306 (base32
307 "0r3i72hnw0a30khlczi9k2c51aamaj6kfmp5mk3844nrjxz7n4jp"))
308 (patches (search-patches "findutils-localstatedir.patch"))))
309 (build-system gnu-build-system)
310 (arguments
311 `(#:configure-flags (list
312 ;; Tell 'updatedb' to write to /var.
313 "--localstatedir=/var")
314 #:phases (modify-phases %standard-phases
315 (add-before 'check 'adjust-test-shebangs
316 (lambda _
317 (substitute* '("tests/xargs/verbose-quote.sh"
318 "tests/find/exec-plus-last-file.sh")
319 (("#!/bin/sh")
320 (string-append "#!" (which "sh")))))))
321 #:make-flags ,(if (hurd-target?)
322 ''("XFAIL_TESTS=test-perror2")
323 ''())))
324 (synopsis "Operating on files matching given criteria")
325 (description
326 "Findutils supplies the basic file directory searching utilities of the
327 GNU system. It consists of two primary searching utilities: \"find\"
328 recursively searches for files in a directory according to given criteria and
329 \"locate\" lists files in a database that match a query. Two auxiliary tools
330 are included: \"updatedb\" updates the file name database and \"xargs\" may be
331 used to apply commands with arbitrarily long arguments.")
332 (license gpl3+)
333 (home-page "https://www.gnu.org/software/findutils/")))
334
335 (define-public coreutils
336 (package
337 (name "coreutils")
338 (version "8.32")
339 (source (origin
340 (method url-fetch)
341 (uri (string-append "mirror://gnu/coreutils/coreutils-"
342 version ".tar.xz"))
343 (sha256
344 (base32
345 "1yjcrh5hw70c0yn8zw55pd6j51dj90anpq8mmg649ps9g3gdhn24"))
346 (patches (search-patches "coreutils-ls.patch"
347 "coreutils-gnulib-tests.patch"))))
348 (build-system gnu-build-system)
349 (inputs `(,acl ;TODO: add SELinux
350 ,attr ;for xattrs in ls, mv, etc
351 ,gmp ;bignums in 'expr', yay!
352
353 ;; Do not use libcap when cross-compiling since it's not quite
354 ;; cross-compilable; and use it only for supported systems.
355 ,@(if (and (not (%current-target-system))
356 (member (%current-system)
357 (package-supported-systems libcap)))
358 `(,libcap) ;capability support in 'ls', etc.
359 '())))
360 (native-inputs
361 ;; Perl is needed to run tests in native builds, and to run the bundled
362 ;; copy of help2man. However, don't pass it when cross-compiling since
363 ;; that would lead it to try to run programs to get their '--help' output
364 ;; for help2man.
365 (if (%current-target-system)
366 '()
367 (list perl)))
368 (outputs '("out" "debug"))
369 (arguments
370 `(#:parallel-build? #f ; help2man may be called too early
371 ,@(if (hurd-target?)
372 '(#:make-flags ; these tests fail deterministically
373 (list (string-append "XFAIL_TESTS=tests/misc/env-S.pl"
374 " tests/misc/kill.sh"
375 " tests/misc/nice.sh"
376 " tests/misc/pwd-long.sh"
377 " tests/split/fail.sh"
378
379 ;; /hurd/fifo issue:
380 ;; <https://issues.guix.gnu.org/58803>.
381 " tests/df/unreadable.sh"
382
383 ;; Gnulib tests.
384 " test-fdutimensat"
385 " test-futimens"
386 " test-linkat"
387 " test-perror2"
388 " test-renameat"
389 " test-renameatu"
390 " test-tls"
391 " test-utimensat")))
392 '())
393 #:phases (modify-phases %standard-phases
394 (add-before 'build 'patch-shell-references
395 (lambda _
396 ;; 'split' uses either $SHELL or /bin/sh. Set $SHELL so
397 ;; that tests pass, since /bin/sh isn't in the chroot.
398 (setenv "SHELL" (which "sh"))
399
400 (substitute* (find-files "gnulib-tests" "\\.c$")
401 (("/bin/sh") (which "sh")))
402 (substitute* (find-files "tests" "\\.sh$")
403 (("#!/bin/sh") (string-append "#!" (which "sh"))))))
404 (add-after 'unpack 'remove-tests
405 (lambda _
406 ,@(if (hurd-target?)
407 '((substitute* "Makefile.in"
408 ;; this test hangs
409 (("^ *tests/misc/timeout-group.sh.*") "")))
410 '())
411 (substitute* "Makefile.in"
412 ;; fails on filesystems where inotify cannot be used,
413 ;; more info in #47935
414 (("^ *tests/tail-2/inotify-dir-recreate.sh.*") "")))))))
415 (synopsis "Core GNU utilities (file, text, shell)")
416 (description
417 "GNU Coreutils package includes all of the basic command-line tools that
418 are expected in a POSIX system, excluding shell. This package is the union of
419 the GNU fileutils, sh-utils, and textutils packages. Most of these tools
420 offer extended functionality beyond that which is outlined in the POSIX
421 standard.")
422 (license gpl3+)
423 (home-page "https://www.gnu.org/software/coreutils/")))
424
425 (define-public coreutils-minimal
426 ;; Coreutils without its optional dependencies.
427 (package
428 (inherit coreutils)
429 (name "coreutils-minimal")
430 (outputs '("out"))
431 (native-inputs '())
432 (inputs '())))
433
434 (define-public coreutils-8.30
435 ;; XXX: This version is kept just so we can run PRoot tests.
436 (hidden-package
437 (package
438 (inherit coreutils-minimal)
439 (version "8.30")
440 (source (origin
441 (method url-fetch)
442 (uri (string-append "mirror://gnu/coreutils/coreutils-"
443 version ".tar.xz"))
444 (sha256
445 (base32
446 "0mxhw43d4wpqmvg0l4znk1vm10fy92biyh90lzdnqjcic2lb6cg8"))))
447 (arguments
448 (substitute-keyword-arguments (package-arguments coreutils-minimal)
449 ((#:phases phases '%standard-phases)
450 `(modify-phases ,phases
451 (add-before 'check 'disable-broken-test
452 (lambda _
453 ;; This test hits the 127 character shebang limit in the build
454 ;; environment due to the way "env -S" splits arguments into
455 ;; shebangs. Note that "env-S-script.sh" works around this
456 ;; specific issue, but "env-S.pl" is not adjusted for build
457 ;; environments with long prefixes (/tmp/guix-build-...).
458 (substitute* "Makefile"
459 (("^.*tests/misc/env-S.pl.*$") "")))))))))))
460
461 (define-public gnu-make
462 (package
463 (name "make")
464 (version "4.3")
465 (source (origin
466 (method url-fetch)
467 (uri (string-append "mirror://gnu/make/make-" version
468 ".tar.gz"))
469 (sha256
470 (base32
471 "06cfqzpqsvdnsxbysl5p2fgdgxgl9y4p7scpnrfa8z2zgkjdspz0"))
472 (patches (search-patches "make-impure-dirs.patch"))))
473 (build-system gnu-build-system)
474 (native-inputs (list pkg-config)) ;to detect Guile
475 (inputs (list guile-3.0))
476 (outputs '("out" "debug"))
477 (arguments
478 `(,@(if (hurd-target?)
479 '(#:configure-flags '("CFLAGS=-D__alloca=alloca"
480 "ac_cv_func_posix_spawn=no"))
481 '())
482 #:phases
483 (modify-phases %standard-phases
484 (add-before 'build 'set-default-shell
485 (lambda* (#:key inputs #:allow-other-keys)
486 ;; Change the default shell from /bin/sh.
487 (let ((bash (assoc-ref inputs "bash")))
488 (substitute* "src/job.c"
489 (("default_shell =.*$")
490 (format #f "default_shell = \"~a/bin/sh\";\n"
491 bash)))))))))
492 (synopsis "Remake files automatically")
493 (description
494 "Make is a program that is used to control the production of
495 executables or other files from their source files. The process is
496 controlled from a Makefile, in which the developer specifies how each file is
497 generated from its source. It has powerful dependency resolution and the
498 ability to determine when files have to be regenerated after their sources
499 change. GNU make offers many powerful extensions over the standard utility.")
500 (license gpl3+)
501 (home-page "https://www.gnu.org/software/make/")))
502
503 (define-public gnu-make-4.2
504 (package
505 (inherit gnu-make)
506 (version "4.2.1")
507 (source (origin
508 (method url-fetch)
509 (uri (string-append "mirror://gnu/make/make-" version
510 ".tar.bz2"))
511 (sha256
512 (base32
513 "12f5zzyq2w56g95nni65hc0g5p7154033y2f3qmjvd016szn5qnn"))))
514 (arguments
515 `(#:configure-flags '("CFLAGS=-D__alloca=alloca -D__stat=stat")
516 #:phases
517 (modify-phases %standard-phases
518 (add-before 'build 'set-default-shell
519 (lambda* (#:key inputs #:allow-other-keys)
520 ;; Change the default shell from /bin/sh.
521 (let ((bash (assoc-ref inputs "bash")))
522 (substitute* "job.c"
523 (("default_shell =.*$")
524 (format #f "default_shell = \"~a/bin/sh\";\n"
525 bash)))))))))))
526
527 (define-public binutils
528 (package
529 (name "binutils")
530 (version "2.37")
531 (source
532 (origin
533 (method url-fetch)
534 (uri (string-append "mirror://gnu/binutils/binutils-"
535 version ".tar.bz2"))
536 (sha256
537 (base32 "1m3b2rdfv1dmdpd0bzg1hy7i8a2qng53szc6livyi3nh6101mz37"))
538 (patches (search-patches "binutils-loongson-workaround.patch"
539 "binutils-2.37-file-descriptor-leak.patch"
540 "binutils-CVE-2021-45078.patch"))))
541 (build-system gnu-build-system)
542 (arguments
543 `(#:out-of-source? #t ;recommended in the README
544 #:configure-flags '(;; Add `-static-libgcc' to not retain a dependency
545 ;; on GCC when bootstrapping.
546 "LDFLAGS=-static-libgcc"
547
548 ;; Turn on --enable-new-dtags by default to make the
549 ;; linker set RUNPATH instead of RPATH on binaries.
550 ;; This is important because RUNPATH can be overriden
551 ;; using LD_LIBRARY_PATH at runtime.
552 "--enable-new-dtags"
553
554 ;; Don't search under /usr/lib & co.
555 "--with-lib-path=/no-ld-lib-path"
556
557 ;; Install BFD. It ends up in a hidden directory,
558 ;; but it's here.
559 "--enable-install-libbfd"
560
561 ;; Make sure 'ar' and 'ranlib' produce archives in a
562 ;; deterministic fashion.
563 "--enable-deterministic-archives"
564
565 "--enable-64-bit-bfd"
566 "--enable-compressed-debug-sections=all"
567 "--enable-lto"
568 "--enable-separate-code"
569 "--enable-threads")))
570
571 (synopsis "Binary utilities: bfd gas gprof ld")
572 (description
573 "GNU Binutils is a collection of tools for working with binary files.
574 Perhaps the most notable are \"ld\", a linker, and \"as\", an assembler.
575 Other tools include programs to display binary profiling information, list
576 the strings in a binary file, and utilities for working with archives. The
577 \"bfd\" library for working with executable and object formats is also
578 included.")
579 (license gpl3+)
580 (home-page "https://www.gnu.org/software/binutils/")))
581
582 ;; FIXME: ath9k-firmware-htc-binutils.patch do not apply on 2.34 because of a
583 ;; big refactoring of xtensa-modules.c (commit 567607c11fbf7105 upstream).
584 ;; Keep this version around until the patch is updated.
585 (define-public binutils-2.33
586 (package
587 (inherit binutils)
588 (version "2.33.1")
589 (source (origin
590 (inherit (package-source binutils))
591 (uri (string-append "mirror://gnu/binutils/binutils-"
592 version ".tar.bz2"))
593 (sha256
594 (base32
595 "1cmd0riv37bqy9mwbg6n3523qgr8b3bbm5kwj19sjrasl4yq9d0c"))
596 (patches '())))
597 (arguments
598 (substitute-keyword-arguments (package-arguments binutils)
599 ((#:make-flags _ ''()) ''())))
600 (properties '())))
601
602 (define-public binutils-gold
603 (package/inherit binutils
604 (name "binutils-gold")
605 (arguments
606 (substitute-keyword-arguments (package-arguments binutils)
607 ((#:configure-flags flags)
608 `(cons* "--enable-gold=default"
609 (delete "LDFLAGS=-static-libgcc" ,flags)))
610 ((#:phases phases '%standard-phases)
611 `(modify-phases ,phases
612 (add-after 'patch-source-shebangs 'patch-more-shebangs
613 (lambda _
614 (substitute* "gold/Makefile.in"
615 (("/bin/sh") (which "sh")))))
616 ;; Multiple failing tests on some architectures in the gold testsuite.
617 ,@(if (or (target-arm?)
618 (target-ppc32?))
619 '((add-after 'unpack 'skip-gold-testsuite
620 (lambda _
621 (substitute* "gold/Makefile.in"
622 ((" testsuite") " ")))))
623 '())))))
624 (native-inputs
625 `(("bc" ,bc)))))
626
627 (define* (make-ld-wrapper name #:key
628 (target (const #f))
629 binutils
630 (linker "ld")
631 (guile (canonical-package guile-3.0))
632 (bash (canonical-package bash))
633 (guile-for-build guile))
634 "Return a package called NAME that contains a wrapper for the 'ld' program
635 of BINUTILS, which adds '-rpath' flags to the actual 'ld' command line. The
636 wrapper uses GUILE and BASH.
637
638 TARGET must be a one-argument procedure that, given a system type, returns a
639 cross-compilation target triplet or #f. When the result is not #f, make a
640 wrapper for the cross-linker for that target, called 'TARGET-ld'. To use a
641 different linker than the default \"ld\", such as \"ld.gold\" the linker name
642 can be provided via the LINKER argument."
643 ;; Note: #:system->target-triplet is a procedure so that the evaluation of
644 ;; its result can be delayed until the 'arguments' field is evaluated, thus
645 ;; in a context where '%current-system' is accurate.
646 (package
647 (name name)
648 (version "0")
649 (source #f)
650 (build-system trivial-build-system)
651 (inputs `(("binutils" ,binutils)
652 ("guile" ,guile)
653 ("bash" ,bash)
654 ("wrapper" ,(search-path %load-path
655 "gnu/packages/ld-wrapper.in"))))
656 (arguments
657 (let ((target (target (%current-system))))
658 `(#:guile ,guile-for-build
659 #:modules ((guix build utils))
660 #:builder (begin
661 (use-modules (guix build utils)
662 (system base compile))
663
664 (let* ((out (assoc-ref %outputs "out"))
665 (bin (string-append out "/bin"))
666 (ld ,(if target
667 `(string-append bin "/" ,target "-"
668 ,linker)
669 `(string-append bin "/" ,linker)))
670 (go (string-append ld ".go")))
671
672 (setvbuf (current-output-port)
673 (cond-expand (guile-2.0 _IOLBF)
674 (else 'line)))
675 (format #t "building ~s/bin/ld wrapper in ~s~%"
676 (assoc-ref %build-inputs "binutils")
677 out)
678
679 (mkdir-p bin)
680 (copy-file (assoc-ref %build-inputs "wrapper") ld)
681 (substitute* ld
682 (("@SELF@")
683 ld)
684 (("@GUILE@")
685 (string-append (assoc-ref %build-inputs "guile")
686 "/bin/guile"))
687 (("@BASH@")
688 (string-append (assoc-ref %build-inputs "bash")
689 "/bin/bash"))
690 (("@LD@")
691 (string-append (assoc-ref %build-inputs "binutils")
692 ,(if target
693 (string-append "/bin/"
694 target "-" linker)
695 (string-append "/bin/" linker)))))
696 (chmod ld #o555)
697 (compile-file ld #:output-file go))))))
698 (synopsis "The linker wrapper")
699 (description
700 "The linker wrapper (or @code{ld-wrapper}) wraps the linker to add any
701 missing @code{-rpath} flags, and to detect any misuse of libraries outside of
702 the store.")
703 (home-page "https://www.gnu.org/software/guix//")
704 (license gpl3+)))
705
706 (define-public glibc
707 ;; This is the GNU C Library, used on GNU/Linux and GNU/Hurd. Prior to
708 ;; version 2.28, GNU/Hurd used a different glibc branch.
709 (package
710 (name "glibc")
711 (version "2.33")
712 (source (origin
713 (method url-fetch)
714 (uri (string-append "mirror://gnu/glibc/glibc-" version ".tar.xz"))
715 (sha256
716 (base32
717 "1zvp0qdfbdyqrzydz18d9zg3n5ygy8ps7cmny1bvsp8h1q05c99f"))
718 (patches (search-patches "glibc-ldd-powerpc.patch"
719 "glibc-ldd-x86_64.patch"
720 "glibc-dl-cache.patch"
721 "glibc-versioned-locpath.patch"
722 "glibc-allow-kernel-2.6.32.patch"
723 "glibc-reinstate-prlimit64-fallback.patch"
724 "glibc-supported-locales.patch"
725 "glibc-cross-objdump.patch"
726 "glibc-cross-objcopy.patch" ;must come 2nd
727 "glibc-hurd-clock_t_centiseconds.patch"
728 "glibc-hurd-clock_gettime_monotonic.patch"
729 "glibc-hurd-mach-print.patch"
730 "glibc-hurd-gettyent.patch"))))
731 (build-system gnu-build-system)
732
733 ;; Glibc's <limits.h> refers to <linux/limit.h>, for instance, so glibc
734 ;; users should automatically pull Linux headers as well. On GNU/Hurd,
735 ;; libc provides <hurd.h>, which includes a bunch of Hurd and Mach headers,
736 ;; so both should be propagated.
737 (propagated-inputs
738 (if (hurd-target?)
739 `(("hurd-core-headers" ,hurd-core-headers))
740 `(("kernel-headers" ,linux-libre-headers))))
741
742 (outputs '("out" "debug"
743 "static")) ;9 MiB of .a files
744
745 (arguments
746 `(#:out-of-source? #t
747
748 ;; The libraries have an empty RUNPATH, but some, such as the versioned
749 ;; libraries (libdl-2.24.so, etc.) have ld.so marked as NEEDED. Since
750 ;; these libraries are always going to be found anyway, just skip
751 ;; RUNPATH checks.
752 #:validate-runpath? #f
753
754 #:modules ((ice-9 ftw)
755 (srfi srfi-26)
756 (guix build utils)
757 (guix build gnu-build-system))
758
759 #:configure-flags
760 (list "--sysconfdir=/etc"
761
762 ;; Installing a locale archive with all the locales is to
763 ;; expensive (~100 MiB), so we rely on users to install the
764 ;; locales they really want.
765 ;;
766 ;; Set the default locale path. In practice, $LOCPATH may be
767 ;; defined to point whatever locales users want. However, setuid
768 ;; binaries don't honor $LOCPATH, so they'll instead look into
769 ;; $libc_cv_complocaledir; we choose /run/current-system/locale/X.Y,
770 ;; with the idea that it is going to be populated by the sysadmin.
771 ;; The "X.Y" sub-directory is because locale data formats are
772 ;; incompatible across libc versions; see
773 ;; <https://lists.gnu.org/archive/html/guix-devel/2015-08/msg00737.html>.
774 ;;
775 ;; `--localedir' is not honored, so work around it.
776 ;; See <http://sourceware.org/ml/libc-alpha/2013-03/msg00093.html>.
777 (string-append "libc_cv_complocaledir=/run/current-system/locale/"
778 ,(version-major+minor version))
779
780 (string-append "--with-headers="
781 (assoc-ref ,(if (%current-target-system)
782 '%build-target-inputs
783 '%build-inputs)
784 "kernel-headers")
785 "/include")
786
787 ;; This is the default for most architectures as of GNU libc 2.26,
788 ;; but we specify it explicitly for clarity and consistency. See
789 ;; "kernel-features.h" in the GNU libc for details.
790 "--enable-kernel=3.2.0"
791
792 ;; Use our Bash instead of /bin/sh.
793 (string-append "BASH_SHELL="
794 (assoc-ref %build-inputs "bash")
795 "/bin/bash")
796
797 ;; On GNU/Hurd we get discarded-qualifiers warnings for
798 ;; 'device_write_inband' among other things. Ignore them.
799 ,@(if (hurd-target?)
800 '("--disable-werror")
801 '()))
802
803 #:tests? #f ; XXX
804 #:phases (modify-phases %standard-phases
805 (add-before
806 'configure 'pre-configure
807 (lambda* (#:key inputs native-inputs outputs
808 #:allow-other-keys)
809 (let* ((out (assoc-ref outputs "out"))
810 (bin (string-append out "/bin"))
811 ;; FIXME: Normally we would look it up only in INPUTS
812 ;; but cross-base uses it as a native input.
813 (bash (or (assoc-ref inputs "static-bash")
814 (assoc-ref native-inputs "static-bash"))))
815 ;; Install the rpc data base file under `$out/etc/rpc'.
816 (substitute* "inet/Makefile"
817 (("^\\$\\(inst_sysconfdir\\)/rpc(.*)$" _ suffix)
818 (string-append out "/etc/rpc" suffix "\n"))
819 (("^install-others =.*$")
820 (string-append "install-others = " out "/etc/rpc\n")))
821
822 (substitute* "Makeconfig"
823 ;; According to
824 ;; <http://www.linuxfromscratch.org/lfs/view/stable/chapter05/glibc.html>,
825 ;; linking against libgcc_s is not needed with GCC
826 ;; 4.7.1.
827 ((" -lgcc_s") ""))
828
829 ;; Tell the ld.so cache code where the store is.
830 (substitute* "elf/dl-cache.c"
831 (("@STORE_DIRECTORY@")
832 (string-append "\"" (%store-directory) "\"")))
833
834 ;; Have `system' use that Bash.
835 (substitute* "sysdeps/posix/system.c"
836 (("#define[[:blank:]]+SHELL_PATH.*$")
837 (format #f "#define SHELL_PATH \"~a/bin/bash\"\n"
838 bash)))
839
840 ;; Same for `popen'.
841 (substitute* "libio/iopopen.c"
842 (("/bin/sh")
843 (string-append bash "/bin/sh")))
844
845 ;; Same for the shell used by the 'exec' functions for
846 ;; scripts that lack a shebang.
847 (substitute* (find-files "." "^paths\\.h$")
848 (("#define[[:blank:]]+_PATH_BSHELL[[:blank:]].*$")
849 (string-append "#define _PATH_BSHELL \""
850 bash "/bin/sh\"\n")))
851
852 ;; Make sure we don't retain a reference to the
853 ;; bootstrap Perl.
854 (substitute* "malloc/mtrace.pl"
855 (("^#!.*")
856 ;; The shebang can be omitted, because there's the
857 ;; "bilingual" eval/exec magic at the top of the file.
858 "")
859 (("exec @PERL@")
860 "exec perl")))))
861
862 (add-after 'install 'move-static-libs
863 (lambda* (#:key outputs #:allow-other-keys)
864 ;; Move static libraries to the "static" output.
865 (define (static-library? file)
866 ;; Return true if FILE is a static library. The
867 ;; "_nonshared.a" files are referred to by libc.so,
868 ;; libpthread.so, etc., which are in fact linker
869 ;; scripts.
870 (and (string-suffix? ".a" file)
871 (not (string-contains file "_nonshared"))))
872
873 (define (linker-script? file)
874 ;; Guess whether FILE, a ".a" file, is actually a
875 ;; linker script.
876 (and (not (ar-file? file))
877 (not (elf-file? file))))
878
879 (let* ((out (assoc-ref outputs "out"))
880 (lib (string-append out "/lib"))
881 (files (scandir lib static-library?))
882 (static (assoc-ref outputs "static"))
883 (slib (string-append static "/lib")))
884 (mkdir-p slib)
885 (for-each (lambda (base)
886 (rename-file (string-append lib "/" base)
887 (string-append slib "/" base)))
888 files)
889
890 ;; Usually libm.a is a linker script so we need to
891 ;; change the file names in there to refer to STATIC
892 ;; instead of OUT.
893 (for-each (lambda (ld-script)
894 (substitute* ld-script
895 ((out) static)))
896 (filter linker-script?
897 (map (cut string-append slib "/" <>)
898 files))))))
899
900 ,@(if (hurd-target?)
901 '((add-after 'install 'augment-libc.so
902 (lambda* (#:key outputs #:allow-other-keys)
903 (let* ((out (assoc-ref outputs "out")))
904 (substitute* (string-append out "/lib/libc.so")
905 (("/[^ ]+/lib/libc.so.0.3")
906 (string-append out "/lib/libc.so.0.3"
907 " libmachuser.so libhurduser.so")))))))
908 '()))))
909
910 (inputs `(("static-bash" ,static-bash)))
911
912 ;; To build the manual, we need Texinfo and Perl. Gettext is needed to
913 ;; install the message catalogs, with 'msgfmt'.
914 (native-inputs `(("texinfo" ,texinfo)
915 ("perl" ,perl)
916 ("bison" ,bison)
917 ("gettext" ,gettext-minimal)
918 ("python" ,python-minimal)
919
920 ,@(if (hurd-target?)
921 `(("mig" ,mig)
922 ("perl" ,perl))
923 '())))
924
925 (native-search-paths
926 ;; Search path for packages that provide locale data. This is useful
927 ;; primarily in build environments. Use 'GUIX_LOCPATH' rather than
928 ;; 'LOCPATH' to avoid interference with the host system's libc on foreign
929 ;; distros.
930 (list (search-path-specification
931 (variable "GUIX_LOCPATH")
932 (files '("lib/locale")))))
933
934 (synopsis "The GNU C Library")
935 (description
936 "Any Unix-like operating system needs a C library: the library which
937 defines the \"system calls\" and other basic facilities such as open, malloc,
938 printf, exit...
939
940 The GNU C library is used as the C library in the GNU system and most systems
941 with the Linux kernel.")
942 (license lgpl2.0+)
943 (home-page "https://www.gnu.org/software/libc/")))
944
945 ;; Define a variation of glibc which uses the default /etc/ld.so.cache, useful
946 ;; in FHS containers.
947 (define-public glibc-for-fhs
948 (hidden-package
949 (package/inherit glibc
950 (name "glibc-for-fhs")
951 (source (origin (inherit (package-source glibc))
952 ;; Remove Guix's patch to read ld.so.cache from /gnu/store
953 ;; directories, re-enabling the default /etc/ld.so.cache
954 ;; behavior.
955 (patches
956 (delete (search-patch "glibc-dl-cache.patch")
957 (origin-patches (package-source glibc)))))))))
958
959 ;; Below are old libc versions, which we use mostly to build locale data in
960 ;; the old format (which the new libc cannot cope with.)
961 (define-public glibc-2.32
962 (package
963 (inherit glibc)
964 (version "2.32")
965 (source (origin
966 (inherit (package-source glibc))
967 (uri (string-append "mirror://gnu/glibc/glibc-" version ".tar.xz"))
968 (sha256
969 (base32
970 "0di848ibffrnwq7g2dvgqrnn4xqhj3h96csn69q4da51ymafl9qn"))
971 (patches (search-patches
972 "glibc-skip-c++.patch"
973 "glibc-ldd-powerpc.patch"
974 "glibc-ldd-x86_64.patch"
975 "glibc-dl-cache.patch"
976 "glibc-hidden-visibility-ldconfig.patch"
977 "glibc-versioned-locpath.patch"
978 "glibc-allow-kernel-2.6.32.patch"
979 "glibc-reinstate-prlimit64-fallback.patch"
980 "glibc-supported-locales.patch"
981 "glibc-hurd-clock_t_centiseconds.patch"
982 "glibc-2.31-hurd-clock_gettime_monotonic.patch"
983 "glibc-hurd-signal-sa-siginfo.patch"
984 "glibc-hurd-mach-print.patch"
985 "glibc-hurd-gettyent.patch"))
986 #;
987 (patches (search-patches "glibc-ldd-x86_64.patch"
988 "glibc-hidden-visibility-ldconfig.patch"
989 "glibc-versioned-locpath.patch"
990 "glibc-allow-kernel-2.6.32.patch"
991 "glibc-reinstate-prlimit64-fallback.patch"
992 "glibc-supported-locales.patch"
993 "glibc-hurd-clock_t_centiseconds.patch"
994 "glibc-hurd-clock_gettime_monotonic.patch"
995 "glibc-hurd-signal-sa-siginfo.patch"))))
996
997 (arguments
998 (substitute-keyword-arguments (package-arguments glibc)
999 ((#:make-flags flags '())
1000 ;; Arrange so that /etc/rpc & co. go to $out/etc.
1001 `(list (string-append "sysconfdir="
1002 (assoc-ref %outputs "out")
1003 "/etc")))
1004 ((#:phases phases)
1005 `(modify-phases ,phases
1006 (add-before 'configure 'set-etc-rpc-installation-directory
1007 (lambda* (#:key outputs #:allow-other-keys)
1008 ;; Install the rpc data base file under `$out/etc/rpc'.
1009 (let ((out (assoc-ref outputs "out")))
1010 (substitute* "sunrpc/Makefile"
1011 (("^\\$\\(inst_sysconfdir\\)/rpc(.*)$" _ suffix)
1012 (string-append out "/etc/rpc" suffix "\n"))
1013 (("^install-others =.*$")
1014 (string-append "install-others = " out "/etc/rpc\n"))))))))))))
1015
1016 (define-public glibc-2.31
1017 (package
1018 (inherit glibc)
1019 (version "2.31")
1020 (source (origin
1021 (inherit (package-source glibc))
1022 (uri (string-append "mirror://gnu/glibc/glibc-" version ".tar.xz"))
1023 (sha256
1024 (base32
1025 "05zxkyz9bv3j9h0xyid1rhvh3klhsmrpkf3bcs6frvlgyr2gwilj"))
1026 (patches (search-patches
1027 "glibc-skip-c++.patch"
1028 "glibc-ldd-powerpc.patch"
1029 "glibc-ldd-x86_64.patch"
1030 "glibc-dl-cache.patch"
1031 "glibc-hidden-visibility-ldconfig.patch"
1032 "glibc-versioned-locpath.patch"
1033 "glibc-allow-kernel-2.6.32.patch"
1034 "glibc-reinstate-prlimit64-fallback.patch"
1035 "glibc-supported-locales.patch"
1036 "glibc-hurd-clock_t_centiseconds.patch"
1037 "glibc-2.31-hurd-clock_gettime_monotonic.patch"
1038 "glibc-hurd-signal-sa-siginfo.patch"
1039 "glibc-hurd-mach-print.patch"
1040 "glibc-hurd-gettyent.patch"))))
1041 (arguments
1042 (substitute-keyword-arguments (package-arguments glibc)
1043 ((#:phases phases)
1044 `(modify-phases ,phases
1045 (add-before 'configure 'set-etc-rpc-installation-directory
1046 (lambda* (#:key outputs #:allow-other-keys)
1047 ;; Install the rpc data base file under `$out/etc/rpc'.
1048 (let ((out (assoc-ref outputs "out")))
1049 (substitute* "sunrpc/Makefile"
1050 (("^\\$\\(inst_sysconfdir\\)/rpc(.*)$" _ suffix)
1051 (string-append out "/etc/rpc" suffix "\n"))
1052 (("^install-others =.*$")
1053 (string-append "install-others = " out "/etc/rpc\n"))))))))))))
1054
1055 (define-public glibc-2.30
1056 (package
1057 (inherit glibc-2.31)
1058 (version "2.30")
1059 (native-inputs
1060 ;; This fails with a build error in libc-tls.c when using GCC 10. Use an
1061 ;; older compiler.
1062 (modify-inputs (package-native-inputs glibc)
1063 (prepend gcc-8)))
1064 (source (origin
1065 (inherit (package-source glibc))
1066 (uri (string-append "mirror://gnu/glibc/glibc-" version ".tar.xz"))
1067 (sha256
1068 (base32
1069 "1bxqpg91d02qnaz837a5kamm0f43pr1il4r9pknygywsar713i72"))
1070 (patches (search-patches "glibc-skip-c++.patch"
1071 "glibc-ldd-x86_64.patch"
1072 "glibc-CVE-2019-19126.patch"
1073 "glibc-hidden-visibility-ldconfig.patch"
1074 "glibc-versioned-locpath.patch"
1075 "glibc-allow-kernel-2.6.32.patch"
1076 "glibc-reinstate-prlimit64-fallback.patch"
1077 "glibc-2.29-supported-locales.patch"))))))
1078
1079 (define-public glibc-2.29
1080 (package
1081 (inherit glibc-2.30)
1082 (version "2.29")
1083 (source (origin
1084 (inherit (package-source glibc))
1085 (uri (string-append "mirror://gnu/glibc/glibc-" version ".tar.xz"))
1086 (sha256
1087 (base32
1088 "0jzh58728flfh939a8k9pi1zdyalfzlxmwra7k0rzji5gvavivpk"))
1089 (patches (search-patches "glibc-skip-c++.patch"
1090 "glibc-ldd-x86_64.patch"
1091 "glibc-CVE-2019-7309.patch"
1092 "glibc-CVE-2019-9169.patch"
1093 "glibc-2.29-git-updates.patch"
1094 "glibc-hidden-visibility-ldconfig.patch"
1095 "glibc-versioned-locpath.patch"
1096 "glibc-allow-kernel-2.6.32.patch"
1097 "glibc-reinstate-prlimit64-fallback.patch"
1098 "glibc-2.29-supported-locales.patch"))))))
1099
1100 (define-public (make-gcc-libc base-gcc libc)
1101 "Return a GCC that targets LIBC."
1102 (package (inherit base-gcc)
1103 (name (string-append (package-name base-gcc) "-"
1104 (package-name libc) "-"
1105 (package-version libc)))
1106 (arguments
1107 (ensure-keyword-arguments (package-arguments base-gcc)
1108 '(#:implicit-inputs? #f)))
1109 (native-inputs
1110 `(,@(package-native-inputs base-gcc)
1111 ,@(append (fold alist-delete (%final-inputs) '("libc" "libc:static")))
1112 ("libc" ,libc)
1113 ("libc:static" ,libc "static")))))
1114
1115 (define-public (make-glibc-locales glibc)
1116 (package
1117 (inherit glibc)
1118 (name "glibc-locales")
1119 (source (origin (inherit (package-source glibc))
1120 ;; The patch for glibc 2.28 and earlier replaces the same
1121 ;; content, but the context in the patch is different
1122 ;; enough to fail to merge.
1123 (patches (cons (search-patch
1124 (if (version>=? (package-version glibc)
1125 "2.29")
1126 "glibc-locales.patch"
1127 "glibc-locales-2.28.patch"))
1128 (origin-patches (package-source glibc))))))
1129 (synopsis "All the locales supported by the GNU C Library")
1130 (description
1131 "This package provides all the locales supported by the GNU C Library,
1132 more than 400 in total. To use them set the @code{LOCPATH} environment variable
1133 to the @code{share/locale} sub-directory of this package.")
1134 (outputs '("out")) ;110+ MiB
1135 (native-search-paths '())
1136 (arguments
1137 (let ((args `(#:tests? #f #:strip-binaries? #f
1138 ,@(package-arguments glibc))))
1139 (substitute-keyword-arguments args
1140 ((#:modules modules '((guix build utils)
1141 (guix build gnu-build-system)))
1142 `((srfi srfi-11)
1143 (gnu build locale)
1144 ,@modules))
1145 ((#:imported-modules modules '())
1146 `((gnu build locale)
1147 ,@%gnu-build-system-modules))
1148 ((#:phases phases)
1149 `(modify-phases ,phases
1150 (replace 'build
1151 (lambda _
1152 (invoke "make" "localedata/install-locales"
1153 "-j" (number->string (parallel-job-count)))))
1154 (add-after 'build 'symlink-normalized-codesets
1155 (lambda* (#:key outputs #:allow-other-keys)
1156 ;; The above phase does not install locales with names using
1157 ;; the "normalized codeset." Thus, create symlinks like:
1158 ;; en_US.utf8 -> en_US.UTF-8
1159 (define (locale-directory? file stat)
1160 (and (file-is-directory? file)
1161 (string-index (basename file) #\_)
1162 (string-rindex (basename file) #\.)))
1163
1164 (let* ((out (assoc-ref outputs "out"))
1165 (locales (find-files out locale-directory?
1166 #:directories? #t)))
1167 (for-each (lambda (directory)
1168 (let*-values (((base)
1169 (basename directory))
1170 ((name codeset)
1171 (locale->name+codeset base))
1172 ((normalized)
1173 (normalize-codeset codeset)))
1174 (unless (string=? codeset normalized)
1175 (symlink base
1176 (string-append (dirname directory)
1177 "/" name "."
1178 normalized)))))
1179 locales))))
1180 (delete 'install)
1181 (delete 'move-static-libs)))
1182 ((#:configure-flags flags)
1183 `(append ,flags
1184 ;; Use $(libdir)/locale/X.Y as is the case by default.
1185 (list (string-append "libc_cv_complocaledir="
1186 (assoc-ref %outputs "out")
1187 "/lib/locale/"
1188 ,(version-major+minor
1189 (package-version glibc)))))))))
1190 (properties `((upstream-name . "glibc")))))
1191
1192 (define %default-utf8-locales
1193 ;; These are the locales commonly used for tests---e.g., in Guile's i18n
1194 ;; tests.
1195 '("de_DE" "el_GR" "en_US" "fr_FR" "tr_TR"))
1196 (define*-public (make-glibc-utf8-locales glibc #:key
1197 (locales %default-utf8-locales)
1198 (name "glibc-utf8-locales"))
1199 (define default-locales? (equal? locales %default-utf8-locales))
1200 (package
1201 (name name)
1202 (version (package-version glibc))
1203 (source #f)
1204 (build-system trivial-build-system)
1205 (arguments
1206 `(#:modules ((guix build utils))
1207 #:builder (begin
1208 (use-modules (guix build utils))
1209
1210 (let* ((libc (assoc-ref %build-inputs "glibc"))
1211 (gzip (assoc-ref %build-inputs "gzip"))
1212 (out (assoc-ref %outputs "out"))
1213 (localedir (string-append out "/lib/locale/"
1214 ,(version-major+minor version))))
1215 ;; 'localedef' needs 'gzip'.
1216 (setenv "PATH" (string-append libc "/bin:" gzip "/bin"))
1217
1218 (mkdir-p localedir)
1219 (for-each (lambda (locale)
1220 (define file
1221 ;; Use the "normalized codeset" by
1222 ;; default--e.g., "en_US.utf8".
1223 (string-append localedir "/" locale ".utf8"))
1224
1225 (invoke "localedef" "--no-archive"
1226 "--prefix" localedir
1227 "-i" locale
1228 "-f" "UTF-8" file)
1229
1230 ;; For backward compatibility with Guix
1231 ;; <= 0.8.3, add "xx_YY.UTF-8".
1232 (symlink (string-append locale ".utf8")
1233 (string-append localedir "/"
1234 locale ".UTF-8")))
1235 ',locales)
1236 #t))))
1237 (native-inputs (list glibc gzip))
1238 (synopsis (if default-locales?
1239 (P_ "Small sample of UTF-8 locales")
1240 (P_ "Customized sample of UTF-8 locales")))
1241 (description
1242 (if default-locales?
1243 (P_ "This package provides a small sample of UTF-8 locales mostly useful in
1244 test environments.")
1245 (format #f (P_ "This package provides the following UTF-8 locales:
1246 @itemize
1247 ~{@item ~a~%~}
1248 @end itemize~%")
1249 locales)))
1250 (home-page (package-home-page glibc))
1251 (license (package-license glibc))))
1252
1253 (define-public glibc-locales
1254 (make-glibc-locales glibc))
1255 (define-public glibc-utf8-locales
1256 (hidden-package
1257 (make-glibc-utf8-locales glibc)))
1258
1259 ;; Packages provided to ease use of binaries linked against the previous libc.
1260 (define-public glibc-locales-2.32
1261 (package (inherit (make-glibc-locales glibc-2.32))
1262 (name "glibc-locales-2.32")))
1263 (define-public glibc-locales-2.31
1264 (package (inherit (make-glibc-locales glibc-2.31))
1265 (name "glibc-locales-2.31")))
1266 (define-public glibc-locales-2.30
1267 (package (inherit (make-glibc-locales glibc-2.30))
1268 (name "glibc-locales-2.30")))
1269 (define-public glibc-locales-2.29
1270 (package (inherit (make-glibc-locales glibc-2.29))
1271 (name "glibc-locales-2.29")))
1272 (define-public glibc-utf8-locales-2.29
1273 (package (inherit (make-glibc-utf8-locales glibc-2.29))
1274 (name "glibc-utf8-locales-2.29")))
1275
1276 (define-public which
1277 (package
1278 (name "which")
1279 (version "2.21")
1280 (source (origin
1281 (method url-fetch)
1282 (uri (string-append "mirror://gnu/which/which-"
1283 version ".tar.gz"))
1284 (sha256
1285 (base32
1286 "1bgafvy3ypbhhfznwjv1lxmd6mci3x1byilnnkc7gcr486wlb8pl"))))
1287 (build-system gnu-build-system)
1288 (home-page "https://gnu.org/software/which/")
1289 (synopsis "Find full path of shell commands")
1290 (description
1291 "The which program finds the location of executables in PATH, with a
1292 variety of options. It is an alternative to the shell \"type\" built-in
1293 command.")
1294 (license gpl3+))) ; some files are under GPLv2+
1295
1296 (define-public glibc/hurd-headers
1297 (package (inherit glibc)
1298 (name "glibc-hurd-headers")
1299 (outputs '("out"))
1300 (propagated-inputs (list gnumach-headers hurd-headers))
1301 (native-inputs
1302 (modify-inputs (package-native-inputs glibc)
1303 (prepend (if (%current-target-system)
1304 ;; XXX: When targeting i586-pc-gnu, we need a 32-bit MiG,
1305 ;; hence this hack.
1306 (package (inherit mig)
1307 (arguments `(#:system "i686-linux")))
1308 mig))))
1309 (arguments
1310 (substitute-keyword-arguments (package-arguments glibc)
1311 ;; We just pass the flags really needed to build the headers.
1312 ((#:configure-flags _)
1313 `(list "--enable-add-ons"
1314 "--host=i586-pc-gnu"))
1315 ((#:phases _)
1316 '(modify-phases %standard-phases
1317 (replace 'install
1318 (lambda* (#:key outputs #:allow-other-keys)
1319 (invoke "make" "install-headers")
1320
1321 ;; Make an empty stubs.h to work around not being able to
1322 ;; produce a valid stubs.h and causing the build to fail. See
1323 ;; <http://lists.gnu.org/archive/html/guix-devel/2014-04/msg00233.html>.
1324 (let ((out (assoc-ref outputs "out")))
1325 (close-port
1326 (open-output-file
1327 (string-append out "/include/gnu/stubs.h"))))))
1328 (delete 'build))))))) ; nothing to build
1329
1330 (define-public tzdata
1331 (package
1332 (name "tzdata")
1333 ;; This package should be kept in sync with python-pytz in (gnu packages
1334 ;; time).
1335 (version "2022a")
1336 (source (origin
1337 (method url-fetch)
1338 (uri (string-append
1339 "https://data.iana.org/time-zones/releases/tzdata"
1340 version ".tar.gz"))
1341 (sha256
1342 (base32
1343 "0r0nhwpk9nyxj5kkvjy58nr5d85568m04dcb69c4y3zmykczyzzg"))))
1344 (build-system gnu-build-system)
1345 (arguments
1346 (list #:tests? #f
1347
1348 ;; This consists purely of (architecture-independent) data, so
1349 ;; ‘cross-compilation’ is pointless here! (The binaries zic,
1350 ;; dump, and tzselect are deleted in the post-install phase.)
1351 #:target #f
1352
1353 #:make-flags
1354 #~(let ((out #$output)
1355 (tmp (getenv "TMPDIR")))
1356 (list (string-append "TOPDIR=" out)
1357 (string-append "TZDIR=" out "/share/zoneinfo")
1358 (string-append "TZDEFAULT=" out
1359 "/share/zoneinfo/localtime")
1360
1361 ;; Likewise for the C library routines.
1362 (string-append "LIBDIR=" tmp "/lib")
1363 (string-append "MANDIR=" tmp "/man")
1364
1365 ;; XXX: tzdata 2020b changed the on-disk format
1366 ;; of the time zone files from 'fat' to 'slim'.
1367 ;; Many packages (particularly evolution-data-server)
1368 ;; can not yet handle the latter, so we stick with
1369 ;; 'fat' for now.
1370 #$@(if (version>=? (package-version this-package)
1371 "2020b")
1372 '("CPPFLAGS=-DZIC_BLOAT_DEFAULT='\"fat\"'")
1373 '())
1374
1375 "AWK=awk"
1376 "CC=gcc"))
1377 #:modules '((guix build utils)
1378 (guix build gnu-build-system)
1379 (srfi srfi-1))
1380 #:phases
1381 #~(modify-phases %standard-phases
1382 (replace 'unpack
1383 (lambda* (#:key source inputs #:allow-other-keys)
1384 (invoke "tar" "xvf" source)
1385 (invoke "tar" "xvf"
1386 #$(match (package-inputs this-package)
1387 (((_ tzcode)) tzcode)))))
1388 (add-after 'install 'post-install
1389 (lambda* (#:key outputs #:allow-other-keys)
1390 ;; Move data in the right place.
1391 (let ((out (assoc-ref outputs "out")))
1392 ;; Discard zic, dump, and tzselect, already
1393 ;; provided by glibc.
1394 (delete-file-recursively (string-append out "/usr"))
1395 (symlink (string-append out "/share/zoneinfo")
1396 (string-append out "/share/zoneinfo/posix"))
1397 (delete-file-recursively
1398 (string-append out "/share/zoneinfo-posix"))
1399 (copy-recursively (string-append out "/share/zoneinfo-leaps")
1400 (string-append out "/share/zoneinfo/right"))
1401 (delete-file-recursively
1402 (string-append out "/share/zoneinfo-leaps")))))
1403 (delete 'configure))))
1404 (inputs (list (origin
1405 (method url-fetch)
1406 (uri (string-append
1407 "https://data.iana.org/time-zones/releases/tzcode"
1408 version ".tar.gz"))
1409 (sha256
1410 (base32
1411 "1iysv8fdkm79k8wh8jizmjmq075q4qjhk090vxjy57my6dz5wmzq")))))
1412 (home-page "https://www.iana.org/time-zones")
1413 (synopsis "Database of current and historical time zones")
1414 (description "The Time Zone Database (often called tz or zoneinfo)
1415 contains code and data that represent the history of local time for many
1416 representative locations around the globe. It is updated periodically to
1417 reflect changes made by political bodies to time zone boundaries, UTC offsets,
1418 and daylight-saving rules.")
1419 (license public-domain)))
1420
1421 ;;; A "fixed" version of tzdata, which is used in the test suites of glib and R
1422 ;;; and a few other places. We can update this whenever we are able to rebuild
1423 ;;; thousands of packages (for example, in a core-updates rebuild). This package
1424 ;;; will typically be obsolete and should never be referred to by a built
1425 ;;; package.
1426 ;;;
1427 ;;; Please make this a hidden-package if it is different from the primary tzdata
1428 ;;; package.
1429 (define-public tzdata-for-tests tzdata)
1430
1431 (define-public libiconv
1432 (package
1433 (name "libiconv")
1434 (version "1.15")
1435 (source (origin
1436 (method url-fetch)
1437 (uri (string-append "mirror://gnu/libiconv/libiconv-"
1438 version ".tar.gz"))
1439 (sha256
1440 (base32
1441 "0y1ij745r4p48mxq84rax40p10ln7fc7m243p8k8sia519i3dxfc"))
1442 (modules '((guix build utils)))
1443 (snippet
1444 ;; Work around "declared gets" error on glibc systems (fixed by
1445 ;; Gnulib commit 66712c23388e93e5c518ebc8515140fa0c807348.)
1446 '(substitute* "srclib/stdio.in.h"
1447 (("^#undef gets") "")
1448 (("^_GL_WARN_ON_USE \\(gets.*") "")))))
1449 (build-system gnu-build-system)
1450 (synopsis "Character set conversion library")
1451 (description
1452 "libiconv provides an implementation of the iconv function for systems
1453 that lack it. iconv is used to convert between character encodings in a
1454 program. It supports a wide variety of different encodings.")
1455 (home-page "https://www.gnu.org/software/libiconv/")
1456 (license lgpl3+)))
1457
1458 (define* (libiconv-if-needed #:optional (target (%current-target-system)))
1459 "Return either a libiconv package specification to include in a dependency
1460 list for platforms that have an incomplete libc, or the empty list. If a
1461 package needs iconv ,@(libiconv-if-needed) should be added."
1462 ;; POSIX C libraries provide iconv. Platforms with an incomplete libc
1463 ;; without iconv, such as MinGW, must return the then clause.
1464 (if (target-mingw? target)
1465 `(("libiconv" ,libiconv))
1466 '()))
1467
1468 (define-public (canonical-package package)
1469 ;; Avoid circular dependency by lazily resolving 'commencement'.
1470 (let* ((iface (resolve-interface '(gnu packages commencement)))
1471 (proc (module-ref iface 'canonical-package)))
1472 (proc package)))
1473
1474 (define-public (%final-inputs)
1475 "Return the list of \"final inputs\"."
1476 ;; Avoid circular dependency by lazily resolving 'commencement'.
1477 (let ((iface (resolve-interface '(gnu packages commencement))))
1478 (module-ref iface '%final-inputs)))
1479
1480 ;;; base.scm ends here