|
| 1 | +{ lib, stdenv, fetchurl, fetchpatch, pkg-config, musl-fts |
| 2 | +, musl-obstack, m4, zlib, zstd, bzip2, bison, flex, gettext, xz, setupDebugInfoDirs |
| 3 | +, argp-standalone |
| 4 | +, enableDebuginfod ? lib.meta.availableOn stdenv.hostPlatform libarchive, sqlite, curl, libmicrohttpd, libarchive |
| 5 | +, gitUpdater, autoreconfHook |
| 6 | +}: |
| 7 | + |
| 8 | +# TODO: Look at the hardcoded paths to kernel, modules etc. |
| 9 | +stdenv.mkDerivation rec { |
| 10 | + pname = "elfutils"; |
| 11 | + version = "0.191"; |
| 12 | + |
| 13 | + src = fetchurl { |
| 14 | + url = "https://sourceware.org/elfutils/ftp/${version}/${pname}-${version}.tar.bz2"; |
| 15 | + hash = "sha256-33bbcTZtHXCDZfx6bGDKSDmPFDZ+sriVTvyIlxR62HE="; |
| 16 | + }; |
| 17 | + |
| 18 | + postPatch = '' |
| 19 | + patchShebangs tests/*.sh |
| 20 | + '' + lib.optionalString stdenv.hostPlatform.isRiscV '' |
| 21 | + # disable failing test: |
| 22 | + # |
| 23 | + # > dwfl_thread_getframes: No DWARF information found |
| 24 | + sed -i s/run-backtrace-dwarf.sh//g tests/Makefile.in |
| 25 | + ''; |
| 26 | + |
| 27 | + outputs = [ "bin" "dev" "out" "man" ]; |
| 28 | + |
| 29 | + # We need bzip2 in NativeInputs because otherwise we can't unpack the src, |
| 30 | + # as the host-bzip2 will be in the path. |
| 31 | + nativeBuildInputs = [ m4 bison flex gettext bzip2 ] |
| 32 | + ++ lib.optional enableDebuginfod pkg-config |
| 33 | + ++ lib.optional (stdenv.targetPlatform.useLLVM or false) autoreconfHook; |
| 34 | + buildInputs = [ zlib zstd bzip2 xz ] |
| 35 | + ++ lib.optionals stdenv.hostPlatform.isMusl [ |
| 36 | + argp-standalone |
| 37 | + musl-fts |
| 38 | + musl-obstack |
| 39 | + ] ++ lib.optionals enableDebuginfod [ |
| 40 | + sqlite |
| 41 | + curl |
| 42 | + libmicrohttpd |
| 43 | + libarchive |
| 44 | + ]; |
| 45 | + |
| 46 | + propagatedNativeBuildInputs = [ setupDebugInfoDirs ]; |
| 47 | + |
| 48 | + configureFlags = [ |
| 49 | + "--program-prefix=eu-" # prevent collisions with binutils |
| 50 | + "--enable-deterministic-archives" |
| 51 | + (lib.enableFeature enableDebuginfod "libdebuginfod") |
| 52 | + (lib.enableFeature enableDebuginfod "debuginfod") |
| 53 | + |
| 54 | + # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101766 |
| 55 | + # Versioned symbols are nice to have, but we can do without. |
| 56 | + (lib.enableFeature (!stdenv.hostPlatform.isMicroBlaze) "symbol-versioning") |
| 57 | + ] ++ lib.optional (stdenv.targetPlatform.useLLVM or false) "--disable-demangler" |
| 58 | + ++ lib.optionals stdenv.cc.isClang [ |
| 59 | + "CFLAGS=-Wno-unused-private-field" |
| 60 | + "CXXFLAGS=-Wno-unused-private-field" |
| 61 | + ]; |
| 62 | + |
| 63 | + enableParallelBuilding = true; |
| 64 | + |
| 65 | + |
| 66 | + doCheck = |
| 67 | + # Backtrace unwinding tests rely on glibc-internal symbol names. |
| 68 | + # Musl provides slightly different forms and fails. |
| 69 | + # Let's disable tests there until musl support is fully upstreamed. |
| 70 | + !stdenv.hostPlatform.isMusl |
| 71 | + # Test suite tries using `uname` to determine whether certain tests |
| 72 | + # can be executed, so we need to match build and host platform exactly. |
| 73 | + && (stdenv.hostPlatform == stdenv.buildPlatform); |
| 74 | + doInstallCheck = !stdenv.hostPlatform.isMusl |
| 75 | + && (stdenv.hostPlatform == stdenv.buildPlatform); |
| 76 | + |
| 77 | + passthru.updateScript = gitUpdater { |
| 78 | + url = "https://sourceware.org/git/elfutils.git"; |
| 79 | + rev-prefix = "elfutils-"; |
| 80 | + }; |
| 81 | + |
| 82 | + meta = with lib; { |
| 83 | + homepage = "https://sourceware.org/elfutils/"; |
| 84 | + description = "Set of utilities to handle ELF objects"; |
| 85 | + platforms = platforms.linux; |
| 86 | + # https://lists.fedorahosted.org/pipermail/elfutils-devel/2014-November/004223.html |
| 87 | + badPlatforms = [ lib.systems.inspect.platformPatterns.isStatic ]; |
| 88 | + # licenses are GPL2 or LGPL3+ for libraries, GPL3+ for bins, |
| 89 | + # but since this package isn't split that way, all three are listed. |
| 90 | + license = with licenses; [ gpl2Only lgpl3Plus gpl3Plus ]; |
| 91 | + maintainers = with maintainers; [ r-burns ]; |
| 92 | + }; |
| 93 | +} |
0 commit comments