1 |
commit: 880cd44162831d473af1c08b9ec604beb8f07153 |
2 |
Author: Andreas K. Hüttel <dilfridge <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sun Apr 28 19:36:48 2019 +0000 |
4 |
Commit: Andreas K. Hüttel <dilfridge <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun Apr 28 19:36:48 2019 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/riscv.git/commit/?id=880cd441 |
7 |
|
8 |
sys-libs/glibc: Copy unmodified from main tree |
9 |
|
10 |
Package-Manager: Portage-2.3.64, Repoman-2.3.12 |
11 |
Signed-off-by: Andreas K. Hüttel <dilfridge <AT> gentoo.org> |
12 |
|
13 |
sys-libs/glibc/Manifest | 3 + |
14 |
.../glibc-2.19-hardened-configure-picdefault.patch | 30 + |
15 |
.../2.19/glibc-2.19-ia64-gcc-4.8-reloc-hack.patch | 32 + |
16 |
.../glibc/files/2.25/glibc-2.25-gentoo-chk_fail.c | 303 ++++ |
17 |
sys-libs/glibc/files/nscd.service | 15 + |
18 |
sys-libs/glibc/files/nscd.tmpfilesd | 4 + |
19 |
sys-libs/glibc/glibc-2.29-r2.ebuild | 1448 ++++++++++++++++++++ |
20 |
sys-libs/glibc/metadata.xml | 21 + |
21 |
8 files changed, 1856 insertions(+) |
22 |
|
23 |
diff --git a/sys-libs/glibc/Manifest b/sys-libs/glibc/Manifest |
24 |
new file mode 100644 |
25 |
index 0000000..f75ed28 |
26 |
--- /dev/null |
27 |
+++ b/sys-libs/glibc/Manifest |
28 |
@@ -0,0 +1,3 @@ |
29 |
+DIST gcc-multilib-bootstrap-20180511.tar.xz 2392908 BLAKE2B f3cf614399368acd8908f60d894c6344a2fa09383b30c1633a0682bc668367c8a2f8c6fec2d41b6e2178d709a2bd8db57e8b2ab56ba263c7d56f819c15acd061 SHA512 98c766e913693ab42ff790557acde2a36a8001e2648046a685b21964200df8d4d52d8452d499c0068c6648284d086ce062c2d36e2c6c2fd8aacd232d193f2853 |
30 |
+DIST glibc-2.29-patches-3.tar.xz 35812 BLAKE2B 90b8bc57b7a63f03617795c368b92e525eccfec462d638dbc25c581e5b7a2a72ffd5191842f5ac443a868cbc950838d7e5120e866d343a14b80c55dcbfa48f30 SHA512 4c9b78d9d1a8aa629418f2d758ef800857780b8a1fd8d3582b88348a513ca26ca7f6ac9110a8c6bae16949b360ba36840d184f42293cd4324760273592d1b438 |
31 |
+DIST glibc-2.29.tar.xz 16515488 BLAKE2B b754e6825176538a2b8ca03fce014f0d87d333dc4d038bf0cda5ee8a2f484cd3ce93ad78ec126737e093ab64b55ceedf04cd08aecb4f8041daaa329e99717afa SHA512 146bc0769fe853d9edbf93cea7f74c5b3d84d69cb7614c62588e7acdecd1ec789a9d8949f3e8b99f8f36f2ccac740a003bed94f32b07817baf780b06cfeb6ed0 |
32 |
|
33 |
diff --git a/sys-libs/glibc/files/2.19/glibc-2.19-hardened-configure-picdefault.patch b/sys-libs/glibc/files/2.19/glibc-2.19-hardened-configure-picdefault.patch |
34 |
new file mode 100644 |
35 |
index 0000000..341d8c5 |
36 |
--- /dev/null |
37 |
+++ b/sys-libs/glibc/files/2.19/glibc-2.19-hardened-configure-picdefault.patch |
38 |
@@ -0,0 +1,30 @@ |
39 |
+Prevent default-fPIE from confusing configure into thinking |
40 |
+PIC code is default. This causes glibc to build both PIC and |
41 |
+non-PIC code as normal, which on the hardened compiler generates |
42 |
+PIC and PIE. |
43 |
+ |
44 |
+Patch by Kevin F. Quinn <kevquinn@g.o> |
45 |
+Fixed for glibc 2.19 by Magnus Granberg <zorry@×××.nu> |
46 |
+ |
47 |
+--- configure.ac |
48 |
++++ configure.ac |
49 |
+@@ -2145,7 +2145,7 @@ |
50 |
+ # error PIC is default. |
51 |
+ #endif |
52 |
+ EOF |
53 |
+-if eval "${CC-cc} -S conftest.c 2>&AS_MESSAGE_LOG_FD 1>&AS_MESSAGE_LOG_FD"; then |
54 |
++if eval "${CC-cc} -fno-PIE -S conftest.c 2>&AS_MESSAGE_LOG_FD 1>&AS_MESSAGE_LOG_FD"; then |
55 |
+ libc_cv_pic_default=no |
56 |
+ fi |
57 |
+ rm -f conftest.*]) |
58 |
+--- configure |
59 |
++++ configure |
60 |
+@@ -7698,7 +7698,7 @@ |
61 |
+ # error PIC is default. |
62 |
+ #endif |
63 |
+ EOF |
64 |
+-if eval "${CC-cc} -S conftest.c 2>&5 1>&5"; then |
65 |
++if eval "${CC-cc} -fno-PIE -S conftest.c 2>&5 1>&5"; then |
66 |
+ libc_cv_pic_default=no |
67 |
+ fi |
68 |
+ rm -f conftest.* |
69 |
|
70 |
diff --git a/sys-libs/glibc/files/2.19/glibc-2.19-ia64-gcc-4.8-reloc-hack.patch b/sys-libs/glibc/files/2.19/glibc-2.19-ia64-gcc-4.8-reloc-hack.patch |
71 |
new file mode 100644 |
72 |
index 0000000..72a616a |
73 |
--- /dev/null |
74 |
+++ b/sys-libs/glibc/files/2.19/glibc-2.19-ia64-gcc-4.8-reloc-hack.patch |
75 |
@@ -0,0 +1,32 @@ |
76 |
+https://bugs.gentoo.org/503838 |
77 |
+http://gcc.gnu.org/PR60465 |
78 |
+https://sourceware.org/ml/libc-alpha/2015-12/msg00556.html |
79 |
+https://trofi.github.io/posts/189-glibc-on-ia64-or-how-relocations-bootstrap.html |
80 |
+ |
81 |
+newer versions of gcc generate relocations in the elf_get_dynamic_info func |
82 |
+which glibc relies on to populate some info structs. those structs are then |
83 |
+used by ldso to process relocations in itself. glibc requires that there are |
84 |
+no relocations until that point (*after* elf_get_dynamic_info), so we end up |
85 |
+crashing during elf_get_dynamic_info because the relocation has not yet been |
86 |
+processed. |
87 |
+ |
88 |
+this hack shuffles the code in a way that tricks gcc into not generating the |
89 |
+relocation. we need to figure out something better for upstream. |
90 |
+ |
91 |
+--- a/elf/get-dynamic-info.h |
92 |
++++ b/elf/get-dynamic-info.h |
93 |
+@@ -66,8 +66,12 @@ elf_get_dynamic_info (struct link_map *l, ElfW(Dyn) *temp) |
94 |
+ info[DT_VALTAGIDX (dyn->d_tag) + DT_NUM + DT_THISPROCNUM |
95 |
+ + DT_VERSIONTAGNUM + DT_EXTRANUM] = dyn; |
96 |
+ else if ((d_tag_utype) DT_ADDRTAGIDX (dyn->d_tag) < DT_ADDRNUM) |
97 |
+- info[DT_ADDRTAGIDX (dyn->d_tag) + DT_NUM + DT_THISPROCNUM |
98 |
+- + DT_VERSIONTAGNUM + DT_EXTRANUM + DT_VALNUM] = dyn; |
99 |
++ { |
100 |
++ d_tag_utype i = |
101 |
++ DT_ADDRTAGIDX (dyn->d_tag) + DT_NUM + DT_THISPROCNUM |
102 |
++ + DT_VERSIONTAGNUM + DT_EXTRANUM + DT_VALNUM; |
103 |
++ info[i] = dyn; |
104 |
++ } |
105 |
+ ++dyn; |
106 |
+ } |
107 |
+ |
108 |
|
109 |
diff --git a/sys-libs/glibc/files/2.25/glibc-2.25-gentoo-chk_fail.c b/sys-libs/glibc/files/2.25/glibc-2.25-gentoo-chk_fail.c |
110 |
new file mode 100644 |
111 |
index 0000000..2ef96b7 |
112 |
--- /dev/null |
113 |
+++ b/sys-libs/glibc/files/2.25/glibc-2.25-gentoo-chk_fail.c |
114 |
@@ -0,0 +1,303 @@ |
115 |
+/* Copyright (C) 2004-2014 Free Software Foundation, Inc. |
116 |
+ Copyright (C) 2006-2014 Gentoo Foundation Inc. |
117 |
+ This file is part of the GNU C Library. |
118 |
+ |
119 |
+ The GNU C Library is free software; you can redistribute it and/or |
120 |
+ modify it under the terms of the GNU Lesser General Public |
121 |
+ License as published by the Free Software Foundation; either |
122 |
+ version 2.1 of the License, or (at your option) any later version. |
123 |
+ |
124 |
+ The GNU C Library is distributed in the hope that it will be useful, |
125 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of |
126 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
127 |
+ Lesser General Public License for more details. |
128 |
+ |
129 |
+ You should have received a copy of the GNU Lesser General Public |
130 |
+ License along with the GNU C Library; if not, write to the Free |
131 |
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
132 |
+ 02111-1307 USA. */ |
133 |
+ |
134 |
+/* Hardened Gentoo SSP and FORTIFY handler |
135 |
+ |
136 |
+ A failure handler that does not use functions from the rest of glibc; |
137 |
+ it uses the INTERNAL_SYSCALL methods directly. This helps ensure no |
138 |
+ possibility of recursion into the handler. |
139 |
+ |
140 |
+ Direct all bug reports to http://bugs.gentoo.org/ |
141 |
+ |
142 |
+ People who have contributed significantly to the evolution of this file: |
143 |
+ Ned Ludd - <solar[@]gentoo.org> |
144 |
+ Alexander Gabert - <pappy[@]gentoo.org> |
145 |
+ The PaX Team - <pageexec[@]freemail.hu> |
146 |
+ Peter S. Mazinger - <ps.m[@]gmx.net> |
147 |
+ Yoann Vandoorselaere - <yoann[@]prelude-ids.org> |
148 |
+ Robert Connolly - <robert[@]linuxfromscratch.org> |
149 |
+ Cory Visi <cory[@]visi.name> |
150 |
+ Mike Frysinger <vapier[@]gentoo.org> |
151 |
+ Magnus Granberg <zorry[@]gentoo.org> |
152 |
+ Kevin F. Quinn - <kevquinn[@]gentoo.org> |
153 |
+ */ |
154 |
+ |
155 |
+#include <errno.h> |
156 |
+#include <stdio.h> |
157 |
+#include <stdlib.h> |
158 |
+#include <unistd.h> |
159 |
+#include <signal.h> |
160 |
+ |
161 |
+#include <sys/types.h> |
162 |
+ |
163 |
+#include <sysdep-cancel.h> |
164 |
+#include <sys/syscall.h> |
165 |
+ |
166 |
+#include <kernel-features.h> |
167 |
+ |
168 |
+#include <alloca.h> |
169 |
+/* from sysdeps */ |
170 |
+#include <socketcall.h> |
171 |
+/* for the stuff in bits/socket.h */ |
172 |
+#include <sys/socket.h> |
173 |
+#include <sys/un.h> |
174 |
+ |
175 |
+/* Sanity check on SYSCALL macro names - force compilation |
176 |
+ * failure if the names used here do not exist |
177 |
+ */ |
178 |
+#if !defined __NR_socketcall && !defined __NR_socket |
179 |
+# error Cannot do syscall socket or socketcall |
180 |
+#endif |
181 |
+#if !defined __NR_socketcall && !defined __NR_connect |
182 |
+# error Cannot do syscall connect or socketcall |
183 |
+#endif |
184 |
+#ifndef __NR_write |
185 |
+# error Cannot do syscall write |
186 |
+#endif |
187 |
+#ifndef __NR_close |
188 |
+# error Cannot do syscall close |
189 |
+#endif |
190 |
+#ifndef __NR_getpid |
191 |
+# error Cannot do syscall getpid |
192 |
+#endif |
193 |
+#ifndef __NR_kill |
194 |
+# error Cannot do syscall kill |
195 |
+#endif |
196 |
+#ifndef __NR_exit |
197 |
+# error Cannot do syscall exit |
198 |
+#endif |
199 |
+#ifdef SSP_SMASH_DUMPS_CORE |
200 |
+# define ENABLE_SSP_SMASH_DUMPS_CORE 1 |
201 |
+# if !defined _KERNEL_NSIG && !defined _NSIG |
202 |
+# error No _NSIG or _KERNEL_NSIG for rt_sigaction |
203 |
+# endif |
204 |
+# if !defined __NR_sigaction && !defined __NR_rt_sigaction |
205 |
+# error Cannot do syscall sigaction or rt_sigaction |
206 |
+# endif |
207 |
+/* Although rt_sigaction expects sizeof(sigset_t) - it expects the size |
208 |
+ * of the _kernel_ sigset_t which is not the same as the user sigset_t. |
209 |
+ * Most arches have this as _NSIG bits - mips has _KERNEL_NSIG bits for |
210 |
+ * some reason. |
211 |
+ */ |
212 |
+# ifdef _KERNEL_NSIG |
213 |
+# define _SSP_NSIG _KERNEL_NSIG |
214 |
+# else |
215 |
+# define _SSP_NSIG _NSIG |
216 |
+# endif |
217 |
+#else |
218 |
+# define _SSP_NSIG 0 |
219 |
+# define ENABLE_SSP_SMASH_DUMPS_CORE 0 |
220 |
+#endif |
221 |
+ |
222 |
+/* Define DO_SIGACTION - default to newer rt signal interface but |
223 |
+ * fallback to old as needed. |
224 |
+ */ |
225 |
+#ifdef __NR_rt_sigaction |
226 |
+# define DO_SIGACTION(signum, act, oldact) \ |
227 |
+ INLINE_SYSCALL(rt_sigaction, 4, signum, act, oldact, _SSP_NSIG/8) |
228 |
+#else |
229 |
+# define DO_SIGACTION(signum, act, oldact) \ |
230 |
+ INLINE_SYSCALL(sigaction, 3, signum, act, oldact) |
231 |
+#endif |
232 |
+ |
233 |
+/* Define DO_SOCKET/DO_CONNECT functions to deal with socketcall vs socket/connect */ |
234 |
+#if defined(__NR_socket) && defined(__NR_connect) |
235 |
+# define USE_OLD_SOCKETCALL 0 |
236 |
+#else |
237 |
+# define USE_OLD_SOCKETCALL 1 |
238 |
+#endif |
239 |
+ |
240 |
+/* stub out the __NR_'s so we can let gcc optimize away dead code */ |
241 |
+#ifndef __NR_socketcall |
242 |
+# define __NR_socketcall 0 |
243 |
+#endif |
244 |
+#ifndef __NR_socket |
245 |
+# define __NR_socket 0 |
246 |
+#endif |
247 |
+#ifndef __NR_connect |
248 |
+# define __NR_connect 0 |
249 |
+#endif |
250 |
+#define DO_SOCKET(result, domain, type, protocol) \ |
251 |
+ do { \ |
252 |
+ if (USE_OLD_SOCKETCALL) { \ |
253 |
+ socketargs[0] = domain; \ |
254 |
+ socketargs[1] = type; \ |
255 |
+ socketargs[2] = protocol; \ |
256 |
+ socketargs[3] = 0; \ |
257 |
+ result = INLINE_SYSCALL(socketcall, 2, SOCKOP_socket, socketargs); \ |
258 |
+ } else \ |
259 |
+ result = INLINE_SYSCALL(socket, 3, domain, type, protocol); \ |
260 |
+ } while (0) |
261 |
+#define DO_CONNECT(result, sockfd, serv_addr, addrlen) \ |
262 |
+ do { \ |
263 |
+ if (USE_OLD_SOCKETCALL) { \ |
264 |
+ socketargs[0] = sockfd; \ |
265 |
+ socketargs[1] = (unsigned long int)serv_addr; \ |
266 |
+ socketargs[2] = addrlen; \ |
267 |
+ socketargs[3] = 0; \ |
268 |
+ result = INLINE_SYSCALL(socketcall, 2, SOCKOP_connect, socketargs); \ |
269 |
+ } else \ |
270 |
+ result = INLINE_SYSCALL(connect, 3, sockfd, serv_addr, addrlen); \ |
271 |
+ } while (0) |
272 |
+ |
273 |
+#ifndef _PATH_LOG |
274 |
+# define _PATH_LOG "/dev/log" |
275 |
+#endif |
276 |
+ |
277 |
+static const char path_log[] = _PATH_LOG; |
278 |
+ |
279 |
+/* For building glibc with SSP switched on, define __progname to a |
280 |
+ * constant if building for the run-time loader, to avoid pulling |
281 |
+ * in more of libc.so into ld.so |
282 |
+ */ |
283 |
+#ifdef IS_IN_rtld |
284 |
+static const char *__progname = "<ldso>"; |
285 |
+#else |
286 |
+extern const char *__progname; |
287 |
+#endif |
288 |
+ |
289 |
+#ifdef GENTOO_SSP_HANDLER |
290 |
+# define ERROR_MSG "stack smashing" |
291 |
+#else |
292 |
+# define ERROR_MSG "buffer overflow" |
293 |
+#endif |
294 |
+ |
295 |
+/* Common handler code, used by chk_fail |
296 |
+ * Inlined to ensure no self-references to the handler within itself. |
297 |
+ * Data static to avoid putting more than necessary on the stack, |
298 |
+ * to aid core debugging. |
299 |
+ */ |
300 |
+__attribute__ ((__noreturn__, __always_inline__)) |
301 |
+static inline void |
302 |
+__hardened_gentoo_fail(void) |
303 |
+{ |
304 |
+#define MESSAGE_BUFSIZ 512 |
305 |
+ static pid_t pid; |
306 |
+ static int plen, i, hlen; |
307 |
+ static char message[MESSAGE_BUFSIZ]; |
308 |
+ /* <11> is LOG_USER|LOG_ERR. A dummy date for loggers to skip over. */ |
309 |
+ static const char msg_header[] = "<11>" __DATE__ " " __TIME__ " glibc-gentoo-hardened-check: "; |
310 |
+ static const char msg_ssd[] = "*** " ERROR_MSG " detected ***: "; |
311 |
+ static const char msg_terminated[] = " terminated; "; |
312 |
+ static const char msg_report[] = "report to " REPORT_BUGS_TO "\n"; |
313 |
+ static const char msg_unknown[] = "<unknown>"; |
314 |
+ static int log_socket, connect_result; |
315 |
+ static struct sockaddr_un sock; |
316 |
+ static unsigned long int socketargs[4]; |
317 |
+ |
318 |
+ /* Build socket address */ |
319 |
+ sock.sun_family = AF_UNIX; |
320 |
+ i = 0; |
321 |
+ while (path_log[i] != '\0' && i < sizeof(sock.sun_path) - 1) { |
322 |
+ sock.sun_path[i] = path_log[i]; |
323 |
+ ++i; |
324 |
+ } |
325 |
+ sock.sun_path[i] = '\0'; |
326 |
+ |
327 |
+ /* Try SOCK_DGRAM connection to syslog */ |
328 |
+ connect_result = -1; |
329 |
+ DO_SOCKET(log_socket, AF_UNIX, SOCK_DGRAM, 0); |
330 |
+ if (log_socket != -1) |
331 |
+ DO_CONNECT(connect_result, log_socket, &sock, sizeof(sock)); |
332 |
+ if (connect_result == -1) { |
333 |
+ if (log_socket != -1) |
334 |
+ INLINE_SYSCALL(close, 1, log_socket); |
335 |
+ /* Try SOCK_STREAM connection to syslog */ |
336 |
+ DO_SOCKET(log_socket, AF_UNIX, SOCK_STREAM, 0); |
337 |
+ if (log_socket != -1) |
338 |
+ DO_CONNECT(connect_result, log_socket, &sock, sizeof(sock)); |
339 |
+ } |
340 |
+ |
341 |
+ /* Build message. Messages are generated both in the old style and new style, |
342 |
+ * so that log watchers that are configured for the old-style message continue |
343 |
+ * to work. |
344 |
+ */ |
345 |
+#define strconcat(str) \ |
346 |
+ ({ \ |
347 |
+ i = 0; \ |
348 |
+ while ((str[i] != '\0') && ((i + plen) < (MESSAGE_BUFSIZ - 1))) { \ |
349 |
+ message[plen + i] = str[i]; \ |
350 |
+ ++i; \ |
351 |
+ } \ |
352 |
+ plen += i; \ |
353 |
+ }) |
354 |
+ |
355 |
+ /* Tersely log the failure */ |
356 |
+ plen = 0; |
357 |
+ strconcat(msg_header); |
358 |
+ hlen = plen; |
359 |
+ strconcat(msg_ssd); |
360 |
+ if (__progname != NULL) |
361 |
+ strconcat(__progname); |
362 |
+ else |
363 |
+ strconcat(msg_unknown); |
364 |
+ strconcat(msg_terminated); |
365 |
+ strconcat(msg_report); |
366 |
+ |
367 |
+ /* Write out error message to STDERR, to syslog if open */ |
368 |
+ INLINE_SYSCALL(write, 3, STDERR_FILENO, message + hlen, plen - hlen); |
369 |
+ if (connect_result != -1) { |
370 |
+ INLINE_SYSCALL(write, 3, log_socket, message, plen); |
371 |
+ INLINE_SYSCALL(close, 1, log_socket); |
372 |
+ } |
373 |
+ |
374 |
+ /* Time to kill self since we have no idea what is going on */ |
375 |
+ pid = INLINE_SYSCALL(getpid, 0); |
376 |
+ |
377 |
+ if (ENABLE_SSP_SMASH_DUMPS_CORE) { |
378 |
+ /* Remove any user-supplied handler for SIGABRT, before using it. */ |
379 |
+#if 0 |
380 |
+ /* |
381 |
+ * Note: Disabled because some programs catch & process their |
382 |
+ * own crashes. We've already enabled this code path which |
383 |
+ * means we want to let core dumps happen. |
384 |
+ */ |
385 |
+ static struct sigaction default_abort_act; |
386 |
+ default_abort_act.sa_handler = SIG_DFL; |
387 |
+ default_abort_act.sa_sigaction = NULL; |
388 |
+ __sigfillset(&default_abort_act.sa_mask); |
389 |
+ default_abort_act.sa_flags = 0; |
390 |
+ if (DO_SIGACTION(SIGABRT, &default_abort_act, NULL) == 0) |
391 |
+#endif |
392 |
+ INLINE_SYSCALL(kill, 2, pid, SIGABRT); |
393 |
+ } |
394 |
+ |
395 |
+ /* SIGKILL is only signal which cannot be caught */ |
396 |
+ INLINE_SYSCALL(kill, 2, pid, SIGKILL); |
397 |
+ |
398 |
+ /* In case the kill didn't work, exit anyway. |
399 |
+ * The loop prevents gcc thinking this routine returns. |
400 |
+ */ |
401 |
+ while (1) |
402 |
+ INLINE_SYSCALL(exit, 1, 137); |
403 |
+} |
404 |
+ |
405 |
+__attribute__ ((__noreturn__)) |
406 |
+#ifdef GENTOO_SSP_HANDLER |
407 |
+void __stack_chk_fail(void) |
408 |
+#else |
409 |
+void __chk_fail(void) |
410 |
+#endif |
411 |
+{ |
412 |
+ __hardened_gentoo_fail(); |
413 |
+} |
414 |
+ |
415 |
+#ifdef GENTOO_SSP_HANDLER |
416 |
+strong_alias (__stack_chk_fail, __stack_chk_fail_local) |
417 |
+#endif |
418 |
|
419 |
diff --git a/sys-libs/glibc/files/nscd.service b/sys-libs/glibc/files/nscd.service |
420 |
new file mode 100644 |
421 |
index 0000000..25a3b1d |
422 |
--- /dev/null |
423 |
+++ b/sys-libs/glibc/files/nscd.service |
424 |
@@ -0,0 +1,15 @@ |
425 |
+[Unit] |
426 |
+Description=Name Service Cache Daemon |
427 |
+After=network.target |
428 |
+ |
429 |
+[Service] |
430 |
+ExecStart=/usr/sbin/nscd -F |
431 |
+ExecStop=/usr/sbin/nscd --shutdown |
432 |
+ExecReload=/usr/sbin/nscd -i passwd |
433 |
+ExecReload=/usr/sbin/nscd -i group |
434 |
+ExecReload=/usr/sbin/nscd -i hosts |
435 |
+ExecReload=/usr/sbin/nscd -i services |
436 |
+Restart=always |
437 |
+ |
438 |
+[Install] |
439 |
+WantedBy=multi-user.target |
440 |
|
441 |
diff --git a/sys-libs/glibc/files/nscd.tmpfilesd b/sys-libs/glibc/files/nscd.tmpfilesd |
442 |
new file mode 100644 |
443 |
index 0000000..52edbba |
444 |
--- /dev/null |
445 |
+++ b/sys-libs/glibc/files/nscd.tmpfilesd |
446 |
@@ -0,0 +1,4 @@ |
447 |
+# Configuration to create /run/nscd directory |
448 |
+# Used as part of systemd's tmpfiles |
449 |
+ |
450 |
+d /run/nscd 0755 root root |
451 |
|
452 |
diff --git a/sys-libs/glibc/glibc-2.29-r2.ebuild b/sys-libs/glibc/glibc-2.29-r2.ebuild |
453 |
new file mode 100644 |
454 |
index 0000000..60641cf |
455 |
--- /dev/null |
456 |
+++ b/sys-libs/glibc/glibc-2.29-r2.ebuild |
457 |
@@ -0,0 +1,1448 @@ |
458 |
+# Copyright 1999-2019 Gentoo Authors |
459 |
+# Distributed under the terms of the GNU General Public License v2 |
460 |
+ |
461 |
+EAPI=6 |
462 |
+ |
463 |
+PYTHON_COMPAT=( python3_{5,6,7} ) |
464 |
+ |
465 |
+inherit python-any-r1 prefix eutils eapi7-ver toolchain-funcs flag-o-matic gnuconfig \ |
466 |
+ multilib systemd multiprocessing |
467 |
+ |
468 |
+DESCRIPTION="GNU libc C library" |
469 |
+HOMEPAGE="https://www.gnu.org/software/libc/" |
470 |
+LICENSE="LGPL-2.1+ BSD HPND ISC inner-net rc PCRE" |
471 |
+RESTRICT="strip" # Strip ourself #46186 |
472 |
+SLOT="2.2" |
473 |
+ |
474 |
+EMULTILIB_PKG="true" |
475 |
+ |
476 |
+if [[ ${PV} == 9999* ]]; then |
477 |
+ EGIT_REPO_URI="https://sourceware.org/git/glibc.git" |
478 |
+ inherit git-r3 |
479 |
+else |
480 |
+ KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86" |
481 |
+ SRC_URI="mirror://gnu/glibc/${P}.tar.xz" |
482 |
+fi |
483 |
+ |
484 |
+RELEASE_VER=${PV} |
485 |
+ |
486 |
+GCC_BOOTSTRAP_VER=20180511 |
487 |
+ |
488 |
+# Gentoo patchset |
489 |
+PATCH_VER=3 |
490 |
+ |
491 |
+SRC_URI+=" https://dev.gentoo.org/~dilfridge/distfiles/${P}-patches-${PATCH_VER}.tar.xz" |
492 |
+SRC_URI+=" multilib? ( https://dev.gentoo.org/~dilfridge/distfiles/gcc-multilib-bootstrap-${GCC_BOOTSTRAP_VER}.tar.xz )" |
493 |
+ |
494 |
+IUSE="audit caps cet compile-locales doc gd headers-only +multiarch multilib nscd profile selinux +ssp suid systemtap test vanilla" |
495 |
+ |
496 |
+# Minimum kernel version that glibc requires |
497 |
+MIN_KERN_VER="3.2.0" |
498 |
+ |
499 |
+# Here's how the cross-compile logic breaks down ... |
500 |
+# CTARGET - machine that will target the binaries |
501 |
+# CHOST - machine that will host the binaries |
502 |
+# CBUILD - machine that will build the binaries |
503 |
+# If CTARGET != CHOST, it means you want a libc for cross-compiling. |
504 |
+# If CHOST != CBUILD, it means you want to cross-compile the libc. |
505 |
+# CBUILD = CHOST = CTARGET - native build/install |
506 |
+# CBUILD != (CHOST = CTARGET) - cross-compile a native build |
507 |
+# (CBUILD = CHOST) != CTARGET - libc for cross-compiler |
508 |
+# CBUILD != CHOST != CTARGET - cross-compile a libc for a cross-compiler |
509 |
+# For install paths: |
510 |
+# CHOST = CTARGET - install into / |
511 |
+# CHOST != CTARGET - install into /usr/CTARGET/ |
512 |
+# |
513 |
+export CBUILD=${CBUILD:-${CHOST}} |
514 |
+export CTARGET=${CTARGET:-${CHOST}} |
515 |
+if [[ ${CTARGET} == ${CHOST} ]] ; then |
516 |
+ if [[ ${CATEGORY} == cross-* ]] ; then |
517 |
+ export CTARGET=${CATEGORY#cross-} |
518 |
+ fi |
519 |
+fi |
520 |
+ |
521 |
+# We need a new-enough binutils/gcc to match upstream baseline. |
522 |
+# Also we need to make sure our binutils/gcc supports TLS, |
523 |
+# and that gcc already contains the hardened patches. |
524 |
+COMMON_DEPEND=" |
525 |
+ nscd? ( selinux? ( |
526 |
+ audit? ( sys-process/audit ) |
527 |
+ caps? ( sys-libs/libcap ) |
528 |
+ ) ) |
529 |
+ suid? ( caps? ( sys-libs/libcap ) ) |
530 |
+ selinux? ( sys-libs/libselinux ) |
531 |
+ systemtap? ( dev-util/systemtap ) |
532 |
+" |
533 |
+DEPEND="${COMMON_DEPEND} |
534 |
+ ${PYTHON_DEPS} |
535 |
+ >=app-misc/pax-utils-0.1.10 |
536 |
+ sys-devel/bison |
537 |
+ !<sys-apps/sandbox-1.6 |
538 |
+ !<sys-apps/portage-2.1.2 |
539 |
+ !<sys-devel/bison-2.7 |
540 |
+ !<sys-devel/make-4 |
541 |
+ doc? ( sys-apps/texinfo ) |
542 |
+ test? ( >=net-dns/libidn2-2.0.5 ) |
543 |
+" |
544 |
+RDEPEND="${COMMON_DEPEND} |
545 |
+ sys-apps/gentoo-functions |
546 |
+ !sys-kernel/ps3-sources |
547 |
+ !sys-libs/nss-db |
548 |
+" |
549 |
+ |
550 |
+if [[ ${CATEGORY} == cross-* ]] ; then |
551 |
+ DEPEND+=" !headers-only? ( |
552 |
+ >=${CATEGORY}/binutils-2.24 |
553 |
+ >=${CATEGORY}/gcc-6 |
554 |
+ )" |
555 |
+ [[ ${CATEGORY} == *-linux* ]] && DEPEND+=" ${CATEGORY}/linux-headers" |
556 |
+else |
557 |
+ DEPEND+=" |
558 |
+ >=sys-devel/binutils-2.24 |
559 |
+ >=sys-devel/gcc-6 |
560 |
+ virtual/os-headers |
561 |
+ " |
562 |
+ RDEPEND+=" |
563 |
+ >=net-dns/libidn2-2.0.5 |
564 |
+ vanilla? ( !sys-libs/timezone-data ) |
565 |
+ " |
566 |
+ PDEPEND+=" !vanilla? ( sys-libs/timezone-data )" |
567 |
+fi |
568 |
+ |
569 |
+# |
570 |
+# Small helper functions |
571 |
+# |
572 |
+ |
573 |
+is_crosscompile() { |
574 |
+ [[ ${CHOST} != ${CTARGET} ]] |
575 |
+} |
576 |
+ |
577 |
+just_headers() { |
578 |
+ is_crosscompile && use headers-only |
579 |
+} |
580 |
+ |
581 |
+alt_prefix() { |
582 |
+ is_crosscompile && echo /usr/${CTARGET} |
583 |
+} |
584 |
+ |
585 |
+# We need to be able to set alternative headers for compiling for non-native |
586 |
+# platform. Will also become useful for testing kernel-headers without screwing |
587 |
+# up the whole system. |
588 |
+alt_headers() { |
589 |
+ echo ${ALT_HEADERS:=$(alt_prefix)/usr/include} |
590 |
+} |
591 |
+ |
592 |
+alt_build_headers() { |
593 |
+ if [[ -z ${ALT_BUILD_HEADERS} ]] ; then |
594 |
+ ALT_BUILD_HEADERS="${EPREFIX}$(alt_headers)" |
595 |
+ if tc-is-cross-compiler ; then |
596 |
+ ALT_BUILD_HEADERS=${SYSROOT}$(alt_headers) |
597 |
+ if [[ ! -e ${ALT_BUILD_HEADERS}/linux/version.h ]] ; then |
598 |
+ local header_path=$(echo '#include <linux/version.h>' | $(tc-getCPP ${CTARGET}) ${CFLAGS} 2>&1 | grep -o '[^"]*linux/version.h') |
599 |
+ ALT_BUILD_HEADERS=${header_path%/linux/version.h} |
600 |
+ fi |
601 |
+ fi |
602 |
+ fi |
603 |
+ echo "${ALT_BUILD_HEADERS}" |
604 |
+} |
605 |
+ |
606 |
+alt_libdir() { |
607 |
+ echo $(alt_prefix)/$(get_libdir) |
608 |
+} |
609 |
+alt_usrlibdir() { |
610 |
+ echo $(alt_prefix)/usr/$(get_libdir) |
611 |
+} |
612 |
+ |
613 |
+builddir() { |
614 |
+ echo "${WORKDIR}/build-${ABI}-${CTARGET}-$1" |
615 |
+} |
616 |
+ |
617 |
+do_compile_test() { |
618 |
+ local ret save_cflags=${CFLAGS} |
619 |
+ CFLAGS+=" $1" |
620 |
+ shift |
621 |
+ |
622 |
+ pushd "${T}" >/dev/null |
623 |
+ |
624 |
+ rm -f glibc-test* |
625 |
+ printf '%b' "$*" > glibc-test.c |
626 |
+ |
627 |
+ nonfatal emake -s glibc-test |
628 |
+ ret=$? |
629 |
+ |
630 |
+ popd >/dev/null |
631 |
+ |
632 |
+ CFLAGS=${save_cflags} |
633 |
+ return ${ret} |
634 |
+} |
635 |
+ |
636 |
+do_run_test() { |
637 |
+ local ret |
638 |
+ |
639 |
+ if [[ ${MERGE_TYPE} == "binary" ]] ; then |
640 |
+ # ignore build failures when installing a binary package #324685 |
641 |
+ do_compile_test "" "$@" 2>/dev/null || return 0 |
642 |
+ else |
643 |
+ if ! do_compile_test "" "$@" ; then |
644 |
+ ewarn "Simple build failed ... assuming this is desired #324685" |
645 |
+ return 0 |
646 |
+ fi |
647 |
+ fi |
648 |
+ |
649 |
+ pushd "${T}" >/dev/null |
650 |
+ |
651 |
+ ./glibc-test |
652 |
+ ret=$? |
653 |
+ rm -f glibc-test* |
654 |
+ |
655 |
+ popd >/dev/null |
656 |
+ |
657 |
+ return ${ret} |
658 |
+} |
659 |
+ |
660 |
+setup_target_flags() { |
661 |
+ # This largely mucks with compiler flags. None of which should matter |
662 |
+ # when building up just the headers. |
663 |
+ just_headers && return 0 |
664 |
+ |
665 |
+ case $(tc-arch) in |
666 |
+ x86) |
667 |
+ # -march needed for #185404 #199334 |
668 |
+ # TODO: When creating the first glibc cross-compile, this test will |
669 |
+ # always fail as it does a full link which in turn requires glibc. |
670 |
+ # Probably also applies when changing multilib profile settings (e.g. |
671 |
+ # enabling x86 when the profile was amd64-only previously). |
672 |
+ # We could change main to _start and pass -nostdlib here so that we |
673 |
+ # only test the gcc code compilation. Or we could do a compile and |
674 |
+ # then look for the symbol via scanelf. |
675 |
+ if ! do_compile_test "" 'void f(int i, void *p) {if (__sync_fetch_and_add(&i, 1)) f(i, p);}\nint main(){return 0;}\n' 2>/dev/null ; then |
676 |
+ local t=${CTARGET_OPT:-${CTARGET}} |
677 |
+ t=${t%%-*} |
678 |
+ filter-flags '-march=*' |
679 |
+ export CFLAGS="-march=${t} ${CFLAGS}" |
680 |
+ einfo "Auto adding -march=${t} to CFLAGS #185404" |
681 |
+ fi |
682 |
+ ;; |
683 |
+ amd64) |
684 |
+ # -march needed for #185404 #199334 |
685 |
+ # Note: This test only matters when the x86 ABI is enabled, so we could |
686 |
+ # optimize a bit and elide it. |
687 |
+ # TODO: See cross-compile issues listed above for x86. |
688 |
+ if ! do_compile_test "${CFLAGS_x86}" 'void f(int i, void *p) {if (__sync_fetch_and_add(&i, 1)) f(i, p);}\nint main(){return 0;}\n' 2>/dev/null ; then |
689 |
+ local t=${CTARGET_OPT:-${CTARGET}} |
690 |
+ t=${t%%-*} |
691 |
+ # Normally the target is x86_64-xxx, so turn that into the -march that |
692 |
+ # gcc actually accepts. #528708 |
693 |
+ [[ ${t} == "x86_64" ]] && t="x86-64" |
694 |
+ filter-flags '-march=*' |
695 |
+ # ugly, ugly, ugly. ugly. |
696 |
+ CFLAGS_x86=$(CFLAGS=${CFLAGS_x86} filter-flags '-march=*'; echo "${CFLAGS}") |
697 |
+ export CFLAGS_x86="${CFLAGS_x86} -march=${t}" |
698 |
+ einfo "Auto adding -march=${t} to CFLAGS_x86 #185404" |
699 |
+ fi |
700 |
+ ;; |
701 |
+ mips) |
702 |
+ # The mips abi cannot support the GNU style hashes. #233233 |
703 |
+ filter-ldflags -Wl,--hash-style=gnu -Wl,--hash-style=both |
704 |
+ ;; |
705 |
+ sparc) |
706 |
+ # Both sparc and sparc64 can use -fcall-used-g6. -g7 is bad, though. |
707 |
+ filter-flags "-fcall-used-g7" |
708 |
+ append-flags "-fcall-used-g6" |
709 |
+ |
710 |
+ # If the CHOST is the basic one (e.g. not sparcv9-xxx already), |
711 |
+ # try to pick a better one so glibc can use cpu-specific .S files. |
712 |
+ # We key off the CFLAGS to get a good value. Also need to handle |
713 |
+ # version skew. |
714 |
+ # We can't force users to set their CHOST to their exact machine |
715 |
+ # as many of these are not recognized by config.sub/gcc and such :(. |
716 |
+ # Note: If the mcpu values don't scale, we might try probing CPP defines. |
717 |
+ # Note: Should we factor in -Wa,-AvXXX flags too ? Or -mvis/etc... ? |
718 |
+ |
719 |
+ local cpu |
720 |
+ case ${CTARGET} in |
721 |
+ sparc64-*) |
722 |
+ case $(get-flag mcpu) in |
723 |
+ niagara[234]) |
724 |
+ if ver_test -ge 2.8 ; then |
725 |
+ cpu="sparc64v2" |
726 |
+ elif ver_test -ge 2.4 ; then |
727 |
+ cpu="sparc64v" |
728 |
+ elif ver_test -ge 2.2.3 ; then |
729 |
+ cpu="sparc64b" |
730 |
+ fi |
731 |
+ ;; |
732 |
+ niagara) |
733 |
+ if ver_test -ge 2.4 ; then |
734 |
+ cpu="sparc64v" |
735 |
+ elif ver_test -ge 2.2.3 ; then |
736 |
+ cpu="sparc64b" |
737 |
+ fi |
738 |
+ ;; |
739 |
+ ultrasparc3) |
740 |
+ cpu="sparc64b" |
741 |
+ ;; |
742 |
+ *) |
743 |
+ # We need to force at least v9a because the base build doesn't |
744 |
+ # work with just v9. |
745 |
+ # https://sourceware.org/bugzilla/show_bug.cgi?id=19477 |
746 |
+ [[ -z ${cpu} ]] && append-flags "-Wa,-xarch=v9a" |
747 |
+ ;; |
748 |
+ esac |
749 |
+ ;; |
750 |
+ sparc-*) |
751 |
+ case $(get-flag mcpu) in |
752 |
+ niagara[234]) |
753 |
+ if ver_test -ge 2.8 ; then |
754 |
+ cpu="sparcv9v2" |
755 |
+ elif ver_test -ge 2.4 ; then |
756 |
+ cpu="sparcv9v" |
757 |
+ elif ver_test -ge 2.2.3 ; then |
758 |
+ cpu="sparcv9b" |
759 |
+ else |
760 |
+ cpu="sparcv9" |
761 |
+ fi |
762 |
+ ;; |
763 |
+ niagara) |
764 |
+ if ver_test -ge 2.4 ; then |
765 |
+ cpu="sparcv9v" |
766 |
+ elif ver_test -ge 2.2.3 ; then |
767 |
+ cpu="sparcv9b" |
768 |
+ else |
769 |
+ cpu="sparcv9" |
770 |
+ fi |
771 |
+ ;; |
772 |
+ ultrasparc3) |
773 |
+ cpu="sparcv9b" |
774 |
+ ;; |
775 |
+ v9|ultrasparc) |
776 |
+ cpu="sparcv9" |
777 |
+ ;; |
778 |
+ v8|supersparc|hypersparc|leon|leon3) |
779 |
+ cpu="sparcv8" |
780 |
+ ;; |
781 |
+ esac |
782 |
+ ;; |
783 |
+ esac |
784 |
+ [[ -n ${cpu} ]] && CTARGET_OPT="${cpu}-${CTARGET#*-}" |
785 |
+ ;; |
786 |
+ esac |
787 |
+} |
788 |
+ |
789 |
+setup_flags() { |
790 |
+ # Make sure host make.conf doesn't pollute us |
791 |
+ if is_crosscompile || tc-is-cross-compiler ; then |
792 |
+ CHOST=${CTARGET} strip-unsupported-flags |
793 |
+ fi |
794 |
+ |
795 |
+ # Store our CFLAGS because it's changed depending on which CTARGET |
796 |
+ # we are building when pulling glibc on a multilib profile |
797 |
+ CFLAGS_BASE=${CFLAGS_BASE-${CFLAGS}} |
798 |
+ CFLAGS=${CFLAGS_BASE} |
799 |
+ CXXFLAGS_BASE=${CXXFLAGS_BASE-${CXXFLAGS}} |
800 |
+ CXXFLAGS=${CXXFLAGS_BASE} |
801 |
+ ASFLAGS_BASE=${ASFLAGS_BASE-${ASFLAGS}} |
802 |
+ ASFLAGS=${ASFLAGS_BASE} |
803 |
+ |
804 |
+ # Over-zealous CFLAGS can often cause problems. What may work for one |
805 |
+ # person may not work for another. To avoid a large influx of bugs |
806 |
+ # relating to failed builds, we strip most CFLAGS out to ensure as few |
807 |
+ # problems as possible. |
808 |
+ strip-flags |
809 |
+ strip-unsupported-flags |
810 |
+ filter-flags -m32 -m64 '-mabi=*' |
811 |
+ |
812 |
+ # glibc aborts if rpath is set by LDFLAGS |
813 |
+ filter-ldflags '-Wl,-rpath=*' |
814 |
+ |
815 |
+ # #492892 |
816 |
+ filter-flags -frecord-gcc-switches |
817 |
+ |
818 |
+ unset CBUILD_OPT CTARGET_OPT |
819 |
+ if use multilib ; then |
820 |
+ CTARGET_OPT=$(get_abi_CTARGET) |
821 |
+ [[ -z ${CTARGET_OPT} ]] && CTARGET_OPT=$(get_abi_CHOST) |
822 |
+ fi |
823 |
+ |
824 |
+ setup_target_flags |
825 |
+ |
826 |
+ if [[ -n ${CTARGET_OPT} && ${CBUILD} == ${CHOST} ]] && ! is_crosscompile; then |
827 |
+ CBUILD_OPT=${CTARGET_OPT} |
828 |
+ fi |
829 |
+ |
830 |
+ # Lock glibc at -O2; we want to be conservative here. |
831 |
+ # -fno-strict-aliasing is to work around #155906. |
832 |
+ filter-flags '-O?' |
833 |
+ append-flags -O2 -fno-strict-aliasing |
834 |
+ |
835 |
+ filter-flags '-fstack-protector*' |
836 |
+} |
837 |
+ |
838 |
+want_tls() { |
839 |
+ # Archs that can use TLS (Thread Local Storage) |
840 |
+ case $(tc-arch) in |
841 |
+ x86) |
842 |
+ # requires i486 or better #106556 |
843 |
+ [[ ${CTARGET} == i[4567]86* ]] && return 0 |
844 |
+ return 1 |
845 |
+ ;; |
846 |
+ esac |
847 |
+ return 0 |
848 |
+} |
849 |
+ |
850 |
+want__thread() { |
851 |
+ want_tls || return 1 |
852 |
+ |
853 |
+ # For some reason --with-tls --with__thread is causing segfaults on sparc32. |
854 |
+ [[ ${PROFILE_ARCH} == "sparc" ]] && return 1 |
855 |
+ |
856 |
+ [[ -n ${WANT__THREAD} ]] && return ${WANT__THREAD} |
857 |
+ |
858 |
+ # only test gcc -- can't test linking yet |
859 |
+ tc-has-tls -c ${CTARGET} |
860 |
+ WANT__THREAD=$? |
861 |
+ |
862 |
+ return ${WANT__THREAD} |
863 |
+} |
864 |
+ |
865 |
+use_multiarch() { |
866 |
+ # Allow user to disable runtime arch detection in multilib. |
867 |
+ use multiarch || return 1 |
868 |
+ # Make sure binutils is new enough to support indirect functions, |
869 |
+ # #336792. This funky sed supports gold and bfd linkers. |
870 |
+ local bver nver |
871 |
+ bver=$($(tc-getLD ${CTARGET}) -v | sed -n -r '1{s:[^0-9]*::;s:^([0-9.]*).*:\1:;p}') |
872 |
+ case $(tc-arch ${CTARGET}) in |
873 |
+ amd64|x86) nver="2.20" ;; |
874 |
+ arm) nver="2.22" ;; |
875 |
+ hppa) nver="2.23" ;; |
876 |
+ ppc|ppc64) nver="2.20" ;; |
877 |
+ # ifunc support was added in 2.23, but glibc also needs |
878 |
+ # machinemode which is in 2.24. |
879 |
+ s390) nver="2.24" ;; |
880 |
+ sparc) nver="2.21" ;; |
881 |
+ *) return 1 ;; |
882 |
+ esac |
883 |
+ ver_test ${bver} -ge ${nver} |
884 |
+} |
885 |
+ |
886 |
+# Setup toolchain variables that had historically been defined in the |
887 |
+# profiles for these archs. |
888 |
+setup_env() { |
889 |
+ # silly users |
890 |
+ unset LD_RUN_PATH |
891 |
+ unset LD_ASSUME_KERNEL |
892 |
+ |
893 |
+ if is_crosscompile || tc-is-cross-compiler ; then |
894 |
+ multilib_env ${CTARGET_OPT:-${CTARGET}} |
895 |
+ |
896 |
+ if ! use multilib ; then |
897 |
+ MULTILIB_ABIS=${DEFAULT_ABI} |
898 |
+ else |
899 |
+ MULTILIB_ABIS=${MULTILIB_ABIS:-${DEFAULT_ABI}} |
900 |
+ fi |
901 |
+ |
902 |
+ # If the user has CFLAGS_<CTARGET> in their make.conf, use that, |
903 |
+ # and fall back on CFLAGS. |
904 |
+ local VAR=CFLAGS_${CTARGET//[-.]/_} |
905 |
+ CFLAGS=${!VAR-${CFLAGS}} |
906 |
+ einfo " $(printf '%15s' 'Manual CFLAGS:') ${CFLAGS}" |
907 |
+ fi |
908 |
+ |
909 |
+ setup_flags |
910 |
+ |
911 |
+ export ABI=${ABI:-${DEFAULT_ABI:-default}} |
912 |
+ |
913 |
+ if just_headers ; then |
914 |
+ # Avoid mixing host's CC and target's CFLAGS_${ABI}: |
915 |
+ # At this bootstrap stage we have only binutils for |
916 |
+ # target but not compiler yet. |
917 |
+ einfo "Skip CC ABI injection. We can't use (cross-)compiler yet." |
918 |
+ return 0 |
919 |
+ fi |
920 |
+ local VAR=CFLAGS_${ABI} |
921 |
+ # We need to export CFLAGS with abi information in them because glibc's |
922 |
+ # configure script checks CFLAGS for some targets (like mips). Keep |
923 |
+ # around the original clean value to avoid appending multiple ABIs on |
924 |
+ # top of each other. |
925 |
+ : ${__GLIBC_CC:=$(tc-getCC ${CTARGET_OPT:-${CTARGET}})} |
926 |
+ export __GLIBC_CC CC="${__GLIBC_CC} ${!VAR}" |
927 |
+ einfo " $(printf '%15s' 'Manual CC:') ${CC}" |
928 |
+} |
929 |
+ |
930 |
+foreach_abi() { |
931 |
+ setup_env |
932 |
+ |
933 |
+ local ret=0 |
934 |
+ local abilist="" |
935 |
+ if use multilib ; then |
936 |
+ abilist=$(get_install_abis) |
937 |
+ else |
938 |
+ abilist=${DEFAULT_ABI} |
939 |
+ fi |
940 |
+ local -x ABI |
941 |
+ for ABI in ${abilist:-default} ; do |
942 |
+ setup_env |
943 |
+ einfo "Running $1 for ABI ${ABI}" |
944 |
+ $1 |
945 |
+ : $(( ret |= $? )) |
946 |
+ done |
947 |
+ return ${ret} |
948 |
+} |
949 |
+ |
950 |
+glibc_banner() { |
951 |
+ local b="Gentoo ${PVR}" |
952 |
+ [[ -n ${PATCH_VER} ]] && ! use vanilla && b+=" p${PATCH_VER}" |
953 |
+ echo "${b}" |
954 |
+} |
955 |
+ |
956 |
+check_devpts() { |
957 |
+ # Make sure devpts is mounted correctly for use w/out setuid pt_chown. |
958 |
+ |
959 |
+ # If merely building the binary package, then there's nothing to verify. |
960 |
+ [[ ${MERGE_TYPE} == "buildonly" ]] && return |
961 |
+ |
962 |
+ # Only sanity check when installing the native glibc. |
963 |
+ [[ ${ROOT} != "/" ]] && return |
964 |
+ |
965 |
+ # If they're opting in to the old suid code, then no need to check. |
966 |
+ use suid && return |
967 |
+ |
968 |
+ if awk '$3 == "devpts" && $4 ~ /[, ]gid=5[, ]/ { exit 1 }' /proc/mounts ; then |
969 |
+ eerror "In order to use glibc with USE=-suid, you must make sure that" |
970 |
+ eerror "you have devpts mounted at /dev/pts with the gid=5 option." |
971 |
+ eerror "Openrc should do this for you, so you should check /etc/fstab" |
972 |
+ eerror "and make sure you do not have any invalid settings there." |
973 |
+ die "mount & fix your /dev/pts settings" |
974 |
+ fi |
975 |
+} |
976 |
+ |
977 |
+# The following Kernel version handling functions are mostly copied from portage |
978 |
+# source. It's better not to use linux-info.eclass here since a) it adds too |
979 |
+# much magic, see bug 326693 for some of the arguments, and b) some of the |
980 |
+# functions are just not provided. |
981 |
+ |
982 |
+g_get_running_KV() { |
983 |
+ uname -r |
984 |
+ return $? |
985 |
+} |
986 |
+ |
987 |
+g_KV_major() { |
988 |
+ [[ -z $1 ]] && return 1 |
989 |
+ local KV=$@ |
990 |
+ echo "${KV%%.*}" |
991 |
+} |
992 |
+ |
993 |
+g_KV_minor() { |
994 |
+ [[ -z $1 ]] && return 1 |
995 |
+ local KV=$@ |
996 |
+ KV=${KV#*.} |
997 |
+ echo "${KV%%.*}" |
998 |
+} |
999 |
+ |
1000 |
+g_KV_micro() { |
1001 |
+ [[ -z $1 ]] && return 1 |
1002 |
+ local KV=$@ |
1003 |
+ KV=${KV#*.*.} |
1004 |
+ echo "${KV%%[^[:digit:]]*}" |
1005 |
+} |
1006 |
+ |
1007 |
+g_KV_to_int() { |
1008 |
+ [[ -z $1 ]] && return 1 |
1009 |
+ local KV_MAJOR=$(g_KV_major "$1") |
1010 |
+ local KV_MINOR=$(g_KV_minor "$1") |
1011 |
+ local KV_MICRO=$(g_KV_micro "$1") |
1012 |
+ local KV_int=$(( KV_MAJOR * 65536 + KV_MINOR * 256 + KV_MICRO )) |
1013 |
+ |
1014 |
+ # We make version 2.2.0 the minimum version we will handle as |
1015 |
+ # a sanity check ... if its less, we fail ... |
1016 |
+ if [[ ${KV_int} -ge 131584 ]] ; then |
1017 |
+ echo "${KV_int}" |
1018 |
+ return 0 |
1019 |
+ fi |
1020 |
+ return 1 |
1021 |
+} |
1022 |
+ |
1023 |
+g_int_to_KV() { |
1024 |
+ local version=$1 major minor micro |
1025 |
+ major=$((version / 65536)) |
1026 |
+ minor=$(((version % 65536) / 256)) |
1027 |
+ micro=$((version % 256)) |
1028 |
+ echo ${major}.${minor}.${micro} |
1029 |
+} |
1030 |
+ |
1031 |
+eend_KV() { |
1032 |
+ [[ $(g_KV_to_int $1) -ge $(g_KV_to_int $2) ]] |
1033 |
+ eend $? |
1034 |
+} |
1035 |
+ |
1036 |
+get_kheader_version() { |
1037 |
+ printf '#include <linux/version.h>\nLINUX_VERSION_CODE\n' | \ |
1038 |
+ $(tc-getCPP ${CTARGET}) -I "${EPREFIX}/$(alt_build_headers)" - | \ |
1039 |
+ tail -n 1 |
1040 |
+} |
1041 |
+ |
1042 |
+# We collect all sanity checks here. Consistency is not guranteed between |
1043 |
+# pkg_ and src_ phases, so we call this function both in pkg_pretend and in |
1044 |
+# src_unpack. |
1045 |
+sanity_prechecks() { |
1046 |
+ # Make sure devpts is mounted correctly for use w/out setuid pt_chown |
1047 |
+ check_devpts |
1048 |
+ |
1049 |
+ # Prevent native builds from downgrading |
1050 |
+ if [[ ${MERGE_TYPE} != "buildonly" ]] && \ |
1051 |
+ [[ ${ROOT} == "/" ]] && \ |
1052 |
+ [[ ${CBUILD} == ${CHOST} ]] && \ |
1053 |
+ [[ ${CHOST} == ${CTARGET} ]] ; then |
1054 |
+ |
1055 |
+ # The high rev # is to allow people to downgrade between -r# |
1056 |
+ # versions. We want to block 2.20->2.19, but 2.20-r3->2.20-r2 |
1057 |
+ # should be fine. Hopefully we never actually use a r# this |
1058 |
+ # high. |
1059 |
+ if has_version ">${CATEGORY}/${P}-r10000" ; then |
1060 |
+ eerror "Sanity check to keep you from breaking your system:" |
1061 |
+ eerror " Downgrading glibc is not supported and a sure way to destruction." |
1062 |
+ die "Aborting to save your system." |
1063 |
+ fi |
1064 |
+ |
1065 |
+ if ! do_run_test '#include <unistd.h>\n#include <sys/syscall.h>\nint main(){return syscall(1000)!=-1;}\n' ; then |
1066 |
+ eerror "Your old kernel is broken. You need to update it to a newer" |
1067 |
+ eerror "version as syscall(<bignum>) will break. See bug 279260." |
1068 |
+ die "Old and broken kernel." |
1069 |
+ fi |
1070 |
+ fi |
1071 |
+ |
1072 |
+ # Users have had a chance to phase themselves, time to give em the boot |
1073 |
+ if [[ -e ${EROOT}/etc/locale.gen ]] && [[ -e ${EROOT}/etc/locales.build ]] ; then |
1074 |
+ eerror "You still haven't deleted ${EROOT}/etc/locales.build." |
1075 |
+ eerror "Do so now after making sure ${EROOT}/etc/locale.gen is kosher." |
1076 |
+ die "Lazy upgrader detected" |
1077 |
+ fi |
1078 |
+ |
1079 |
+ if [[ ${CTARGET} == i386-* ]] ; then |
1080 |
+ eerror "i386 CHOSTs are no longer supported." |
1081 |
+ eerror "Chances are you don't actually want/need i386." |
1082 |
+ eerror "Please read https://www.gentoo.org/doc/en/change-chost.xml" |
1083 |
+ die "Please fix your CHOST" |
1084 |
+ fi |
1085 |
+ |
1086 |
+ if [[ -e /proc/xen ]] && [[ $(tc-arch) == "x86" ]] && ! is-flag -mno-tls-direct-seg-refs ; then |
1087 |
+ ewarn "You are using Xen but don't have -mno-tls-direct-seg-refs in your CFLAGS." |
1088 |
+ ewarn "This will result in a 50% performance penalty when running with a 32bit" |
1089 |
+ ewarn "hypervisor, which is probably not what you want." |
1090 |
+ fi |
1091 |
+ |
1092 |
+ # Check for sanity of /etc/nsswitch.conf |
1093 |
+ if [[ -e ${EROOT}/etc/nsswitch.conf ]] ; then |
1094 |
+ local entry |
1095 |
+ for entry in passwd group shadow; do |
1096 |
+ if ! egrep -q "^[ \t]*${entry}:.*files" "${EROOT}"/etc/nsswitch.conf; then |
1097 |
+ eerror "Your ${EROOT}/etc/nsswitch.conf is out of date." |
1098 |
+ eerror "Please make sure you have 'files' entries for" |
1099 |
+ eerror "'passwd:', 'group:' and 'shadow:' databases." |
1100 |
+ eerror "For more details see:" |
1101 |
+ eerror " https://wiki.gentoo.org/wiki/Project:Toolchain/nsswitch.conf_in_glibc-2.26" |
1102 |
+ die "nsswitch.conf has no 'files' provider in '${entry}'." |
1103 |
+ fi |
1104 |
+ done |
1105 |
+ fi |
1106 |
+ |
1107 |
+ # ABI-specific checks follow here. Hey, we have a lot more specific conditions that |
1108 |
+ # we test for... |
1109 |
+ if ! is_crosscompile ; then |
1110 |
+ if use amd64 && use multilib && [[ ${MERGE_TYPE} != "binary" ]] ; then |
1111 |
+ ebegin "Checking that IA32 emulation is enabled in the running kernel" |
1112 |
+ echo 'int main(){return 0;}' > "${T}/check-ia32-emulation.c" |
1113 |
+ local STAT |
1114 |
+ if "${CC-${CHOST}-gcc}" ${CFLAGS_x86} "${T}/check-ia32-emulation.c" -o "${T}/check-ia32-emulation.elf32"; then |
1115 |
+ "${T}/check-ia32-emulation.elf32" |
1116 |
+ STAT=$? |
1117 |
+ else |
1118 |
+ # Don't fail here to allow single->multi ABI switch |
1119 |
+ # or recover from breakage like bug #646424 |
1120 |
+ ewarn "Failed to compile the ABI test. Broken host glibc?" |
1121 |
+ STAT=0 |
1122 |
+ fi |
1123 |
+ rm -f "${T}/check-ia32-emulation.elf32" |
1124 |
+ eend $STAT |
1125 |
+ [[ $STAT -eq 0 ]] || die "CONFIG_IA32_EMULATION must be enabled in the kernel to compile a multilib glibc." |
1126 |
+ fi |
1127 |
+ |
1128 |
+ fi |
1129 |
+ |
1130 |
+ # When we actually have to compile something... |
1131 |
+ if ! just_headers ; then |
1132 |
+ ebegin "Checking gcc for __thread support" |
1133 |
+ if ! eend $(want__thread ; echo $?) ; then |
1134 |
+ echo |
1135 |
+ eerror "Could not find a gcc that supports the __thread directive!" |
1136 |
+ eerror "Please update your binutils/gcc and try again." |
1137 |
+ die "No __thread support in gcc!" |
1138 |
+ fi |
1139 |
+ |
1140 |
+ if [[ ${CTARGET} == *-linux* ]] ; then |
1141 |
+ local run_kv build_kv want_kv |
1142 |
+ |
1143 |
+ run_kv=$(g_get_running_KV) |
1144 |
+ build_kv=$(g_int_to_KV $(get_kheader_version)) |
1145 |
+ want_kv=${MIN_KERN_VER} |
1146 |
+ |
1147 |
+ if ! is_crosscompile && ! tc-is-cross-compiler ; then |
1148 |
+ # Building fails on an non-supporting kernel |
1149 |
+ ebegin "Checking running kernel version (${run_kv} >= ${want_kv})" |
1150 |
+ if ! eend_KV ${run_kv} ${want_kv} ; then |
1151 |
+ echo |
1152 |
+ eerror "You need a kernel of at least ${want_kv}!" |
1153 |
+ die "Kernel version too low!" |
1154 |
+ fi |
1155 |
+ fi |
1156 |
+ |
1157 |
+ ebegin "Checking linux-headers version (${build_kv} >= ${want_kv})" |
1158 |
+ if ! eend_KV ${build_kv} ${want_kv} ; then |
1159 |
+ echo |
1160 |
+ eerror "You need linux-headers of at least ${want_kv}!" |
1161 |
+ die "linux-headers version too low!" |
1162 |
+ fi |
1163 |
+ fi |
1164 |
+ fi |
1165 |
+} |
1166 |
+ |
1167 |
+# |
1168 |
+# the phases |
1169 |
+# |
1170 |
+ |
1171 |
+# pkg_pretend |
1172 |
+ |
1173 |
+pkg_pretend() { |
1174 |
+ # All the checks... |
1175 |
+ einfo "Checking general environment sanity." |
1176 |
+ sanity_prechecks |
1177 |
+} |
1178 |
+ |
1179 |
+pkg_setup() { |
1180 |
+ # see bug 682570 |
1181 |
+ [[ -z ${BOOTSTRAP_RAP} ]] && python-any-r1_pkg_setup |
1182 |
+} |
1183 |
+ |
1184 |
+# src_unpack |
1185 |
+ |
1186 |
+src_unpack() { |
1187 |
+ # Consistency is not guaranteed between pkg_ and src_ ... |
1188 |
+ sanity_prechecks |
1189 |
+ |
1190 |
+ use multilib && unpack gcc-multilib-bootstrap-${GCC_BOOTSTRAP_VER}.tar.xz |
1191 |
+ |
1192 |
+ setup_env |
1193 |
+ |
1194 |
+ if [[ -n ${EGIT_REPO_URI} ]] ; then |
1195 |
+ git-r3_src_unpack |
1196 |
+ else |
1197 |
+ unpack ${P}.tar.xz |
1198 |
+ fi |
1199 |
+ |
1200 |
+ cd "${WORKDIR}" || die |
1201 |
+ unpack glibc-${RELEASE_VER}-patches-${PATCH_VER}.tar.xz |
1202 |
+} |
1203 |
+ |
1204 |
+src_prepare() { |
1205 |
+ if ! use vanilla ; then |
1206 |
+ elog "Applying Gentoo Glibc Patchset ${RELEASE_VER}-${PATCH_VER}" |
1207 |
+ eapply "${WORKDIR}"/patches |
1208 |
+ einfo "Done." |
1209 |
+ fi |
1210 |
+ |
1211 |
+ default |
1212 |
+ |
1213 |
+ gnuconfig_update |
1214 |
+ |
1215 |
+ cd "${WORKDIR}" |
1216 |
+ find . -name configure -exec touch {} + |
1217 |
+ |
1218 |
+ eprefixify extra/locale/locale-gen |
1219 |
+ |
1220 |
+ # Fix permissions on some of the scripts. |
1221 |
+ chmod u+x "${S}"/scripts/*.sh |
1222 |
+ |
1223 |
+ cd "${S}" |
1224 |
+} |
1225 |
+ |
1226 |
+glibc_do_configure() { |
1227 |
+ # Glibc does not work with gold (for various reasons) #269274. |
1228 |
+ tc-ld-disable-gold |
1229 |
+ |
1230 |
+ # CXX isnt handled by the multilib system, so if we dont unset here |
1231 |
+ # we accumulate crap across abis |
1232 |
+ unset CXX |
1233 |
+ |
1234 |
+ einfo "Configuring glibc for nptl" |
1235 |
+ |
1236 |
+ if use doc ; then |
1237 |
+ export MAKEINFO=makeinfo |
1238 |
+ else |
1239 |
+ export MAKEINFO=/dev/null |
1240 |
+ fi |
1241 |
+ |
1242 |
+ local v |
1243 |
+ for v in ABI CBUILD CHOST CTARGET CBUILD_OPT CTARGET_OPT CC CXX LD {AS,C,CPP,CXX,LD}FLAGS MAKEINFO ; do |
1244 |
+ einfo " $(printf '%15s' ${v}:) ${!v}" |
1245 |
+ done |
1246 |
+ |
1247 |
+ # CFLAGS can contain ABI-specific flags like -mfpu=neon, see bug #657760 |
1248 |
+ # To build .S (assembly) files with the same ABI-specific flags |
1249 |
+ # upstream currently recommends adding CFLAGS to CC/CXX: |
1250 |
+ # https://sourceware.org/PR23273 |
1251 |
+ # Note: Passing CFLAGS via CPPFLAGS overrides glibc's arch-specific CFLAGS |
1252 |
+ # and breaks multiarch support. See 659030#c3 for an example. |
1253 |
+ # The glibc configure script doesn't properly use LDFLAGS all the time. |
1254 |
+ export CC="$(tc-getCC ${CTARGET}) ${CFLAGS} ${LDFLAGS}" |
1255 |
+ einfo " $(printf '%15s' 'Manual CC:') ${CC}" |
1256 |
+ |
1257 |
+ # Some of the tests are written in C++, so we need to force our multlib abis in, bug 623548 |
1258 |
+ export CXX="$(tc-getCXX ${CTARGET}) $(get_abi_CFLAGS) ${CFLAGS}" |
1259 |
+ |
1260 |
+ if is_crosscompile; then |
1261 |
+ # Assume worst-case bootstrap: glibc is buil first time |
1262 |
+ # when ${CTARGET}-g++ is not available yet. We avoid |
1263 |
+ # building auxiliary programs that require C++: bug #683074 |
1264 |
+ # It should not affect final result. |
1265 |
+ export libc_cv_cxx_link_ok=no |
1266 |
+ # The line above has the same effect. We set CXX explicitly |
1267 |
+ # to make build logs less confusing. |
1268 |
+ export CXX= |
1269 |
+ fi |
1270 |
+ einfo " $(printf '%15s' 'Manual CXX:') ${CXX}" |
1271 |
+ |
1272 |
+ echo |
1273 |
+ |
1274 |
+ local myconf=() |
1275 |
+ |
1276 |
+ case ${CTARGET} in |
1277 |
+ m68k*) |
1278 |
+ # setjmp() is not compatible with stack protection: |
1279 |
+ # https://sourceware.org/PR24202 |
1280 |
+ myconf+=( --enable-stack-protector=no ) |
1281 |
+ ;; |
1282 |
+ powerpc-*) |
1283 |
+ # Currently gcc on powerpc32 generates invalid code for |
1284 |
+ # __builtin_return_address(0) calls. Normally programs |
1285 |
+ # don't do that but malloc hooks in glibc do: |
1286 |
+ # https://gcc.gnu.org/PR81996 |
1287 |
+ # https://bugs.gentoo.org/629054 |
1288 |
+ myconf+=( --enable-stack-protector=no ) |
1289 |
+ ;; |
1290 |
+ *) |
1291 |
+ myconf+=( --enable-stack-protector=$(usex ssp all no) ) |
1292 |
+ ;; |
1293 |
+ esac |
1294 |
+ myconf+=( --enable-stackguard-randomization ) |
1295 |
+ |
1296 |
+ # Keep a whitelist of targets supporing IFUNC. glibc's ./configure |
1297 |
+ # is not robust enough to detect proper support: |
1298 |
+ # https://bugs.gentoo.org/641216 |
1299 |
+ # https://sourceware.org/PR22634#c0 |
1300 |
+ case $(tc-arch ${CTARGET}) in |
1301 |
+ # Keep whitelist of targets where autodetection mostly works. |
1302 |
+ amd64|x86|sparc|ppc|ppc64|arm|arm64|s390) ;; |
1303 |
+ # Blacklist everywhere else |
1304 |
+ *) myconf+=( libc_cv_ld_gnu_indirect_function=no ) ;; |
1305 |
+ esac |
1306 |
+ |
1307 |
+ # Enable Intel Control-flow Enforcement Technology on amd64 if requested |
1308 |
+ case ${CTARGET} in |
1309 |
+ x86_64-*) myconf+=( $(use_enable cet) ) ;; |
1310 |
+ *) ;; |
1311 |
+ esac |
1312 |
+ |
1313 |
+ [[ $(tc-is-softfloat) == "yes" ]] && myconf+=( --without-fp ) |
1314 |
+ |
1315 |
+ myconf+=( --enable-kernel=${MIN_KERN_VER} ) |
1316 |
+ |
1317 |
+ # Since SELinux support is only required for nscd, only enable it if: |
1318 |
+ # 1. USE selinux |
1319 |
+ # 2. only for the primary ABI on multilib systems |
1320 |
+ # 3. Not a crosscompile |
1321 |
+ if ! is_crosscompile && use selinux ; then |
1322 |
+ if use multilib ; then |
1323 |
+ if is_final_abi ; then |
1324 |
+ myconf+=( --with-selinux ) |
1325 |
+ else |
1326 |
+ myconf+=( --without-selinux ) |
1327 |
+ fi |
1328 |
+ else |
1329 |
+ myconf+=( --with-selinux ) |
1330 |
+ fi |
1331 |
+ else |
1332 |
+ myconf+=( --without-selinux ) |
1333 |
+ fi |
1334 |
+ |
1335 |
+ # Force a few tests where we always know the answer but |
1336 |
+ # configure is incapable of finding it. |
1337 |
+ if is_crosscompile ; then |
1338 |
+ export \ |
1339 |
+ libc_cv_c_cleanup=yes \ |
1340 |
+ libc_cv_forced_unwind=yes |
1341 |
+ fi |
1342 |
+ |
1343 |
+ myconf+=( |
1344 |
+ --without-cvs |
1345 |
+ --disable-werror |
1346 |
+ --enable-bind-now |
1347 |
+ --build=${CBUILD_OPT:-${CBUILD}} |
1348 |
+ --host=${CTARGET_OPT:-${CTARGET}} |
1349 |
+ $(use_enable profile) |
1350 |
+ $(use_with gd) |
1351 |
+ --with-headers=$(alt_build_headers) |
1352 |
+ --prefix="${EPREFIX}/usr" |
1353 |
+ --sysconfdir="${EPREFIX}/etc" |
1354 |
+ --localstatedir="${EPREFIX}/var" |
1355 |
+ --libdir='$(prefix)'/$(get_libdir) |
1356 |
+ --mandir='$(prefix)'/share/man |
1357 |
+ --infodir='$(prefix)'/share/info |
1358 |
+ --libexecdir='$(libdir)'/misc/glibc |
1359 |
+ --with-bugurl=https://bugs.gentoo.org/ |
1360 |
+ --with-pkgversion="$(glibc_banner)" |
1361 |
+ $(use_multiarch || echo --disable-multi-arch) |
1362 |
+ $(use_enable systemtap) |
1363 |
+ $(use_enable nscd) |
1364 |
+ ${EXTRA_ECONF} |
1365 |
+ ) |
1366 |
+ |
1367 |
+ # We rely on sys-libs/timezone-data for timezone tools normally. |
1368 |
+ myconf+=( $(use_enable vanilla timezone-tools) ) |
1369 |
+ |
1370 |
+ # These libs don't have configure flags. |
1371 |
+ ac_cv_lib_audit_audit_log_user_avc_message=$(usex audit || echo no) |
1372 |
+ ac_cv_lib_cap_cap_init=$(usex caps || echo no) |
1373 |
+ |
1374 |
+ # There is no configure option for this and we need to export it |
1375 |
+ # since the glibc build will re-run configure on itself |
1376 |
+ export libc_cv_rootsbindir="${EPREFIX}/sbin" |
1377 |
+ export libc_cv_slibdir="${EPREFIX}/$(get_libdir)" |
1378 |
+ |
1379 |
+ # We take care of patching our binutils to use both hash styles, |
1380 |
+ # and many people like to force gnu hash style only, so disable |
1381 |
+ # this overriding check. #347761 |
1382 |
+ export libc_cv_hashstyle=no |
1383 |
+ |
1384 |
+ local builddir=$(builddir nptl) |
1385 |
+ mkdir -p "${builddir}" |
1386 |
+ cd "${builddir}" |
1387 |
+ set -- "${S}"/configure "${myconf[@]}" |
1388 |
+ echo "$@" |
1389 |
+ "$@" || die "failed to configure glibc" |
1390 |
+ |
1391 |
+ # ia64 static cross-compilers are a pita in so much that they |
1392 |
+ # can't produce static ELFs (as the libgcc.a is broken). so |
1393 |
+ # disable building of the programs for those targets if it |
1394 |
+ # doesn't work. |
1395 |
+ # XXX: We could turn this into a compiler test, but ia64 is |
1396 |
+ # the only one that matters, so this should be fine for now. |
1397 |
+ if is_crosscompile && [[ ${CTARGET} == ia64* ]] ; then |
1398 |
+ sed -i '1i+link-static = touch $@' config.make |
1399 |
+ fi |
1400 |
+ |
1401 |
+ # If we're trying to migrate between ABI sets, we need |
1402 |
+ # to lie and use a local copy of gcc. Like if the system |
1403 |
+ # is built with MULTILIB_ABIS="amd64 x86" but we want to |
1404 |
+ # add x32 to it, gcc/glibc don't yet support x32. |
1405 |
+ # |
1406 |
+ if [[ -n ${GCC_BOOTSTRAP_VER} ]] && use multilib ; then |
1407 |
+ echo 'main(){}' > "${T}"/test.c |
1408 |
+ if ! $(tc-getCC ${CTARGET}) ${CFLAGS} ${LDFLAGS} "${T}"/test.c -Wl,-emain -lgcc 2>/dev/null ; then |
1409 |
+ sed -i -e '/^CC = /s:$: -B$(objdir)/../'"gcc-multilib-bootstrap-${GCC_BOOTSTRAP_VER}/${ABI}:" config.make || die |
1410 |
+ fi |
1411 |
+ fi |
1412 |
+} |
1413 |
+ |
1414 |
+glibc_headers_configure() { |
1415 |
+ export ABI=default |
1416 |
+ |
1417 |
+ local builddir=$(builddir "headers") |
1418 |
+ mkdir -p "${builddir}" |
1419 |
+ cd "${builddir}" |
1420 |
+ |
1421 |
+ # if we don't have a compiler yet, we can't really test it now ... |
1422 |
+ # hopefully they don't affect header generation, so let's hope for |
1423 |
+ # the best here ... |
1424 |
+ local v vars=( |
1425 |
+ ac_cv_header_cpuid_h=yes |
1426 |
+ libc_cv_{386,390,alpha,arm,hppa,ia64,mips,{powerpc,sparc}{,32,64},sh,x86_64}_tls=yes |
1427 |
+ libc_cv_asm_cfi_directives=yes |
1428 |
+ libc_cv_broken_visibility_attribute=no |
1429 |
+ libc_cv_c_cleanup=yes |
1430 |
+ libc_cv_compiler_powerpc64le_binary128_ok=yes |
1431 |
+ libc_cv_forced_unwind=yes |
1432 |
+ libc_cv_gcc___thread=yes |
1433 |
+ libc_cv_mlong_double_128=yes |
1434 |
+ libc_cv_mlong_double_128ibm=yes |
1435 |
+ libc_cv_ppc_machine=yes |
1436 |
+ libc_cv_ppc_rel16=yes |
1437 |
+ libc_cv_predef_fortify_source=no |
1438 |
+ libc_cv_target_power8_ok=yes |
1439 |
+ libc_cv_visibility_attribute=yes |
1440 |
+ libc_cv_z_combreloc=yes |
1441 |
+ libc_cv_z_execstack=yes |
1442 |
+ libc_cv_z_initfirst=yes |
1443 |
+ libc_cv_z_nodelete=yes |
1444 |
+ libc_cv_z_nodlopen=yes |
1445 |
+ libc_cv_z_relro=yes |
1446 |
+ libc_mips_abi=${ABI} |
1447 |
+ libc_mips_float=$([[ $(tc-is-softfloat) == "yes" ]] && echo soft || echo hard) |
1448 |
+ # These libs don't have configure flags. |
1449 |
+ ac_cv_lib_audit_audit_log_user_avc_message=no |
1450 |
+ ac_cv_lib_cap_cap_init=no |
1451 |
+ ) |
1452 |
+ |
1453 |
+ einfo "Forcing cached settings:" |
1454 |
+ for v in "${vars[@]}" ; do |
1455 |
+ einfo " ${v}" |
1456 |
+ export ${v} |
1457 |
+ done |
1458 |
+ |
1459 |
+ local headers_only_arch_CPPFLAGS=() |
1460 |
+ |
1461 |
+ # Blow away some random CC settings that screw things up. #550192 |
1462 |
+ if [[ -d ${S}/sysdeps/mips ]]; then |
1463 |
+ pushd "${S}"/sysdeps/mips >/dev/null |
1464 |
+ sed -i -e '/^CC +=/s:=.*:= -D_MIPS_SZPTR=32:' mips32/Makefile mips64/n32/Makefile || die |
1465 |
+ sed -i -e '/^CC +=/s:=.*:= -D_MIPS_SZPTR=64:' mips64/n64/Makefile || die |
1466 |
+ |
1467 |
+ # Force the mips ABI to the default. This is OK because the set of |
1468 |
+ # installed headers in this phase is the same between the 3 ABIs. |
1469 |
+ # If this ever changes, this hack will break, but that's unlikely |
1470 |
+ # as glibc discourages that behavior. |
1471 |
+ # https://crbug.com/647033 |
1472 |
+ sed -i -e 's:abiflag=.*:abiflag=_ABIO32:' preconfigure || die |
1473 |
+ |
1474 |
+ popd >/dev/null |
1475 |
+ fi |
1476 |
+ |
1477 |
+ case ${CTARGET} in |
1478 |
+ riscv*) |
1479 |
+ # RISC-V interrogates the compiler to determine which target to |
1480 |
+ # build. If building the headers then we don't strictly need a |
1481 |
+ # RISC-V compiler, so the built-in definitions that are provided |
1482 |
+ # along with all RISC-V compiler might not exist. This causes |
1483 |
+ # glibc's RISC-V preconfigure script to blow up. Since we're just |
1484 |
+ # building the headers any value will actually work here, so just |
1485 |
+ # pick the standard one (rv64g/lp64d) to make the build scripts |
1486 |
+ # happy for now -- the headers are all the same anyway so it |
1487 |
+ # doesn't matter. |
1488 |
+ headers_only_arch_CPPFLAGS+=( |
1489 |
+ -D__riscv_xlen=64 |
1490 |
+ -D__riscv_flen=64 |
1491 |
+ -D__riscv_float_abi_double=1 |
1492 |
+ -D__riscv_atomic=1 |
1493 |
+ ) ;; |
1494 |
+ esac |
1495 |
+ |
1496 |
+ local myconf=() |
1497 |
+ myconf+=( |
1498 |
+ --disable-sanity-checks |
1499 |
+ --enable-hacker-mode |
1500 |
+ --without-cvs |
1501 |
+ --disable-werror |
1502 |
+ --enable-bind-now |
1503 |
+ --build=${CBUILD_OPT:-${CBUILD}} |
1504 |
+ --host=${CTARGET_OPT:-${CTARGET}} |
1505 |
+ --with-headers=$(alt_build_headers) |
1506 |
+ --prefix="${EPREFIX}/usr" |
1507 |
+ ${EXTRA_ECONF} |
1508 |
+ ) |
1509 |
+ |
1510 |
+ # Nothing is compiled here which would affect the headers for the target. |
1511 |
+ # So forcing CC/CFLAGS is sane. |
1512 |
+ local headers_only_CC=$(tc-getBUILD_CC) |
1513 |
+ local headers_only_CFLAGS="-O1 -pipe" |
1514 |
+ local headers_only_CPPFLAGS="-U_FORTIFY_SOURCE ${headers_only_arch_CPPFLAGS[*]}" |
1515 |
+ local headers_only_LDFLAGS="" |
1516 |
+ set -- "${S}"/configure "${myconf[@]}" |
1517 |
+ echo \ |
1518 |
+ "CC=${headers_only_CC}" \ |
1519 |
+ "CFLAGS=${headers_only_CFLAGS}" \ |
1520 |
+ "CPPFLAGS=${headers_only_CPPFLAGS}" \ |
1521 |
+ "LDFLAGS=${headers_only_LDFLAGS}" \ |
1522 |
+ "$@" |
1523 |
+ CC=${headers_only_CC} \ |
1524 |
+ CFLAGS=${headers_only_CFLAGS} \ |
1525 |
+ CPPFLAGS=${headers_only_CPPFLAGS} \ |
1526 |
+ LDFLAGS="" \ |
1527 |
+ "$@" || die "failed to configure glibc" |
1528 |
+} |
1529 |
+ |
1530 |
+do_src_configure() { |
1531 |
+ if just_headers ; then |
1532 |
+ glibc_headers_configure |
1533 |
+ else |
1534 |
+ glibc_do_configure nptl |
1535 |
+ fi |
1536 |
+} |
1537 |
+ |
1538 |
+src_configure() { |
1539 |
+ foreach_abi do_src_configure |
1540 |
+} |
1541 |
+ |
1542 |
+do_src_compile() { |
1543 |
+ emake -C "$(builddir nptl)" || die "make nptl for ${ABI} failed" |
1544 |
+} |
1545 |
+ |
1546 |
+src_compile() { |
1547 |
+ if just_headers ; then |
1548 |
+ return |
1549 |
+ fi |
1550 |
+ |
1551 |
+ foreach_abi do_src_compile |
1552 |
+} |
1553 |
+ |
1554 |
+glibc_src_test() { |
1555 |
+ cd "$(builddir nptl)" |
1556 |
+ emake check |
1557 |
+} |
1558 |
+ |
1559 |
+do_src_test() { |
1560 |
+ local ret=0 |
1561 |
+ |
1562 |
+ glibc_src_test |
1563 |
+ : $(( ret |= $? )) |
1564 |
+ |
1565 |
+ return ${ret} |
1566 |
+} |
1567 |
+ |
1568 |
+src_test() { |
1569 |
+ if just_headers ; then |
1570 |
+ return |
1571 |
+ fi |
1572 |
+ |
1573 |
+ # Give tests more time to complete. |
1574 |
+ export TIMEOUTFACTOR=5 |
1575 |
+ |
1576 |
+ foreach_abi do_src_test || die "tests failed" |
1577 |
+} |
1578 |
+ |
1579 |
+run_locale_gen() { |
1580 |
+ # if the host locales.gen contains no entries, we'll install everything |
1581 |
+ local root="$1" |
1582 |
+ local locale_list="${root}/etc/locale.gen" |
1583 |
+ if [[ -z $(locale-gen --list --config "${locale_list}") ]] ; then |
1584 |
+ ewarn "Generating all locales; edit /etc/locale.gen to save time/space" |
1585 |
+ locale_list="${root}/usr/share/i18n/SUPPORTED" |
1586 |
+ fi |
1587 |
+ |
1588 |
+ locale-gen --jobs $(makeopts_jobs) --config "${locale_list}" \ |
1589 |
+ --destdir "${root}" |
1590 |
+} |
1591 |
+ |
1592 |
+glibc_do_src_install() { |
1593 |
+ local builddir=$(builddir nptl) |
1594 |
+ cd "${builddir}" |
1595 |
+ |
1596 |
+ emake install_root="${D}$(alt_prefix)" install || die |
1597 |
+ |
1598 |
+ # This version (2.26) provides some compatibility libraries for the NIS/NIS+ support |
1599 |
+ # which come without headers etc. Only needed for binary packages since the |
1600 |
+ # external net-libs/libnsl has increased soversion. Keep only versioned libraries. |
1601 |
+ find "${D}" -name "libnsl.a" -delete |
1602 |
+ find "${D}" -name "libnsl.so" -delete |
1603 |
+ |
1604 |
+ # Normally upstream_pv is ${PV}. Live ebuilds are exception, there we need |
1605 |
+ # to infer upstream version: |
1606 |
+ # '#define VERSION "2.26.90"' -> '2.26.90' |
1607 |
+ local upstream_pv=$(sed -n -r 's/#define VERSION "(.*)"/\1/p' "${S}"/version.h) |
1608 |
+ |
1609 |
+ if [[ -e ${ED}$(alt_usrlibdir)/libm-${upstream_pv}.a ]] ; then |
1610 |
+ # Move versioned .a file out of libdir to evade portage QA checks |
1611 |
+ # instead of using gen_usr_ldscript(). We fix ldscript as: |
1612 |
+ # "GROUP ( /usr/lib64/libm-<pv>.a ..." -> "GROUP ( /usr/lib64/glibc-<pv>/libm-<pv>.a ..." |
1613 |
+ sed -i "s@\(libm-${upstream_pv}.a\)@${P}/\1@" "${ED}"$(alt_usrlibdir)/libm.a || die |
1614 |
+ dodir $(alt_usrlibdir)/${P} |
1615 |
+ mv "${ED}"$(alt_usrlibdir)/libm-${upstream_pv}.a "${ED}"$(alt_usrlibdir)/${P}/libm-${upstream_pv}.a || die |
1616 |
+ fi |
1617 |
+ |
1618 |
+ # We'll take care of the cache ourselves |
1619 |
+ rm -f "${ED}"/etc/ld.so.cache |
1620 |
+ |
1621 |
+ # Everything past this point just needs to be done once ... |
1622 |
+ is_final_abi || return 0 |
1623 |
+ |
1624 |
+ # Make sure the non-native interp can be found on multilib systems even |
1625 |
+ # if the main library set isn't installed into the right place. Maybe |
1626 |
+ # we should query the active gcc for info instead of hardcoding it ? |
1627 |
+ local i ldso_abi ldso_name |
1628 |
+ local ldso_abi_list=( |
1629 |
+ # x86 |
1630 |
+ amd64 /lib64/ld-linux-x86-64.so.2 |
1631 |
+ x32 /libx32/ld-linux-x32.so.2 |
1632 |
+ x86 /lib/ld-linux.so.2 |
1633 |
+ # mips |
1634 |
+ o32 /lib/ld.so.1 |
1635 |
+ n32 /lib32/ld.so.1 |
1636 |
+ n64 /lib64/ld.so.1 |
1637 |
+ # powerpc |
1638 |
+ ppc /lib/ld.so.1 |
1639 |
+ ppc64 /lib64/ld64.so.1 |
1640 |
+ # riscv |
1641 |
+ lp64d /lib/ld-linux-riscv64-lp64d.so.1 |
1642 |
+ lp64 /lib/ld-linux-riscv64-lp64.so.1 |
1643 |
+ # s390 |
1644 |
+ s390 /lib/ld.so.1 |
1645 |
+ s390x /lib/ld64.so.1 |
1646 |
+ # sparc |
1647 |
+ sparc32 /lib/ld-linux.so.2 |
1648 |
+ sparc64 /lib64/ld-linux.so.2 |
1649 |
+ ) |
1650 |
+ case $(tc-endian) in |
1651 |
+ little) |
1652 |
+ ldso_abi_list+=( |
1653 |
+ # arm |
1654 |
+ arm64 /lib/ld-linux-aarch64.so.1 |
1655 |
+ ) |
1656 |
+ ;; |
1657 |
+ big) |
1658 |
+ ldso_abi_list+=( |
1659 |
+ # arm |
1660 |
+ arm64 /lib/ld-linux-aarch64_be.so.1 |
1661 |
+ ) |
1662 |
+ ;; |
1663 |
+ esac |
1664 |
+ if [[ ${SYMLINK_LIB} == "yes" ]] && [[ ! -e ${ED}/$(alt_prefix)/lib ]] ; then |
1665 |
+ dosym $(get_abi_LIBDIR ${DEFAULT_ABI}) $(alt_prefix)/lib |
1666 |
+ fi |
1667 |
+ for (( i = 0; i < ${#ldso_abi_list[@]}; i += 2 )) ; do |
1668 |
+ ldso_abi=${ldso_abi_list[i]} |
1669 |
+ has ${ldso_abi} $(get_install_abis) || continue |
1670 |
+ |
1671 |
+ ldso_name="$(alt_prefix)${ldso_abi_list[i+1]}" |
1672 |
+ if [[ ! -L ${ED}/${ldso_name} && ! -e ${ED}/${ldso_name} ]] ; then |
1673 |
+ dosym ../$(get_abi_LIBDIR ${ldso_abi})/${ldso_name##*/} ${ldso_name} |
1674 |
+ fi |
1675 |
+ done |
1676 |
+ |
1677 |
+ # With devpts under Linux mounted properly, we do not need the pt_chown |
1678 |
+ # binary to be setuid. This is because the default owners/perms will be |
1679 |
+ # exactly what we want. |
1680 |
+ if ! use suid ; then |
1681 |
+ find "${ED}" -name pt_chown -exec chmod -s {} + |
1682 |
+ fi |
1683 |
+ |
1684 |
+ ################################################################# |
1685 |
+ # EVERYTHING AFTER THIS POINT IS FOR NATIVE GLIBC INSTALLS ONLY # |
1686 |
+ # Make sure we install some symlink hacks so that when we build |
1687 |
+ # a 2nd stage cross-compiler, gcc finds the target system |
1688 |
+ # headers correctly. See gcc/doc/gccinstall.info |
1689 |
+ if is_crosscompile ; then |
1690 |
+ # We need to make sure that /lib and /usr/lib always exists. |
1691 |
+ # gcc likes to use relative paths to get to its multilibs like |
1692 |
+ # /usr/lib/../lib64/. So while we don't install any files into |
1693 |
+ # /usr/lib/, we do need it to exist. |
1694 |
+ keepdir $(alt_prefix)/lib |
1695 |
+ keepdir $(alt_prefix)/usr/lib |
1696 |
+ |
1697 |
+ dosym usr/include $(alt_prefix)/sys-include |
1698 |
+ return 0 |
1699 |
+ fi |
1700 |
+ |
1701 |
+ # Files for Debian-style locale updating |
1702 |
+ dodir /usr/share/i18n |
1703 |
+ sed \ |
1704 |
+ -e "/^#/d" \ |
1705 |
+ -e "/SUPPORTED-LOCALES=/d" \ |
1706 |
+ -e "s: \\\\::g" -e "s:/: :g" \ |
1707 |
+ "${S}"/localedata/SUPPORTED > "${ED}"/usr/share/i18n/SUPPORTED \ |
1708 |
+ || die "generating /usr/share/i18n/SUPPORTED failed" |
1709 |
+ cd "${WORKDIR}"/extra/locale |
1710 |
+ dosbin locale-gen |
1711 |
+ doman *.[0-8] |
1712 |
+ insinto /etc |
1713 |
+ doins locale.gen |
1714 |
+ |
1715 |
+ # Make sure all the ABI's can find the locales and so we only |
1716 |
+ # have to generate one set |
1717 |
+ local a |
1718 |
+ keepdir /usr/$(get_libdir)/locale |
1719 |
+ for a in $(get_install_abis) ; do |
1720 |
+ if [[ ! -e ${ED}/usr/$(get_abi_LIBDIR ${a})/locale ]] ; then |
1721 |
+ dosym ../$(get_libdir)/locale /usr/$(get_abi_LIBDIR ${a})/locale |
1722 |
+ fi |
1723 |
+ done |
1724 |
+ |
1725 |
+ # HACK: If we're building for riscv, we need to additionally make sure that |
1726 |
+ # we can find the locale archive afterwards |
1727 |
+ case ${CTARGET} in |
1728 |
+ riscv*) |
1729 |
+ if [[ ! -e ${ED}/usr/lib/locale ]] ; then |
1730 |
+ dosym ../$(get_libdir)/locale /usr/lib/locale |
1731 |
+ fi |
1732 |
+ ;; |
1733 |
+ *) ;; |
1734 |
+ esac |
1735 |
+ |
1736 |
+ cd "${S}" |
1737 |
+ |
1738 |
+ # Install misc network config files |
1739 |
+ insinto /etc |
1740 |
+ doins nscd/nscd.conf posix/gai.conf nss/nsswitch.conf |
1741 |
+ doins "${WORKDIR}"/extra/etc/*.conf |
1742 |
+ |
1743 |
+ if use nscd ; then |
1744 |
+ doinitd "$(prefixify_ro "${WORKDIR}"/extra/etc/nscd)" |
1745 |
+ |
1746 |
+ local nscd_args=( |
1747 |
+ -e "s:@PIDFILE@:$(strings "${ED}"/usr/sbin/nscd | grep nscd.pid):" |
1748 |
+ ) |
1749 |
+ |
1750 |
+ sed -i "${nscd_args[@]}" "${ED}"/etc/init.d/nscd |
1751 |
+ |
1752 |
+ systemd_dounit nscd/nscd.service |
1753 |
+ systemd_newtmpfilesd nscd/nscd.tmpfiles nscd.conf |
1754 |
+ else |
1755 |
+ # Do this since extra/etc/*.conf above might have nscd.conf. |
1756 |
+ rm -f "${ED}"/etc/nscd.conf |
1757 |
+ fi |
1758 |
+ |
1759 |
+ echo 'LDPATH="include ld.so.conf.d/*.conf"' > "${T}"/00glibc |
1760 |
+ doenvd "${T}"/00glibc |
1761 |
+ |
1762 |
+ for d in BUGS ChangeLog CONFORMANCE FAQ NEWS NOTES PROJECTS README* ; do |
1763 |
+ [[ -s ${d} ]] && dodoc ${d} |
1764 |
+ done |
1765 |
+ dodoc -r ChangeLog.old |
1766 |
+ |
1767 |
+ # Prevent overwriting of the /etc/localtime symlink. We'll handle the |
1768 |
+ # creation of the "factory" symlink in pkg_postinst(). |
1769 |
+ rm -f "${ED}"/etc/localtime |
1770 |
+ |
1771 |
+ # Generate all locales if this is a native build as locale generation |
1772 |
+ if use compile-locales && ! is_crosscompile ; then |
1773 |
+ run_locale_gen "${ED}" |
1774 |
+ fi |
1775 |
+} |
1776 |
+ |
1777 |
+glibc_headers_install() { |
1778 |
+ local builddir=$(builddir "headers") |
1779 |
+ cd "${builddir}" |
1780 |
+ emake install_root="${D}$(alt_prefix)" install-headers |
1781 |
+ |
1782 |
+ insinto $(alt_headers)/gnu |
1783 |
+ doins "${S}"/include/gnu/stubs.h |
1784 |
+ |
1785 |
+ # Make sure we install the sys-include symlink so that when |
1786 |
+ # we build a 2nd stage cross-compiler, gcc finds the target |
1787 |
+ # system headers correctly. See gcc/doc/gccinstall.info |
1788 |
+ dosym usr/include $(alt_prefix)/sys-include |
1789 |
+} |
1790 |
+ |
1791 |
+src_strip() { |
1792 |
+ # gdb is lame and requires some debugging information to remain in |
1793 |
+ # libpthread, so we need to strip it by hand. libthread_db makes no |
1794 |
+ # sense stripped as it is only used when debugging. |
1795 |
+ local pthread=$(has splitdebug ${FEATURES} && echo "libthread_db" || echo "lib{pthread,thread_db}") |
1796 |
+ env \ |
1797 |
+ -uRESTRICT \ |
1798 |
+ CHOST=${CTARGET} \ |
1799 |
+ STRIP_MASK="/*/{,tls/}${pthread}*" \ |
1800 |
+ prepallstrip |
1801 |
+ # if user has stripping enabled and does not have split debug turned on, |
1802 |
+ # then leave the debugging sections in libpthread. |
1803 |
+ if ! has nostrip ${FEATURES} && ! has splitdebug ${FEATURES} ; then |
1804 |
+ ${STRIP:-${CTARGET}-strip} --strip-debug "${ED}"$(alt_prefix)/*/libpthread-*.so |
1805 |
+ fi |
1806 |
+} |
1807 |
+ |
1808 |
+src_install() { |
1809 |
+ if just_headers ; then |
1810 |
+ export ABI=default |
1811 |
+ glibc_headers_install |
1812 |
+ return |
1813 |
+ fi |
1814 |
+ |
1815 |
+ foreach_abi glibc_do_src_install |
1816 |
+ src_strip |
1817 |
+} |
1818 |
+ |
1819 |
+# Simple test to make sure our new glibc isn't completely broken. |
1820 |
+# Make sure we don't test with statically built binaries since |
1821 |
+# they will fail. Also, skip if this glibc is a cross compiler. |
1822 |
+# |
1823 |
+# If coreutils is built with USE=multicall, some of these files |
1824 |
+# will just be wrapper scripts, not actual ELFs we can test. |
1825 |
+glibc_sanity_check() { |
1826 |
+ cd / #228809 |
1827 |
+ |
1828 |
+ # We enter ${ED} so to avoid trouble if the path contains |
1829 |
+ # special characters; for instance if the path contains the |
1830 |
+ # colon character (:), then the linker will try to split it |
1831 |
+ # and look for the libraries in an unexpected place. This can |
1832 |
+ # lead to unsafe code execution if the generated prefix is |
1833 |
+ # within a world-writable directory. |
1834 |
+ # (e.g. /var/tmp/portage:${HOSTNAME}) |
1835 |
+ pushd "${ED}"/$(get_libdir) >/dev/null |
1836 |
+ |
1837 |
+ local x striptest |
1838 |
+ for x in cal date env free ls true uname uptime ; do |
1839 |
+ x=$(type -p ${x}) |
1840 |
+ [[ -z ${x} || ${x} != ${EPREFIX}/* ]] && continue |
1841 |
+ striptest=$(LC_ALL="C" file -L ${x} 2>/dev/null) || continue |
1842 |
+ case ${striptest} in |
1843 |
+ *"statically linked"*) continue;; |
1844 |
+ *"ASCII text"*) continue;; |
1845 |
+ esac |
1846 |
+ # We need to clear the locale settings as the upgrade might want |
1847 |
+ # incompatible locale data. This test is not for verifying that. |
1848 |
+ LC_ALL=C \ |
1849 |
+ ./ld-*.so --library-path . ${x} > /dev/null \ |
1850 |
+ || die "simple run test (${x}) failed" |
1851 |
+ done |
1852 |
+ |
1853 |
+ popd >/dev/null |
1854 |
+} |
1855 |
+ |
1856 |
+pkg_preinst() { |
1857 |
+ # nothing to do if just installing headers |
1858 |
+ just_headers && return |
1859 |
+ |
1860 |
+ # prepare /etc/ld.so.conf.d/ for files |
1861 |
+ mkdir -p "${EROOT}"/etc/ld.so.conf.d |
1862 |
+ |
1863 |
+ # Default /etc/hosts.conf:multi to on for systems with small dbs. |
1864 |
+ if [[ $(wc -l < "${EROOT}"/etc/hosts) -lt 1000 ]] ; then |
1865 |
+ sed -i '/^multi off/s:off:on:' "${ED}"/etc/host.conf |
1866 |
+ einfo "Defaulting /etc/host.conf:multi to on" |
1867 |
+ fi |
1868 |
+ |
1869 |
+ [[ ${ROOT} != "/" ]] && return 0 |
1870 |
+ [[ -d ${ED}/$(get_libdir) ]] || return 0 |
1871 |
+ [[ -z ${BOOTSTRAP_RAP} ]] && glibc_sanity_check |
1872 |
+} |
1873 |
+ |
1874 |
+pkg_postinst() { |
1875 |
+ # nothing to do if just installing headers |
1876 |
+ just_headers && return |
1877 |
+ |
1878 |
+ if ! tc-is-cross-compiler && [[ -x ${EROOT}/usr/sbin/iconvconfig ]] ; then |
1879 |
+ # Generate fastloading iconv module configuration file. |
1880 |
+ "${EROOT}"/usr/sbin/iconvconfig --prefix="${ROOT}" |
1881 |
+ fi |
1882 |
+ |
1883 |
+ if ! is_crosscompile && [[ ${ROOT} == "/" ]] ; then |
1884 |
+ # Reload init ... if in a chroot or a diff init package, ignore |
1885 |
+ # errors from this step #253697 |
1886 |
+ /sbin/telinit U 2>/dev/null |
1887 |
+ |
1888 |
+ use compile-locales || run_locale_gen "${EROOT}" |
1889 |
+ fi |
1890 |
+ |
1891 |
+ # Check for sanity of /etc/nsswitch.conf, take 2 |
1892 |
+ if [[ -e ${EROOT}/etc/nsswitch.conf ]] && ! has_version sys-auth/libnss-nis ; then |
1893 |
+ local entry |
1894 |
+ for entry in passwd group shadow; do |
1895 |
+ if egrep -q "^[ \t]*${entry}:.*nis" "${EROOT}"/etc/nsswitch.conf; then |
1896 |
+ ewarn "" |
1897 |
+ ewarn "Your ${EROOT}/etc/nsswitch.conf uses NIS. Support for that has been" |
1898 |
+ ewarn "removed from glibc and is now provided by the package" |
1899 |
+ ewarn " sys-auth/libnss-nis" |
1900 |
+ ewarn "Install it now to keep your NIS setup working." |
1901 |
+ ewarn "" |
1902 |
+ fi |
1903 |
+ done |
1904 |
+ fi |
1905 |
+} |
1906 |
|
1907 |
diff --git a/sys-libs/glibc/metadata.xml b/sys-libs/glibc/metadata.xml |
1908 |
new file mode 100644 |
1909 |
index 0000000..002e981 |
1910 |
--- /dev/null |
1911 |
+++ b/sys-libs/glibc/metadata.xml |
1912 |
@@ -0,0 +1,21 @@ |
1913 |
+<?xml version="1.0" encoding="UTF-8"?> |
1914 |
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd"> |
1915 |
+<pkgmetadata> |
1916 |
+<maintainer type="project"> |
1917 |
+ <email>toolchain@g.o</email> |
1918 |
+ <name>Gentoo Toolchain Project</name> |
1919 |
+</maintainer> |
1920 |
+<use> |
1921 |
+ <flag name="cet">Enable Intel Control-flow Enforcement Technology (needs binutils 2.29 and gcc 8)</flag> |
1922 |
+ <flag name="compile-locales">build *all* locales in src_install; this is generally meant for stage building only as it ignores /etc/locale.gen file and can be pretty slow</flag> |
1923 |
+ <flag name="gd">build memusage and memusagestat tools</flag> |
1924 |
+ <flag name="multiarch">enable optimizations for multiple CPU architectures (detected at runtime)</flag> |
1925 |
+ <flag name="nscd">Build, and enable support for, the Name Service Cache Daemon</flag> |
1926 |
+ <flag name="ssp">protect stack of glibc internals</flag> |
1927 |
+ <flag name="suid">Make internal pt_chown helper setuid -- not needed if using Linux and have /dev/pts mounted with gid=5</flag> |
1928 |
+ <flag name="systemtap">enable systemtap static probe points</flag> |
1929 |
+</use> |
1930 |
+<upstream> |
1931 |
+ <remote-id type="cpe">cpe:/a:gnu:glibc</remote-id> |
1932 |
+</upstream> |
1933 |
+</pkgmetadata> |