sys-libs/glibc upstream sync: add 2.33 remove 2.29

Signed-off-by: Thilo Fromm <thilo@kinvolk.io>
This commit is contained in:
Thilo Fromm 2021-06-21 09:02:53 +02:00
parent 99dca5debb
commit 3baf9c2c44
6 changed files with 329 additions and 396 deletions

View File

@ -4,3 +4,6 @@ DIST glibc-2.29.tar.xz 16515488 BLAKE2B b754e6825176538a2b8ca03fce014f0d87d333dc
DIST glibc-2.32-patches-2.tar.xz 8588 BLAKE2B 57a85241e3270d14df0332b039a933c5a7ee4d089684d85cca564eeec2d6796735de60b628c5746858757342922d58993d6cf7187ce1d7102b2299ca2cf8513f SHA512 45bbab9e2f813f55cb4a1438dcd9365170b8facff50b11648ba6022da06c20029bb65a4b06fd906af82aa7461b7374f85105fd7eedb7915cec3f1df3779b68a3 DIST glibc-2.32-patches-2.tar.xz 8588 BLAKE2B 57a85241e3270d14df0332b039a933c5a7ee4d089684d85cca564eeec2d6796735de60b628c5746858757342922d58993d6cf7187ce1d7102b2299ca2cf8513f SHA512 45bbab9e2f813f55cb4a1438dcd9365170b8facff50b11648ba6022da06c20029bb65a4b06fd906af82aa7461b7374f85105fd7eedb7915cec3f1df3779b68a3
DIST glibc-2.32.tar.xz 16744512 BLAKE2B a56b4afbb35315c5cd6dca0f62e44455dceae3e6e88a8453621f9a5394a60ddf10ca9309b2db0911830c7fd77e3faa5d94694eb94d5b2c05fc5285cef52255da SHA512 8460c155b7003e04f18dabece4ed9ad77445fa2288a7dc08e80a8fc4c418828af29e0649951bd71a54ea2ad2d4da7570aafd9bdfe4a37e9951b772b442afe50b DIST glibc-2.32.tar.xz 16744512 BLAKE2B a56b4afbb35315c5cd6dca0f62e44455dceae3e6e88a8453621f9a5394a60ddf10ca9309b2db0911830c7fd77e3faa5d94694eb94d5b2c05fc5285cef52255da SHA512 8460c155b7003e04f18dabece4ed9ad77445fa2288a7dc08e80a8fc4c418828af29e0649951bd71a54ea2ad2d4da7570aafd9bdfe4a37e9951b772b442afe50b
DIST locale-gen-2.10.tar.gz 7747 BLAKE2B 49f569c5ae5260fca128503bc6f22d6f6f1cda817920c41fdadadf1527bbb4f3eb161f79fa729830666a4673e9092f99f4685ec8fcac8ddea0b8242bca9c1f4f SHA512 e350e60d458d67638e3090711fca05af6fafac06c51b97648244549f8a0621dab7543f09dc7ad4c62392f13bdae8e5875dc6d0b6c3d83efc29d116bc2eef92db DIST locale-gen-2.10.tar.gz 7747 BLAKE2B 49f569c5ae5260fca128503bc6f22d6f6f1cda817920c41fdadadf1527bbb4f3eb161f79fa729830666a4673e9092f99f4685ec8fcac8ddea0b8242bca9c1f4f SHA512 e350e60d458d67638e3090711fca05af6fafac06c51b97648244549f8a0621dab7543f09dc7ad4c62392f13bdae8e5875dc6d0b6c3d83efc29d116bc2eef92db
DIST glibc-2.33-patches-3.tar.xz 37076 BLAKE2B 718ab706df85c966145958fb6137b5499c1989ff27a62c22beaabd530d641e4937e6d6ab0cf00052b649dc99c3acc319997640eef95669235dab864f5e0afc9f SHA512 6d460976610a1c3bd3dabee9250008b5b3024ba486d598f85bc81cbd0b88188d125714b93a8b253f9b59b292e998f35118562e2a3ca90c418ff14fa53af2a7c3
DIST glibc-2.33-patches-4.tar.xz 60124 BLAKE2B a7a99f39c16df241745772c31b10946dc44c51e6c09f8a447b905e7dd6ba529aee08f66a581431453c6665485ac1848861559aa3f0aaba8c2061c1f1eb77d9be SHA512 05c33dc465a98097f836783bb5037dfa14b3a2c0c140014f642ea72954222ae919fe2db9573ee70ca9c1881b3b59dd4b815a8f39f331494fa12951c9012797ef
DIST glibc-2.33.tar.xz 17031280 BLAKE2B 703d12121c1e2c5d9e0c6ba5341f5fb5c4d9111611a83f2360029b5de9c6e5a5611249d1833684a58ed4afdf49cae614365d87ec8721ba0e5d218f593b1f229d SHA512 4cb5777b68b22b746cc51669e0e9282b43c83f6944e42656e6db7195ebb68f2f9260f130fdeb4e3cfc64efae4f58d96c43d388f52be1eb024ca448084684abdb

View File

@ -1,114 +0,0 @@
From 74250a7cdf106d4ca7d9506e6d5dc7c448dc3434 Mon Sep 17 00:00:00 2001
From: David Michael <david.michael@coreos.com>
Date: Thu, 15 Dec 2016 15:22:57 -0800
Subject: [PATCH] gshadow: Sync fgetsgent_r.c with grp/fgetgrent_r.c
[BZ #20338]
* gshadow/fgetsgent_r.c: Include <libio/iolibio.h>.
(flockfile): New macro.
(funlockfile): Likewise.
(__fgetsgent_r): Sync with __fgetgrent_r.
* nss/nss_files/files-sgrp.c: Fix "fgetsgent_r.c" typo.
---
gshadow/fgetsgent_r.c | 35 ++++++++++++++++++++++++-----------
nss/nss_files/files-sgrp.c | 2 +-
2 files changed, 25 insertions(+), 12 deletions(-)
diff --git a/gshadow/fgetsgent_r.c b/gshadow/fgetsgent_r.c
index b70f6fa..02cd33a 100644
--- a/gshadow/fgetsgent_r.c
+++ b/gshadow/fgetsgent_r.c
@@ -20,39 +20,44 @@
#include <gshadow.h>
#include <stdio.h>
+#include <libio/iolibio.h>
+#define flockfile(s) _IO_flockfile (s)
+#define funlockfile(s) _IO_funlockfile (s)
+
/* Define a line parsing function using the common code
used in the nss_files module. */
#define STRUCTURE sgrp
#define ENTNAME sgent
-#define EXTERN_PARSER 1
+#define EXTERN_PARSER 1
struct sgent_data {};
#include <nss/nss_files/files-parse.c>
-/* Read one shadow entry from the given stream. */
+/* Read one entry from the given stream. */
int
__fgetsgent_r (FILE *stream, struct sgrp *resbuf, char *buffer, size_t buflen,
struct sgrp **result)
{
char *p;
+ int parse_result;
- _IO_flockfile (stream);
+ flockfile (stream);
do
{
buffer[buflen - 1] = '\xff';
p = fgets_unlocked (buffer, buflen, stream);
- if (p == NULL && feof_unlocked (stream))
+ if (__builtin_expect (p == NULL, 0) && feof_unlocked (stream))
{
- _IO_funlockfile (stream);
+ funlockfile (stream);
*result = NULL;
__set_errno (ENOENT);
return errno;
}
- if (p == NULL || buffer[buflen - 1] != '\xff')
+ if (__builtin_expect (p == NULL, 0) || buffer[buflen - 1] != '\xff')
{
- _IO_funlockfile (stream);
+ funlockfile (stream);
*result = NULL;
__set_errno (ERANGE);
return errno;
@@ -61,13 +66,21 @@ __fgetsgent_r (FILE *stream, struct sgrp *resbuf, char *buffer, size_t buflen,
/* Skip leading blanks. */
while (isspace (*p))
++p;
- } while (*p == '\0' || *p == '#' || /* Ignore empty and comment lines. */
+ } while (*p == '\0' || *p == '#' /* Ignore empty and comment lines. */
/* Parse the line. If it is invalid, loop to
get the next line of the file to parse. */
- ! parse_line (buffer, (void *) resbuf, (void *) buffer, buflen,
- &errno));
+ || ! (parse_result = parse_line (p, resbuf,
+ (void *) buffer, buflen,
+ &errno)));
+
+ funlockfile (stream);
- _IO_funlockfile (stream);
+ if (__builtin_expect (parse_result, 0) == -1)
+ {
+ /* The parser ran out of space. */
+ *result = NULL;
+ return errno;
+ }
*result = resbuf;
return 0;
diff --git a/nss/nss_files/files-sgrp.c b/nss/nss_files/files-sgrp.c
index 15dc659..05c3805 100644
--- a/nss/nss_files/files-sgrp.c
+++ b/nss/nss_files/files-sgrp.c
@@ -23,7 +23,7 @@
#define DATABASE "gshadow"
struct sgent_data {};
-/* Our parser function is already defined in sgetspent_r.c, so use that
+/* Our parser function is already defined in sgetsgent_r.c, so use that
to parse lines from the database file. */
#define EXTERN_PARSER
#include "files-parse.c"
--
2.7.4

View File

@ -1,2 +0,0 @@
L /etc/nscd.conf - - - - ../usr/share/baselayout/nscd.conf
d /var/db/nscd - - - - -

View File

@ -1,11 +1,11 @@
# Copyright 1999-2020 Gentoo Authors # Copyright 1999-2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2 # Distributed under the terms of the GNU General Public License v2
EAPI=6 EAPI=7
PYTHON_COMPAT=( python3_{6,7} ) PYTHON_COMPAT=( python3_{6,7,8,9} )
inherit python-any-r1 prefix eutils eapi7-ver toolchain-funcs flag-o-matic gnuconfig \ inherit python-any-r1 prefix eutils toolchain-funcs flag-o-matic gnuconfig \
multilib systemd multiprocessing multilib systemd multiprocessing
DESCRIPTION="GNU libc C library" DESCRIPTION="GNU libc C library"
@ -22,7 +22,7 @@ PATCH_DEV=dilfridge
if [[ ${PV} == 9999* ]]; then if [[ ${PV} == 9999* ]]; then
inherit git-r3 inherit git-r3
else else
KEYWORDS="~alpha amd64 arm arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~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" SRC_URI="mirror://gnu/glibc/${P}.tar.xz"
SRC_URI+=" https://dev.gentoo.org/~${PATCH_DEV}/distfiles/${P}-patches-${PATCH_VER}.tar.xz" SRC_URI+=" https://dev.gentoo.org/~${PATCH_DEV}/distfiles/${P}-patches-${PATCH_VER}.tar.xz"
SRC_URI+=" riscv? ( https://dev.gentoo.org/~dilfridge/distfiles/backport-rv32.txz )" SRC_URI+=" riscv? ( https://dev.gentoo.org/~dilfridge/distfiles/backport-rv32.txz )"
@ -93,6 +93,7 @@ fi
# gzip, grep, awk are needed by locale-gen, bug 740750 # gzip, grep, awk are needed by locale-gen, bug 740750
BDEPEND=" BDEPEND="
${PYTHON_DEPS}
>=app-misc/pax-utils-0.1.10 >=app-misc/pax-utils-0.1.10
sys-devel/bison sys-devel/bison
doc? ( sys-apps/texinfo ) doc? ( sys-apps/texinfo )
@ -114,7 +115,6 @@ COMMON_DEPEND="
!<net-misc/openssh-8.1_p1-r2 !<net-misc/openssh-8.1_p1-r2
" "
DEPEND="${COMMON_DEPEND} DEPEND="${COMMON_DEPEND}
${PYTHON_DEPS}
compile-locales? ( compile-locales? (
app-arch/gzip app-arch/gzip
sys-apps/grep sys-apps/grep
@ -724,12 +724,12 @@ sanity_prechecks() {
# the phases # the phases
# #
# Flatcar: Skip sanity checks at pretend time because we don't ship a compiler # pkg_pretend
# in the OS image. This test fails when installing the glibc binpkg and no
# compiler is present.
pkg_pretend() { pkg_pretend() {
einfo "Flatcar: Skipping sanity_prechecks for binpkg installation. src_unpack will take care of compile-time prechecks." # All the checks...
# sanity_prechecks einfo "Checking general environment sanity."
sanity_prechecks
} }
pkg_setup() { pkg_setup() {
@ -1228,13 +1228,12 @@ glibc_do_src_install() {
# '#define VERSION "2.26.90"' -> '2.26.90' # '#define VERSION "2.26.90"' -> '2.26.90'
local upstream_pv=$(sed -n -r 's/#define VERSION "(.*)"/\1/p' "${S}"/version.h) local upstream_pv=$(sed -n -r 's/#define VERSION "(.*)"/\1/p' "${S}"/version.h)
# Flatcar: dostrip not available in EAPI6
# Avoid stripping binaries not targeted by ${CHOST}. Or else # Avoid stripping binaries not targeted by ${CHOST}. Or else
# ${CHOST}-strip would break binaries build for ${CTARGET}. # ${CHOST}-strip would break binaries build for ${CTARGET}.
# is_crosscompile && dostrip -x / is_crosscompile && dostrip -x /
# gdb thread introspection relies on local libpthreas symbols. stripping breaks it # gdb thread introspection relies on local libpthreas symbols. stripping breaks it
# See Note [Disable automatic stripping] # See Note [Disable automatic stripping]
# dostrip -x $(alt_libdir)/libpthread-${upstream_pv}.so dostrip -x $(alt_libdir)/libpthread-${upstream_pv}.so
if [[ -e ${ED}/$(alt_usrlibdir)/libm-${upstream_pv}.a ]] ; then if [[ -e ${ED}/$(alt_usrlibdir)/libm-${upstream_pv}.a ]] ; then
# Move versioned .a file out of libdir to evade portage QA checks # Move versioned .a file out of libdir to evade portage QA checks
@ -1406,23 +1405,6 @@ glibc_do_src_install() {
run_locale_gen --inplace-glibc "${ED}/" run_locale_gen --inplace-glibc "${ED}/"
sed -e 's:COMPILED_LOCALES="":COMPILED_LOCALES="1":' -i "${ED}"/usr/sbin/locale-gen || die sed -e 's:COMPILED_LOCALES="":COMPILED_LOCALES="1":' -i "${ED}"/usr/sbin/locale-gen || die
fi fi
## Flatcar Container Linux: Add some local changes:
# - Config files are installed by baselayout, not glibc.
# - Install nscd/systemd stuff in /usr.
# Use tmpfiles to put nscd.conf in /etc and create directories.
insinto /usr/share/baselayout
if ! in_iuse nscd || use nscd ; then
doins "${S}"/nscd/nscd.conf || die
systemd_newtmpfilesd "${FILESDIR}"/nscd-conf.tmpfiles nscd-conf.conf || die
fi
# Clean out any default configs.
rm -rf "${ED}"/etc
# Restore this one for the SDK.
test ! -e "${T}"/00glibc || doenvd "${T}"/00glibc
} }
glibc_headers_install() { glibc_headers_install() {

View File

@ -1,40 +1,43 @@
# Copyright 1999-2019 Gentoo Authors # Copyright 1999-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2 # Distributed under the terms of the GNU General Public License v2
EAPI=6 EAPI=7
PYTHON_COMPAT=( python3_{5,6,7} ) PYTHON_COMPAT=( python3_{7,8,9,10} )
TMPFILES_OPTIONAL=1
inherit python-any-r1 prefix eutils eapi7-ver toolchain-funcs flag-o-matic gnuconfig \ inherit python-any-r1 prefix toolchain-funcs flag-o-matic gnuconfig \
multilib systemd multiprocessing multilib systemd multiprocessing tmpfiles
DESCRIPTION="GNU libc C library" DESCRIPTION="GNU libc C library"
HOMEPAGE="https://www.gnu.org/software/libc/" HOMEPAGE="https://www.gnu.org/software/libc/"
LICENSE="LGPL-2.1+ BSD HPND ISC inner-net rc PCRE" LICENSE="LGPL-2.1+ BSD HPND ISC inner-net rc PCRE"
RESTRICT="strip" # Strip ourself #46186
SLOT="2.2" SLOT="2.2"
EMULTILIB_PKG="true" EMULTILIB_PKG="true"
# Gentoo patchset (ignored for live ebuilds)
PATCH_VER=4
PATCH_DEV=dilfridge
if [[ ${PV} == 9999* ]]; then if [[ ${PV} == 9999* ]]; then
EGIT_REPO_URI="https://sourceware.org/git/glibc.git"
inherit git-r3 inherit git-r3
else else
KEYWORDS="~alpha amd64 arm arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~riscv ~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" SRC_URI="mirror://gnu/glibc/${P}.tar.xz"
SRC_URI+=" https://dev.gentoo.org/~${PATCH_DEV}/distfiles/${P}-patches-${PATCH_VER}.tar.xz"
fi fi
RELEASE_VER=${PV} RELEASE_VER=${PV}
GCC_BOOTSTRAP_VER=20180511 GCC_BOOTSTRAP_VER=20201208
# Gentoo patchset LOCALE_GEN_VER=2.10
PATCH_VER=3
SRC_URI+=" https://dev.gentoo.org/~dilfridge/distfiles/${P}-patches-${PATCH_VER}.tar.xz" SRC_URI+=" https://gitweb.gentoo.org/proj/locale-gen.git/snapshot/locale-gen-${LOCALE_GEN_VER}.tar.gz"
SRC_URI+=" multilib? ( https://dev.gentoo.org/~dilfridge/distfiles/gcc-multilib-bootstrap-${GCC_BOOTSTRAP_VER}.tar.xz )" SRC_URI+=" multilib-bootstrap? ( 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 multilib-bootstrap nscd profile selinux +ssp +static-libs static-pie suid systemtap test vanilla"
# Minimum kernel version that glibc requires # Minimum kernel version that glibc requires
MIN_KERN_VER="3.2.0" MIN_KERN_VER="3.2.0"
@ -61,10 +64,47 @@ if [[ ${CTARGET} == ${CHOST} ]] ; then
fi fi
fi fi
# Note [Disable automatic stripping]
# Disabling automatic stripping for a few reasons:
# - portage's attempt to strip breaks non-native binaries at least on
# arm: bug #697428
# - portage's attempt to strip libpthread.so.0 breaks gdb thread
# enumeration: bug #697910. This is quite subtle:
# * gdb uses glibc's libthread_db-1.0.so to enumerate threads.
# * libthread_db-1.0.so needs access to libpthread.so.0 local symbols
# via 'ps_pglobal_lookup' symbol defined in gdb.
# * 'ps_pglobal_lookup' uses '.symtab' section table to resolve all
# known symbols in 'libpthread.so.0'. Specifically 'nptl_version'
# (unexported) is used to sanity check compatibility before enabling
# debugging.
# Also see https://sourceware.org/gdb/wiki/FAQ#GDB_does_not_see_any_threads_besides_the_one_in_which_crash_occurred.3B_or_SIGTRAP_kills_my_program_when_I_set_a_breakpoint
# * normal 'strip' command trims '.symtab'
# 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 strip selectively.
# We need a new-enough binutils/gcc to match upstream baseline. # We need a new-enough binutils/gcc to match upstream baseline.
# Also we need to make sure our binutils/gcc supports TLS, # Also we need to make sure our binutils/gcc supports TLS,
# and that gcc already contains the hardened patches. # and that gcc already contains the hardened patches.
# Lastly, let's avoid some openssh nastiness, bug 708224, as
# convenience to our users.
# gzip, grep, awk are needed by locale-gen, bug 740750
BDEPEND="
${PYTHON_DEPS}
>=app-misc/pax-utils-0.1.10
sys-devel/bison
doc? ( sys-apps/texinfo )
!compile-locales? (
app-arch/gzip
sys-apps/grep
virtual/awk
)
"
COMMON_DEPEND=" COMMON_DEPEND="
gd? ( media-libs/gd:2= )
nscd? ( selinux? ( nscd? ( selinux? (
audit? ( sys-process/audit ) audit? ( sys-process/audit )
caps? ( sys-libs/libcap ) caps? ( sys-libs/libcap )
@ -72,42 +112,64 @@ COMMON_DEPEND="
suid? ( caps? ( sys-libs/libcap ) ) suid? ( caps? ( sys-libs/libcap ) )
selinux? ( sys-libs/libselinux ) selinux? ( sys-libs/libselinux )
systemtap? ( dev-util/systemtap ) systemtap? ( dev-util/systemtap )
!<net-misc/openssh-8.1_p1-r2
" "
DEPEND="${COMMON_DEPEND} DEPEND="${COMMON_DEPEND}
${PYTHON_DEPS} compile-locales? (
>=app-misc/pax-utils-0.1.10 app-arch/gzip
sys-devel/bison sys-apps/grep
!<sys-apps/sandbox-1.6 virtual/awk
!<sys-apps/portage-2.1.2 )
!<sys-devel/bison-2.7 test? ( >=net-dns/libidn2-2.3.0 )
!<sys-devel/make-4
doc? ( sys-apps/texinfo )
test? ( >=net-dns/libidn2-2.0.5 )
" "
RDEPEND="${COMMON_DEPEND} RDEPEND="${COMMON_DEPEND}
app-arch/gzip
sys-apps/grep
virtual/awk
sys-apps/gentoo-functions sys-apps/gentoo-functions
!sys-kernel/ps3-sources
!sys-libs/nss-db
" "
RESTRICT="!test? ( test )"
if [[ ${CATEGORY} == cross-* ]] ; then if [[ ${CATEGORY} == cross-* ]] ; then
DEPEND+=" !headers-only? ( BDEPEND+=" !headers-only? (
>=${CATEGORY}/binutils-2.24 >=${CATEGORY}/binutils-2.27
>=${CATEGORY}/gcc-6 >=${CATEGORY}/gcc-6
)" )"
[[ ${CATEGORY} == *-linux* ]] && DEPEND+=" ${CATEGORY}/linux-headers" [[ ${CATEGORY} == *-linux* ]] && DEPEND+=" ${CATEGORY}/linux-headers"
else else
DEPEND+=" BDEPEND+="
>=sys-devel/binutils-2.24 >=sys-devel/binutils-2.27
>=sys-devel/gcc-6 >=sys-devel/gcc-6
virtual/os-headers
" "
DEPEND+=" virtual/os-headers "
RDEPEND+=" RDEPEND+="
>=net-dns/libidn2-2.3.0
vanilla? ( !sys-libs/timezone-data ) vanilla? ( !sys-libs/timezone-data )
" "
PDEPEND+=" !vanilla? ( sys-libs/timezone-data )" PDEPEND+=" !vanilla? ( sys-libs/timezone-data )"
fi 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=(
# 9) Failures of unknown origin
tst-latepthread
# buggy test, assumes /dev/ and /dev/null on a single filesystem
# 'mount --bind /dev/null /chroot/dev/null' breaks it.
# https://sourceware.org/PR25909
tst-support_descriptors
# Flaky test, known to fail occasionally:
# https://sourceware.org/PR19329
# https://bugs.gentoo.org/719674#c12
tst-stack4
)
# #
# Small helper functions # Small helper functions
# #
@ -124,6 +186,18 @@ alt_prefix() {
is_crosscompile && echo /usr/${CTARGET} 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 # 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 # platform. Will also become useful for testing kernel-headers without screwing
# up the whole system. # up the whole system.
@ -133,7 +207,7 @@ alt_headers() {
alt_build_headers() { alt_build_headers() {
if [[ -z ${ALT_BUILD_HEADERS} ]] ; then 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 if tc-is-cross-compiler ; then
ALT_BUILD_HEADERS=${SYSROOT}$(alt_headers) ALT_BUILD_HEADERS=${SYSROOT}$(alt_headers)
if [[ ! -e ${ALT_BUILD_HEADERS}/linux/version.h ]] ; then if [[ ! -e ${ALT_BUILD_HEADERS}/linux/version.h ]] ; then
@ -166,7 +240,8 @@ do_compile_test() {
rm -f glibc-test* rm -f glibc-test*
printf '%b' "$*" > glibc-test.c printf '%b' "$*" > glibc-test.c
nonfatal emake -s glibc-test # Most of the time CC is already set, but not in early sanity checks.
nonfatal emake glibc-test CC="${CC-$(tc-getCC ${CTARGET})}"
ret=$? ret=$?
popd >/dev/null popd >/dev/null
@ -214,7 +289,7 @@ setup_target_flags() {
# We could change main to _start and pass -nostdlib here so that we # 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 # only test the gcc code compilation. Or we could do a compile and
# then look for the symbol via scanelf. # 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}} local t=${CTARGET_OPT:-${CTARGET}}
t=${t%%-*} t=${t%%-*}
filter-flags '-march=*' filter-flags '-march=*'
@ -224,10 +299,9 @@ setup_target_flags() {
;; ;;
amd64) amd64)
# -march needed for #185404 #199334 # -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. # 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}} local t=${CTARGET_OPT:-${CTARGET}}
t=${t%%-*} t=${t%%-*}
# Normally the target is x86_64-xxx, so turn that into the -march that # Normally the target is x86_64-xxx, so turn that into the -march that
@ -237,89 +311,47 @@ setup_target_flags() {
# ugly, ugly, ugly. ugly. # ugly, ugly, ugly. ugly.
CFLAGS_x86=$(CFLAGS=${CFLAGS_x86} filter-flags '-march=*'; echo "${CFLAGS}") CFLAGS_x86=$(CFLAGS=${CFLAGS_x86} filter-flags '-march=*'; echo "${CFLAGS}")
export CFLAGS_x86="${CFLAGS_x86} -march=${t}" 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 fi
;; ;;
mips) mips)
# The mips abi cannot support the GNU style hashes. #233233 # The mips abi cannot support the GNU style hashes. #233233
filter-ldflags -Wl,--hash-style=gnu -Wl,--hash-style=both filter-ldflags -Wl,--hash-style=gnu -Wl,--hash-style=both
;; ;;
ppc|ppc64)
# Many arch-specific implementations do not work on ppc with
# cache-block not equal to 128 bytes. This breaks memset:
# https://sourceware.org/PR26522
# https://bugs.gentoo.org/737996
# Use default -mcpu=. For ppc it means non-multiarch setup.
filter-flags '-mcpu=*'
;;
sparc) sparc)
# Both sparc and sparc64 can use -fcall-used-g6. -g7 is bad, though. # Both sparc and sparc64 can use -fcall-used-g6. -g7 is bad, though.
filter-flags "-fcall-used-g7" filter-flags "-fcall-used-g7"
append-flags "-fcall-used-g6" 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 local cpu
case ${CTARGET} in case ${CTARGET} in
sparc64-*) sparc64-*)
cpu="sparc64"
case $(get-flag mcpu) in case $(get-flag mcpu) in
niagara[234]) v9)
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"
;;
*)
# We need to force at least v9a because the base build doesn't # We need to force at least v9a because the base build doesn't
# work with just v9. # work with just v9.
# https://sourceware.org/bugzilla/show_bug.cgi?id=19477 # https://sourceware.org/bugzilla/show_bug.cgi?id=19477
[[ -z ${cpu} ]] && append-flags "-Wa,-xarch=v9a" append-flags "-Wa,-xarch=v9a"
;; ;;
esac esac
;; ;;
sparc-*) sparc-*)
case $(get-flag mcpu) in 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) v8|supersparc|hypersparc|leon|leon3)
cpu="sparcv8" cpu="sparcv8"
;; ;;
*)
cpu="sparcv9"
;;
esac esac
;; ;;
esac esac
@ -343,17 +375,28 @@ setup_flags() {
ASFLAGS_BASE=${ASFLAGS_BASE-${ASFLAGS}} ASFLAGS_BASE=${ASFLAGS_BASE-${ASFLAGS}}
ASFLAGS=${ASFLAGS_BASE} ASFLAGS=${ASFLAGS_BASE}
# Over-zealous CFLAGS can often cause problems. What may work for one # Allow users to explicitly avoid flag sanitization via
# person may not work for another. To avoid a large influx of bugs # USE=custom-cflags.
# relating to failed builds, we strip most CFLAGS out to ensure as few if ! use custom-cflags; then
# problems as possible. # Over-zealous CFLAGS can often cause problems. What may work for one
strip-flags # 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 strip-unsupported-flags
filter-flags -m32 -m64 '-mabi=*' filter-flags -m32 -m64 '-mabi=*'
# glibc aborts if rpath is set by LDFLAGS # glibc aborts if rpath is set by LDFLAGS
filter-ldflags '-Wl,-rpath=*' filter-ldflags '-Wl,-rpath=*'
# ld can't use -r & --relax at the same time, bug #788901
# https://sourceware.org/PR27837
filter-ldflags '-Wl,--relax'
# #492892 # #492892
filter-flags -frecord-gcc-switches filter-flags -frecord-gcc-switches
@ -369,10 +412,9 @@ setup_flags() {
CBUILD_OPT=${CTARGET_OPT} CBUILD_OPT=${CTARGET_OPT}
fi fi
# Lock glibc at -O2; we want to be conservative here. # glibc's headers disallow -O0 and fail at build time:
# -fno-strict-aliasing is to work around #155906. # include/libc-symbols.h:75:3: #error "glibc cannot be compiled without optimization"
filter-flags '-O?' replace-flags -O0 -O1
append-flags -O2 -fno-strict-aliasing
filter-flags '-fstack-protector*' filter-flags '-fstack-protector*'
} }
@ -464,7 +506,7 @@ setup_env() {
# configure script checks CFLAGS for some targets (like mips). Keep # configure script checks CFLAGS for some targets (like mips). Keep
# around the original clean value to avoid appending multiple ABIs on # around the original clean value to avoid appending multiple ABIs on
# top of each other. # top of each other.
: ${__GLIBC_CC:=$(tc-getCC ${CTARGET_OPT:-${CTARGET}})} : ${__GLIBC_CC:=$(tc-getCC ${CTARGET})}
export __GLIBC_CC CC="${__GLIBC_CC} ${!VAR}" export __GLIBC_CC CC="${__GLIBC_CC} ${!VAR}"
einfo " $(printf '%15s' 'Manual CC:') ${CC}" einfo " $(printf '%15s' 'Manual CC:') ${CC}"
} }
@ -495,27 +537,6 @@ glibc_banner() {
echo "${b}" echo "${b}"
} }
check_devpts() {
# Make sure devpts is mounted correctly for use w/out setuid pt_chown.
# If merely building the binary package, then there's nothing to verify.
[[ ${MERGE_TYPE} == "buildonly" ]] && return
# Only sanity check when installing the native glibc.
[[ ${ROOT} != "/" ]] && return
# If they're opting in to the old suid code, then no need to check.
use suid && return
if awk '$3 == "devpts" && $4 ~ /[, ]gid=5[, ]/ { exit 1 }' /proc/mounts ; then
eerror "In order to use glibc with USE=-suid, you must make sure that"
eerror "you have devpts mounted at /dev/pts with the gid=5 option."
eerror "Openrc should do this for you, so you should check /etc/fstab"
eerror "and make sure you do not have any invalid settings there."
die "mount & fix your /dev/pts settings"
fi
}
# The following Kernel version handling functions are mostly copied from portage # The following Kernel version handling functions are mostly copied from portage
# source. It's better not to use linux-info.eclass here since a) it adds too # source. It's better not to use linux-info.eclass here since a) it adds too
# much magic, see bug 326693 for some of the arguments, and b) some of the # much magic, see bug 326693 for some of the arguments, and b) some of the
@ -577,7 +598,7 @@ eend_KV() {
get_kheader_version() { get_kheader_version() {
printf '#include <linux/version.h>\nLINUX_VERSION_CODE\n' | \ 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 tail -n 1
} }
@ -587,7 +608,7 @@ get_kheader_version() {
sanity_prechecks() { sanity_prechecks() {
# Prevent native builds from downgrading # Prevent native builds from downgrading
if [[ ${MERGE_TYPE} != "buildonly" ]] && \ if [[ ${MERGE_TYPE} != "buildonly" ]] && \
[[ ${ROOT} == "/" ]] && \ [[ -z ${ROOT} ]] && \
[[ ${CBUILD} == ${CHOST} ]] && \ [[ ${CBUILD} == ${CHOST} ]] && \
[[ ${CHOST} == ${CTARGET} ]] ; then [[ ${CHOST} == ${CTARGET} ]] ; then
@ -598,7 +619,7 @@ sanity_prechecks() {
if has_version ">${CATEGORY}/${P}-r10000" ; then if has_version ">${CATEGORY}/${P}-r10000" ; then
eerror "Sanity check to keep you from breaking your system:" eerror "Sanity check to keep you from breaking your system:"
eerror " Downgrading glibc is not supported and a sure way to destruction." eerror " Downgrading glibc is not supported and a sure way to destruction."
die "Aborting to save your system." [[ ${I_ALLOW_TO_BREAK_MY_SYSTEM} = yes ]] || die "Aborting to save your system."
fi fi
if ! do_run_test '#include <unistd.h>\n#include <sys/syscall.h>\nint main(){return syscall(1000)!=-1;}\n' ; then if ! do_run_test '#include <unistd.h>\n#include <sys/syscall.h>\nint main(){return syscall(1000)!=-1;}\n' ; then
@ -628,21 +649,6 @@ sanity_prechecks() {
ewarn "hypervisor, which is probably not what you want." ewarn "hypervisor, which is probably not what you want."
fi fi
# Check for sanity of /etc/nsswitch.conf
if [[ -e ${EROOT}/etc/nsswitch.conf ]] ; then
local entry
for entry in passwd group shadow; do
if ! egrep -q "^[ \t]*${entry}:.*files" "${EROOT}"/etc/nsswitch.conf; then
eerror "Your ${EROOT}/etc/nsswitch.conf is out of date."
eerror "Please make sure you have 'files' entries for"
eerror "'passwd:', 'group:' and 'shadow:' databases."
eerror "For more details see:"
eerror " https://wiki.gentoo.org/wiki/Project:Toolchain/nsswitch.conf_in_glibc-2.26"
die "nsswitch.conf has no 'files' provider in '${entry}'."
fi
done
fi
# ABI-specific checks follow here. Hey, we have a lot more specific conditions that # ABI-specific checks follow here. Hey, we have a lot more specific conditions that
# we test for... # we test for...
if ! is_crosscompile ; then if ! is_crosscompile ; then
@ -707,6 +713,14 @@ sanity_prechecks() {
# the phases # the phases
# #
# pkg_pretend
pkg_pretend() {
# All the checks...
einfo "Checking general environment sanity."
sanity_prechecks
}
pkg_setup() { pkg_setup() {
# see bug 682570 # see bug 682570
[[ -z ${BOOTSTRAP_RAP} ]] && python-any-r1_pkg_setup [[ -z ${BOOTSTRAP_RAP} ]] && python-any-r1_pkg_setup
@ -718,27 +732,39 @@ src_unpack() {
# Consistency is not guaranteed between pkg_ and src_ ... # Consistency is not guaranteed between pkg_ and src_ ...
sanity_prechecks sanity_prechecks
use multilib && unpack gcc-multilib-bootstrap-${GCC_BOOTSTRAP_VER}.tar.xz use multilib-bootstrap && unpack gcc-multilib-bootstrap-${GCC_BOOTSTRAP_VER}.tar.xz
setup_env setup_env
if [[ -n ${EGIT_REPO_URI} ]] ; then if [[ ${PV} == 9999* ]] ; then
EGIT_REPO_URI="https://anongit.gentoo.org/git/proj/toolchain/glibc-patches.git"
EGIT_CHECKOUT_DIR=${WORKDIR}/patches-git
git-r3_src_unpack
mv patches-git/9999 patches || die
EGIT_REPO_URI="https://sourceware.org/git/glibc.git"
EGIT_CHECKOUT_DIR=${S}
git-r3_src_unpack git-r3_src_unpack
else else
unpack ${P}.tar.xz unpack ${P}.tar.xz
cd "${WORKDIR}" || die
unpack glibc-${RELEASE_VER}-patches-${PATCH_VER}.tar.xz
fi fi
cd "${WORKDIR}" || die cd "${WORKDIR}" || die
unpack glibc-${RELEASE_VER}-patches-${PATCH_VER}.tar.xz unpack locale-gen-${LOCALE_GEN_VER}.tar.gz
} }
PATCHES=(
"${FILESDIR}"/2.25/glibc-2.25-gshadow-handle-erange.patch
)
src_prepare() { src_prepare() {
local patchsetname
if ! use vanilla ; then if ! use vanilla ; then
elog "Applying Gentoo Glibc Patchset ${RELEASE_VER}-${PATCH_VER}" if [[ ${PV} == 9999* ]] ; then
patchsetname="from git master"
else
patchsetname="${RELEASE_VER}-${PATCH_VER}"
fi
einfo "Applying Gentoo Glibc Patchset ${patchsetname}"
eapply "${WORKDIR}"/patches eapply "${WORKDIR}"/patches
einfo "Done." einfo "Done."
fi fi
@ -750,6 +776,10 @@ src_prepare() {
cd "${WORKDIR}" cd "${WORKDIR}"
find . -name configure -exec touch {} + find . -name configure -exec touch {} +
# move the external locale-gen to its old place
mkdir extra || die
mv locale-gen-${LOCALE_GEN_VER} extra/locale || die
eprefixify extra/locale/locale-gen eprefixify extra/locale/locale-gen
# Fix permissions on some of the scripts. # Fix permissions on some of the scripts.
@ -775,7 +805,7 @@ glibc_do_configure() {
fi fi
local v local v
for v in ABI CBUILD CHOST CTARGET CBUILD_OPT CTARGET_OPT CC CXX LD {AS,C,CPP,CXX,LD}FLAGS MAKEINFO ; do for v in ABI CBUILD CHOST CTARGET CBUILD_OPT CTARGET_OPT CC CXX LD {AS,C,CPP,CXX,LD}FLAGS MAKEINFO NM READELF; do
einfo " $(printf '%15s' ${v}:) ${!v}" einfo " $(printf '%15s' ${v}:) ${!v}"
done done
@ -804,6 +834,14 @@ glibc_do_configure() {
fi fi
einfo " $(printf '%15s' 'Manual CXX:') ${CXX}" einfo " $(printf '%15s' 'Manual CXX:') ${CXX}"
# Always use tuple-prefixed toolchain. For non-native ABI glibc's configure
# can't detect them automatically due to ${CHOST} mismatch and fallbacks
# to unprefixed tools. Similar to multilib.eclass:multilib_toolchain_setup().
export NM="$(tc-getNM ${CTARGET})"
export READELF="$(tc-getREADELF ${CTARGET})"
einfo " $(printf '%15s' 'Manual NM:') ${NM}"
einfo " $(printf '%15s' 'Manual READELF:') ${READELF}"
echo echo
local myconf=() local myconf=()
@ -814,16 +852,12 @@ glibc_do_configure() {
# https://sourceware.org/PR24202 # https://sourceware.org/PR24202
myconf+=( --enable-stack-protector=no ) myconf+=( --enable-stack-protector=no )
;; ;;
powerpc-*)
# Currently gcc on powerpc32 generates invalid code for
# __builtin_return_address(0) calls. Normally programs
# don't do that but malloc hooks in glibc do:
# https://gcc.gnu.org/PR81996
# https://bugs.gentoo.org/629054
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 esac
myconf+=( --enable-stackguard-randomization ) myconf+=( --enable-stackguard-randomization )
@ -883,19 +917,35 @@ glibc_do_configure() {
--host=${CTARGET_OPT:-${CTARGET}} --host=${CTARGET_OPT:-${CTARGET}}
$(use_enable profile) $(use_enable profile)
$(use_with gd) $(use_with gd)
--with-headers=$(alt_build_headers) --with-headers=$(build_eprefix)$(alt_build_headers)
--prefix="${EPREFIX}/usr" --prefix="$(host_eprefix)/usr"
--sysconfdir="${EPREFIX}/etc" --sysconfdir="$(host_eprefix)/etc"
--localstatedir="${EPREFIX}/var" --localstatedir="$(host_eprefix)/var"
--libdir='$(prefix)'/$(get_libdir) --libdir='$(prefix)'/$(get_libdir)
--mandir='$(prefix)'/share/man --mandir='$(prefix)'/share/man
--infodir='$(prefix)'/share/info --infodir='$(prefix)'/share/info
--libexecdir='$(libdir)'/misc/glibc --libexecdir='$(libdir)'/misc/glibc
--with-bugurl=https://bugs.gentoo.org/ --with-bugurl=https://bugs.gentoo.org/
--with-pkgversion="$(glibc_banner)" --with-pkgversion="$(glibc_banner)"
$(use_enable crypt)
$(use_multiarch || echo --disable-multi-arch) $(use_multiarch || echo --disable-multi-arch)
$(use_enable static-pie)
$(use_enable systemtap) $(use_enable systemtap)
$(use_enable nscd) $(use_enable nscd)
# locale data is arch-independent
# https://bugs.gentoo.org/753740
libc_cv_complocaledir='${exec_prefix}/lib/locale'
# -march= option tricks build system to infer too
# high ISA level: https://sourceware.org/PR27318
libc_cv_include_x86_isa_level=no
# Explicit override of https://sourceware.org/PR27991
# exposes a bug in glibc's configure:
# https://sourceware.org/PR27991
libc_cv_have_x86_lahf_sahf=no
libc_cv_have_x86_movbe=no
${EXTRA_ECONF} ${EXTRA_ECONF}
) )
@ -908,8 +958,8 @@ glibc_do_configure() {
# There is no configure option for this and we need to export it # There is no configure option for this and we need to export it
# since the glibc build will re-run configure on itself # since the glibc build will re-run configure on itself
export libc_cv_rootsbindir="${EPREFIX}/sbin" export libc_cv_rootsbindir="$(host_eprefix)/sbin"
export libc_cv_slibdir="${EPREFIX}/$(get_libdir)" export libc_cv_slibdir="$(host_eprefix)/$(get_libdir)"
# We take care of patching our binutils to use both hash styles, # We take care of patching our binutils to use both hash styles,
# and many people like to force gnu hash style only, so disable # and many people like to force gnu hash style only, so disable
@ -938,7 +988,7 @@ glibc_do_configure() {
# is built with MULTILIB_ABIS="amd64 x86" but we want to # is built with MULTILIB_ABIS="amd64 x86" but we want to
# add x32 to it, gcc/glibc don't yet support x32. # add x32 to it, gcc/glibc don't yet support x32.
# #
if [[ -n ${GCC_BOOTSTRAP_VER} ]] && use multilib ; then if [[ -n ${GCC_BOOTSTRAP_VER} ]] && use multilib-bootstrap ; then
echo 'main(){}' > "${T}"/test.c echo 'main(){}' > "${T}"/test.c
if ! $(tc-getCC ${CTARGET}) ${CFLAGS} ${LDFLAGS} "${T}"/test.c -Wl,-emain -lgcc 2>/dev/null ; then if ! $(tc-getCC ${CTARGET}) ${CFLAGS} ${LDFLAGS} "${T}"/test.c -Wl,-emain -lgcc 2>/dev/null ; then
sed -i -e '/^CC = /s:$: -B$(objdir)/../'"gcc-multilib-bootstrap-${GCC_BOOTSTRAP_VER}/${ABI}:" config.make || die sed -i -e '/^CC = /s:$: -B$(objdir)/../'"gcc-multilib-bootstrap-${GCC_BOOTSTRAP_VER}/${ABI}:" config.make || die
@ -1037,8 +1087,8 @@ glibc_headers_configure() {
--enable-bind-now --enable-bind-now
--build=${CBUILD_OPT:-${CBUILD}} --build=${CBUILD_OPT:-${CBUILD}}
--host=${CTARGET_OPT:-${CTARGET}} --host=${CTARGET_OPT:-${CTARGET}}
--with-headers=$(alt_build_headers) --with-headers=$(build_eprefix)$(alt_build_headers)
--prefix="${EPREFIX}/usr" --prefix="$(host_eprefix)/usr"
${EXTRA_ECONF} ${EXTRA_ECONF}
) )
@ -1075,7 +1125,7 @@ src_configure() {
} }
do_src_compile() { do_src_compile() {
emake -C "$(builddir nptl)" || die "make nptl for ${ABI} failed" emake -C "$(builddir nptl)"
} }
src_compile() { src_compile() {
@ -1088,7 +1138,18 @@ src_compile() {
glibc_src_test() { glibc_src_test() {
cd "$(builddir nptl)" 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
# sandbox does not understand unshare() and prevents
# writes to /proc/, which makes many tests fail
SANDBOX_ON=0 LD_PRELOAD= emake ${myxfailparams} check
} }
do_src_test() { do_src_test() {
@ -1114,21 +1175,35 @@ src_test() {
run_locale_gen() { run_locale_gen() {
# if the host locales.gen contains no entries, we'll install everything # if the host locales.gen contains no entries, we'll install everything
local root="$1" local root="$1"
local inplace=""
if [[ "${root}" == "--inplace-glibc" ]] ; then
inplace="--inplace-glibc"
root="$2"
fi
local locale_list="${root}/etc/locale.gen" local locale_list="${root}/etc/locale.gen"
pushd "${ED}"/$(get_libdir) >/dev/null
if [[ -z $(locale-gen --list --config "${locale_list}") ]] ; then 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" locale_list="${root}/usr/share/i18n/SUPPORTED"
fi fi
locale-gen --jobs $(makeopts_jobs) --config "${locale_list}" \ set -- locale-gen ${inplace} --jobs $(makeopts_jobs) --config "${locale_list}" \
--destdir "${root}" --destdir "${root}"
echo "$@"
"$@"
popd >/dev/null
} }
glibc_do_src_install() { glibc_do_src_install() {
local builddir=$(builddir nptl) local builddir=$(builddir nptl)
cd "${builddir}" cd "${builddir}"
emake install_root="${D}$(alt_prefix)" install || die emake install_root="${D}/$(build_eprefix)$(alt_prefix)" install
# This version (2.26) provides some compatibility libraries for the NIS/NIS+ support # 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 # which come without headers etc. Only needed for binary packages since the
@ -1141,13 +1216,20 @@ glibc_do_src_install() {
# '#define VERSION "2.26.90"' -> '2.26.90' # '#define VERSION "2.26.90"' -> '2.26.90'
local upstream_pv=$(sed -n -r 's/#define VERSION "(.*)"/\1/p' "${S}"/version.h) 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 # Move versioned .a file out of libdir to evade portage QA checks
# instead of using gen_usr_ldscript(). We fix ldscript as: # instead of using gen_usr_ldscript(). We fix ldscript as:
# "GROUP ( /usr/lib64/libm-<pv>.a ..." -> "GROUP ( /usr/lib64/glibc-<pv>/libm-<pv>.a ..." # "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} 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 fi
# We'll take care of the cache ourselves # We'll take care of the cache ourselves
@ -1171,8 +1253,9 @@ glibc_do_src_install() {
n64 /lib64/ld.so.1 n64 /lib64/ld.so.1
# powerpc # powerpc
ppc /lib/ld.so.1 ppc /lib/ld.so.1
ppc64 /lib64/ld64.so.1
# riscv # riscv
ilp32d /lib/ld-linux-riscv32-ilp32d.so.1
ilp32 /lib/ld-linux-riscv32-ilp32.so.1
lp64d /lib/ld-linux-riscv64-lp64d.so.1 lp64d /lib/ld-linux-riscv64-lp64d.so.1
lp64 /lib/ld-linux-riscv64-lp64.so.1 lp64 /lib/ld-linux-riscv64-lp64.so.1
# s390 # s390
@ -1187,12 +1270,16 @@ glibc_do_src_install() {
ldso_abi_list+=( ldso_abi_list+=(
# arm # arm
arm64 /lib/ld-linux-aarch64.so.1 arm64 /lib/ld-linux-aarch64.so.1
# ELFv2 (glibc does not support ELFv1 on LE)
ppc64 /lib64/ld64.so.2
) )
;; ;;
big) big)
ldso_abi_list+=( ldso_abi_list+=(
# arm # arm
arm64 /lib/ld-linux-aarch64_be.so.1 arm64 /lib/ld-linux-aarch64_be.so.1
# ELFv1 (glibc does not support ELFv2 on BE)
ppc64 /lib64/ld64.so.1
) )
;; ;;
esac esac
@ -1209,6 +1296,27 @@ glibc_do_src_install() {
fi fi
done done
# In the LSB 5.0 definition, someone had the excellent idea to "standardize"
# the runtime loader name, see also https://xkcd.com/927/
# Normally, in Gentoo one should never come across executables that require this.
# However, binary commercial packages are known to adhere to weird practices.
# https://refspecs.linuxfoundation.org/LSB_5.0.0/LSB-Core-AMD64/LSB-Core-AMD64.html#BASELIB
local lsb_ldso_name native_ldso_name lsb_ldso_abi
local lsb_ldso_abi_list=(
# x86
amd64 ld-linux-x86-64.so.2 ld-lsb-x86-64.so.3
)
for (( i = 0; i < ${#lsb_ldso_abi_list[@]}; i += 3 )) ; do
lsb_ldso_abi=${lsb_ldso_abi_list[i]}
native_ldso_name=${lsb_ldso_abi_list[i+1]}
lsb_ldso_name=${lsb_ldso_abi_list[i+2]}
has ${lsb_ldso_abi} $(get_install_abis) || continue
if [[ ! -L ${ED}/$(get_abi_LIBDIR ${lsb_ldso_abi})/${lsb_ldso_name} && ! -e ${ED}/$(get_abi_LIBDIR ${lsb_ldso_abi})/${lsb_ldso_name} ]] ; then
dosym ${native_ldso_name} "$(alt_prefix)/$(get_abi_LIBDIR ${lsb_ldso_abi})/${lsb_ldso_name}"
fi
done
# With devpts under Linux mounted properly, we do not need the pt_chown # With devpts under Linux mounted properly, we do not need the pt_chown
# binary to be setuid. This is because the default owners/perms will be # binary to be setuid. This is because the default owners/perms will be
# exactly what we want. # exactly what we want.
@ -1247,36 +1355,21 @@ glibc_do_src_install() {
insinto /etc insinto /etc
doins locale.gen doins locale.gen
# Make sure all the ABI's can find the locales and so we only keepdir /usr/lib/locale
# have to generate one set
local a
keepdir /usr/$(get_libdir)/locale
for a in $(get_install_abis) ; do
if [[ ! -e ${ED}/usr/$(get_abi_LIBDIR ${a})/locale ]] ; then
dosym ../$(get_libdir)/locale /usr/$(get_abi_LIBDIR ${a})/locale
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}" cd "${S}"
# Install misc network config files # Install misc network config files
insinto /etc insinto /etc
doins nscd/nscd.conf posix/gai.conf nss/nsswitch.conf doins posix/gai.conf nss/nsswitch.conf
doins "${WORKDIR}"/extra/etc/*.conf
# Gentoo-specific
newins "${FILESDIR}"/host.conf-1 host.conf
if use nscd ; then if use nscd ; then
doinitd "$(prefixify_ro "${WORKDIR}"/extra/etc/nscd)" doins nscd/nscd.conf
newinitd "$(prefixify_ro "${FILESDIR}"/nscd-1)" nscd
local nscd_args=( local nscd_args=(
-e "s:@PIDFILE@:$(strings "${ED}"/usr/sbin/nscd | grep nscd.pid):" -e "s:@PIDFILE@:$(strings "${ED}"/usr/sbin/nscd | grep nscd.pid):"
@ -1285,10 +1378,7 @@ glibc_do_src_install() {
sed -i "${nscd_args[@]}" "${ED}"/etc/init.d/nscd sed -i "${nscd_args[@]}" "${ED}"/etc/init.d/nscd
systemd_dounit nscd/nscd.service systemd_dounit nscd/nscd.service
systemd_newtmpfilesd nscd/nscd.tmpfiles nscd.conf newtmpfiles nscd/nscd.tmpfiles nscd.conf
else
# Do this since extra/etc/*.conf above might have nscd.conf.
rm -f "${ED}"/etc/nscd.conf
fi fi
echo 'LDPATH="include ld.so.conf.d/*.conf"' > "${T}"/00glibc echo 'LDPATH="include ld.so.conf.d/*.conf"' > "${T}"/00glibc
@ -1305,31 +1395,15 @@ glibc_do_src_install() {
# Generate all locales if this is a native build as locale generation # Generate all locales if this is a native build as locale generation
if use compile-locales && ! is_crosscompile ; then 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 fi
## Flatcar Container Linux: Add some local changes:
# - Config files are installed by baselayout, not glibc.
# - Install nscd/systemd stuff in /usr.
# Use tmpfiles to put nscd.conf in /etc and create directories.
insinto /usr/share/baselayout
if ! in_iuse nscd || use nscd ; then
doins "${S}"/nscd/nscd.conf || die
systemd_newtmpfilesd "${FILESDIR}"/nscd-conf.tmpfiles nscd-conf.conf || die
fi
# Clean out any default configs.
rm -rf "${ED}"/etc
# Restore this one for the SDK.
test ! -e "${T}"/00glibc || doenvd "${T}"/00glibc
} }
glibc_headers_install() { glibc_headers_install() {
local builddir=$(builddir "headers") local builddir=$(builddir "headers")
cd "${builddir}" cd "${builddir}"
emake install_root="${D}$(alt_prefix)" install-headers emake install_root="${D}/$(build_eprefix)$(alt_prefix)" install-headers
insinto $(alt_headers)/gnu insinto $(alt_headers)/gnu
doins "${S}"/include/gnu/stubs.h doins "${S}"/include/gnu/stubs.h
@ -1340,23 +1414,6 @@ glibc_headers_install() {
dosym usr/include $(alt_prefix)/sys-include dosym usr/include $(alt_prefix)/sys-include
} }
src_strip() {
# gdb is lame and requires some debugging information to remain in
# libpthread, so we need to strip it by hand. libthread_db makes no
# sense stripped as it is only used when debugging.
local pthread=$(has splitdebug ${FEATURES} && echo "libthread_db" || echo "lib{pthread,thread_db}")
env \
-uRESTRICT \
CHOST=${CTARGET} \
STRIP_MASK="/*/{,tls/}${pthread}*" \
prepallstrip
# if user has stripping enabled and does not have split debug turned on,
# then leave the debugging sections in libpthread.
if ! has nostrip ${FEATURES} && ! has splitdebug ${FEATURES} ; then
${STRIP:-${CTARGET}-strip} --strip-debug "${ED}"$(alt_prefix)/*/libpthread-*.so
fi
}
src_install() { src_install() {
if just_headers ; then if just_headers ; then
export ABI=default export ABI=default
@ -1365,7 +1422,11 @@ src_install() {
fi fi
foreach_abi glibc_do_src_install foreach_abi glibc_do_src_install
src_strip
if ! use static-libs ; then
einfo "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. # Simple test to make sure our new glibc isn't completely broken.
@ -1418,9 +1479,15 @@ pkg_preinst() {
einfo "Defaulting /etc/host.conf:multi to on" einfo "Defaulting /etc/host.conf:multi to on"
fi fi
[[ ${ROOT} != "/" ]] && return 0 [[ -n ${ROOT} ]] && return 0
[[ -d ${ED}/$(get_libdir) ]] || return 0 [[ -d ${ED}/$(get_libdir) ]] || return 0
[[ -z ${BOOTSTRAP_RAP} ]] && glibc_sanity_check [[ -z ${BOOTSTRAP_RAP} ]] && glibc_sanity_check
if [[ -L ${EROOT}/usr/lib/locale ]]; then
# Help portage migrate this to a directory
# https://bugs.gentoo.org/753740
rm "${EROOT}"/usr/lib/locale || die
fi
} }
pkg_postinst() { pkg_postinst() {
@ -1429,15 +1496,11 @@ pkg_postinst() {
if ! tc-is-cross-compiler && [[ -x ${EROOT}/usr/sbin/iconvconfig ]] ; then if ! tc-is-cross-compiler && [[ -x ${EROOT}/usr/sbin/iconvconfig ]] ; then
# Generate fastloading iconv module configuration file. # Generate fastloading iconv module configuration file.
"${EROOT}"/usr/sbin/iconvconfig --prefix="${ROOT}" "${EROOT}"/usr/sbin/iconvconfig --prefix="${ROOT}/"
fi fi
if ! is_crosscompile && [[ ${ROOT} == "/" ]] ; then if ! is_crosscompile && [[ -z ${ROOT} ]] ; then
# Reload init ... if in a chroot or a diff init package, ignore use compile-locales || run_locale_gen "${EROOT}/"
# errors from this step #253697
/sbin/telinit U 2>/dev/null
use compile-locales || run_locale_gen "${EROOT}"
fi fi
# Check for sanity of /etc/nsswitch.conf, take 2 # Check for sanity of /etc/nsswitch.conf, take 2

View File

@ -12,6 +12,7 @@
<flag name="debug">When USE=hardened, allow fortify/stack violations to dump core (SIGABRT) and not kill self (SIGKILL)</flag> <flag name="debug">When USE=hardened, allow fortify/stack violations to dump core (SIGABRT) and not kill self (SIGKILL)</flag>
<flag name="gd">build memusage and memusagestat tools</flag> <flag name="gd">build memusage and memusagestat tools</flag>
<flag name="multiarch">enable optimizations for multiple CPU architectures (detected at runtime)</flag> <flag name="multiarch">enable optimizations for multiple CPU architectures (detected at runtime)</flag>
<flag name="multilib-bootstrap">Provide prebuilt libgcc.a and crt files if missing. Only needed for ABI switch.</flag>
<flag name="nscd">Build, and enable support for, the Name Service Cache Daemon</flag> <flag name="nscd">Build, and enable support for, the Name Service Cache Daemon</flag>
<flag name="rpc">Enable obsolete RPC/NIS layers</flag> <flag name="rpc">Enable obsolete RPC/NIS layers</flag>
<flag name="ssp">protect stack of glibc internals</flag> <flag name="ssp">protect stack of glibc internals</flag>