1 |
commit: d465289bebb01cb8b90344996e9c4e0cd82b93eb |
2 |
Author: Sam James <sam <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sun Nov 7 06:42:40 2021 +0000 |
4 |
Commit: Sam James <sam <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun Nov 7 06:44:09 2021 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=d465289b |
7 |
|
8 |
dev-libs/elfutils: add musl support |
9 |
|
10 |
- Pull in patches and dependencies on libbsd and *-standalone from ::musl |
11 |
- Borrowed a patch or two from upstream elfutils (new release coming shortly) |
12 |
as well as Alpine Linux. |
13 |
|
14 |
Bug: https://bugs.gentoo.org/602126 |
15 |
Bug: https://bugs.gentoo.org/701478 |
16 |
Signed-off-by: Sam James <sam <AT> gentoo.org> |
17 |
|
18 |
dev-libs/elfutils/elfutils-0.185.ebuild | 10 +++ |
19 |
.../elfutils/files/musl/elfutils-0.185-cdefs.patch | 20 ++++++ |
20 |
.../files/musl/elfutils-0.185-error-h.patch | 83 +++++++++++++++++++++ |
21 |
.../files/musl/elfutils-0.185-macros.patch | 84 ++++++++++++++++++++++ |
22 |
.../files/musl/elfutils-0.185-strndupa.patch | 20 ++++++ |
23 |
profiles/features/musl/package.mask | 8 --- |
24 |
6 files changed, 217 insertions(+), 8 deletions(-) |
25 |
|
26 |
diff --git a/dev-libs/elfutils/elfutils-0.185.ebuild b/dev-libs/elfutils/elfutils-0.185.ebuild |
27 |
index a73fbfc0492..84df482f3f8 100644 |
28 |
--- a/dev-libs/elfutils/elfutils-0.185.ebuild |
29 |
+++ b/dev-libs/elfutils/elfutils-0.185.ebuild |
30 |
@@ -18,6 +18,12 @@ RDEPEND=">=sys-libs/zlib-1.2.8-r1[static-libs?,${MULTILIB_USEDEP}] |
31 |
bzip2? ( >=app-arch/bzip2-1.0.6-r4[static-libs?,${MULTILIB_USEDEP}] ) |
32 |
lzma? ( >=app-arch/xz-utils-5.0.5-r1[static-libs?,${MULTILIB_USEDEP}] ) |
33 |
zstd? ( app-arch/zstd:=[static-libs?,${MULTILIB_USEDEP}] ) |
34 |
+ elibc_musl? ( |
35 |
+ dev-libs/libbsd |
36 |
+ sys-libs/argp-standalone |
37 |
+ sys-libs/fts-standalone |
38 |
+ sys-libs/obstack-standalone |
39 |
+ ) |
40 |
!dev-libs/libelf |
41 |
" |
42 |
DEPEND="${RDEPEND} |
43 |
@@ -42,6 +48,10 @@ PATCHES=( |
44 |
src_prepare() { |
45 |
default |
46 |
|
47 |
+ if use elibc_musl; then |
48 |
+ eapply "${FILESDIR}"/musl/ |
49 |
+ fi |
50 |
+ |
51 |
if ! use static-libs; then |
52 |
sed -i -e '/^lib_LIBRARIES/s:=.*:=:' -e '/^%.os/s:%.o$::' lib{asm,dw,elf}/Makefile.in || die |
53 |
fi |
54 |
|
55 |
diff --git a/dev-libs/elfutils/files/musl/elfutils-0.185-cdefs.patch b/dev-libs/elfutils/files/musl/elfutils-0.185-cdefs.patch |
56 |
new file mode 100644 |
57 |
index 00000000000..42fc10945eb |
58 |
--- /dev/null |
59 |
+++ b/dev-libs/elfutils/files/musl/elfutils-0.185-cdefs.patch |
60 |
@@ -0,0 +1,20 @@ |
61 |
+From: Jory Pratt <anarchy@g.o> |
62 |
+Date: Thu, 12 Dec 2019 22:38:30 -0600 |
63 |
+Subject: [PATCH 3/3] Fix cdefs.h include for musl |
64 |
+ |
65 |
+--- a/lib/fixedsizehash.h |
66 |
++++ b/lib/fixedsizehash.h |
67 |
+@@ -30,8 +30,11 @@ |
68 |
+ #include <errno.h> |
69 |
+ #include <stdlib.h> |
70 |
+ #include <string.h> |
71 |
++#if !defined(__GLIBC__) |
72 |
++#include <bsd/sys/cdefs.h> |
73 |
++#else |
74 |
+ #include <sys/cdefs.h> |
75 |
+- |
76 |
++#endif |
77 |
+ #include <system.h> |
78 |
+ |
79 |
+ #ifdef __CONCAT |
80 |
+ |
81 |
|
82 |
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 |
83 |
new file mode 100644 |
84 |
index 00000000000..b9ee9b6e35a |
85 |
--- /dev/null |
86 |
+++ b/dev-libs/elfutils/files/musl/elfutils-0.185-error-h.patch |
87 |
@@ -0,0 +1,83 @@ |
88 |
+https://raw.githubusercontent.com/gentoo/musl/master/dev-libs/elfutils/files/0.178/musl-error_h.patch |
89 |
+ |
90 |
+From 9cb8fad40329cc6445233af0b6ac3f2adde19c65 Mon Sep 17 00:00:00 2001 |
91 |
+From: |
92 |
+Date: Thu, 12 Dec 2019 22:00:47 -0600 |
93 |
+Subject: [PATCH 9/9] Add hacked up error header for non GLIBC machines |
94 |
+ |
95 |
+--- |
96 |
+ lib/error.h | 27 +++++++++++++++++++++++++++ |
97 |
+ src/error.h | 27 +++++++++++++++++++++++++++ |
98 |
+ 2 files changed, 54 insertions(+) |
99 |
+ create mode 100644 lib/error.h |
100 |
+ create mode 100644 src/error.h |
101 |
+ |
102 |
+diff --git a/lib/error.h b/lib/error.h |
103 |
+new file mode 100644 |
104 |
+index 0000000..ef06827 |
105 |
+--- /dev/null |
106 |
++++ b/lib/error.h |
107 |
+@@ -0,0 +1,27 @@ |
108 |
++#ifndef _ERROR_H_ |
109 |
++#define _ERROR_H_ |
110 |
++ |
111 |
++#include <stdarg.h> |
112 |
++#include <stdio.h> |
113 |
++#include <stdlib.h> |
114 |
++#include <string.h> |
115 |
++#include <errno.h> |
116 |
++ |
117 |
++static unsigned int error_message_count = 0; |
118 |
++ |
119 |
++static inline void error(int status, int errnum, const char* format, ...) |
120 |
++{ |
121 |
++ va_list ap; |
122 |
++ fprintf(stderr, "%s: ", program_invocation_name); |
123 |
++ va_start(ap, format); |
124 |
++ vfprintf(stderr, format, ap); |
125 |
++ va_end(ap); |
126 |
++ if (errnum) |
127 |
++ fprintf(stderr, ": %s", strerror(errnum)); |
128 |
++ fprintf(stderr, "\n"); |
129 |
++ error_message_count++; |
130 |
++ if (status) |
131 |
++ exit(status); |
132 |
++} |
133 |
++ |
134 |
++#endif /* _ERROR_H_ */ |
135 |
+diff --git a/src/error.h b/src/error.h |
136 |
+new file mode 100644 |
137 |
+index 0000000..ef06827 |
138 |
+--- /dev/null |
139 |
++++ b/src/error.h |
140 |
+@@ -0,0 +1,27 @@ |
141 |
++#ifndef _ERROR_H_ |
142 |
++#define _ERROR_H_ |
143 |
++ |
144 |
++#include <stdarg.h> |
145 |
++#include <stdio.h> |
146 |
++#include <stdlib.h> |
147 |
++#include <string.h> |
148 |
++#include <errno.h> |
149 |
++ |
150 |
++static unsigned int error_message_count = 0; |
151 |
++ |
152 |
++static inline void error(int status, int errnum, const char* format, ...) |
153 |
++{ |
154 |
++ va_list ap; |
155 |
++ fprintf(stderr, "%s: ", program_invocation_name); |
156 |
++ va_start(ap, format); |
157 |
++ vfprintf(stderr, format, ap); |
158 |
++ va_end(ap); |
159 |
++ if (errnum) |
160 |
++ fprintf(stderr, ": %s", strerror(errnum)); |
161 |
++ fprintf(stderr, "\n"); |
162 |
++ error_message_count++; |
163 |
++ if (status) |
164 |
++ exit(status); |
165 |
++} |
166 |
++ |
167 |
++#endif /* _ERROR_H_ */ |
168 |
+-- |
169 |
+2.24.1 |
170 |
+ |
171 |
|
172 |
diff --git a/dev-libs/elfutils/files/musl/elfutils-0.185-macros.patch b/dev-libs/elfutils/files/musl/elfutils-0.185-macros.patch |
173 |
new file mode 100644 |
174 |
index 00000000000..3dbfdb6f7b3 |
175 |
--- /dev/null |
176 |
+++ b/dev-libs/elfutils/files/musl/elfutils-0.185-macros.patch |
177 |
@@ -0,0 +1,84 @@ |
178 |
+https://git.alpinelinux.org/aports/plain/main/elfutils/musl-macros.patch |
179 |
+--- a/src/arlib.h |
180 |
++++ b/src/arlib.h |
181 |
+@@ -29,6 +29,16 @@ |
182 |
+ #include <stdint.h> |
183 |
+ #include <sys/types.h> |
184 |
+ |
185 |
++#if !defined(ACCESSPERMS) |
186 |
++# define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO) /* 0777 */ |
187 |
++#endif |
188 |
++#if !defined(ALLPERMS) |
189 |
++# define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO) /* 07777 */ |
190 |
++#endif |
191 |
++#if !defined(DEFFILEMODE) |
192 |
++# define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)/* 0666*/ |
193 |
++#endif |
194 |
++ |
195 |
+ |
196 |
+ /* State of -D/-U flags. */ |
197 |
+ extern bool arlib_deterministic_output; |
198 |
+--- a/src/elfcompress.c |
199 |
++++ b/src/elfcompress.c |
200 |
+@@ -35,6 +35,14 @@ |
201 |
+ #include <gelf.h> |
202 |
+ #include "system.h" |
203 |
+ |
204 |
++#if !defined(FNM_EXTMATCH) |
205 |
++# define FNM_EXTMATCH 0 |
206 |
++#endif |
207 |
++ |
208 |
++#if !defined(ALLPERMS) |
209 |
++# define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO) /* 07777 */ |
210 |
++#endif |
211 |
++ |
212 |
+ /* Name and version of program. */ |
213 |
+ static void print_version (FILE *stream, struct argp_state *state); |
214 |
+ ARGP_PROGRAM_VERSION_HOOK_DEF = print_version; |
215 |
+--- a/lib/libeu.h |
216 |
++++ b/lib/libeu.h |
217 |
+@@ -31,6 +31,27 @@ |
218 |
+ |
219 |
+ #include <stddef.h> |
220 |
+ #include <stdint.h> |
221 |
++#include <unistd.h> |
222 |
++#include <alloca.h> |
223 |
++#include <string.h> |
224 |
++ |
225 |
++#ifndef TEMP_FAILURE_RETRY |
226 |
++#define TEMP_FAILURE_RETRY(expression) \ |
227 |
++ (__extension__ \ |
228 |
++ ({ long int __result; \ |
229 |
++ do __result = (long int) (expression); \ |
230 |
++ while (__result == -1L && errno == EINTR); \ |
231 |
++ __result; })) |
232 |
++#endif |
233 |
++ |
234 |
++#ifndef strndupa |
235 |
++#define strndupa(s, n) \ |
236 |
++ (__extension__ ({const char *__in = (s); \ |
237 |
++ size_t __len = strnlen (__in, (n)) + 1; \ |
238 |
++ char *__out = (char *) alloca (__len); \ |
239 |
++ __out[__len-1] = '\0'; \ |
240 |
++ (char *) memcpy (__out, __in, __len-1);})) |
241 |
++#endif |
242 |
+ |
243 |
+ extern void *xmalloc (size_t) __attribute__ ((__malloc__)); |
244 |
+ extern void *xcalloc (size_t, size_t) __attribute__ ((__malloc__)); |
245 |
+--- a/src/strip.c |
246 |
++++ b/src/strip.c |
247 |
+@@ -46,6 +46,14 @@ |
248 |
+ #include <system.h> |
249 |
+ #include <printversion.h> |
250 |
+ |
251 |
++#if !defined(FNM_EXTMATCH) |
252 |
++# define FNM_EXTMATCH 0 |
253 |
++#endif |
254 |
++ |
255 |
++#if !defined(ACCESSPERMS) |
256 |
++#define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO) |
257 |
++#endif |
258 |
++ |
259 |
+ typedef uint8_t GElf_Byte; |
260 |
+ |
261 |
+ /* Name and version of program. */ |
262 |
|
263 |
diff --git a/dev-libs/elfutils/files/musl/elfutils-0.185-strndupa.patch b/dev-libs/elfutils/files/musl/elfutils-0.185-strndupa.patch |
264 |
new file mode 100644 |
265 |
index 00000000000..4175e28fd62 |
266 |
--- /dev/null |
267 |
+++ b/dev-libs/elfutils/files/musl/elfutils-0.185-strndupa.patch |
268 |
@@ -0,0 +1,20 @@ |
269 |
+https://sourceware.org/git/?p=elfutils.git;a=commit;h=e7e4c92650892cf67210be5ea89ffba967427cbf |
270 |
+https://git.alpinelinux.org/aports/plain/main/elfutils/musl-strndupa.patch |
271 |
+--- a/src/unstrip.c |
272 |
++++ b/src/unstrip.c |
273 |
+@@ -56,6 +56,15 @@ |
274 |
+ # define _(str) gettext (str) |
275 |
+ #endif |
276 |
+ |
277 |
++#ifndef strndupa |
278 |
++#define strndupa(s, n) \ |
279 |
++ (__extension__ ({const char *__in = (s); \ |
280 |
++ size_t __len = strnlen (__in, (n)) + 1; \ |
281 |
++ char *__out = (char *) alloca (__len); \ |
282 |
++ __out[__len-1] = '\0'; \ |
283 |
++ (char *) memcpy (__out, __in, __len-1);})) |
284 |
++#endif |
285 |
++ |
286 |
+ /* Name and version of program. */ |
287 |
+ ARGP_PROGRAM_VERSION_HOOK_DEF = print_version; |
288 |
+ |
289 |
|
290 |
diff --git a/profiles/features/musl/package.mask b/profiles/features/musl/package.mask |
291 |
index 0dc88bebc59..bc9ffc405fa 100644 |
292 |
--- a/profiles/features/musl/package.mask |
293 |
+++ b/profiles/features/musl/package.mask |
294 |
@@ -31,14 +31,6 @@ sys-auth/libnss-nis |
295 |
# Needs a port no musl. Uses glibc-specific termio and __getppid. |
296 |
app-emulation/ski |
297 |
|
298 |
-# Sergei Trofimovich <slyfox@g.o> (2020-03-21) |
299 |
-# In ::gentoo dev-libs/elfutils needs an upstream port to |
300 |
-# musl: #602126, #701478 |
301 |
-# - https://sourceware.org/PR21002 |
302 |
-# - https://sourceware.org/PR21008 |
303 |
-# - https://sourceware.org/PR21010 |
304 |
-dev-libs/elfutils |
305 |
- |
306 |
# Sergei Trofimovich <slyfox@g.o> (2020-03-21) |
307 |
# Linux debugger needs a port to musl. |
308 |
app-emulation/dosemu |