at master 177 lines 5.3 kB view raw
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.193"; 32 33 src = fetchurl { 34 url = "https://sourceware.org/elfutils/ftp/${version}/${pname}-${version}.tar.bz2"; 35 hash = "sha256-eFf0S2JPTY1CHfhRqq57FALP5rzdLYBJ8V/AfT3edjU="; 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 ] 61 ++ lib.optionals stdenv.hostPlatform.isMusl [ ./musl-error_h.patch ]; 62 63 postPatch = '' 64 patchShebangs tests/*.sh 65 '' 66 + lib.optionalString stdenv.hostPlatform.isRiscV '' 67 # disable failing test: 68 # 69 # > dwfl_thread_getframes: No DWARF information found 70 sed -i s/run-backtrace-dwarf.sh//g tests/Makefile.in 71 ''; 72 73 outputs = [ 74 "bin" 75 "dev" 76 "out" 77 "man" 78 ]; 79 80 # We need bzip2 in NativeInputs because otherwise we can't unpack the src, 81 # as the host-bzip2 will be in the path. 82 nativeBuildInputs = [ 83 m4 84 bison 85 flex 86 gettext 87 bzip2 88 ] 89 ++ lib.optional enableDebuginfod pkg-config; 90 buildInputs = [ 91 zlib 92 zstd 93 bzip2 94 xz 95 ] 96 ++ lib.optionals stdenv.hostPlatform.isMusl [ 97 argp-standalone 98 musl-fts 99 musl-obstack 100 ] 101 ++ lib.optionals enableDebuginfod [ 102 sqlite 103 curl 104 json_c 105 libmicrohttpd 106 libarchive 107 ]; 108 109 propagatedNativeBuildInputs = [ setupDebugInfoDirs ]; 110 111 hardeningDisable = [ "strictflexarrays3" ]; 112 113 # build elfutils out-of-source-tree to avoid ./stack inclusion 114 # as a c++ header on libc++: https://sourceware.org/PR33103 115 preConfigure = 116 if (stdenv.targetPlatform.useLLVM or false) then 117 '' 118 mkdir build-tree 119 cd build-tree 120 '' 121 else 122 null; 123 configureScript = if (stdenv.targetPlatform.useLLVM or false) then "../configure" else null; 124 125 configureFlags = [ 126 "--program-prefix=eu-" # prevent collisions with binutils 127 "--enable-deterministic-archives" 128 (lib.enableFeature enableDebuginfod "libdebuginfod") 129 (lib.enableFeature enableDebuginfod "debuginfod") 130 131 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101766 132 # Versioned symbols are nice to have, but we can do without. 133 (lib.enableFeature (!stdenv.hostPlatform.isMicroBlaze) "symbol-versioning") 134 ] 135 ++ lib.optional (stdenv.targetPlatform.useLLVM or false) "--disable-demangler"; 136 137 enableParallelBuilding = true; 138 139 doCheck = 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); 148 149 preCheck = '' 150 # Workaround lack of rpath linking: 151 # ./dwarf_srclang_check: error while loading shared libraries: 152 # libelf.so.1: cannot open shared object file: No such file or directory 153 # Remove once https://sourceware.org/PR32929 is fixed. 154 export LD_LIBRARY_PATH="$PWD/libelf:$LD_LIBRARY_PATH" 155 ''; 156 157 passthru.updateScript = gitUpdater { 158 url = "https://sourceware.org/git/elfutils.git"; 159 rev-prefix = "elfutils-"; 160 }; 161 162 meta = with lib; { 163 homepage = "https://sourceware.org/elfutils/"; 164 description = "Set of utilities to handle ELF objects"; 165 platforms = platforms.linux; 166 # https://lists.fedorahosted.org/pipermail/elfutils-devel/2014-November/004223.html 167 badPlatforms = [ lib.systems.inspect.platformPatterns.isStatic ]; 168 # licenses are GPL2 or LGPL3+ for libraries, GPL3+ for bins, 169 # but since this package isn't split that way, all three are listed. 170 license = with licenses; [ 171 gpl2Only 172 lgpl3Plus 173 gpl3Plus 174 ]; 175 maintainers = with maintainers; [ r-burns ]; 176 }; 177}