projects/guix·blob java-team · refs

480 lines · 21.5 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 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 meson)
43 #:use-module (guix build-system gnu)
44 #:use-module ((guix licenses) #:prefix license:)
45 #:use-module (gnu packages)
46 #:use-module (gnu packages autotools)
47 #:use-module (gnu packages compression)
48 #:use-module (gnu packages base)
49 #:use-module (gnu packages bash)
50 #:use-module (gnu packages digest)
51 #:use-module (gnu packages docbook)
52 #:use-module (gnu packages documentation)
53 #:use-module (gnu packages gawk)
54 #:use-module (gnu packages gcc)
55 #:use-module (gnu packages m4)
56 #:use-module (gnu packages pkg-config)
57 #:use-module (gnu packages python)
58 #:use-module (gnu packages sphinx)
59 #:use-module (gnu packages texinfo)
60 #:use-module (gnu packages xml)
61 #:use-module (srfi srfi-1)
62 #:use-module (srfi srfi-26))
63
64(define-public chrpath
65 (package
66 (name "chrpath")
67 (version "0.18")
68 (source (origin
69 (method git-fetch)
70 (uri (git-reference
71 (url "https://codeberg.org/pere/chrpath")
72 (commit (string-append "release_" version))))
73 (file-name (git-file-name name version))
74 (sha256
75 (base32
76 "0n7fp6xm660m8inaadlblh7zr8izyc3x39bfdqi6rj1kn0vmzra6"))))
77 (build-system gnu-build-system)
78 (native-inputs (list automake autoconf))
79 (home-page "https://codeberg.org/pere/chrpath")
80 (synopsis "Utility for editing the RPATH or RUNPATH of ELF binaries")
81 (description "@code{chrpath} allows listing, changing or removing the
82dynamic library load path (RPATH and RUNPATH) of compiled programs and
83libraries.")
84 (license license:gpl2+)))
85
86(define-public elfutils
87 (package
88 (name "elfutils")
89 (version "0.192")
90 (source (origin
91 (method url-fetch)
92 (uri (string-append "https://sourceware.org/elfutils/ftp/"
93 version "/elfutils-" version ".tar.bz2"))
94 (sha256
95 (base32
96 "1d0nnkm59pwi9hrr28w0ifb6smldrjk6rn33kcgs3ar4msz9jq31"))
97 (patches (search-patches "elfutils-tests-ptrace.patch"))))
98 (build-system gnu-build-system)
99
100 ;; Separate programs because that's usually not what elfutils users want,
101 ;; and because they duplicate what Binutils provides (but are named
102 ;; differently, using the eu- prefix and can be installed in parallel).
103 (outputs '("out" ; libelf.so, elfutils/*.h, etc.
104 "bin")) ; eu-nm, eu-objdump, etc.
105
106 (arguments
107 ;; Programs don't have libelf.so in their RUNPATH and libraries don't
108 ;; know where to find each other.
109 `(#:configure-flags (list (string-append "LDFLAGS=-Wl,-rpath="
110 (assoc-ref %outputs "out")
111 "/lib")
112 "--disable-static"
113 ;; TODO: Enable the debuginfo server. It
114 ;; increases the closure size significantly
115 ;; and presents bootstrapping problems, so
116 ;; we disable it for now. See
117 ;; https://issues.guix.gnu.org/38803 and
118 ;; https://sourceware.org/bugzilla/show_bug.cgi?id=25509
119 ;; for more information.
120 "--disable-libdebuginfod"
121 "--disable-debuginfod")
122
123 ,@(if (target-hurd64?)
124 '(#:make-flags '("core-file_no_Werror=yes"))
125 '())
126
127 ;; Disable tests on MIPS and PowerPC (without changing
128 ;; the arguments list on other systems).
129 ,@(if (any (cute string-prefix? <> (or (%current-target-system)
130 (%current-system)))
131 '("mips" "powerpc"))
132 '(#:tests? #f)
133 '())
134
135 #:phases
136 ,#~(modify-phases %standard-phases
137 ;; No reason has been found for this test to reliably fail on aarch64-linux.
138 (add-after 'unpack 'disable-failing-aarch64-tests
139 (lambda _
140 (substitute* "tests/Makefile.in"
141 (("run-backtrace-native.sh") ""))
142 #t))
143 #$@(if (target-riscv64?)
144 #~((add-after 'unpack 'disable-failing-riscv64-test
145 (lambda _
146 (substitute* "tests/Makefile.in"
147 ;; dwfl_thread_getframes: No DWARF information found
148 (("run-backtrace-dwarf.sh") "")
149 ;; These tests have several errors:
150 ;; unknown program header entry type 0x70000003
151 ;; '.riscv.attributes' has unsupported type 1879048195
152 (("run-reverse-sections-self.sh") "")
153 (("run-strip-strmerge.sh") "")
154 (("run-elflint-self.sh") "")))))
155 #~())
156 #$@(if (system-hurd?)
157 #~((add-after 'unpack 'skip-tests
158 (lambda _
159 (substitute* '("tests/elfstrtab.c"
160 "tests/emptyfile.c")
161 (("elf_version \\(EV_CURRENT\\);" all)
162 "exit (77);"))
163 (substitute* '("tests/run-all-dwarf-ranges.sh"
164 "tests/run-allfcts-multi.sh"
165 "tests/run-attr-integrate-skel.sh"
166 "tests/run-bug1-test.sh"
167 "tests/run-copyadd-sections.sh"
168 "tests/run-declfiles.sh"
169 "tests/run-deleted.sh"
170 "tests/run-dwarf-getmacros.sh"
171 "tests/run-get-units-split.sh"
172 "tests/run-native-test.sh"
173 "tests/run-readelf-loc.sh"
174 "tests/run-readelf-ranges.sh"
175 "tests/run-unit-info.sh"
176 "tests/run-varlocs.sh")
177 (("^#!.*" all)
178 (string-append all "exit 77;\n"))))))
179 #~()))))
180
181 (native-inputs (list m4))
182 (inputs (list xz zlib))
183 (home-page "https://sourceware.org/elfutils/")
184 (synopsis "Collection of utilities and libraries to handle ELF files and
185DWARF data")
186 (description
187 "Elfutils is a collection of utilities and libraries to read, create and
188modify Executable and Linkable Format (@dfn{ELF}) binary files, find and
189handle Debugging With Arbitrary Record Formats (@dfn{DWARF}) debug data,
190symbols, thread state and stacktraces for processes and core files on
191GNU/Linux. Elfutils includes @file{libelf} for manipulating ELF files,
192@file{libdw} for inspecting DWARF data and process state and utilities like
193@command{eu-stack} (to show backtraces), @command{eu-nm} (for listing symbols
194from object files), @command{eu-size} (for listing the section sizes of an
195object or archive file), @command{eu-strip} (for discarding symbols),
196@command{eu-readelf} (to see the raw ELF file structures),
197@command{eu-elflint} (to check for well-formed ELF files),
198@command{eu-elfcompress} (to compress or decompress ELF sections), and more.")
199
200 ;; Libraries are dual-licensed LGPLv3.0+ | GPLv2, and programs are GPLv3+.
201 (license license:lgpl3+)))
202
203(define-public libabigail
204 (package
205 (name "libabigail")
206 (home-page "https://sourceware.org/libabigail/")
207 (version "2.9")
208 (source (origin
209 (method url-fetch)
210 (uri (string-append "https://sourceware.org/pub/libabigail/"
211 "libabigail-" version ".tar.xz"))
212 (sha256
213 (base32
214 "0f6p86ispkiaxsqlqp9xdmhn0yjyagq1w7q94pd8m8h566m6pf5l"))))
215 (build-system gnu-build-system)
216 (arguments
217 (list #:configure-flags #~(list "--disable-static"
218 "--enable-bash-completion"
219 "--enable-manual")
220 #:make-flags #~(list "V=1")
221 #:phases #~(modify-phases %standard-phases
222 (add-after 'unpack 'patch-source
223 (lambda _
224 (substitute* "build-aux/ltmain.sh"
225 ;; Don't add -specs=/usr/lib/rpm/redhat/redhat-hardened-ld
226 ;; to the GCC command line.
227 (("compiler_flags=\"-specs=.*")
228 "compiler_flags=\n"))))
229 (add-after 'build 'build-documentation
230 (lambda _
231 (invoke "make" "-C" "doc/manuals" "html-doc" "man" "info")))
232 (add-before 'check 'set-test-environment
233 (lambda _
234 (setenv "XDG_CACHE_HOME" "/tmp")))
235 (add-after 'install 'install-documentation
236 (lambda _
237 (invoke "make" "-C" "doc/manuals"
238 "install-man-and-info-doc")))
239 (add-after 'install-documentation 'install-bash-completion
240 (lambda _
241 (for-each (lambda (file)
242 (install-file
243 file (string-append #$output
244 "/share/bash-completion"
245 "/completions")))
246 (find-files "bash-completion" ".*abi.*")))))))
247 (native-inputs
248 (list pkg-config texinfo python-sphinx python))
249 (propagated-inputs
250 (list elfutils ;libabigail.la says -lelf
251 libxml2 ;in Requires.private of libabigail.pc
252 xxhash))
253 (synopsis "Analyze application binary interfaces (ABIs)")
254 (description
255 "@dfn{ABIGAIL} stands for the Application Binary Interface Generic
256Analysis and Instrumentation Library. It is a framework which aims at
257helping developers and software distributors to spot ABI-related issues
258like interface incompatibility in ELF shared libraries by performing a
259static analysis of the ELF binaries at hand.")
260 (license license:lgpl3+)))
261
262(define-public libelf
263 (package
264 (name "libelf")
265 (version "0.8.13")
266 (source
267 (origin
268 (method url-fetch)
269 (uri (list
270 ;; As of May 2019, the original URL at mr511.de redirects to a
271 ;; domain that doesn't resolve. Use these two mirrors instead.
272 (string-append "https://fossies.org/linux/misc/old/"
273 "libelf-" version ".tar.gz")
274 (string-append "https://ftp.osuosl.org/pub/blfs/conglomeration/"
275 "libelf/libelf-" version ".tar.gz")))
276 (sha256
277 (base32
278 "0vf7s9dwk2xkmhb79aigqm0x0yfbw1j0b9ksm51207qwr179n6jr"))))
279 (build-system gnu-build-system)
280 (arguments
281 `(#:phases
282 (modify-phases %standard-phases
283 ;; This old 'configure' script doesn't support cross-compilation
284 ;; well. I.e., it fails to find the cross-compiler. Also,
285 ;; the old `configure' script doesn't support variables passed as
286 ;; arguments. A third problem is that config.sub is too old to
287 ;; recognise aarch64 and powerpc64le.
288 ;;
289 ;; Solve this by regenerating the configure script and letting
290 ;; autoreconf update 'config.sub'. While 'config.sub' is updated
291 ;; anyway, update 'config.guess' as well.
292 (add-before 'bootstrap 'delete-configure
293 (lambda* (#:key native-inputs inputs #:allow-other-keys)
294 (delete-file "configure")
295 (delete-file "config.sub")
296 (delete-file "config.guess")
297 (for-each (lambda (file)
298 (install-file
299 (string-append
300 (assoc-ref (or native-inputs inputs) "automake")
301 "/share/automake-"
302 ,(version-major+minor (package-version automake))
303 "/" file) "."))
304 '("config.sub" "config.guess")))))))
305 (native-inputs
306 (list autoconf
307 ;; For up-to-date 'config.guess' and 'config.sub'
308 automake))
309 (home-page (string-append "https://web.archive.org/web/20181111033959/"
310 "http://www.mr511.de/software/english.html"))
311 (synopsis "ELF object file access library")
312 (description "Libelf is a C library to access ELF object files.")
313 (license license:lgpl2.0+)))
314
315
316;; This is a shared library version of libelf, currently only needed for ROCm
317;; packages in (gnu packages rocm).
318(define-public libelf-shared
319 (package
320 (inherit libelf)
321 (arguments
322 (substitute-keyword-arguments arguments
323 ((#:make-flags flags #~'())
324 #~(append #$flags '("CFLAGS=-fPIC")))))
325 (properties `((hidden? . #t) ,@(package-properties libelf)))))
326
327(define-public patchelf
328 (package
329 (name "patchelf")
330 (version "0.18.0")
331 (source (origin
332 (method url-fetch)
333 (uri (string-append
334 "https://github.com/NixOS/patchelf/releases/download/"
335 version
336 "/patchelf-" version ".tar.bz2"))
337 (sha256
338 (base32
339 "02s7ap86rx6yagfh9xwp96sgsj0p6hp99vhiq9wn4mxshakv4lhr"))))
340 (build-system gnu-build-system)
341 (arguments
342 '(#:phases
343 (modify-phases %standard-phases
344 (add-after 'unpack 'fix-tests
345 ;; Our GCC code ensures that RUNPATH is never empty, it includes
346 ;; at least glibc/lib and gcc:lib/lib.
347 (lambda* (#:key inputs #:allow-other-keys)
348 (substitute* "tests/no-rpath.sh"
349 ;; Disable checking for an empty runpath:
350 (("^if test.*") "")
351 ;; Find libgcc_s.so, which is necessary for the test:
352 (("/xxxxxxxxxxxxxxx") (string-append (assoc-ref inputs "gcc:lib")
353 "/lib")))
354 (substitute* "tests/replace-needed.sh"
355 ;; This test assumes that only libc will be linked alongside
356 ;; libfoo, but we also link libgcc_s.
357 (("grep -v 'foo\\\\.so'") "grep -E 'libc.*\\.so'"))
358 (substitute* "tests/set-empty-rpath.sh"
359 ;; Binaries with empty RPATHs cannot run on Guix, because
360 ;; we still need to find libgcc_s (see above).
361 (("^\"\\$\\{SCRATCH\\}\"\\/simple.$") ""))
362 ;; Skip this test for now.
363 (substitute* "tests/Makefile.in"
364 ((".*shared-rpath\\.sh \\.*") "")))))))
365 (native-inputs
366 `(("gcc:lib" ,gcc "lib")))
367 (home-page "https://nixos.org/patchelf.html")
368 (synopsis "Modify the dynamic linker and RPATH of ELF executables")
369 (description
370 "PatchELF allows the ELF \"interpreter\" and RPATH of an ELF binary to be
371changed.")
372 (license license:gpl3+)))
373
374;; Newer patchelf may break binaries. e.g. When setting RUNPATH for a Go
375;; program.
376;; See also: https://github.com/NixOS/patchelf/issues/482
377(define-public patchelf-0.16
378 (package
379 (inherit patchelf)
380 (name "patchelf")
381 (version "0.16.1")
382 (source (origin
383 (method url-fetch)
384 (uri (string-append
385 "https://github.com/NixOS/patchelf/releases/download/"
386 version
387 "/patchelf-" version ".tar.bz2"))
388 (sha256
389 (base32
390 "0zdby3gpmm8q4735pviaq92zj41i2rdnhwhyrsb3sinc9hzmz4db"))))
391 (arguments
392 (substitute-keyword-arguments arguments
393 ((#:phases phases '%standard-phases)
394 #~(modify-phases #$phases
395 (add-after 'fix-tests 'skip-empty-rpath-test
396 (lambda _
397 (substitute* "tests/set-empty-rpath.sh"
398 (("^\\$\\{SCRATCH\\}\\/simple.$") ""))))))))))
399
400(define-public pax-utils
401 (package
402 (name "pax-utils")
403 (version "1.3.9")
404 (source (origin
405 (method git-fetch)
406 (uri (git-reference
407 (url "https://anongit.gentoo.org/git/proj/pax-utils.git")
408 (commit (string-append "v" version))))
409 (file-name (git-file-name name version))
410 (sha256
411 (base32
412 "1ds0bjlivvqpm3kr8y9blawrkhn134zwng2zq6cdbh5xw87vqwg4"))))
413 (build-system meson-build-system)
414 (arguments
415 (list
416 #:modules '((guix build meson-build-system)
417 (guix build utils)
418 (srfi srfi-26))
419 #:configure-flags #~(list "-Dlddtree_implementation=sh")
420 #:phases
421 #~(modify-phases %standard-phases
422 (add-after 'install 'wrap-lddtree
423 (lambda* (#:key inputs outputs #:allow-other-keys)
424 (let* ((needed-bin
425 (map (cut string-append <> "/bin")
426 (list #$(this-package-input "coreutils-minimal")
427 #$(this-package-input "gawk")
428 #$(this-package-input "sed")
429 #$output)))
430 (PATH `("PATH" = (,@needed-bin))))
431 (for-each (lambda (p)
432 (wrap-program
433 (search-input-file outputs
434 (string-append "bin/" p))
435 PATH))
436 (list "lddtree" "symtree"))))))))
437 (native-inputs (list docbook-xsl xmlto))
438 (inputs (list bash-minimal coreutils-minimal gawk sed))
439 (home-page "https://wiki.gentoo.org/wiki/Hardened/PaX_Utilities")
440 (synopsis "ELF integrity and security-focused utils")
441 (description "The pax-utils package contains a small set of utilities
442for performing mostly security checks on systems. It is focused on the ELF
443format. The included utilities are:
444@table @command
445@item pspax List ELF/PaX information about running processes
446@item scanelf Scan ELF binaries
447@item dumpelf Dump internal ELF structure
448@item scanmacho Scan Mach-O binaries
449@item symtree Display libraries that satisfy undefined symbols, as a tree
450@item lddtree Display ELF dependencies as a tree.
451@end table")
452 (license license:gpl2+)))
453
454(define-public libdwarf
455 (package
456 (name "libdwarf")
457 (version "0.11.0")
458 (source (origin
459 (method git-fetch)
460 ;; The archive at
461 ;; https://www.prevanders.net/libdwarf-0.5.0.tar.xz
462 ;; has a bad date header (3600).
463 (uri (git-reference
464 (url "https://github.com/davea42/libdwarf-code")
465 (commit (string-append "v" version))))
466 (file-name (git-file-name name version))
467 (sha256
468 (base32
469 "0j4r6558rsgx7fhwa46mqix4jlxyf6m4h8i2nsxcq8j30siq5b85"))))
470 (build-system gnu-build-system)
471 (arguments
472 '(#:configure-flags '("--enable-shared")))
473 (native-inputs (list autoconf automake libtool pkg-config python))
474 (inputs (list elfutils))
475 (home-page "https://www.prevanders.net/dwarf.html")
476 (synopsis "Handle DWARF debugging information")
477 (description "@code{libdwarf} is a library that handles the DWARF
478debugging information format.")
479 ;; See https://www.prevanders.net/dwarflicense.html:
480 (license (list license:lgpl2.1 license:gpl2 license:bsd-2))))