summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys-libs/glibc/Manifest4
-rw-r--r--sys-libs/glibc/files/2.20/glibc-2.20-gentoo-chk_fail.c299
-rw-r--r--sys-libs/glibc/files/2.20/glibc-2.20-gentoo-stack_chk_fail.c2
-rw-r--r--sys-libs/glibc/files/2.20/glibc-2.20-hardened-inittls-nosysenter.patch306
-rw-r--r--sys-libs/glibc/glibc-2.30-r8.ebuild (renamed from sys-libs/glibc/glibc-2.28-r314.ebuild)304
5 files changed, 181 insertions, 734 deletions
diff --git a/sys-libs/glibc/Manifest b/sys-libs/glibc/Manifest
index 01f7837d..f1a1af01 100644
--- a/sys-libs/glibc/Manifest
+++ b/sys-libs/glibc/Manifest
@@ -1,3 +1,3 @@
DIST gcc-multilib-bootstrap-20180511.tar.xz 2392908 BLAKE2B f3cf614399368acd8908f60d894c6344a2fa09383b30c1633a0682bc668367c8a2f8c6fec2d41b6e2178d709a2bd8db57e8b2ab56ba263c7d56f819c15acd061 SHA512 98c766e913693ab42ff790557acde2a36a8001e2648046a685b21964200df8d4d52d8452d499c0068c6648284d086ce062c2d36e2c6c2fd8aacd232d193f2853
-DIST glibc-2.28-patches-9.tar.xz 98588 BLAKE2B 4ab583be712994f949dee2512da6e12fd7f7ad73e96393f21678552b43da98f49321b53b5b009551300cdb09ca135e7f6adc636ff750c251a1d6d7f262dbc410 SHA512 e3f40ae6e9d06471c1a11bd2bce7b5161d07c3d0a81791505a72aec4817e7faf9ef09841e98c6dcf62a0a00754dff87dd194d97ac6b6354aeb2497cf60900b96
-DIST glibc-2.28.tar.xz 16484344 BLAKE2B 9aa8cbd5a145c2a6fde3a60b3d0a14b12b46ed79333ad1ca3e73464adcfe700277a17a9e7fd0ca36e355a0c5b0b27decfa091da320ba802741ad75cc955bbcc8 SHA512 521f820953ff07c69ece4c2186f59fc061a7f9747932cd70ef2995c2b2deee76eeb6de700d85071cdca5949179aa8ccee75eda7feca1394121ec7b821ad0a3f3
+DIST glibc-2.30-patches-10.tar.xz 72808 BLAKE2B a7a95c99482524b2896d15539766f1e6b1fe34a22f32119248c6dd44f42632076e86fdcbbdc2d604ec73ceccdd8a7f5936a62a6f4c3d039fae8f6901dfc6be77 SHA512 af5e213ff08bf38f6f529816c36b4e38df27207c2df254609ebe45b2f039ab553bbe563aa6f64b6667d328fd2c120dc21b6e2676540bdd94e58079237089eac3
+DIST glibc-2.30.tar.xz 16576920 BLAKE2B bd5aae4c9854f40785b91f83c3b632de6d48d811027ddfe61651cb1bc617db8017d7914c23a770cdd3feed06fcc316da841eea916cdba54179e7eace4ea45484 SHA512 37483990cd653685873e96c45dd1651b32b441b6d7919a68ebe3bae31a0c3f7ce183fc9b110f0b268b353f80312f18370559a1e7aecea0e5aa755c8f2aef1d6b
diff --git a/sys-libs/glibc/files/2.20/glibc-2.20-gentoo-chk_fail.c b/sys-libs/glibc/files/2.20/glibc-2.20-gentoo-chk_fail.c
deleted file mode 100644
index a8ab9d8a..00000000
--- a/sys-libs/glibc/files/2.20/glibc-2.20-gentoo-chk_fail.c
+++ /dev/null
@@ -1,299 +0,0 @@
-/* Copyright (C) 2004-2014 Free Software Foundation, Inc.
- Copyright (C) 2006-2014 Gentoo Foundation Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
-
-/* Hardened Gentoo SSP and FORTIFY handler
-
- A failure handler that does not use functions from the rest of glibc;
- it uses the INTERNAL_SYSCALL methods directly. This helps ensure no
- possibility of recursion into the handler.
-
- Direct all bug reports to http://bugs.gentoo.org/
-
- People who have contributed significantly to the evolution of this file:
- Ned Ludd - <solar[@]gentoo.org>
- Alexander Gabert - <pappy[@]gentoo.org>
- The PaX Team - <pageexec[@]freemail.hu>
- Peter S. Mazinger - <ps.m[@]gmx.net>
- Yoann Vandoorselaere - <yoann[@]prelude-ids.org>
- Robert Connolly - <robert[@]linuxfromscratch.org>
- Cory Visi <cory[@]visi.name>
- Mike Frysinger <vapier[@]gentoo.org>
- Magnus Granberg <zorry[@]gentoo.org>
- Kevin F. Quinn - <kevquinn[@]gentoo.org>
- */
-
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <signal.h>
-
-#include <sys/types.h>
-
-#include <sysdep-cancel.h>
-#include <sys/syscall.h>
-
-#include <kernel-features.h>
-
-#include <alloca.h>
-/* from sysdeps */
-#include <socketcall.h>
-/* for the stuff in bits/socket.h */
-#include <sys/socket.h>
-#include <sys/un.h>
-
-/* Sanity check on SYSCALL macro names - force compilation
- * failure if the names used here do not exist
- */
-#if !defined __NR_socketcall && !defined __NR_socket
-# error Cannot do syscall socket or socketcall
-#endif
-#if !defined __NR_socketcall && !defined __NR_connect
-# error Cannot do syscall connect or socketcall
-#endif
-#ifndef __NR_write
-# error Cannot do syscall write
-#endif
-#ifndef __NR_close
-# error Cannot do syscall close
-#endif
-#ifndef __NR_getpid
-# error Cannot do syscall getpid
-#endif
-#ifndef __NR_kill
-# error Cannot do syscall kill
-#endif
-#ifndef __NR_exit
-# error Cannot do syscall exit
-#endif
-#ifdef SSP_SMASH_DUMPS_CORE
-# define ENABLE_SSP_SMASH_DUMPS_CORE 1
-# if !defined _KERNEL_NSIG && !defined _NSIG
-# error No _NSIG or _KERNEL_NSIG for rt_sigaction
-# endif
-# if !defined __NR_sigaction && !defined __NR_rt_sigaction
-# error Cannot do syscall sigaction or rt_sigaction
-# endif
-/* Although rt_sigaction expects sizeof(sigset_t) - it expects the size
- * of the _kernel_ sigset_t which is not the same as the user sigset_t.
- * Most arches have this as _NSIG bits - mips has _KERNEL_NSIG bits for
- * some reason.
- */
-# ifdef _KERNEL_NSIG
-# define _SSP_NSIG _KERNEL_NSIG
-# else
-# define _SSP_NSIG _NSIG
-# endif
-#else
-# define _SSP_NSIG 0
-# define ENABLE_SSP_SMASH_DUMPS_CORE 0
-#endif
-
-/* Define DO_SIGACTION - default to newer rt signal interface but
- * fallback to old as needed.
- */
-#ifdef __NR_rt_sigaction
-# define DO_SIGACTION(signum, act, oldact) \
- INLINE_SYSCALL(rt_sigaction, 4, signum, act, oldact, _SSP_NSIG/8)
-#else
-# define DO_SIGACTION(signum, act, oldact) \
- INLINE_SYSCALL(sigaction, 3, signum, act, oldact)
-#endif
-
-/* Define DO_SOCKET/DO_CONNECT functions to deal with socketcall vs socket/connect */
-#if defined(__NR_socket) && defined(__NR_connect)
-# define USE_OLD_SOCKETCALL 0
-#else
-# define USE_OLD_SOCKETCALL 1
-#endif
-
-/* stub out the __NR_'s so we can let gcc optimize away dead code */
-#ifndef __NR_socketcall
-# define __NR_socketcall 0
-#endif
-#ifndef __NR_socket
-# define __NR_socket 0
-#endif
-#ifndef __NR_connect
-# define __NR_connect 0
-#endif
-#define DO_SOCKET(result, domain, type, protocol) \
- do { \
- if (USE_OLD_SOCKETCALL) { \
- socketargs[0] = domain; \
- socketargs[1] = type; \
- socketargs[2] = protocol; \
- socketargs[3] = 0; \
- result = INLINE_SYSCALL(socketcall, 2, SOCKOP_socket, socketargs); \
- } else \
- result = INLINE_SYSCALL(socket, 3, domain, type, protocol); \
- } while (0)
-#define DO_CONNECT(result, sockfd, serv_addr, addrlen) \
- do { \
- if (USE_OLD_SOCKETCALL) { \
- socketargs[0] = sockfd; \
- socketargs[1] = (unsigned long int)serv_addr; \
- socketargs[2] = addrlen; \
- socketargs[3] = 0; \
- result = INLINE_SYSCALL(socketcall, 2, SOCKOP_connect, socketargs); \
- } else \
- result = INLINE_SYSCALL(connect, 3, sockfd, serv_addr, addrlen); \
- } while (0)
-
-#ifndef _PATH_LOG
-# define _PATH_LOG "/dev/log"
-#endif
-
-static const char path_log[] = _PATH_LOG;
-
-/* For building glibc with SSP switched on, define __progname to a
- * constant if building for the run-time loader, to avoid pulling
- * in more of libc.so into ld.so
- */
-#ifdef IS_IN_rtld
-static const char *__progname = "<ldso>";
-#else
-extern const char *__progname;
-#endif
-
-#ifdef GENTOO_SSP_HANDLER
-# define ERROR_MSG "stack smashing"
-#else
-# define ERROR_MSG "buffer overflow"
-#endif
-
-/* Common handler code, used by chk_fail
- * Inlined to ensure no self-references to the handler within itself.
- * Data static to avoid putting more than necessary on the stack,
- * to aid core debugging.
- */
-__attribute__ ((__noreturn__, __always_inline__))
-static inline void
-__hardened_gentoo_fail(void)
-{
-#define MESSAGE_BUFSIZ 512
- static pid_t pid;
- static int plen, i, hlen;
- static char message[MESSAGE_BUFSIZ];
- /* <11> is LOG_USER|LOG_ERR. A dummy date for loggers to skip over. */
- static const char msg_header[] = "<11>" __DATE__ " " __TIME__ " glibc-gentoo-hardened-check: ";
- static const char msg_ssd[] = "*** " ERROR_MSG " detected ***: ";
- static const char msg_terminated[] = " terminated; ";
- static const char msg_report[] = "report to " REPORT_BUGS_TO "\n";
- static const char msg_unknown[] = "<unknown>";
- static int log_socket, connect_result;
- static struct sockaddr_un sock;
- static unsigned long int socketargs[4];
-
- /* Build socket address */
- sock.sun_family = AF_UNIX;
- i = 0;
- while (path_log[i] != '\0' && i < sizeof(sock.sun_path) - 1) {
- sock.sun_path[i] = path_log[i];
- ++i;
- }
- sock.sun_path[i] = '\0';
-
- /* Try SOCK_DGRAM connection to syslog */
- connect_result = -1;
- DO_SOCKET(log_socket, AF_UNIX, SOCK_DGRAM, 0);
- if (log_socket != -1)
- DO_CONNECT(connect_result, log_socket, &sock, sizeof(sock));
- if (connect_result == -1) {
- if (log_socket != -1)
- INLINE_SYSCALL(close, 1, log_socket);
- /* Try SOCK_STREAM connection to syslog */
- DO_SOCKET(log_socket, AF_UNIX, SOCK_STREAM, 0);
- if (log_socket != -1)
- DO_CONNECT(connect_result, log_socket, &sock, sizeof(sock));
- }
-
- /* Build message. Messages are generated both in the old style and new style,
- * so that log watchers that are configured for the old-style message continue
- * to work.
- */
-#define strconcat(str) \
- ({ \
- i = 0; \
- while ((str[i] != '\0') && ((i + plen) < (MESSAGE_BUFSIZ - 1))) { \
- message[plen + i] = str[i]; \
- ++i; \
- } \
- plen += i; \
- })
-
- /* Tersely log the failure */
- plen = 0;
- strconcat(msg_header);
- hlen = plen;
- strconcat(msg_ssd);
- if (__progname != NULL)
- strconcat(__progname);
- else
- strconcat(msg_unknown);
- strconcat(msg_terminated);
- strconcat(msg_report);
-
- /* Write out error message to STDERR, to syslog if open */
- INLINE_SYSCALL(write, 3, STDERR_FILENO, message + hlen, plen - hlen);
- if (connect_result != -1) {
- INLINE_SYSCALL(write, 3, log_socket, message, plen);
- INLINE_SYSCALL(close, 1, log_socket);
- }
-
- /* Time to kill self since we have no idea what is going on */
- pid = INLINE_SYSCALL(getpid, 0);
-
- if (ENABLE_SSP_SMASH_DUMPS_CORE) {
- /* Remove any user-supplied handler for SIGABRT, before using it. */
-#if 0
- /*
- * Note: Disabled because some programs catch & process their
- * own crashes. We've already enabled this code path which
- * means we want to let core dumps happen.
- */
- static struct sigaction default_abort_act;
- default_abort_act.sa_handler = SIG_DFL;
- default_abort_act.sa_sigaction = NULL;
- __sigfillset(&default_abort_act.sa_mask);
- default_abort_act.sa_flags = 0;
- if (DO_SIGACTION(SIGABRT, &default_abort_act, NULL) == 0)
-#endif
- INLINE_SYSCALL(kill, 2, pid, SIGABRT);
- }
-
- /* SIGKILL is only signal which cannot be caught */
- INLINE_SYSCALL(kill, 2, pid, SIGKILL);
-
- /* In case the kill didn't work, exit anyway.
- * The loop prevents gcc thinking this routine returns.
- */
- while (1)
- INLINE_SYSCALL(exit, 1, 137);
-}
-
-__attribute__ ((__noreturn__))
-#ifdef GENTOO_SSP_HANDLER
-void __stack_chk_fail(void)
-#else
-void __chk_fail(void)
-#endif
-{
- __hardened_gentoo_fail();
-}
diff --git a/sys-libs/glibc/files/2.20/glibc-2.20-gentoo-stack_chk_fail.c b/sys-libs/glibc/files/2.20/glibc-2.20-gentoo-stack_chk_fail.c
deleted file mode 100644
index 4a537bb5..00000000
--- a/sys-libs/glibc/files/2.20/glibc-2.20-gentoo-stack_chk_fail.c
+++ /dev/null
@@ -1,2 +0,0 @@
-#define GENTOO_SSP_HANDLER
-#include <debug/chk_fail.c>
diff --git a/sys-libs/glibc/files/2.20/glibc-2.20-hardened-inittls-nosysenter.patch b/sys-libs/glibc/files/2.20/glibc-2.20-hardened-inittls-nosysenter.patch
deleted file mode 100644
index 35eabe94..00000000
--- a/sys-libs/glibc/files/2.20/glibc-2.20-hardened-inittls-nosysenter.patch
+++ /dev/null
@@ -1,306 +0,0 @@
-When building glibc PIE (which is not something upstream support),
-several modifications are necessary to the glibc build process.
-
-First, any syscalls in PIEs must be of the PIC variant, otherwise
-textrels ensue. Then, any syscalls made before the initialisation
-of the TLS will fail on i386, as the sysenter variant on i386 uses
-the TLS, giving rise to a chicken-and-egg situation. This patch
-defines a PIC syscall variant that doesn't use sysenter, even when the sysenter
-version is normally used, and uses the non-sysenter version for the brk
-syscall that is performed by the TLS initialisation. Further, the TLS
-initialisation is moved in this case prior to the initialisation of
-dl_osversion, as that requires further syscalls.
-
-csu/libc-start.c: Move initial TLS initialization to before the
-initialisation of dl_osversion, when INTERNAL_SYSCALL_PRE_TLS is defined
-
-csu/libc-tls.c: Use the no-sysenter version of sbrk when
-INTERNAL_SYSCALL_PRE_TLS is defined.
-
-misc/sbrk.c: Define a no-sysenter version of sbrk, using the no-sysenter
-version of brk - if INTERNAL_SYSCALL_PRE_TLS is defined.
-
-misc/brk.c: Define a no-sysenter version of brk if
-INTERNAL_SYSCALL_PRE_TLS is defined.
-
-sysdeps/unix/sysv/linux/i386/sysdep.h: Define INTERNAL_SYSCALL_PRE_TLS
-Make INTERNAL_SYSCALL always use the PIC variant, even if not SHARED.
-
-Patch by Kevin F. Quinn <kevquinn@gentoo.org>
-Fixed for 2.10 by Magnus Granberg <zorry@ume.nu>
-Fixed for 2.18 by Magnus Granberg <zorry@gentoo.org>
-Fixed for 2.20 by Francisco Blas Izquierdo Riera <klondike@gentoo.org>
-
---- a/csu/libc-start.c
-+++ b/csu/libc-start.c
-@@ -28,6 +28,7 @@
- extern int __libc_multiple_libcs;
-
- #include <tls.h>
-+#include <sysdep.h>
- #ifndef SHARED
- # include <dl-osinfo.h>
- extern void __pthread_initialize_minimal (void);
-@@ -170,6 +171,11 @@ LIBC_START_MAIN (int (*main) (int, char
- }
- }
-
-+# ifdef INTERNAL_SYSCALL_PRE_TLS
-+ /* Do the initial TLS initialization before _dl_osversion,
-+ since the latter uses the uname syscall. */
-+ __pthread_initialize_minimal ();
-+# endif
- # ifdef DL_SYSDEP_OSCHECK
- if (!__libc_multiple_libcs)
- {
-@@ -138,10 +144,12 @@
- }
- # endif
-
-+# ifndef INTERNAL_SYSCALL_PRE_TLS
- /* Initialize the thread library at least a bit since the libgcc
- functions are using thread functions if these are available and
- we need to setup errno. */
- __pthread_initialize_minimal ();
-+# endif
-
- /* Set up the stack checker's canary. */
- uintptr_t stack_chk_guard = _dl_setup_stack_chk_guard ();
---- a/csu/libc-tls.c
-+++ b/csu/libc-tls.c
-@@ -22,12 +22,17 @@
- #include <unistd.h>
- #include <stdio.h>
- #include <sys/param.h>
-+#include <sysdep.h>
-
-
- #ifdef SHARED
- #error makefile bug, this file is for static only
- #endif
-
-+#ifdef INTERNAL_SYSCALL_PRE_TLS
-+extern void *__sbrk_nosysenter (intptr_t __delta);
-+#endif
-+
- dtv_t _dl_static_dtv[2 + TLS_SLOTINFO_SURPLUS];
-
-
-@@ -139,20 +144,29 @@ __libc_setup_tls (size_t tcbsize, size_t
-
- The initialized value of _dl_tls_static_size is provided by dl-open.c
- to request some surplus that permits dynamic loading of modules with
-- IE-model TLS. */
-+ IE-model TLS.
-+
-+ Where the normal sbrk would use a syscall that needs the TLS (i386)
-+ use the special non-sysenter version instead. */
-+#ifdef INTERNAL_SYSCALL_PRE_TLS
-+# define __sbrk __sbrk_nosysenter
-+#endif
- #if TLS_TCB_AT_TP
- tcb_offset = roundup (memsz + GL(dl_tls_static_size), tcbalign);
- tlsblock = __sbrk (tcb_offset + tcbsize + max_align);
- #elif TLS_DTV_AT_TP
- tcb_offset = roundup (tcbsize, align ?: 1);
- tlsblock = __sbrk (tcb_offset + memsz + max_align
- + TLS_PRE_TCB_SIZE + GL(dl_tls_static_size));
- tlsblock += TLS_PRE_TCB_SIZE;
- #else
- /* In case a model with a different layout for the TCB and DTV
- is defined add another #elif here and in the following #ifs. */
- # error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined"
- #endif
-+#ifdef INTERNAL_SYSCALL_PRE_TLS
-+# undef __sbrk
-+#endif
-
- /* Align the TLS block. */
- tlsblock = (void *) (((uintptr_t) tlsblock + max_align - 1)
---- a/misc/sbrk.c
-+++ b/misc/sbrk.c
-@@ -18,6 +18,7 @@
- #include <errno.h>
- #include <stdint.h>
- #include <unistd.h>
-+#include <sysdep.h>
-
- /* Defined in brk.c. */
- extern void *__curbrk;
-@@ -29,6 +30,35 @@
- /* Extend the process's data space by INCREMENT.
- If INCREMENT is negative, shrink data space by - INCREMENT.
- Return start of new space allocated, or -1 for errors. */
-+#ifdef INTERNAL_SYSCALL_PRE_TLS
-+/* This version is used by csu/libc-tls.c whem initialising the TLS
-+ if the SYSENTER version requires the TLS (which it does on i386).
-+ Obviously using the TLS before it is initialised is broken. */
-+extern int __brk_nosysenter (void *addr);
-+void *
-+__sbrk_nosysenter (intptr_t increment)
-+{
-+ void *oldbrk;
-+
-+ /* If this is not part of the dynamic library or the library is used via
-+ dynamic loading in a statically linked program update __curbrk from the
-+ kernel's brk value. That way two separate instances of __brk and __sbrk
-+ can share the heap, returning interleaved pieces of it. */
-+ if (__curbrk == NULL || __libc_multiple_libcs)
-+ if (__brk_nosysenter (0) < 0) /* Initialize the break. */
-+ return (void *) -1;
-+
-+ if (increment == 0)
-+ return __curbrk;
-+
-+ oldbrk = __curbrk;
-+ if (__brk_nosysenter (oldbrk + increment) < 0)
-+ return (void *) -1;
-+
-+ return oldbrk;
-+}
-+#endif
-+
- void *
- __sbrk (intptr_t increment)
- {
---- a/sysdeps/unix/sysv/linux/i386/brk.c
-+++ b/sysdeps/unix/sysv/linux/i386/brk.c
-@@ -31,6 +31,30 @@
- linker. */
- weak_alias (__curbrk, ___brk_addr)
-
-+#ifdef INTERNAL_SYSCALL_PRE_TLS
-+/* This version is used by csu/libc-tls.c whem initialising the TLS
-+ if the SYSENTER version requires the TLS (which it does on i386).
-+ Obviously using the TLS before it is initialised is broken. */
-+int
-+__brk_nosysenter (void *addr)
-+{
-+ void *newbrk;
-+
-+ INTERNAL_SYSCALL_DECL (err);
-+ newbrk = (void *) INTERNAL_SYSCALL_PRE_TLS (brk, err, 1, addr);
-+
-+ __curbrk = newbrk;
-+
-+ if (newbrk < addr)
-+ {
-+ __set_errno (ENOMEM);
-+ return -1;
-+ }
-+
-+ return 0;
-+}
-+#endif
-+
- int
- __brk (void *addr)
- {
---- a/sysdeps/unix/sysv/linux/i386/sysdep.h
-+++ b/sysdeps/unix/sysv/linux/i386/sysdep.h
-@@ -187,7 +187,7 @@
- /* The original calling convention for system calls on Linux/i386 is
- to use int $0x80. */
- #ifdef I386_USE_SYSENTER
--# ifdef SHARED
-+# ifdef __PIC__
- # define ENTER_KERNEL call *%gs:SYSINFO_OFFSET
- # else
- # define ENTER_KERNEL call *_dl_sysinfo
-@@ -358,7 +358,7 @@
- possible to use more than four parameters. */
- #undef INTERNAL_SYSCALL
- #ifdef I386_USE_SYSENTER
--# ifdef SHARED
-+# ifdef __PIC__
- # define INTERNAL_SYSCALL(name, err, nr, args...) \
- ({ \
- register unsigned int resultvar; \
-@@ -384,6 +384,18 @@
- : "0" (name), "i" (offsetof (tcbhead_t, sysinfo)) \
- ASMFMT_##nr(args) : "memory", "cc"); \
- (int) resultvar; })
-+# define INTERNAL_SYSCALL_PRE_TLS(name, err, nr, args...) \
-+ ({ \
-+ register unsigned int resultvar; \
-+ EXTRAVAR_##nr \
-+ asm volatile ( \
-+ LOADARGS_NOSYSENTER_##nr \
-+ "movl %1, %%eax\n\t" \
-+ "int $0x80\n\t" \
-+ RESTOREARGS_NOSYSENTER_##nr \
-+ : "=a" (resultvar) \
-+ : "i" (__NR_##name) ASMFMT_##nr(args) : "memory", "cc"); \
-+ (int) resultvar; })
- # else
- # define INTERNAL_SYSCALL(name, err, nr, args...) \
- ({ \
-@@ -447,12 +459,20 @@
-
- #define LOADARGS_0
- #ifdef __PIC__
--# if defined I386_USE_SYSENTER && defined SHARED
-+# if defined I386_USE_SYSENTER && defined __PIC__
- # define LOADARGS_1 \
- "bpushl .L__X'%k3, %k3\n\t"
- # define LOADARGS_5 \
- "movl %%ebx, %4\n\t" \
- "movl %3, %%ebx\n\t"
-+# define LOADARGS_NOSYSENTER_1 \
-+ "bpushl .L__X'%k2, %k2\n\t"
-+# define LOADARGS_NOSYSENTER_2 LOADARGS_NOSYSENTER_1
-+# define LOADARGS_NOSYSENTER_3 LOADARGS_3
-+# define LOADARGS_NOSYSENTER_4 LOADARGS_3
-+# define LOADARGS_NOSYSENTER_5 \
-+ "movl %%ebx, %3\n\t" \
-+ "movl %2, %%ebx\n\t"
- # else
- # define LOADARGS_1 \
- "bpushl .L__X'%k2, %k2\n\t"
-@@ -474,11 +494,18 @@
-
- #define RESTOREARGS_0
- #ifdef __PIC__
--# if defined I386_USE_SYSENTER && defined SHARED
-+# if defined I386_USE_SYSENTER && defined __PIC__
- # define RESTOREARGS_1 \
- "bpopl .L__X'%k3, %k3\n\t"
- # define RESTOREARGS_5 \
- "movl %4, %%ebx"
-+# define RESTOREARGS_NOSYSENTER_1 \
-+ "bpopl .L__X'%k2, %k2\n\t"
-+# define RESTOREARGS_NOSYSENTER_2 RESTOREARGS_NOSYSENTER_1
-+# define RESTOREARGS_NOSYSENTER_3 RESTOREARGS_3
-+# define RESTOREARGS_NOSYSENTER_4 RESTOREARGS_3
-+# define RESTOREARGS_NOSYSENTER_5 \
-+ "movl %3, %%ebx"
- # else
- # define RESTOREARGS_1 \
- "bpopl .L__X'%k2, %k2\n\t"
---- a/sysdeps/i386/nptl/tls.h
-+++ b/sysdeps/i386/nptl/tls.h
-@@ -189,6 +189,15 @@
- desc->vals[3] = 0x51;
- }
-
-+/* We have no sysenter until the tls is initialized which is a
-+ problem for PIC. Thus we need to do the right call depending
-+ on the situation. */
-+#ifndef INTERNAL_SYSCALL_PRE_TLS
-+# define TLS_INIT_SYSCALL INTERNAL_SYSCALL
-+#else
-+# define TLS_INIT_SYSCALL INTERNAL_SYSCALL_PRE_TLS
-+#endif
-+
- /* Code to initially initialize the thread pointer. This might need
- special attention since 'errno' is not yet available and if the
- operation can cause a failure 'errno' must not be touched. */
-@@ -209,7 +218,7 @@
- \
- /* Install the TLS. */ \
- INTERNAL_SYSCALL_DECL (err); \
-- _result = INTERNAL_SYSCALL (set_thread_area, err, 1, &_segdescr.desc); \
-+ _result = TLS_INIT_SYSCALL (set_thread_area, err, 1, &_segdescr.desc); \
- \
- if (_result == 0) \
- /* We know the index in the GDT, now load the segment register. \
diff --git a/sys-libs/glibc/glibc-2.28-r314.ebuild b/sys-libs/glibc/glibc-2.30-r8.ebuild
index 8752c872..ca347296 100644
--- a/sys-libs/glibc/glibc-2.28-r314.ebuild
+++ b/sys-libs/glibc/glibc-2.30-r8.ebuild
@@ -1,9 +1,11 @@
-# Copyright 1999-2019 Gentoo Authors
+# Copyright 1999-2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
-EAPI=6
+EAPI=7
-inherit prefix eutils eapi7-ver toolchain-funcs flag-o-matic gnuconfig \
+PYTHON_COMPAT=( python3_{6,7,8} )
+
+inherit python-any-r1 prefix eutils toolchain-funcs flag-o-matic gnuconfig \
multilib systemd multiprocessing
DESCRIPTION="GNU libc C library"
@@ -17,7 +19,7 @@ if [[ ${PV} == 9999* ]]; then
EGIT_REPO_URI="https://sourceware.org/git/glibc.git"
inherit git-r3
else
- KEYWORDS="alpha amd64 arm arm64 hppa ia64 m68k ~mips ppc ppc64 s390 sh sparc x86"
+ KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86"
SRC_URI="mirror://gnu/glibc/${P}.tar.xz"
fi
@@ -26,12 +28,13 @@ RELEASE_VER=${PV}
GCC_BOOTSTRAP_VER=20180511
# Gentoo patchset
-PATCH_VER=9
+PATCH_VER=10
+PATCH_DEV=dilfridge
-SRC_URI+=" https://dev.gentoo.org/~dilfridge/distfiles/${P}-patches-${PATCH_VER}.tar.xz"
+SRC_URI+=" https://dev.gentoo.org/~${PATCH_DEV}/distfiles/${P}-patches-${PATCH_VER}.tar.xz"
SRC_URI+=" multilib? ( https://dev.gentoo.org/~dilfridge/distfiles/gcc-multilib-bootstrap-${GCC_BOOTSTRAP_VER}.tar.xz )"
-IUSE="audit caps cet compile-locales doc gd headers-only +multiarch multilib nscd profile selinux +ssp suid systemtap test vanilla"
+IUSE="audit caps cet compile-locales +crypt custom-cflags doc gd headers-only +multiarch multilib nscd profile selinux +ssp +static-libs suid systemtap test vanilla"
# Minimum kernel version that glibc requires
MIN_KERN_VER="3.2.0"
@@ -76,14 +79,20 @@ fi
# Thus our main goal here is to prevent 'libpthread.so.0' from
# losing it's '.symtab' entries.
# As Gentoo's strip does not allow us to pass less aggressive stripping
-# options and does not check the machine target we disable stripping
-# entirely.
-RESTRICT="strip !test? ( test )"
+# options and does not check the machine target we strip selectively.
# We need a new-enough binutils/gcc to match upstream baseline.
# Also we need to make sure our binutils/gcc supports TLS,
# and that gcc already contains the hardened patches.
+BDEPEND="
+ ${PYTHON_DEPS}
+ >=app-misc/pax-utils-0.1.10
+ sys-devel/bison
+ !<sys-devel/bison-2.7
+ doc? ( sys-apps/texinfo )
+"
COMMON_DEPEND="
+ gd? ( media-libs/gd:2= )
nscd? ( selinux? (
audit? ( sys-process/audit )
caps? ( sys-libs/libcap )
@@ -93,36 +102,53 @@ COMMON_DEPEND="
systemtap? ( dev-util/systemtap )
"
DEPEND="${COMMON_DEPEND}
- >=app-misc/pax-utils-0.1.10
- sys-devel/bison
- !<sys-devel/bison-2.7
- !<sys-devel/make-4
- doc? ( sys-apps/texinfo )
- test? ( >=net-dns/libidn2-2.0.5 )
+ test? ( >=net-dns/libidn2-2.3.0 )
"
RDEPEND="${COMMON_DEPEND}
sys-apps/gentoo-functions
"
+RESTRICT="!test? ( test )"
+
if [[ ${CATEGORY} == cross-* ]] ; then
- DEPEND+=" !headers-only? (
+ BDEPEND+=" !headers-only? (
>=${CATEGORY}/binutils-2.24
>=${CATEGORY}/gcc-6
)"
[[ ${CATEGORY} == *-linux* ]] && DEPEND+=" ${CATEGORY}/linux-headers"
else
- DEPEND+="
+ BDEPEND+="
>=sys-devel/binutils-2.24
>=sys-devel/gcc-6
- virtual/os-headers
"
+ DEPEND+=" virtual/os-headers "
RDEPEND+="
- >=net-dns/libidn2-2.0.5
+ >=net-dns/libidn2-2.3.0
vanilla? ( !sys-libs/timezone-data )
"
PDEPEND+=" !vanilla? ( sys-libs/timezone-data )"
fi
+# Ignore tests whitelisted below
+GENTOO_GLIBC_XFAIL_TESTS="${GENTOO_GLIBC_XFAIL_TESTS:-yes}"
+
+# The following tests fail due to the Gentoo build system and are thus
+# executed but ignored:
+XFAIL_TEST_LIST=(
+ # 1) Sandbox
+ tst-ldconfig-bad-aux-cache
+ tst-pldd
+ tst-mallocfork2
+ tst-nss-db-endgrent
+ tst-nss-db-endpwent
+ tst-nss-files-hosts-long
+ tst-nss-test3
+ # 2) Namespaces and cgroup
+ tst-locale-locpath
+ # 9) Failures of unknown origin
+ tst-latepthread
+)
+
#
# Small helper functions
#
@@ -139,6 +165,18 @@ alt_prefix() {
is_crosscompile && echo /usr/${CTARGET}
}
+# This prefix is applicable to CHOST when building against this
+# glibc. It is baked into the library at configure time.
+host_eprefix() {
+ is_crosscompile || echo "${EPREFIX}"
+}
+
+# This prefix is applicable to CBUILD when building against this
+# glibc. It determines the destination path at install time.
+build_eprefix() {
+ is_crosscompile && echo "${EPREFIX}"
+}
+
# We need to be able to set alternative headers for compiling for non-native
# platform. Will also become useful for testing kernel-headers without screwing
# up the whole system.
@@ -148,7 +186,7 @@ alt_headers() {
alt_build_headers() {
if [[ -z ${ALT_BUILD_HEADERS} ]] ; then
- ALT_BUILD_HEADERS="${EPREFIX}$(alt_headers)"
+ ALT_BUILD_HEADERS="$(host_eprefix)$(alt_headers)"
if tc-is-cross-compiler ; then
ALT_BUILD_HEADERS=${SYSROOT}$(alt_headers)
if [[ ! -e ${ALT_BUILD_HEADERS}/linux/version.h ]] ; then
@@ -181,7 +219,7 @@ do_compile_test() {
rm -f glibc-test*
printf '%b' "$*" > glibc-test.c
- nonfatal emake -s glibc-test
+ nonfatal emake glibc-test
ret=$?
popd >/dev/null
@@ -229,7 +267,7 @@ setup_target_flags() {
# We could change main to _start and pass -nostdlib here so that we
# only test the gcc code compilation. Or we could do a compile and
# then look for the symbol via scanelf.
- 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
+ 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
local t=${CTARGET_OPT:-${CTARGET}}
t=${t%%-*}
filter-flags '-march=*'
@@ -239,10 +277,9 @@ setup_target_flags() {
;;
amd64)
# -march needed for #185404 #199334
- # Note: This test only matters when the x86 ABI is enabled, so we could
- # optimize a bit and elide it.
# TODO: See cross-compile issues listed above for x86.
- 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
+ [[ ${ABI} == x86 ]] &&
+ 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
local t=${CTARGET_OPT:-${CTARGET}}
t=${t%%-*}
# Normally the target is x86_64-xxx, so turn that into the -march that
@@ -252,7 +289,7 @@ setup_target_flags() {
# ugly, ugly, ugly. ugly.
CFLAGS_x86=$(CFLAGS=${CFLAGS_x86} filter-flags '-march=*'; echo "${CFLAGS}")
export CFLAGS_x86="${CFLAGS_x86} -march=${t}"
- einfo "Auto adding -march=${t} to CFLAGS_x86 #185404"
+ einfo "Auto adding -march=${t} to CFLAGS_x86 #185404 (ABI=${ABI})"
fi
;;
mips)
@@ -264,77 +301,27 @@ setup_target_flags() {
filter-flags "-fcall-used-g7"
append-flags "-fcall-used-g6"
- # If the CHOST is the basic one (e.g. not sparcv9-xxx already),
- # try to pick a better one so glibc can use cpu-specific .S files.
- # We key off the CFLAGS to get a good value. Also need to handle
- # version skew.
- # We can't force users to set their CHOST to their exact machine
- # as many of these are not recognized by config.sub/gcc and such :(.
- # Note: If the mcpu values don't scale, we might try probing CPP defines.
- # Note: Should we factor in -Wa,-AvXXX flags too ? Or -mvis/etc... ?
-
local cpu
case ${CTARGET} in
sparc64-*)
+ cpu="sparc64"
case $(get-flag mcpu) in
- niagara[234])
- if ver_test -ge 2.8 ; then
- cpu="sparc64v2"
- elif ver_test -ge 2.4 ; then
- cpu="sparc64v"
- elif ver_test -ge 2.2.3 ; then
- cpu="sparc64b"
- fi
- ;;
- niagara)
- if ver_test -ge 2.4 ; then
- cpu="sparc64v"
- elif ver_test -ge 2.2.3 ; then
- cpu="sparc64b"
- fi
- ;;
- ultrasparc3)
- cpu="sparc64b"
- ;;
- *)
+ v9)
# We need to force at least v9a because the base build doesn't
# work with just v9.
# https://sourceware.org/bugzilla/show_bug.cgi?id=19477
- [[ -z ${cpu} ]] && append-flags "-Wa,-xarch=v9a"
+ append-flags "-Wa,-xarch=v9a"
;;
esac
;;
sparc-*)
case $(get-flag mcpu) in
- niagara[234])
- if ver_test -ge 2.8 ; then
- cpu="sparcv9v2"
- elif ver_test -ge 2.4 ; then
- cpu="sparcv9v"
- elif ver_test -ge 2.2.3 ; then
- cpu="sparcv9b"
- else
- cpu="sparcv9"
- fi
- ;;
- niagara)
- if ver_test -ge 2.4 ; then
- cpu="sparcv9v"
- elif ver_test -ge 2.2.3 ; then
- cpu="sparcv9b"
- else
- cpu="sparcv9"
- fi
- ;;
- ultrasparc3)
- cpu="sparcv9b"
- ;;
- v9|ultrasparc)
- cpu="sparcv9"
- ;;
v8|supersparc|hypersparc|leon|leon3)
cpu="sparcv8"
;;
+ *)
+ cpu="sparcv9"
+ ;;
esac
;;
esac
@@ -358,11 +345,18 @@ setup_flags() {
ASFLAGS_BASE=${ASFLAGS_BASE-${ASFLAGS}}
ASFLAGS=${ASFLAGS_BASE}
- # Over-zealous CFLAGS can often cause problems. What may work for one
- # person may not work for another. To avoid a large influx of bugs
- # relating to failed builds, we strip most CFLAGS out to ensure as few
- # problems as possible.
- strip-flags
+ # Allow users to explicitly avoid flag sanitization via
+ # USE=custom-cflags.
+ if ! use custom-cflags; then
+ # Over-zealous CFLAGS can often cause problems. What may work for one
+ # person may not work for another. To avoid a large influx of bugs
+ # relating to failed builds, we strip most CFLAGS out to ensure as few
+ # problems as possible.
+ strip-flags
+ # Lock glibc at -O2; we want to be conservative here.
+ filter-flags '-O?'
+ append-flags -O2
+ fi
strip-unsupported-flags
filter-flags -m32 -m64 '-mabi=*'
@@ -384,10 +378,9 @@ setup_flags() {
CBUILD_OPT=${CTARGET_OPT}
fi
- # Lock glibc at -O2; we want to be conservative here.
- # -fno-strict-aliasing is to work around #155906.
- filter-flags '-O?'
- append-flags -O2 -fno-strict-aliasing
+ # glibc's headers disallow -O0 and fail at build time:
+ # include/libc-symbols.h:75:3: #error "glibc cannot be compiled without optimization"
+ replace-flags -O0 -O1
filter-flags '-fstack-protector*'
}
@@ -479,7 +472,7 @@ setup_env() {
# configure script checks CFLAGS for some targets (like mips). Keep
# around the original clean value to avoid appending multiple ABIs on
# top of each other.
- : ${__GLIBC_CC:=$(tc-getCC ${CTARGET_OPT:-${CTARGET}})}
+ : ${__GLIBC_CC:=$(tc-getCC ${CTARGET})}
export __GLIBC_CC CC="${__GLIBC_CC} ${!VAR}"
einfo " $(printf '%15s' 'Manual CC:') ${CC}"
}
@@ -517,7 +510,7 @@ check_devpts() {
[[ ${MERGE_TYPE} == "buildonly" ]] && return
# Only sanity check when installing the native glibc.
- [[ ${ROOT} != "/" ]] && return
+ [[ -n ${ROOT} ]] && return
# If they're opting in to the old suid code, then no need to check.
use suid && return
@@ -592,7 +585,7 @@ eend_KV() {
get_kheader_version() {
printf '#include <linux/version.h>\nLINUX_VERSION_CODE\n' | \
- $(tc-getCPP ${CTARGET}) -I "${EPREFIX}/$(alt_build_headers)" - | \
+ $(tc-getCPP ${CTARGET}) -I "$(build_eprefix)$(alt_build_headers)" - | \
tail -n 1
}
@@ -605,7 +598,7 @@ sanity_prechecks() {
# Prevent native builds from downgrading
if [[ ${MERGE_TYPE} != "buildonly" ]] && \
- [[ ${ROOT} == "/" ]] && \
+ [[ -z ${ROOT} ]] && \
[[ ${CBUILD} == ${CHOST} ]] && \
[[ ${CHOST} == ${CTARGET} ]] ; then
@@ -733,6 +726,11 @@ pkg_pretend() {
sanity_prechecks
}
+pkg_setup() {
+ # see bug 682570
+ [[ -z ${BOOTSTRAP_RAP} ]] && python-any-r1_pkg_setup
+}
+
# src_unpack
src_unpack() {
@@ -749,9 +747,6 @@ src_unpack() {
unpack ${P}.tar.xz
fi
- cd "${S}" || die
- touch locale/C-translit.h || die #185476 #218003
-
cd "${WORKDIR}" || die
unpack glibc-${RELEASE_VER}-patches-${PATCH_VER}.tar.xz
}
@@ -811,6 +806,17 @@ glibc_do_configure() {
# Some of the tests are written in C++, so we need to force our multlib abis in, bug 623548
export CXX="$(tc-getCXX ${CTARGET}) $(get_abi_CFLAGS) ${CFLAGS}"
+
+ if is_crosscompile; then
+ # Assume worst-case bootstrap: glibc is buil first time
+ # when ${CTARGET}-g++ is not available yet. We avoid
+ # building auxiliary programs that require C++: bug #683074
+ # It should not affect final result.
+ export libc_cv_cxx_link_ok=no
+ # The line above has the same effect. We set CXX explicitly
+ # to make build logs less confusing.
+ export CXX=
+ fi
einfo " $(printf '%15s' 'Manual CXX:') ${CXX}"
echo
@@ -832,7 +838,11 @@ glibc_do_configure() {
myconf+=( --enable-stack-protector=no )
;;
*)
- myconf+=( --enable-stack-protector=$(usex ssp all no) )
+ # Use '=strong' instead of '=all' to protect only functions
+ # worth protecting from stack smashes.
+ # '=all' is also known to have a problem in IFUNC resolution
+ # tests: https://sourceware.org/PR25680, bug #712356.
+ myconf+=( --enable-stack-protector=$(usex ssp strong no) )
;;
esac
myconf+=( --enable-stackguard-randomization )
@@ -892,16 +902,17 @@ glibc_do_configure() {
--host=${CTARGET_OPT:-${CTARGET}}
$(use_enable profile)
$(use_with gd)
- --with-headers=$(alt_build_headers)
- --prefix="${EPREFIX}/usr"
- --sysconfdir="${EPREFIX}/etc"
- --localstatedir="${EPREFIX}/var"
+ --with-headers=$(build_eprefix)$(alt_build_headers)
+ --prefix="$(host_eprefix)/usr"
+ --sysconfdir="$(host_eprefix)/etc"
+ --localstatedir="$(host_eprefix)/var"
--libdir='$(prefix)'/$(get_libdir)
--mandir='$(prefix)'/share/man
--infodir='$(prefix)'/share/info
--libexecdir='$(libdir)'/misc/glibc
--with-bugurl=https://bugs.gentoo.org/
--with-pkgversion="$(glibc_banner)"
+ $(use_enable crypt)
$(use_multiarch || echo --disable-multi-arch)
$(use_enable systemtap)
$(use_enable nscd)
@@ -917,8 +928,8 @@ glibc_do_configure() {
# There is no configure option for this and we need to export it
# since the glibc build will re-run configure on itself
- export libc_cv_rootsbindir="${EPREFIX}/sbin"
- export libc_cv_slibdir="${EPREFIX}/$(get_libdir)"
+ export libc_cv_rootsbindir="$(host_eprefix)/sbin"
+ export libc_cv_slibdir="$(host_eprefix)/$(get_libdir)"
# We take care of patching our binutils to use both hash styles,
# and many people like to force gnu hash style only, so disable
@@ -1046,8 +1057,8 @@ glibc_headers_configure() {
--enable-bind-now
--build=${CBUILD_OPT:-${CBUILD}}
--host=${CTARGET_OPT:-${CTARGET}}
- --with-headers=$(alt_build_headers)
- --prefix="${EPREFIX}/usr"
+ --with-headers=$(build_eprefix)$(alt_build_headers)
+ --prefix="$(host_eprefix)/usr"
${EXTRA_ECONF}
)
@@ -1097,7 +1108,15 @@ src_compile() {
glibc_src_test() {
cd "$(builddir nptl)"
- emake check
+
+ local myxfailparams=""
+ if [[ "${GENTOO_GLIBC_XFAIL_TESTS}" == "yes" ]] ; then
+ for myt in ${XFAIL_TEST_LIST[@]} ; do
+ myxfailparams+="test-xfail-${myt}=yes "
+ done
+ fi
+
+ emake ${myxfailparams} check
}
do_src_test() {
@@ -1123,21 +1142,33 @@ src_test() {
run_locale_gen() {
# if the host locales.gen contains no entries, we'll install everything
local root="$1"
+ local inplace=""
+
+ if [[ "${root}" == "--inplace-glibc" ]] ; then
+ inplace="--inplace-glibc"
+ root="$2"
+ fi
+
local locale_list="${root}/etc/locale.gen"
+
+ pushd "${ED}"/$(get_libdir) >/dev/null
+
if [[ -z $(locale-gen --list --config "${locale_list}") ]] ; then
- ewarn "Generating all locales; edit /etc/locale.gen to save time/space"
+ [[ -z ${inplace} ]] && ewarn "Generating all locales; edit /etc/locale.gen to save time/space"
locale_list="${root}/usr/share/i18n/SUPPORTED"
fi
- locale-gen --jobs $(makeopts_jobs) --config "${locale_list}" \
+ locale-gen ${inplace} --jobs $(makeopts_jobs) --config "${locale_list}" \
--destdir "${root}"
+
+ popd >/dev/null
}
glibc_do_src_install() {
local builddir=$(builddir nptl)
cd "${builddir}"
- emake install_root="${D}$(alt_prefix)" install
+ emake install_root="${D}/$(build_eprefix)$(alt_prefix)" install
# This version (2.26) provides some compatibility libraries for the NIS/NIS+ support
# which come without headers etc. Only needed for binary packages since the
@@ -1150,13 +1181,20 @@ glibc_do_src_install() {
# '#define VERSION "2.26.90"' -> '2.26.90'
local upstream_pv=$(sed -n -r 's/#define VERSION "(.*)"/\1/p' "${S}"/version.h)
- if [[ -e ${ED}$(alt_usrlibdir)/libm-${upstream_pv}.a ]] ; then
+ # Avoid stripping binaries not targeted by ${CHOST}. Or else
+ # ${CHOST}-strip would break binaries build for ${CTARGET}.
+ is_crosscompile && dostrip -x /
+ # gdb thread introspection relies on local libpthreas symbols. stripping breaks it
+ # See Note [Disable automatic stripping]
+ dostrip -x $(alt_libdir)/libpthread-${upstream_pv}.so
+
+ if [[ -e ${ED}/$(alt_usrlibdir)/libm-${upstream_pv}.a ]] ; then
# Move versioned .a file out of libdir to evade portage QA checks
# instead of using gen_usr_ldscript(). We fix ldscript as:
# "GROUP ( /usr/lib64/libm-<pv>.a ..." -> "GROUP ( /usr/lib64/glibc-<pv>/libm-<pv>.a ..."
- sed -i "s@\(libm-${upstream_pv}.a\)@${P}/\1@" "${ED}"$(alt_usrlibdir)/libm.a || die
+ sed -i "s@\(libm-${upstream_pv}.a\)@${P}/\1@" "${ED}"/$(alt_usrlibdir)/libm.a || die
dodir $(alt_usrlibdir)/${P}
- mv "${ED}"$(alt_usrlibdir)/libm-${upstream_pv}.a "${ED}"$(alt_usrlibdir)/${P}/libm-${upstream_pv}.a || die
+ mv "${ED}"/$(alt_usrlibdir)/libm-${upstream_pv}.a "${ED}"/$(alt_usrlibdir)/${P}/libm-${upstream_pv}.a || die
fi
# We'll take care of the cache ourselves
@@ -1181,6 +1219,9 @@ glibc_do_src_install() {
# powerpc
ppc /lib/ld.so.1
ppc64 /lib64/ld64.so.1
+ # riscv
+ lp64d /lib/ld-linux-riscv64-lp64d.so.1
+ lp64 /lib/ld-linux-riscv64-lp64.so.1
# s390
s390 /lib/ld.so.1
s390x /lib/ld64.so.1
@@ -1263,6 +1304,17 @@ glibc_do_src_install() {
fi
done
+ # HACK: If we're building for riscv, we need to additionally make sure that
+ # we can find the locale archive afterwards
+ case ${CTARGET} in
+ riscv*)
+ if [[ ! -e ${ED}/usr/lib/locale ]] ; then
+ dosym ../$(get_libdir)/locale /usr/lib/locale
+ fi
+ ;;
+ *) ;;
+ esac
+
cd "${S}"
# Install misc network config files
@@ -1300,14 +1352,15 @@ glibc_do_src_install() {
# Generate all locales if this is a native build as locale generation
if use compile-locales && ! is_crosscompile ; then
- run_locale_gen "${ED}"
+ run_locale_gen --inplace-glibc "${ED}/"
+ sed -e 's:COMPILED_LOCALES="":COMPILED_LOCALES="1":' -i "${ED}"/usr/sbin/locale-gen || die
fi
}
glibc_headers_install() {
local builddir=$(builddir "headers")
cd "${builddir}"
- emake install_root="${D}$(alt_prefix)" install-headers
+ emake install_root="${D}/$(build_eprefix)$(alt_prefix)" install-headers
insinto $(alt_headers)/gnu
doins "${S}"/include/gnu/stubs.h
@@ -1326,6 +1379,11 @@ src_install() {
fi
foreach_abi glibc_do_src_install
+
+ if ! use static-libs ; then
+ elog "Not installing static glibc libraries"
+ find "${ED}" -name "*.a" -and -not -name "*_nonshared.a" -delete
+ fi
}
# Simple test to make sure our new glibc isn't completely broken.
@@ -1378,7 +1436,7 @@ pkg_preinst() {
einfo "Defaulting /etc/host.conf:multi to on"
fi
- [[ ${ROOT} != "/" ]] && return 0
+ [[ -n ${ROOT} ]] && return 0
[[ -d ${ED}/$(get_libdir) ]] || return 0
[[ -z ${BOOTSTRAP_RAP} ]] && glibc_sanity_check
}
@@ -1389,15 +1447,11 @@ pkg_postinst() {
if ! tc-is-cross-compiler && [[ -x ${EROOT}/usr/sbin/iconvconfig ]] ; then
# Generate fastloading iconv module configuration file.
- "${EROOT}"/usr/sbin/iconvconfig --prefix="${ROOT}"
+ "${EROOT}"/usr/sbin/iconvconfig --prefix="${ROOT}/"
fi
- if ! is_crosscompile && [[ ${ROOT} == "/" ]] ; then
- # Reload init ... if in a chroot or a diff init package, ignore
- # errors from this step #253697
- /sbin/telinit U 2>/dev/null
-
- use compile-locales || run_locale_gen "${EROOT}"
+ if ! is_crosscompile && [[ -z ${ROOT} ]] ; then
+ use compile-locales || run_locale_gen "${EROOT}/"
fi
# Check for sanity of /etc/nsswitch.conf, take 2