19 enableDebuginfod ? lib.meta.availableOn stdenv.hostPlatform libarchive,
29 # TODO: Look at the hardcoded paths to kernel, modules etc.
30 stdenv.mkDerivation rec {
35 url = "https://sourceware.org/elfutils/ftp/${version}/${pname}-${version}.tar.bz2";
36 hash = "sha256-YWCZvq4kq6Efm2PYbKbMjVZtlouAI5EzTJHfVOq0FrQ=";
41 ./debug-info-from-env.patch
43 name = "fix-aarch64_fregs.patch";
44 url = "https://git.alpinelinux.org/aports/plain/main/elfutils/fix-aarch64_fregs.patch?id=2e3d4976eeffb4704cf83e2cc3306293b7c7b2e9";
45 sha256 = "zvncoRkQx3AwPx52ehjA2vcFroF+yDC2MQR5uS6DATs=";
48 name = "musl-asm-ptrace-h.patch";
49 url = "https://git.alpinelinux.org/aports/plain/main/elfutils/musl-asm-ptrace-h.patch?id=2e3d4976eeffb4704cf83e2cc3306293b7c7b2e9";
50 sha256 = "8D1wPcdgAkE/TNBOgsHaeTZYhd9l+9TrZg8d5C7kG6k=";
53 name = "musl-macros.patch";
54 url = "https://git.alpinelinux.org/aports/plain/main/elfutils/musl-macros.patch?id=2e3d4976eeffb4704cf83e2cc3306293b7c7b2e9";
55 sha256 = "tp6O1TRsTAMsFe8vw3LMENT/vAu6OmyA8+pzgThHeA8=";
58 name = "musl-strndupa.patch";
59 url = "https://git.alpinelinux.org/aports/plain/main/elfutils/musl-strndupa.patch?id=2e3d4976eeffb4704cf83e2cc3306293b7c7b2e9";
60 sha256 = "sha256-7daehJj1t0wPtQzTv+/Rpuqqs5Ng/EYnZzrcf2o/Lb0=";
63 ++ lib.optionals stdenv.hostPlatform.isMusl [ ./musl-error_h.patch ]
64 # Prevent headers and binaries from colliding which results in an error.
65 # https://sourceware.org/pipermail/elfutils-devel/2024q3/007281.html
66 ++ lib.optional (stdenv.targetPlatform.useLLVM or false) ./cxx-header-collision.patch;
70 patchShebangs tests/*.sh
72 + lib.optionalString stdenv.hostPlatform.isRiscV ''
73 # disable failing test:
75 # > dwfl_thread_getframes: No DWARF information found
76 sed -i s/run-backtrace-dwarf.sh//g tests/Makefile.in
86 # We need bzip2 in NativeInputs because otherwise we can't unpack the src,
87 # as the host-bzip2 will be in the path.
96 ++ lib.optional enableDebuginfod pkg-config
97 ++ lib.optional (stdenv.targetPlatform.useLLVM or false) autoreconfHook;
105 ++ lib.optionals stdenv.hostPlatform.isMusl [
110 ++ lib.optionals enableDebuginfod [
118 propagatedNativeBuildInputs = [ setupDebugInfoDirs ];
122 "--program-prefix=eu-" # prevent collisions with binutils
123 "--enable-deterministic-archives"
124 (lib.enableFeature enableDebuginfod "libdebuginfod")
125 (lib.enableFeature enableDebuginfod "debuginfod")
127 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101766
128 # Versioned symbols are nice to have, but we can do without.
129 (lib.enableFeature (!stdenv.hostPlatform.isMicroBlaze) "symbol-versioning")
131 ++ lib.optional (stdenv.targetPlatform.useLLVM or false) "--disable-demangler"
132 ++ lib.optionals stdenv.cc.isClang [
133 "CFLAGS=-Wno-unused-private-field"
134 "CXXFLAGS=-Wno-unused-private-field"
137 enableParallelBuilding = true;
140 # Backtrace unwinding tests rely on glibc-internal symbol names.
141 # Musl provides slightly different forms and fails.
142 # Let's disable tests there until musl support is fully upstreamed.
143 !stdenv.hostPlatform.isMusl
144 # Test suite tries using `uname` to determine whether certain tests
145 # can be executed, so we need to match build and host platform exactly.
146 && (stdenv.hostPlatform == stdenv.buildPlatform);
147 doInstallCheck = !stdenv.hostPlatform.isMusl && (stdenv.hostPlatform == stdenv.buildPlatform);
149 passthru.updateScript = gitUpdater {
150 url = "https://sourceware.org/git/elfutils.git";
151 rev-prefix = "elfutils-";
155 homepage = "https://sourceware.org/elfutils/";
156 description = "Set of utilities to handle ELF objects";
157 platforms = platforms.linux;
158 # https://lists.fedorahosted.org/pipermail/elfutils-devel/2014-November/004223.html
159 badPlatforms = [ lib.systems.inspect.platformPatterns.isStatic ];
160 # licenses are GPL2 or LGPL3+ for libraries, GPL3+ for bins,
161 # but since this package isn't split that way, all three are listed.
162 license = with licenses; [
167 maintainers = with maintainers; [ r-burns ];