# Copyright 1999-2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=7
# Bumping notes: https://wiki.gentoo.org/wiki/Project:Toolchain/sys-libs/glibc
# Please read & adapt the page as necessary if obsolete.
PYTHON_COMPAT=( python3_{10..11} )
TMPFILES_OPTIONAL=1
inherit python-any-r1 prefix preserve-libs toolchain-funcs flag-o-matic gnuconfig \
multilib systemd multiprocessing tmpfiles
DESCRIPTION="GNU libc C library"
HOMEPAGE="https://www.gnu.org/software/libc/"
LICENSE="LGPL-2.1+ BSD HPND ISC inner-net rc PCRE"
SLOT="2.2"
EMULTILIB_PKG="true"
# Gentoo patchset (ignored for live ebuilds)
PATCH_VER=10
PATCH_DEV=dilfridge
if [[ ${PV} == 9999* ]]; then
inherit git-r3
else
KEYWORDS="~alpha amd64 arm arm64 ~hppa ~loong ~m68k ~mips ppc ppc64 ~riscv ~s390 ~sparc x86"
SRC_URI="mirror://gnu/glibc/${P}.tar.xz"
SRC_URI+=" https://dev.gentoo.org/~${PATCH_DEV}/distfiles/${P}-patches-${PATCH_VER}.tar.xz"
fi
RELEASE_VER=${PV}
GCC_BOOTSTRAP_VER=20201208
LOCALE_GEN_VER=2.23
GLIBC_SYSTEMD_VER=20210729
SRC_URI+=" https://gitweb.gentoo.org/proj/locale-gen.git/snapshot/locale-gen-${LOCALE_GEN_VER}.tar.gz"
SRC_URI+=" multilib-bootstrap? ( https://dev.gentoo.org/~dilfridge/distfiles/gcc-multilib-bootstrap-${GCC_BOOTSTRAP_VER}.tar.xz )"
SRC_URI+=" systemd? ( https://gitweb.gentoo.org/proj/toolchain/glibc-systemd.git/snapshot/glibc-systemd-${GLIBC_SYSTEMD_VER}.tar.gz )"
IUSE="audit caps cet compile-locales +crypt custom-cflags doc gd hash-sysv-compat headers-only +multiarch multilib multilib-bootstrap nscd perl profile selinux +ssp stack-realign +static-libs suid systemd systemtap test vanilla"
# Minimum kernel version that glibc requires
MIN_KERN_VER="3.2.0"
# Minimum pax-utils version needed (which contains any new syscall changes for
# its seccomp filter!). Please double check this!
MIN_PAX_UTILS_VER="1.3.3"
# Here's how the cross-compile logic breaks down ...
# CTARGET - machine that will target the binaries
# CHOST - machine that will host the binaries
# CBUILD - machine that will build the binaries
# If CTARGET != CHOST, it means you want a libc for cross-compiling.
# If CHOST != CBUILD, it means you want to cross-compile the libc.
# CBUILD = CHOST = CTARGET - native build/install
# CBUILD != (CHOST = CTARGET) - cross-compile a native build
# (CBUILD = CHOST) != CTARGET - libc for cross-compiler
# CBUILD != CHOST != CTARGET - cross-compile a libc for a cross-compiler
# For install paths:
# CHOST = CTARGET - install into /
# CHOST != CTARGET - install into /usr/CTARGET/
#
export CBUILD=${CBUILD:-${CHOST}}
export CTARGET=${CTARGET:-${CHOST}}
if [[ ${CTARGET} == ${CHOST} ]] ; then
if [[ ${CATEGORY} == cross-* ]] ; then
export CTARGET=${CATEGORY#cross-}
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' f