1 # Copyright 1999-2017 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
6 inherit toolchain-glibc
8 DESCRIPTION="GNU libc6 (also called glibc2) C library"
9 HOMEPAGE="https://www.gnu.org/software/libc/libc.html"
11 LICENSE="LGPL-2.1+ BSD HPND ISC inner-net rc PCRE"
12 KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86"
13 RESTRICT="strip" # strip ourself #46186
16 # Configuration variables
20 EGIT_REPO_URIS="git://sourceware.org/git/glibc.git"
21 EGIT_SOURCEDIRS="${S}"
28 GCC_BOOTSTRAP_VER="4.7.3-r1"
29 PATCH_VER="8" # Gentoo patchset
30 : ${NPTL_KERN_VER:="2.6.32"} # min kernel version nptl requires
32 IUSE="audit caps debug gd hardened multilib nscd +rpc selinux systemtap profile suid vanilla crosscompile_opts_headers-only"
34 # Here's how the cross-compile logic breaks down ...
35 # CTARGET - machine that will target the binaries
36 # CHOST - machine that will host the binaries
37 # CBUILD - machine that will build the binaries
38 # If CTARGET != CHOST, it means you want a libc for cross-compiling.
39 # If CHOST != CBUILD, it means you want to cross-compile the libc.
40 # CBUILD = CHOST = CTARGET - native build/install
41 # CBUILD != (CHOST = CTARGET) - cross-compile a native build
42 # (CBUILD = CHOST) != CTARGET - libc for cross-compiler
43 # CBUILD != CHOST != CTARGET - cross-compile a libc for a cross-compiler
45 # CHOST = CTARGET - install into /
46 # CHOST != CTARGET - install into /usr/CTARGET/
48 export CBUILD=${CBUILD:-${CHOST}}
49 export CTARGET=${CTARGET:-${CHOST}}
50 if [[ ${CTARGET} == ${CHOST} ]] ; then
51 if [[ ${CATEGORY} == cross-* ]] ; then
52 export CTARGET=${CATEGORY#cross-}
57 [[ ${CHOST} != ${CTARGET} ]]
60 # Why SLOT 2.2 you ask yourself while sippin your tea ?
61 # Everyone knows 2.2 > 0, duh.
64 # General: We need a new-enough binutils/gcc to match upstream baseline.
65 # arch: we need to make sure our binutils/gcc supports TLS.
68 audit? ( sys-process/audit )
69 caps? ( sys-libs/libcap )
71 suid? ( caps? ( sys-libs/libcap ) )
72 selinux? ( sys-libs/libselinux )
74 DEPEND="${COMMON_DEPEND}
75 >=app-misc/pax-utils-0.1.10
76 !<sys-apps/sandbox-1.6
77 !<sys-apps/portage-2.1.2"
78 RDEPEND="${COMMON_DEPEND}
79 !sys-kernel/ps3-sources
80 sys-apps/gentoo-functions
83 if [[ ${CATEGORY} == cross-* ]] ; then
84 DEPEND+=" !crosscompile_opts_headers-only? (
85 >=${CATEGORY}/binutils-2.24
88 [[ ${CATEGORY} == *-linux* ]] && DEPEND+=" ${CATEGORY}/linux-headers"
91 >=sys-devel/binutils-2.24
94 RDEPEND+=" vanilla? ( !sys-libs/timezone-data )"
95 PDEPEND+=" !vanilla? ( sys-libs/timezone-data )"
99 echo mirror://gnu/glibc/$1 ftp://sourceware.org/pub/glibc/{releases,snapshots}/$1 mirror://gentoo/$1
102 local devspace="HTTP~vapier/dist/URI HTTP~azarah/glibc/URI HTTP~tamiko/distfiles/URI"
103 devspace=${devspace//HTTP/https://dev.gentoo.org/}
104 echo mirror://gentoo/$1 ${devspace//URI/$1}
107 [[ -z ${EGIT_REPO_URIS} ]] && upstream_uris ${P}.tar.xz
108 [[ -n ${PATCH_VER} ]] && gentoo_uris ${P}-patches-${PATCH_VER}.tar.bz2
110 SRC_URI+=" ${GCC_BOOTSTRAP_VER:+multilib? ( $(gentoo_uris gcc-${GCC_BOOTSTRAP_VER}-multilib-bootstrap.tar.bz2) )}"
113 [[ -n ${GCC_BOOTSTRAP_VER} ]] && use multilib && unpack gcc-${GCC_BOOTSTRAP_VER}-multilib-bootstrap.tar.bz2
115 toolchain-glibc_src_unpack
119 toolchain-glibc_src_prepare
123 epatch "${FILESDIR}"/2.19/${PN}-2.19-ia64-gcc-4.8-reloc-hack.patch #503838
125 if use hardened ; then
126 # We don't enable these for non-hardened as the output is very terse --
127 # it only states that a crash happened. The default upstream behavior
128 # includes backtraces and symbols.
129 einfo "Installing Hardened Gentoo SSP and FORTIFY_SOURCE handler"
130 cp "${FILESDIR}"/2.20/glibc-2.20-gentoo-stack_chk_fail.c debug/stack_chk_fail.c || die
131 cp "${FILESDIR}"/2.20/glibc-2.20-gentoo-chk_fail.c debug/chk_fail.c || die
134 # Allow SIGABRT to dump core on non-hardened systems, or when debug is requested.
136 -e '/^CFLAGS-backtrace.c/ iCPPFLAGS-stack_chk_fail.c = -DSSP_SMASH_DUMPS_CORE' \
137 -e '/^CFLAGS-backtrace.c/ iCPPFLAGS-chk_fail.c = -DSSP_SMASH_DUMPS_CORE' \
138 debug/Makefile || die
141 # Build various bits with ssp-all
143 -e 's:-fstack-protector$:-fstack-protector-all:' \
147 case $(gcc-fullversion) in
149 eerror "You need to switch to a newer compiler; gcc-4.8.[0-3] and gcc-4.9.0 miscompile"
150 eerror "glibc. See https://bugs.gentoo.org/547420 for details."
151 die "need to switch compilers #547420"