From 1b6050092997d18ed12de84e746c0c2a43733db1 Mon Sep 17 00:00:00 2001 From: Peter Woodman Date: Thu, 21 Jan 2021 07:00:49 -0500 Subject: [PATCH] elfutils: 0.180 -> 0.182 + musl fixes --- .../tools/misc/elfutils/default.nix | 80 +++++++++++++++---- .../tools/misc/elfutils/musl-cdefs_h.patch | 15 ++++ .../tools/misc/elfutils/musl-error_h.patch | 66 +++++++++++++++ 3 files changed, 145 insertions(+), 16 deletions(-) create mode 100644 pkgs/development/tools/misc/elfutils/musl-cdefs_h.patch create mode 100644 pkgs/development/tools/misc/elfutils/musl-error_h.patch diff --git a/pkgs/development/tools/misc/elfutils/default.nix b/pkgs/development/tools/misc/elfutils/default.nix index 4ad7f830066..72c8c2fab91 100644 --- a/pkgs/development/tools/misc/elfutils/default.nix +++ b/pkgs/development/tools/misc/elfutils/default.nix @@ -1,47 +1,95 @@ -{ lib, stdenv, fetchurl, m4, zlib, bzip2, bison, flex, gettext, xz, setupDebugInfoDirs, argp-standalone }: +{ lib, stdenv, fetchurl, fetchpatch, pkg-config, autoreconfHook, musl-fts +, musl-obstack, m4, zlib, bzip2, bison, flex, gettext, xz, setupDebugInfoDirs +, argp-standalone }: # TODO: Look at the hardcoded paths to kernel, modules etc. stdenv.mkDerivation rec { pname = "elfutils"; - version = "0.180"; + version = "0.182"; src = fetchurl { url = "https://sourceware.org/elfutils/ftp/${version}/${pname}-${version}.tar.bz2"; - sha256 = "17an1f67bfzxin482nbcxdl5qvywm27i9kypjyx8ilarbkivc9xq"; + sha256 = "7MQGkU7fM18Lf8CE6+bEYMTW1Rdb/dZojBx42RRriFg="; }; - patches = [ ./debug-info-from-env.patch ]; + patches = [ + ./debug-info-from-env.patch + ./musl-cdefs_h.patch + (fetchpatch { + name = "fix-aarch64_fregs.patch"; + url = "https://git.alpinelinux.org/aports/plain/main/elfutils/fix-aarch64_fregs.patch?id=2e3d4976eeffb4704cf83e2cc3306293b7c7b2e9"; + sha256 = "zvncoRkQx3AwPx52ehjA2vcFroF+yDC2MQR5uS6DATs="; + }) + (fetchpatch { + name = "musl-asm-ptrace-h.patch"; + url = "https://git.alpinelinux.org/aports/plain/main/elfutils/musl-asm-ptrace-h.patch?id=2e3d4976eeffb4704cf83e2cc3306293b7c7b2e9"; + sha256 = "8D1wPcdgAkE/TNBOgsHaeTZYhd9l+9TrZg8d5C7kG6k="; + }) + (fetchpatch { + name = "musl-fts-obstack.patch"; + url = "https://git.alpinelinux.org/aports/plain/main/elfutils/musl-fts-obstack.patch?id=2e3d4976eeffb4704cf83e2cc3306293b7c7b2e9"; + sha256 = "3lbC0UtscTIJgT7kOXnnjWrpPAVt2PYMbW+uJK6K350="; + }) + (fetchpatch { + name = "musl-macros.patch"; + url = "https://git.alpinelinux.org/aports/plain/main/elfutils/musl-macros.patch?id=2e3d4976eeffb4704cf83e2cc3306293b7c7b2e9"; + sha256 = "tp6O1TRsTAMsFe8vw3LMENT/vAu6OmyA8+pzgThHeA8="; + }) + (fetchpatch { + name = "musl-qsort_r.patch"; + url = "https://git.alpinelinux.org/aports/plain/main/elfutils/musl-qsort_r.patch?id=2e3d4976eeffb4704cf83e2cc3306293b7c7b2e9"; + sha256 = "FPWCkdtFT3zw8aNnz0Jz5Vmu8B/mRfNgfhbM/ej7d8M="; + }) + (fetchpatch { + name = "musl-strerror_r.patch"; + url = "https://git.alpinelinux.org/aports/plain/main/elfutils/musl-strerror_r.patch?id=2e3d4976eeffb4704cf83e2cc3306293b7c7b2e9"; + sha256 = "QF6YwWkcT12dZHKzfqFgxy/1fkIllo0AAosbV0sM5PU="; + }) + (fetchpatch { + name = "musl-strndupa.patch"; + url = "https://git.alpinelinux.org/aports/plain/main/elfutils/musl-strndupa.patch?id=2e3d4976eeffb4704cf83e2cc3306293b7c7b2e9"; + sha256 = "sha256-7daehJj1t0wPtQzTv+/Rpuqqs5Ng/EYnZzrcf2o/Lb0="; + }) + ] ++ lib.optional stdenv.hostPlatform.isMusl [ ./musl-error_h.patch ]; hardeningDisable = [ "format" ]; # We need bzip2 in NativeInputs because otherwise we can't unpack the src, # as the host-bzip2 will be in the path. - nativeBuildInputs = [ m4 bison flex gettext bzip2 ]; + nativeBuildInputs = [ m4 bison flex gettext bzip2 ] + ++ lib.optional stdenv.hostPlatform.isMusl [ pkg-config autoreconfHook ]; buildInputs = [ zlib bzip2 xz ] - ++ lib.optional stdenv.hostPlatform.isMusl argp-standalone; + ++ lib.optional stdenv.hostPlatform.isMusl [ + argp-standalone + musl-fts + musl-obstack + ]; propagatedNativeBuildInputs = [ setupDebugInfoDirs ]; preConfigure = lib.optionalString stdenv.hostPlatform.isMusl '' - NIX_CFLAGS_COMPILE+=" -fgnu89-inline" + NIX_CFLAGS_COMPILE+=" -Wno-null-dereference" ''; - configureFlags = - [ "--program-prefix=eu-" # prevent collisions with binutils - "--enable-deterministic-archives" - "--disable-debuginfod" - ]; + configureFlags = [ + "--program-prefix=eu-" # prevent collisions with binutils + "--enable-deterministic-archives" + "--disable-libdebuginfod" + "--disable-debuginfod" + ]; enableParallelBuilding = true; doCheck = false; # fails 3 out of 174 tests doInstallCheck = false; # fails 70 out of 174 tests - meta = { + meta = with lib; { homepage = "https://sourceware.org/elfutils/"; description = "A set of utilities to handle ELF objects"; - platforms = lib.platforms.linux; - license = lib.licenses.gpl3; - maintainers = [ lib.maintainers.eelco ]; + platforms = platforms.linux; + # licenses are GPL2 or LGPL3+ for libraries, GPL3+ for bins, + # but since this package isn't split that way, all three are listed. + license = with licenses; [ gpl2Only lgpl3Plus gpl3Plus ]; + maintainers = [ maintainers.eelco ]; }; } diff --git a/pkgs/development/tools/misc/elfutils/musl-cdefs_h.patch b/pkgs/development/tools/misc/elfutils/musl-cdefs_h.patch new file mode 100644 index 00000000000..1b5bf466217 --- /dev/null +++ b/pkgs/development/tools/misc/elfutils/musl-cdefs_h.patch @@ -0,0 +1,15 @@ +# avoids a warning about including an internal header when +# compiling with musl-libc +diff -crb --new-file a/lib/fixedsizehash.h b/lib/fixedsizehash.h +*** a/lib/fixedsizehash.h 2020-06-11 11:37:46.000000000 -0400 +--- b/lib/fixedsizehash.h 2021-01-21 05:52:59.000000000 -0500 +*************** +*** 30,36 **** + #include + #include + #include +- #include + + #include + +--- 30,35 ---- diff --git a/pkgs/development/tools/misc/elfutils/musl-error_h.patch b/pkgs/development/tools/misc/elfutils/musl-error_h.patch new file mode 100644 index 00000000000..711928078d3 --- /dev/null +++ b/pkgs/development/tools/misc/elfutils/musl-error_h.patch @@ -0,0 +1,66 @@ +diff -crb --new-file a/lib/error.h b/lib/error.h +*** a/lib/error.h 1969-12-31 19:00:00.000000000 -0500 +--- b/lib/error.h 2021-01-21 04:38:25.000000000 -0500 +*************** +*** 0 **** +--- 1,27 ---- ++ #ifndef _ERROR_H_ ++ #define _ERROR_H_ ++ ++ #include ++ #include ++ #include ++ #include ++ #include ++ ++ static unsigned int error_message_count = 0; ++ ++ static inline void error(int status, int errnum, const char* format, ...) ++ { ++ va_list ap; ++ fprintf(stderr, "%s: ", program_invocation_name); ++ va_start(ap, format); ++ vfprintf(stderr, format, ap); ++ va_end(ap); ++ if (errnum) ++ fprintf(stderr, ": %s", strerror(errnum)); ++ fprintf(stderr, "\n"); ++ error_message_count++; ++ if (status) ++ exit(status); ++ } ++ ++ #endif /* _ERROR_H_ */ +diff -crb --new-file a/src/error.h b/src/error.h +*** a/src/error.h 1969-12-31 19:00:00.000000000 -0500 +--- b/src/error.h 2021-01-21 04:38:29.000000000 -0500 +*************** +*** 0 **** +--- 1,27 ---- ++ #ifndef _ERROR_H_ ++ #define _ERROR_H_ ++ ++ #include ++ #include ++ #include ++ #include ++ #include ++ ++ static unsigned int error_message_count = 0; ++ ++ static inline void error(int status, int errnum, const char* format, ...) ++ { ++ va_list ap; ++ fprintf(stderr, "%s: ", program_invocation_name); ++ va_start(ap, format); ++ vfprintf(stderr, format, ap); ++ va_end(ap); ++ if (errnum) ++ fprintf(stderr, ": %s", strerror(errnum)); ++ fprintf(stderr, "\n"); ++ error_message_count++; ++ if (status) ++ exit(status); ++ } ++ ++ #endif /* _ERROR_H_ */