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