public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] repo/gentoo:master commit in: dev-libs/elfutils/, dev-libs/elfutils/files/musl/, profiles/features/musl/
@ 2021-11-07  6:44 Sam James
  0 siblings, 0 replies; only message in thread
From: Sam James @ 2021-11-07  6:44 UTC (permalink / raw
  To: gentoo-commits

commit:     d465289bebb01cb8b90344996e9c4e0cd82b93eb
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sun Nov  7 06:42:40 2021 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Nov  7 06:44:09 2021 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=d465289b

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 <AT> gentoo.org>

 dev-libs/elfutils/elfutils-0.185.ebuild            | 10 +++
 .../elfutils/files/musl/elfutils-0.185-cdefs.patch | 20 ++++++
 .../files/musl/elfutils-0.185-error-h.patch        | 83 +++++++++++++++++++++
 .../files/musl/elfutils-0.185-macros.patch         | 84 ++++++++++++++++++++++
 .../files/musl/elfutils-0.185-strndupa.patch       | 20 ++++++
 profiles/features/musl/package.mask                |  8 ---
 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 a73fbfc0492..84df482f3f8 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 00000000000..42fc10945eb
--- /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 00000000000..b9ee9b6e35a
--- /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 00000000000..3dbfdb6f7b3
--- /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 00000000000..4175e28fd62
--- /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 0dc88bebc59..bc9ffc405fa 100644
--- a/profiles/features/musl/package.mask
+++ b/profiles/features/musl/package.mask
@@ -31,14 +31,6 @@ sys-auth/libnss-nis
 # Needs a port no musl. Uses glibc-specific termio and __getppid.
 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


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-11-07  6:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-07  6:44 [gentoo-commits] repo/gentoo:master commit in: dev-libs/elfutils/, dev-libs/elfutils/files/musl/, profiles/features/musl/ Sam James

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox