Gentoo Archives: gentoo-commits

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