summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam James <sam@gentoo.org>2021-11-07 06:42:40 +0000
committerSam James <sam@gentoo.org>2021-11-07 06:44:09 +0000
commitd465289bebb01cb8b90344996e9c4e0cd82b93eb (patch)
tree9e0f49fa1413c0306483612b20bd819bfc766cb1
parentmedia-gfx/exiv2: x86 stable wrt bug #822198 (diff)
downloadgentoo-d465289bebb01cb8b90344996e9c4e0cd82b93eb.tar.gz
gentoo-d465289bebb01cb8b90344996e9c4e0cd82b93eb.tar.bz2
gentoo-d465289bebb01cb8b90344996e9c4e0cd82b93eb.zip
dev-libs/elfutils: add musl support
- Pull in patches and dependencies on libbsd and *-standalone from ::musl - Borrowed a patch or two from upstream elfutils (new release coming shortly) as well as Alpine Linux. Bug: https://bugs.gentoo.org/602126 Bug: https://bugs.gentoo.org/701478 Signed-off-by: Sam James <sam@gentoo.org>
-rw-r--r--dev-libs/elfutils/elfutils-0.185.ebuild10
-rw-r--r--dev-libs/elfutils/files/musl/elfutils-0.185-cdefs.patch20
-rw-r--r--dev-libs/elfutils/files/musl/elfutils-0.185-error-h.patch83
-rw-r--r--dev-libs/elfutils/files/musl/elfutils-0.185-macros.patch84
-rw-r--r--dev-libs/elfutils/files/musl/elfutils-0.185-strndupa.patch20
-rw-r--r--profiles/features/musl/package.mask8
6 files changed, 217 insertions, 8 deletions
diff --git a/dev-libs/elfutils/elfutils-0.185.ebuild b/dev-libs/elfutils/elfutils-0.185.ebuild
index a73fbfc04925..84df482f3f86 100644
--- a/dev-libs/elfutils/elfutils-0.185.ebuild
+++ b/dev-libs/elfutils/elfutils-0.185.ebuild
@@ -18,6 +18,12 @@ RDEPEND=">=sys-libs/zlib-1.2.8-r1[static-libs?,${MULTILIB_USEDEP}]
bzip2? ( >=app-arch/bzip2-1.0.6-r4[static-libs?,${MULTILIB_USEDEP}] )
lzma? ( >=app-arch/xz-utils-5.0.5-r1[static-libs?,${MULTILIB_USEDEP}] )
zstd? ( app-arch/zstd:=[static-libs?,${MULTILIB_USEDEP}] )
+ elibc_musl? (
+ dev-libs/libbsd
+ sys-libs/argp-standalone
+ sys-libs/fts-standalone
+ sys-libs/obstack-standalone
+ )
!dev-libs/libelf
"
DEPEND="${RDEPEND}
@@ -42,6 +48,10 @@ PATCHES=(
src_prepare() {
default
+ if use elibc_musl; then
+ eapply "${FILESDIR}"/musl/
+ fi
+
if ! use static-libs; then
sed -i -e '/^lib_LIBRARIES/s:=.*:=:' -e '/^%.os/s:%.o$::' lib{asm,dw,elf}/Makefile.in || die
fi
diff --git a/dev-libs/elfutils/files/musl/elfutils-0.185-cdefs.patch b/dev-libs/elfutils/files/musl/elfutils-0.185-cdefs.patch
new file mode 100644
index 000000000000..42fc10945ebe
--- /dev/null
+++ b/dev-libs/elfutils/files/musl/elfutils-0.185-cdefs.patch
@@ -0,0 +1,20 @@
+From: Jory Pratt <anarchy@gentoo.org>
+Date: Thu, 12 Dec 2019 22:38:30 -0600
+Subject: [PATCH 3/3] Fix cdefs.h include for musl
+
+--- a/lib/fixedsizehash.h
++++ b/lib/fixedsizehash.h
+@@ -30,8 +30,11 @@
+ #include <errno.h>
+ #include <stdlib.h>
+ #include <string.h>
++#if !defined(__GLIBC__)
++#include <bsd/sys/cdefs.h>
++#else
+ #include <sys/cdefs.h>
+-
++#endif
+ #include <system.h>
+
+ #ifdef __CONCAT
+
diff --git a/dev-libs/elfutils/files/musl/elfutils-0.185-error-h.patch b/dev-libs/elfutils/files/musl/elfutils-0.185-error-h.patch
new file mode 100644
index 000000000000..b9ee9b6e35ab
--- /dev/null
+++ b/dev-libs/elfutils/files/musl/elfutils-0.185-error-h.patch
@@ -0,0 +1,83 @@
+https://raw.githubusercontent.com/gentoo/musl/master/dev-libs/elfutils/files/0.178/musl-error_h.patch
+
+From 9cb8fad40329cc6445233af0b6ac3f2adde19c65 Mon Sep 17 00:00:00 2001
+From:
+Date: Thu, 12 Dec 2019 22:00:47 -0600
+Subject: [PATCH 9/9] Add hacked up error header for non GLIBC machines
+
+---
+ lib/error.h | 27 +++++++++++++++++++++++++++
+ src/error.h | 27 +++++++++++++++++++++++++++
+ 2 files changed, 54 insertions(+)
+ create mode 100644 lib/error.h
+ create mode 100644 src/error.h
+
+diff --git a/lib/error.h b/lib/error.h
+new file mode 100644
+index 0000000..ef06827
+--- /dev/null
++++ b/lib/error.h
+@@ -0,0 +1,27 @@
++#ifndef _ERROR_H_
++#define _ERROR_H_
++
++#include <stdarg.h>
++#include <stdio.h>
++#include <stdlib.h>
++#include <string.h>
++#include <errno.h>
++
++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 --git a/src/error.h b/src/error.h
+new file mode 100644
+index 0000000..ef06827
+--- /dev/null
++++ b/src/error.h
+@@ -0,0 +1,27 @@
++#ifndef _ERROR_H_
++#define _ERROR_H_
++
++#include <stdarg.h>
++#include <stdio.h>
++#include <stdlib.h>
++#include <string.h>
++#include <errno.h>
++
++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_ */
+--
+2.24.1
+
diff --git a/dev-libs/elfutils/files/musl/elfutils-0.185-macros.patch b/dev-libs/elfutils/files/musl/elfutils-0.185-macros.patch
new file mode 100644
index 000000000000..3dbfdb6f7b31
--- /dev/null
+++ b/dev-libs/elfutils/files/musl/elfutils-0.185-macros.patch
@@ -0,0 +1,84 @@
+https://git.alpinelinux.org/aports/plain/main/elfutils/musl-macros.patch
+--- a/src/arlib.h
++++ b/src/arlib.h
+@@ -29,6 +29,16 @@
+ #include <stdint.h>
+ #include <sys/types.h>
+
++#if !defined(ACCESSPERMS)
++# define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO) /* 0777 */
++#endif
++#if !defined(ALLPERMS)
++# define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO) /* 07777 */
++#endif
++#if !defined(DEFFILEMODE)
++# define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)/* 0666*/
++#endif
++
+
+ /* State of -D/-U flags. */
+ extern bool arlib_deterministic_output;
+--- a/src/elfcompress.c
++++ b/src/elfcompress.c
+@@ -35,6 +35,14 @@
+ #include <gelf.h>
+ #include "system.h"
+
++#if !defined(FNM_EXTMATCH)
++# define FNM_EXTMATCH 0
++#endif
++
++#if !defined(ALLPERMS)
++# define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO) /* 07777 */
++#endif
++
+ /* Name and version of program. */
+ static void print_version (FILE *stream, struct argp_state *state);
+ ARGP_PROGRAM_VERSION_HOOK_DEF = print_version;
+--- a/lib/libeu.h
++++ b/lib/libeu.h
+@@ -31,6 +31,27 @@
+
+ #include <stddef.h>
+ #include <stdint.h>
++#include <unistd.h>
++#include <alloca.h>
++#include <string.h>
++
++#ifndef TEMP_FAILURE_RETRY
++#define TEMP_FAILURE_RETRY(expression) \
++ (__extension__ \
++ ({ long int __result; \
++ do __result = (long int) (expression); \
++ while (__result == -1L && errno == EINTR); \
++ __result; }))
++#endif
++
++#ifndef strndupa
++#define strndupa(s, n) \
++ (__extension__ ({const char *__in = (s); \
++ size_t __len = strnlen (__in, (n)) + 1; \
++ char *__out = (char *) alloca (__len); \
++ __out[__len-1] = '\0'; \
++ (char *) memcpy (__out, __in, __len-1);}))
++#endif
+
+ extern void *xmalloc (size_t) __attribute__ ((__malloc__));
+ extern void *xcalloc (size_t, size_t) __attribute__ ((__malloc__));
+--- a/src/strip.c
++++ b/src/strip.c
+@@ -46,6 +46,14 @@
+ #include <system.h>
+ #include <printversion.h>
+
++#if !defined(FNM_EXTMATCH)
++# define FNM_EXTMATCH 0
++#endif
++
++#if !defined(ACCESSPERMS)
++#define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO)
++#endif
++
+ typedef uint8_t GElf_Byte;
+
+ /* Name and version of program. */
diff --git a/dev-libs/elfutils/files/musl/elfutils-0.185-strndupa.patch b/dev-libs/elfutils/files/musl/elfutils-0.185-strndupa.patch
new file mode 100644
index 000000000000..4175e28fd62f
--- /dev/null
+++ b/dev-libs/elfutils/files/musl/elfutils-0.185-strndupa.patch
@@ -0,0 +1,20 @@
+https://sourceware.org/git/?p=elfutils.git;a=commit;h=e7e4c92650892cf67210be5ea89ffba967427cbf
+https://git.alpinelinux.org/aports/plain/main/elfutils/musl-strndupa.patch
+--- a/src/unstrip.c
++++ b/src/unstrip.c
+@@ -56,6 +56,15 @@
+ # define _(str) gettext (str)
+ #endif
+
++#ifndef strndupa
++#define strndupa(s, n) \
++ (__extension__ ({const char *__in = (s); \
++ size_t __len = strnlen (__in, (n)) + 1; \
++ char *__out = (char *) alloca (__len); \
++ __out[__len-1] = '\0'; \
++ (char *) memcpy (__out, __in, __len-1);}))
++#endif
++
+ /* Name and version of program. */
+ ARGP_PROGRAM_VERSION_HOOK_DEF = print_version;
+
diff --git a/profiles/features/musl/package.mask b/profiles/features/musl/package.mask
index 0dc88bebc590..bc9ffc405fad 100644
--- a/profiles/features/musl/package.mask
+++ b/profiles/features/musl/package.mask
@@ -32,14 +32,6 @@ sys-auth/libnss-nis
app-emulation/ski
# Sergei Trofimovich <slyfox@gentoo.org> (2020-03-21)
-# In ::gentoo dev-libs/elfutils needs an upstream port to
-# musl: #602126, #701478
-# - https://sourceware.org/PR21002
-# - https://sourceware.org/PR21008
-# - https://sourceware.org/PR21010
-dev-libs/elfutils
-
-# Sergei Trofimovich <slyfox@gentoo.org> (2020-03-21)
# Linux debugger needs a port to musl.
app-emulation/dosemu