1 { lib, stdenv, fetchurl, fetchpatch, pkg-config, musl-fts
2 , musl-obstack, m4, zlib, zstd, bzip2, bison, flex, gettext, xz, setupDebugInfoDirs
4 , enableDebuginfod ? lib.meta.availableOn stdenv.hostPlatform libarchive, sqlite, curl, libmicrohttpd, libarchive
5 , gitUpdater, autoreconfHook
8 # TODO: Look at the hardcoded paths to kernel, modules etc.
9 stdenv.mkDerivation rec {
14 url = "https://sourceware.org/elfutils/ftp/${version}/${pname}-${version}.tar.bz2";
15 hash = "sha256-33bbcTZtHXCDZfx6bGDKSDmPFDZ+sriVTvyIlxR62HE=";
19 ./debug-info-from-env.patch
21 name = "fix-aarch64_fregs.patch";
22 url = "https://git.alpinelinux.org/aports/plain/main/elfutils/fix-aarch64_fregs.patch?id=2e3d4976eeffb4704cf83e2cc3306293b7c7b2e9";
23 sha256 = "zvncoRkQx3AwPx52ehjA2vcFroF+yDC2MQR5uS6DATs=";
26 name = "musl-asm-ptrace-h.patch";
27 url = "https://git.alpinelinux.org/aports/plain/main/elfutils/musl-asm-ptrace-h.patch?id=2e3d4976eeffb4704cf83e2cc3306293b7c7b2e9";
28 sha256 = "8D1wPcdgAkE/TNBOgsHaeTZYhd9l+9TrZg8d5C7kG6k=";
31 name = "musl-macros.patch";
32 url = "https://git.alpinelinux.org/aports/plain/main/elfutils/musl-macros.patch?id=2e3d4976eeffb4704cf83e2cc3306293b7c7b2e9";
33 sha256 = "tp6O1TRsTAMsFe8vw3LMENT/vAu6OmyA8+pzgThHeA8=";
36 name = "musl-strndupa.patch";
37 url = "https://git.alpinelinux.org/aports/plain/main/elfutils/musl-strndupa.patch?id=2e3d4976eeffb4704cf83e2cc3306293b7c7b2e9";
38 sha256 = "sha256-7daehJj1t0wPtQzTv+/Rpuqqs5Ng/EYnZzrcf2o/Lb0=";
40 ] ++ lib.optionals stdenv.hostPlatform.isMusl [ ./musl-error_h.patch ]
41 # Prevent headers and binaries from colliding which results in an error.
42 # https://sourceware.org/pipermail/elfutils-devel/2024q3/007281.html
43 ++ lib.optional (stdenv.targetPlatform.useLLVM or false) ./cxx-header-collision.patch;
46 patchShebangs tests/*.sh
47 '' + lib.optionalString stdenv.hostPlatform.isRiscV ''
48 # disable failing test:
50 # > dwfl_thread_getframes: No DWARF information found
51 sed -i s/run-backtrace-dwarf.sh//g tests/Makefile.in
54 outputs = [ "bin" "dev" "out" "man" ];
56 # We need bzip2 in NativeInputs because otherwise we can't unpack the src,
57 # as the host-bzip2 will be in the path.
58 nativeBuildInputs = [ m4 bison flex gettext bzip2 ]
59 ++ lib.optional enableDebuginfod pkg-config
60 ++ lib.optional (stdenv.targetPlatform.useLLVM or false) autoreconfHook;
61 buildInputs = [ zlib zstd bzip2 xz ]
62 ++ lib.optionals stdenv.hostPlatform.isMusl [
66 ] ++ lib.optionals enableDebuginfod [
73 propagatedNativeBuildInputs = [ setupDebugInfoDirs ];
76 "--program-prefix=eu-" # prevent collisions with binutils
77 "--enable-deterministic-archives"
78 (lib.enableFeature enableDebuginfod "libdebuginfod")
79 (lib.enableFeature enableDebuginfod "debuginfod")
81 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101766
82 # Versioned symbols are nice to have, but we can do without.
83 (lib.enableFeature (!stdenv.hostPlatform.isMicroBlaze) "symbol-versioning")
84 ] ++ lib.optional (stdenv.targetPlatform.useLLVM or false) "--disable-demangler"
85 ++ lib.optionals stdenv.cc.isClang [
86 "CFLAGS=-Wno-unused-private-field"
87 "CXXFLAGS=-Wno-unused-private-field"
90 enableParallelBuilding = true;
94 # Backtrace unwinding tests rely on glibc-internal symbol names.
95 # Musl provides slightly different forms and fails.
96 # Let's disable tests there until musl support is fully upstreamed.
97 !stdenv.hostPlatform.isMusl
98 # Test suite tries using `uname` to determine whether certain tests
99 # can be executed, so we need to match build and host platform exactly.
100 && (stdenv.hostPlatform == stdenv.buildPlatform);
101 doInstallCheck = !stdenv.hostPlatform.isMusl
102 && (stdenv.hostPlatform == stdenv.buildPlatform);
104 passthru.updateScript = gitUpdater {
105 url = "https://sourceware.org/git/elfutils.git";
106 rev-prefix = "elfutils-";
110 homepage = "https://sourceware.org/elfutils/";
111 description = "Set of utilities to handle ELF objects";
112 platforms = platforms.linux;
113 # https://lists.fedorahosted.org/pipermail/elfutils-devel/2014-November/004223.html
114 badPlatforms = [ lib.systems.inspect.platformPatterns.isStatic ];
115 # licenses are GPL2 or LGPL3+ for libraries, GPL3+ for bins,
116 # but since this package isn't split that way, all three are listed.
117 license = with licenses; [ gpl2Only lgpl3Plus gpl3Plus ];
118 maintainers = with maintainers; [ r-burns ];