projects/guix·blob javascript-team · refs

551 lines · 24.2 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2013, 2014, 2015 Ludovic Courtès <[email protected]>
3;;; Copyright © 2014, 2015 Mark H Weaver <[email protected]>
4;;; Copyright © 2015 Andreas Enge <[email protected]>
5;;; Copyright © 2017-2024 Efraim Flashner <[email protected]>
6;;; Copyright © 2017 Leo Famulari <[email protected]>
7;;; Copyright © 2018 Tobias Geerinckx-Rice <[email protected]>
8;;; Copyright © 2018, 2020 Marius Bakke <[email protected]>
9;;; Copyright © 2020 Mark Wielaard <[email protected]>
10;;; Copyright © 2020 Michael Rohleder <[email protected]>
11;;; Copyright © 2021 Leo Le Bouter <[email protected]>
12;;; Copyright © 2021 Maxime Devos <[email protected]>
13;;; Copyright © 2022 Daniel Maksymow <[email protected]>
14;;; Copyright © 2023, 2024 Janneke Nieuwenhuizen <[email protected]>
15;;; Copyright © 2024 Zheng Junjie <[email protected]>
16;;; Copyright © 2025 John Kehayias <[email protected]>
17;;; Copyright © 2025 Nicolas Graves <[email protected]>
18;;; Copyright © 2025, 2026 Maxim Cournoyer <[email protected]>
19;;; Copyright © 2025 Artyom V. Poptsov <[email protected]>
20;;;
21;;; This file is part of GNU Guix.
22;;;
23;;; GNU Guix is free software; you can redistribute it and/or modify it
24;;; under the terms of the GNU General Public License as published by
25;;; the Free Software Foundation; either version 3 of the License, or (at
26;;; your option) any later version.
27;;;
28;;; GNU Guix is distributed in the hope that it will be useful, but
29;;; WITHOUT ANY WARRANTY; without even the implied warranty of
30;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31;;; GNU General Public License for more details.
32;;;
33;;; You should have received a copy of the GNU General Public License
34;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
35
36(define-module (gnu packages elf)
37 #:use-module (guix gexp)
38 #:use-module (guix utils)
39 #:use-module (guix packages)
40 #:use-module (guix download)
41 #:use-module (guix git-download)
42 #:use-module (guix build-system cmake)
43 #:use-module (guix build-system meson)
44 #:use-module (guix build-system gnu)
45 #:use-module ((guix licenses) #:prefix license:)
46 #:use-module (gnu packages)
47 #:use-module (gnu packages autotools)
48 #:use-module (gnu packages compression)
49 #:use-module (gnu packages base)
50 #:use-module (gnu packages bash)
51 #:use-module (gnu packages cpp)
52 #:use-module (gnu packages digest)
53 #:use-module (gnu packages docbook)
54 #:use-module (gnu packages documentation)
55 #:use-module (gnu packages gawk)
56 #:use-module (gnu packages gcc)
57 #:use-module (gnu packages logging)
58 #:use-module (gnu packages m4)
59 #:use-module (gnu packages pkg-config)
60 #:use-module (gnu packages python)
61 #:use-module (gnu packages sphinx)
62 #:use-module (gnu packages texinfo)
63 #:use-module (gnu packages textutils)
64 #:use-module (gnu packages tls)
65 #:use-module (gnu packages xml)
66 #:use-module (srfi srfi-1)
67 #:use-module (srfi srfi-26))
68
69(define-public chrpath
70 (package
71 (name "chrpath")
72 (version "0.18")
73 (source (origin
74 (method git-fetch)
75 (uri (git-reference
76 (url "https://codeberg.org/pere/chrpath")
77 (commit (string-append "release_" version))))
78 (file-name (git-file-name name version))
79 (sha256
80 (base32
81 "0n7fp6xm660m8inaadlblh7zr8izyc3x39bfdqi6rj1kn0vmzra6"))))
82 (build-system gnu-build-system)
83 (native-inputs (list automake autoconf))
84 (home-page "https://codeberg.org/pere/chrpath")
85 (synopsis "Utility for editing the RPATH or RUNPATH of ELF binaries")
86 (description "@code{chrpath} allows listing, changing or removing the
87dynamic library load path (RPATH and RUNPATH) of compiled programs and
88libraries.")
89 (license license:gpl2+)))
90
91(define-public elfutils
92 (package
93 (name "elfutils")
94 (version "0.192")
95 (source (origin
96 (method url-fetch)
97 (uri (string-append "https://sourceware.org/elfutils/ftp/"
98 version "/elfutils-" version ".tar.bz2"))
99 (sha256
100 (base32
101 "1d0nnkm59pwi9hrr28w0ifb6smldrjk6rn33kcgs3ar4msz9jq31"))
102 (patches (search-patches "elfutils-tests-ptrace.patch"))))
103 (build-system gnu-build-system)
104
105 ;; Separate programs because that's usually not what elfutils users want,
106 ;; and because they duplicate what Binutils provides (but are named
107 ;; differently, using the eu- prefix and can be installed in parallel).
108 (outputs '("out" ; libelf.so, elfutils/*.h, etc.
109 "bin")) ; eu-nm, eu-objdump, etc.
110
111 (arguments
112 ;; Programs don't have libelf.so in their RUNPATH and libraries don't
113 ;; know where to find each other.
114 `(#:configure-flags (list (string-append "LDFLAGS=-Wl,-rpath="
115 (assoc-ref %outputs "out")
116 "/lib")
117 "--disable-static"
118 ;; TODO: Enable the debuginfo server. It
119 ;; increases the closure size significantly
120 ;; and presents bootstrapping problems, so
121 ;; we disable it for now. See
122 ;; https://issues.guix.gnu.org/38803 and
123 ;; https://sourceware.org/bugzilla/show_bug.cgi?id=25509
124 ;; for more information.
125 "--disable-libdebuginfod"
126 "--disable-debuginfod")
127
128 ,@(if (target-hurd64?)
129 '(#:make-flags '("core-file_no_Werror=yes"))
130 '())
131
132 ;; Disable tests on MIPS and PowerPC (without changing
133 ;; the arguments list on other systems).
134 ,@(if (any (cute string-prefix? <> (or (%current-target-system)
135 (%current-system)))
136 '("mips" "powerpc"))
137 '(#:tests? #f)
138 '())
139
140 #:phases
141 ,#~(modify-phases %standard-phases
142 ;; No reason has been found for this test to reliably fail on aarch64-linux.
143 (add-after 'unpack 'disable-failing-aarch64-tests
144 (lambda _
145 (substitute* "tests/Makefile.in"
146 (("run-backtrace-native.sh") ""))
147 #t))
148 #$@(if (target-riscv64?)
149 #~((add-after 'unpack 'disable-failing-riscv64-test
150 (lambda _
151 (substitute* "tests/Makefile.in"
152 ;; dwfl_thread_getframes: No DWARF information found
153 (("run-backtrace-dwarf.sh") "")
154 ;; These tests have several errors:
155 ;; unknown program header entry type 0x70000003
156 ;; '.riscv.attributes' has unsupported type 1879048195
157 (("run-reverse-sections-self.sh") "")
158 (("run-strip-strmerge.sh") "")
159 (("run-elflint-self.sh") "")))))
160 #~())
161 #$@(if (system-hurd?)
162 #~((add-after 'unpack 'skip-tests
163 (lambda _
164 (substitute* '("tests/elfstrtab.c"
165 "tests/emptyfile.c")
166 (("elf_version \\(EV_CURRENT\\);" all)
167 "exit (77);"))
168 (substitute* '("tests/run-all-dwarf-ranges.sh"
169 "tests/run-allfcts-multi.sh"
170 "tests/run-attr-integrate-skel.sh"
171 "tests/run-bug1-test.sh"
172 "tests/run-copyadd-sections.sh"
173 "tests/run-declfiles.sh"
174 "tests/run-deleted.sh"
175 "tests/run-dwarf-getmacros.sh"
176 "tests/run-get-units-split.sh"
177 "tests/run-native-test.sh"
178 "tests/run-readelf-loc.sh"
179 "tests/run-readelf-ranges.sh"
180 "tests/run-unit-info.sh"
181 "tests/run-varlocs.sh")
182 (("^#!.*" all)
183 (string-append all "exit 77;\n"))))))
184 #~()))))
185
186 (native-inputs (list m4))
187 (inputs (list xz zlib))
188 (home-page "https://sourceware.org/elfutils/")
189 (synopsis "Collection of utilities and libraries to handle ELF files and
190DWARF data")
191 (description
192 "Elfutils is a collection of utilities and libraries to read, create and
193modify Executable and Linkable Format (@dfn{ELF}) binary files, find and
194handle Debugging With Arbitrary Record Formats (@dfn{DWARF}) debug data,
195symbols, thread state and stacktraces for processes and core files on
196GNU/Linux. Elfutils includes @file{libelf} for manipulating ELF files,
197@file{libdw} for inspecting DWARF data and process state and utilities like
198@command{eu-stack} (to show backtraces), @command{eu-nm} (for listing symbols
199from object files), @command{eu-size} (for listing the section sizes of an
200object or archive file), @command{eu-strip} (for discarding symbols),
201@command{eu-readelf} (to see the raw ELF file structures),
202@command{eu-elflint} (to check for well-formed ELF files),
203@command{eu-elfcompress} (to compress or decompress ELF sections), and more.")
204
205 ;; Libraries are dual-licensed LGPLv3.0+ | GPLv2, and programs are GPLv3+.
206 (license license:lgpl3+)))
207
208(define-public libabigail
209 (package
210 (name "libabigail")
211 (home-page "https://sourceware.org/libabigail/")
212 (version "2.9")
213 (source (origin
214 (method url-fetch)
215 (uri (string-append "https://sourceware.org/pub/libabigail/"
216 "libabigail-" version ".tar.xz"))
217 (sha256
218 (base32
219 "0f6p86ispkiaxsqlqp9xdmhn0yjyagq1w7q94pd8m8h566m6pf5l"))))
220 (build-system gnu-build-system)
221 (arguments
222 (list #:configure-flags #~(list "--disable-static"
223 "--enable-bash-completion"
224 "--enable-manual")
225 #:make-flags #~(list "V=1")
226 #:phases #~(modify-phases %standard-phases
227 (add-after 'unpack 'patch-source
228 (lambda _
229 (substitute* "build-aux/ltmain.sh"
230 ;; Don't add -specs=/usr/lib/rpm/redhat/redhat-hardened-ld
231 ;; to the GCC command line.
232 (("compiler_flags=\"-specs=.*")
233 "compiler_flags=\n"))))
234 (add-after 'build 'build-documentation
235 (lambda _
236 (invoke "make" "-C" "doc/manuals" "html-doc" "man" "info")))
237 (add-before 'check 'set-test-environment
238 (lambda _
239 (setenv "XDG_CACHE_HOME" "/tmp")))
240 (add-after 'install 'install-documentation
241 (lambda _
242 (invoke "make" "-C" "doc/manuals"
243 "install-man-and-info-doc")))
244 (add-after 'install-documentation 'install-bash-completion
245 (lambda _
246 (for-each (lambda (file)
247 (install-file
248 file (string-append #$output
249 "/share/bash-completion"
250 "/completions")))
251 (find-files "bash-completion" ".*abi.*")))))))
252 (native-inputs
253 (list pkg-config texinfo python-sphinx python))
254 (propagated-inputs
255 (list elfutils ;libabigail.la says -lelf
256 libxml2 ;in Requires.private of libabigail.pc
257 xxhash))
258 (synopsis "Analyze application binary interfaces (ABIs)")
259 (description
260 "@dfn{ABIGAIL} stands for the Application Binary Interface Generic
261Analysis and Instrumentation Library. It is a framework which aims at
262helping developers and software distributors to spot ABI-related issues
263like interface incompatibility in ELF shared libraries by performing a
264static analysis of the ELF binaries at hand.")
265 (license license:lgpl3+)))
266
267(define-public libelf
268 (package
269 (name "libelf")
270 (version "0.8.13")
271 (source
272 (origin
273 (method url-fetch)
274 (uri (list
275 ;; As of May 2019, the original URL at mr511.de redirects to a
276 ;; domain that doesn't resolve. Use these two mirrors instead.
277 (string-append "https://fossies.org/linux/misc/old/"
278 "libelf-" version ".tar.gz")
279 (string-append "https://ftp.osuosl.org/pub/blfs/conglomeration/"
280 "libelf/libelf-" version ".tar.gz")))
281 (sha256
282 (base32
283 "0vf7s9dwk2xkmhb79aigqm0x0yfbw1j0b9ksm51207qwr179n6jr"))))
284 (build-system gnu-build-system)
285 (arguments
286 `(#:phases
287 (modify-phases %standard-phases
288 ;; This old 'configure' script doesn't support cross-compilation
289 ;; well. I.e., it fails to find the cross-compiler. Also,
290 ;; the old `configure' script doesn't support variables passed as
291 ;; arguments. A third problem is that config.sub is too old to
292 ;; recognise aarch64 and powerpc64le.
293 ;;
294 ;; Solve this by regenerating the configure script and letting
295 ;; autoreconf update 'config.sub'. While 'config.sub' is updated
296 ;; anyway, update 'config.guess' as well.
297 (add-before 'bootstrap 'delete-configure
298 (lambda* (#:key native-inputs inputs #:allow-other-keys)
299 (delete-file "configure")
300 (delete-file "config.sub")
301 (delete-file "config.guess")
302 (for-each (lambda (file)
303 (install-file
304 (string-append
305 (assoc-ref (or native-inputs inputs) "automake")
306 "/share/automake-"
307 ,(version-major+minor (package-version automake))
308 "/" file) "."))
309 '("config.sub" "config.guess")))))))
310 (native-inputs
311 (list autoconf
312 ;; For up-to-date 'config.guess' and 'config.sub'
313 automake))
314 (home-page (string-append "https://web.archive.org/web/20181111033959/"
315 "http://www.mr511.de/software/english.html"))
316 (synopsis "ELF object file access library")
317 (description "Libelf is a C library to access ELF object files.")
318 (license license:lgpl2.0+)))
319
320
321;; This is a shared library version of libelf, currently only needed for ROCm
322;; packages in (gnu packages rocm).
323(define-public libelf-shared
324 (package
325 (inherit libelf)
326 (arguments
327 (substitute-keyword-arguments arguments
328 ((#:make-flags flags #~'())
329 #~(append #$flags '("CFLAGS=-fPIC")))))
330 (properties `((hidden? . #t) ,@(package-properties libelf)))))
331
332(define-public lief
333 (package
334 (name "lief")
335 (version "1.0.0")
336 (source (origin
337 (method git-fetch)
338 (uri (git-reference
339 (url "https://github.com/lief-project/LIEF")
340 (commit version)))
341 (file-name (git-file-name name version))
342 (sha256
343 (base32
344 "0yhs1x8nli5lhwiq383nnfv8ajgbdidcjckdls1j0zrmyf9kbfa2"))
345 (modules '((guix build utils)))
346 (snippet '(delete-file-recursively "third-party"))
347 (patches (search-patches "lief-utfcpp-4.2.patch"))))
348 (build-system cmake-build-system)
349 (arguments
350 (list #:configure-flags
351 #~(list "-DLIEF_OPT_EXTERNAL_EXPECTED=ON"
352 "-DLIEF_OPT_EXTERNAL_SPAN=ON"
353 "-DLIEF_EXTERNAL_SPDLOG=ON"
354 "-DLIEF_OPT_FROZEN_EXTERNAL=ON"
355 "-DLIEF_OPT_MBEDTLS_EXTERNAL=ON"
356 "-DLIEF_OPT_NLOHMANN_JSON_EXTERNAL=ON"
357 "-DLIEF_OPT_UTFCPP_EXTERNAL=ON"
358 "-DBUILD_SHARED_LIBS=ON")
359 ;; The test suite is disabled by default, and requires to
360 ;; download/extract a 350 MiB compressed archive of test data.
361 #:tests? #f))
362 (inputs
363 (list frozen
364 mbedtls-4.0 ;<https://github.com/lief-project/LIEF/issues/1381>
365 nlohmann-json
366 spdlog
367 utfcpp)) ;<https://github.com/lief-project/LIEF/issues/1382>
368 (propagated-inputs
369 ;; Included in the include/LIEF/third-party headers.
370 (list libexpected
371 tcbrindle-span))
372 (home-page "https://lief.re/")
373 (synopsis "Library to instrument executable formats")
374 (description "The @acronym{LIEF, Library to Instrument Executable Formats}
375library can parse, modify and abstract ELF, PE, MachO and other formats. It
376provides an abstraction over common features like sections, symbols and entry
377points. This package provides the C/C++ API. The table below lists its main
378features in more details:
379@table @asis
380@item Parsing
381LIEF can parse ELF, PE, MachO, COFF, OAT, DEX, VDEX, ART and provides a
382user-friendly API to access their internals.
383
384@item Modify
385LIEF can be used to modify some parts of these formats (adding a section,
386changing a symbol's name, etc.)
387
388@item Abstract
389Three formats have common features like sections, symbols, entry point, etc. LIEF
390factors them.
391
392@item API
393The LIEF API is available for C/C++ (this package), Python (@code{python-lief}),
394and other languages.
395@end table")
396 (license license:asl2.0)))
397
398(define-public patchelf
399 (package
400 (name "patchelf")
401 (version "0.18.0")
402 (source (origin
403 (method url-fetch)
404 (uri (string-append
405 "https://github.com/NixOS/patchelf/releases/download/"
406 version
407 "/patchelf-" version ".tar.bz2"))
408 (sha256
409 (base32
410 "02s7ap86rx6yagfh9xwp96sgsj0p6hp99vhiq9wn4mxshakv4lhr"))))
411 (build-system gnu-build-system)
412 (arguments
413 '(#:phases
414 (modify-phases %standard-phases
415 (add-after 'unpack 'fix-tests
416 ;; Our GCC code ensures that RUNPATH is never empty, it includes
417 ;; at least glibc/lib and gcc:lib/lib.
418 (lambda* (#:key inputs #:allow-other-keys)
419 (substitute* "tests/no-rpath.sh"
420 ;; Disable checking for an empty runpath:
421 (("^if test.*") "")
422 ;; Find libgcc_s.so, which is necessary for the test:
423 (("/xxxxxxxxxxxxxxx") (string-append (assoc-ref inputs "gcc:lib")
424 "/lib")))
425 (substitute* "tests/replace-needed.sh"
426 ;; This test assumes that only libc will be linked alongside
427 ;; libfoo, but we also link libgcc_s.
428 (("grep -v 'foo\\\\.so'") "grep -E 'libc.*\\.so'"))
429 (substitute* "tests/set-empty-rpath.sh"
430 ;; Binaries with empty RPATHs cannot run on Guix, because
431 ;; we still need to find libgcc_s (see above).
432 (("^\"\\$\\{SCRATCH\\}\"\\/simple.$") ""))
433 ;; Skip this test for now.
434 (substitute* "tests/Makefile.in"
435 ((".*shared-rpath\\.sh \\.*") "")))))))
436 (native-inputs
437 `(("gcc:lib" ,gcc "lib")))
438 (home-page "https://nixos.org/patchelf.html")
439 (synopsis "Modify the dynamic linker and RPATH of ELF executables")
440 (description
441 "PatchELF allows the ELF \"interpreter\" and RPATH of an ELF binary to be
442changed.")
443 (license license:gpl3+)))
444
445;; Newer patchelf may break binaries. e.g. When setting RUNPATH for a Go
446;; program.
447;; See also: https://github.com/NixOS/patchelf/issues/482
448(define-public patchelf-0.16
449 (package
450 (inherit patchelf)
451 (name "patchelf")
452 (version "0.16.1")
453 (source (origin
454 (method url-fetch)
455 (uri (string-append
456 "https://github.com/NixOS/patchelf/releases/download/"
457 version
458 "/patchelf-" version ".tar.bz2"))
459 (sha256
460 (base32
461 "0zdby3gpmm8q4735pviaq92zj41i2rdnhwhyrsb3sinc9hzmz4db"))))
462 (arguments
463 (substitute-keyword-arguments arguments
464 ((#:phases phases '%standard-phases)
465 #~(modify-phases #$phases
466 (add-after 'fix-tests 'skip-empty-rpath-test
467 (lambda _
468 (substitute* "tests/set-empty-rpath.sh"
469 (("^\\$\\{SCRATCH\\}\\/simple.$") ""))))))))))
470
471(define-public pax-utils
472 (package
473 (name "pax-utils")
474 (version "1.3.9")
475 (source (origin
476 (method git-fetch)
477 (uri (git-reference
478 (url "https://anongit.gentoo.org/git/proj/pax-utils.git")
479 (commit (string-append "v" version))))
480 (file-name (git-file-name name version))
481 (sha256
482 (base32
483 "1ds0bjlivvqpm3kr8y9blawrkhn134zwng2zq6cdbh5xw87vqwg4"))))
484 (build-system meson-build-system)
485 (arguments
486 (list
487 #:modules '((guix build meson-build-system)
488 (guix build utils)
489 (srfi srfi-26))
490 #:configure-flags #~(list "-Dlddtree_implementation=sh")
491 #:phases
492 #~(modify-phases %standard-phases
493 (add-after 'install 'wrap-lddtree
494 (lambda* (#:key inputs outputs #:allow-other-keys)
495 (let* ((needed-bin
496 (map (cut string-append <> "/bin")
497 (list #$(this-package-input "coreutils-minimal")
498 #$(this-package-input "gawk")
499 #$(this-package-input "sed")
500 #$output)))
501 (PATH `("PATH" = (,@needed-bin))))
502 (for-each (lambda (p)
503 (wrap-program
504 (search-input-file outputs
505 (string-append "bin/" p))
506 PATH))
507 (list "lddtree" "symtree"))))))))
508 (native-inputs (list docbook-xsl xmlto))
509 (inputs (list bash-minimal coreutils-minimal gawk sed))
510 (home-page "https://wiki.gentoo.org/wiki/Hardened/PaX_Utilities")
511 (synopsis "ELF integrity and security-focused utils")
512 (description "The pax-utils package contains a small set of utilities
513for performing mostly security checks on systems. It is focused on the ELF
514format. The included utilities are:
515@table @command
516@item pspax List ELF/PaX information about running processes
517@item scanelf Scan ELF binaries
518@item dumpelf Dump internal ELF structure
519@item scanmacho Scan Mach-O binaries
520@item symtree Display libraries that satisfy undefined symbols, as a tree
521@item lddtree Display ELF dependencies as a tree.
522@end table")
523 (license license:gpl2+)))
524
525(define-public libdwarf
526 (package
527 (name "libdwarf")
528 (version "0.11.0")
529 (source (origin
530 (method git-fetch)
531 ;; The archive at
532 ;; https://www.prevanders.net/libdwarf-0.5.0.tar.xz
533 ;; has a bad date header (3600).
534 (uri (git-reference
535 (url "https://github.com/davea42/libdwarf-code")
536 (commit (string-append "v" version))))
537 (file-name (git-file-name name version))
538 (sha256
539 (base32
540 "0j4r6558rsgx7fhwa46mqix4jlxyf6m4h8i2nsxcq8j30siq5b85"))))
541 (build-system gnu-build-system)
542 (arguments
543 '(#:configure-flags '("--enable-shared")))
544 (native-inputs (list autoconf automake libtool pkg-config python))
545 (inputs (list elfutils))
546 (home-page "https://www.prevanders.net/dwarf.html")
547 (synopsis "Handle DWARF debugging information")
548 (description "@code{libdwarf} is a library that handles the DWARF
549debugging information format.")
550 ;; See https://www.prevanders.net/dwarflicense.html:
551 (license (list license:lgpl2.1 license:gpl2 license:bsd-2))))