nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchurl,
5 fetchpatch,
6 pkg-config,
7 musl-fts,
8 musl-obstack,
9 m4,
10 zlib,
11 zstd,
12 bzip2,
13 bison,
14 flex,
15 gettext,
16 xz,
17 setupDebugInfoDirs,
18 argp-standalone,
19 enableDebuginfod ? lib.meta.availableOn stdenv.hostPlatform libarchive,
20 sqlite,
21 curl,
22 json_c,
23 libmicrohttpd,
24 libarchive,
25 gitUpdater,
26}:
27
28# TODO: Look at the hardcoded paths to kernel, modules etc.
29stdenv.mkDerivation rec {
30 pname = "elfutils";
31 version = "0.194";
32
33 src = fetchurl {
34 url = "https://sourceware.org/elfutils/ftp/${version}/${pname}-${version}.tar.bz2";
35 hash = "sha256-CeL/Az05uqiziKLX+8U5C/3pmuO3xnx9qvdDP7zw8B4=";
36 };
37
38 patches = [
39 ./debug-info-from-env.patch
40 (fetchpatch {
41 name = "fix-aarch64_fregs.patch";
42 url = "https://git.alpinelinux.org/aports/plain/main/elfutils/fix-aarch64_fregs.patch?id=2e3d4976eeffb4704cf83e2cc3306293b7c7b2e9";
43 sha256 = "zvncoRkQx3AwPx52ehjA2vcFroF+yDC2MQR5uS6DATs=";
44 })
45 (fetchpatch {
46 name = "musl-asm-ptrace-h.patch";
47 url = "https://git.alpinelinux.org/aports/plain/main/elfutils/musl-asm-ptrace-h.patch?id=2e3d4976eeffb4704cf83e2cc3306293b7c7b2e9";
48 sha256 = "8D1wPcdgAkE/TNBOgsHaeTZYhd9l+9TrZg8d5C7kG6k=";
49 })
50 (fetchpatch {
51 name = "musl-macros.patch";
52 url = "https://git.alpinelinux.org/aports/plain/main/elfutils/musl-macros.patch?id=2e3d4976eeffb4704cf83e2cc3306293b7c7b2e9";
53 sha256 = "tp6O1TRsTAMsFe8vw3LMENT/vAu6OmyA8+pzgThHeA8=";
54 })
55 (fetchpatch {
56 name = "musl-strndupa.patch";
57 url = "https://git.alpinelinux.org/aports/plain/main/elfutils/musl-strndupa.patch?id=2e3d4976eeffb4704cf83e2cc3306293b7c7b2e9";
58 sha256 = "sha256-7daehJj1t0wPtQzTv+/Rpuqqs5Ng/EYnZzrcf2o/Lb0=";
59 })
60 # https://patchwork.sourceware.org/project/elfutils/patch/20251205145241.1165646-1-arnout@bzzt.net/
61 ./test-run-sysroot-reliability.patch
62 ]
63 ++ lib.optionals stdenv.hostPlatform.isMusl [ ./musl-error_h.patch ];
64
65 postPatch = ''
66 patchShebangs tests/*.sh
67 ''
68 + lib.optionalString stdenv.hostPlatform.isRiscV ''
69 # disable failing test:
70 #
71 # > dwfl_thread_getframes: No DWARF information found
72 sed -i s/run-backtrace-dwarf.sh//g tests/Makefile.in
73 '';
74
75 outputs = [
76 "bin"
77 "dev"
78 "out"
79 "man"
80 ];
81
82 # We need bzip2 in NativeInputs because otherwise we can't unpack the src,
83 # as the host-bzip2 will be in the path.
84 nativeBuildInputs = [
85 m4
86 bison
87 flex
88 gettext
89 bzip2
90 ]
91 ++ lib.optional enableDebuginfod pkg-config;
92 buildInputs = [
93 zlib
94 zstd
95 bzip2
96 xz
97 ]
98 ++ lib.optionals stdenv.hostPlatform.isMusl [
99 argp-standalone
100 musl-fts
101 musl-obstack
102 ]
103 ++ lib.optionals enableDebuginfod [
104 sqlite
105 curl
106 json_c
107 libmicrohttpd
108 libarchive
109 ];
110
111 propagatedNativeBuildInputs = [ setupDebugInfoDirs ];
112
113 hardeningDisable = [ "strictflexarrays3" ];
114
115 configureFlags = [
116 "--program-prefix=eu-" # prevent collisions with binutils
117 "--enable-deterministic-archives"
118 (lib.enableFeature enableDebuginfod "libdebuginfod")
119 (lib.enableFeature enableDebuginfod "debuginfod")
120
121 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101766
122 # Versioned symbols are nice to have, but we can do without.
123 (lib.enableFeature (!stdenv.hostPlatform.isMicroBlaze) "symbol-versioning")
124 ]
125 ++ lib.optional (stdenv.targetPlatform.useLLVM or false) "--disable-demangler";
126
127 enableParallelBuilding = true;
128
129 doCheck =
130 # Backtrace unwinding tests rely on glibc-internal symbol names.
131 # Musl provides slightly different forms and fails.
132 # Let's disable tests there until musl support is fully upstreamed.
133 !stdenv.hostPlatform.isMusl
134 # Test suite tries using `uname` to determine whether certain tests
135 # can be executed, so we need to match build and host platform exactly.
136 && (stdenv.hostPlatform == stdenv.buildPlatform);
137 doInstallCheck = !stdenv.hostPlatform.isMusl && (stdenv.hostPlatform == stdenv.buildPlatform);
138
139 passthru.updateScript = gitUpdater {
140 url = "https://sourceware.org/git/elfutils.git";
141 rev-prefix = "elfutils-";
142 };
143
144 meta = {
145 homepage = "https://sourceware.org/elfutils/";
146 description = "Set of utilities to handle ELF objects";
147 platforms = lib.platforms.linux;
148 # https://lists.fedorahosted.org/pipermail/elfutils-devel/2014-November/004223.html
149 badPlatforms = [ lib.systems.inspect.platformPatterns.isStatic ];
150 # licenses are GPL2 or LGPL3+ for libraries, GPL3+ for bins,
151 # but since this package isn't split that way, all three are listed.
152 license = with lib.licenses; [
153 gpl2Only
154 lgpl3Plus
155 gpl3Plus
156 ];
157 maintainers = with lib.maintainers; [ r-burns ];
158 };
159}