1 # Copyright 1999-2018 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
4 # @ECLASS: toolchain-glibc.eclass
6 # <toolchain@gentoo.org>
7 # @BLURB: Common code for sys-libs/glibc ebuilds
9 # This eclass contains the common phase functions migrated from
10 # sys-libs/glibc eblits.
12 if [[ -z ${_TOOLCHAIN_GLIBC_ECLASS} ]]; then
14 inherit eutils versionator toolchain-funcs flag-o-matic gnuconfig \
15 multilib systemd unpacker multiprocessing prefix
18 0|1|2|3) EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_test \
19 src_install pkg_preinst pkg_postinst;;
20 2|3) EXPORT_FUNCTIONS pkg_setup src_unpack src_prepare src_configure \
21 src_compile src_test src_install pkg_preinst pkg_postinst;;
22 4|5) EXPORT_FUNCTIONS pkg_pretend pkg_setup src_unpack src_prepare \
23 src_configure src_compile src_test src_install \
24 pkg_preinst pkg_postinst;;
25 6) EXPORT_FUNCTIONS pkg_pretend;;
26 *) die "Unsupported EAPI=${EAPI}";;
32 is_crosscompile && echo /usr/${CTARGET}
35 if [[ ${EAPI:-0} == [012] ]] ; then
39 # This indirection is for binpkgs. #523332
40 _nonfatal() { nonfatal "$@" ; }
41 if [[ ${EAPI:-0} == [0123] ]] ; then
43 _nonfatal() { "$@" ; }
46 # We need to be able to set alternative headers for
47 # compiling for non-native platform
48 # Will also become useful for testing kernel-headers without screwing up
50 # note: intentionally undocumented.
52 echo ${ALT_HEADERS:=$(alt_prefix)/usr/include}
55 if [[ -z ${ALT_BUILD_HEADERS} ]] ; then
56 ALT_BUILD_HEADERS="${EPREFIX}$(alt_headers)"
57 if tc-is-cross-compiler ; then
58 ALT_BUILD_HEADERS=${SYSROOT}$(alt_headers)
59 if [[ ! -e ${ALT_BUILD_HEADERS}/linux/version.h ]] ; then
60 local header_path=$(echo '#include <linux/version.h>' | $(tc-getCPP ${CTARGET}) ${CFLAGS} 2>&1 | grep -o '[^"]*linux/version.h')
61 ALT_BUILD_HEADERS=${header_path%/linux/version.h}
65 echo "${ALT_BUILD_HEADERS}"
69 echo $(alt_prefix)/$(get_libdir)
72 echo $(alt_prefix)/usr/$(get_libdir)
76 echo "${WORKDIR}/build-${ABI}-${CTARGET}-$1"
79 setup_target_flags() {
80 # This largely mucks with compiler flags. None of which should matter
81 # when building up just the headers.
82 just_headers && return 0
86 # -march needed for #185404 #199334
87 # TODO: When creating the first glibc cross-compile, this test will
88 # always fail as it does a full link which in turn requires glibc.
89 # Probably also applies when changing multilib profile settings (e.g.
90 # enabling x86 when the profile was amd64-only previously).
91 # We could change main to _start and pass -nostdlib here so that we
92 # only test the gcc code compilation. Or we could do a compile and
93 # then look for the symbol via scanelf.
94 if ! glibc_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
95 local t=${CTARGET_OPT:-${CTARGET}}
97 filter-flags '-march=*'
98 export CFLAGS="-march=${t} ${CFLAGS}"
99 einfo "Auto adding -march=${t} to CFLAGS #185404"
103 # -march needed for #185404 #199334
104 # Note: This test only matters when the x86 ABI is enabled, so we could
105 # optimize a bit and elide it.
106 # TODO: See cross-compile issues listed above for x86.
107 if ! glibc_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
108 local t=${CTARGET_OPT:-${CTARGET}}
110 # Normally the target is x86_64-xxx, so turn that into the -march that
111 # gcc actually accepts. #528708
112 [[ ${t} == "x86_64" ]] && t="x86-64"
113 filter-flags '-march=*'
114 # ugly, ugly, ugly. ugly.
115 CFLAGS_x86=$(CFLAGS=${CFLAGS_x86} filter-flags '-march=*'; echo "${CFLAGS}")
116 export CFLAGS_x86="${CFLAGS_x86} -march=${t}"
117 einfo "Auto adding -march=${t} to CFLAGS_x86 #185404"
121 # The mips abi cannot support the GNU style hashes. #233233
122 filter-ldflags -Wl,--hash-style=gnu -Wl,--hash-style=both
125 # Both sparc and sparc64 can use -fcall-used-g6. -g7 is bad, though.
126 filter-flags "-fcall-used-g7"
127 append-flags "-fcall-used-g6"
129 # If the CHOST is the basic one (e.g. not sparcv9-xxx already),
130 # try to pick a better one so glibc can use cpu-specific .S files.
131 # We key off the CFLAGS to get a good value. Also need to handle
133 # We can't force users to set their CHOST to their exact machine
134 # as many of these are not recognized by config.sub/gcc and such :(.
135 # Note: If the mcpu values don't scale, we might try probing CPP defines.
136 # Note: Should we factor in -Wa,-AvXXX flags too ? Or -mvis/etc... ?
141 case $(get-flag mcpu) in
143 if version_is_at_least 2.8 ; then
145 elif version_is_at_least 2.4 ; then
147 elif version_is_at_least 2.2.3 ; then
152 if version_is_at_least 2.4 ; then
154 elif version_is_at_least 2.2.3 ; then
162 # We need to force at least v9a because the base build doesn't
164 # https://sourceware.org/bugzilla/show_bug.cgi?id=19477
165 [[ -z ${cpu} ]] && append-flags "-Wa,-xarch=v9a"
170 case $(get-flag mcpu) in
172 if version_is_at_least 2.8 ; then
174 elif version_is_at_least 2.4 ; then
176 elif version_is_at_least 2.2.3 ; then
183 if version_is_at_least 2.4 ; then
185 elif version_is_at_least 2.2.3 ; then
197 v8|supersparc|hypersparc|leon|leon3)
203 [[ -n ${cpu} ]] && CTARGET_OPT="${cpu}-${CTARGET#*-}"
209 # Make sure host make.conf doesn't pollute us
210 if is_crosscompile || tc-is-cross-compiler ; then
211 CHOST=${CTARGET} strip-unsupported-flags
214 # Store our CFLAGS because it's changed depending on which CTARGET
215 # we are building when pulling glibc on a multilib profile
216 CFLAGS_BASE=${CFLAGS_BASE-${CFLAGS}}
217 CFLAGS=${CFLAGS_BASE}
218 CXXFLAGS_BASE=${CXXFLAGS_BASE-${CXXFLAGS}}
219 CXXFLAGS=${CXXFLAGS_BASE}
220 ASFLAGS_BASE=${ASFLAGS_BASE-${ASFLAGS}}
221 ASFLAGS=${ASFLAGS_BASE}
223 # Over-zealous CFLAGS can often cause problems. What may work for one
224 # person may not work for another. To avoid a large influx of bugs
225 # relating to failed builds, we strip most CFLAGS out to ensure as few
226 # problems as possible.
228 strip-unsupported-flags
229 filter-flags -m32 -m64 -mabi=*
230 filter-ldflags -Wl,-rpath=*
233 filter-flags -frecord-gcc-switches
235 unset CBUILD_OPT CTARGET_OPT
236 if use multilib ; then
237 CTARGET_OPT=$(get_abi_CTARGET)
238 [[ -z ${CTARGET_OPT} ]] && CTARGET_OPT=$(get_abi_CHOST)
243 if [[ -n ${CTARGET_OPT} && ${CBUILD} == ${CHOST} ]] && ! is_crosscompile; then
244 CBUILD_OPT=${CTARGET_OPT}
247 # Lock glibc at -O2 -- linuxthreads needs it and we want to be
248 # conservative here. -fno-strict-aliasing is to work around #155906
250 append-flags -O2 -fno-strict-aliasing
252 # Can't build glibc itself with fortify code. Newer versions add
253 # this flag for us, so no need to do it manually.
254 version_is_at_least 2.16 ${PV} || append-cppflags -U_FORTIFY_SOURCE
256 # building glibc <2.25 with SSP is fraught with difficulty, especially
257 # due to __stack_chk_fail_local which would mean significant changes
258 # to the glibc build process. See bug #94325 #293721
259 # Note we have to handle both user-given CFLAGS and gcc defaults via
260 # spec rules here. We can't simply add -fno-stack-protector as it gets
261 # added before user flags, and we can't just filter-flags because
262 # _filter_hardened doesn't support globs.
263 filter-flags -fstack-protector*
264 if ! version_is_at_least 2.25 ; then
265 tc-enables-ssp && append-flags $(test-flags -fno-stack-protector)
268 if [[ $(gcc-major-version) -lt 6 ]]; then
269 # Starting with gcc-6 (and fully upstreamed pie patches) we control
270 # default enabled/disabled pie via use flags. So nothing to do
273 if use hardened && tc-enables-pie ; then
274 # Force PIC macro definition for all compilations since they're all
275 # either -fPIC or -fPIE with the default-PIE compiler.
276 append-cppflags -DPIC
278 # Don't build -fPIE without the default-PIE compiler and the
286 [[ -z ${LT_VER} ]] && return 0
290 # Older versions of glibc had incomplete arch support for nptl.
291 # But if you're building those now, you can handle USE=nptl yourself.
295 want_linuxthreads() {
296 [[ -z ${LT_VER} ]] && return 1
301 # Archs that can use TLS (Thread Local Storage)
304 # requires i486 or better #106556
305 [[ ${CTARGET} == i[4567]86* ]] && return 0
316 # For some reason --with-tls --with__thread is causing segfaults on sparc32.
317 [[ ${PROFILE_ARCH} == "sparc" ]] && return 1
319 [[ -n ${WANT__THREAD} ]] && return ${WANT__THREAD}
321 # only test gcc -- can't test linking yet
322 tc-has-tls -c ${CTARGET}
325 return ${WANT__THREAD}
329 # Make sure binutils is new enough to support indirect functions #336792
330 # This funky sed supports gold and bfd linkers.
332 bver=$($(tc-getLD ${CTARGET}) -v | sed -n -r '1{s:[^0-9]*::;s:^([0-9.]*).*:\1:;p}')
333 case $(tc-arch ${CTARGET}) in
334 amd64|x86) nver="2.20" ;;
337 ppc|ppc64) nver="2.20" ;;
338 # ifunc was added in 2.23, but glibc also needs machinemode which is in 2.24.
340 sparc) nver="2.21" ;;
343 version_is_at_least ${nver} ${bver}
346 # Setup toolchain variables that had historically
347 # been defined in the profiles for these archs.
351 unset LD_ASSUME_KERNEL
353 if is_crosscompile || tc-is-cross-compiler ; then
354 multilib_env ${CTARGET_OPT:-${CTARGET}}
356 if ! use multilib ; then
357 MULTILIB_ABIS=${DEFAULT_ABI}
359 MULTILIB_ABIS=${MULTILIB_ABIS:-${DEFAULT_ABI}}
362 # If the user has CFLAGS_<CTARGET> in their make.conf, use that,
363 # and fall back on CFLAGS.
364 local VAR=CFLAGS_${CTARGET//[-.]/_}
365 CFLAGS=${!VAR-${CFLAGS}}
366 einfo " $(printf '%15s' 'Manual CFLAGS:') ${CFLAGS}"
371 export ABI=${ABI:-${DEFAULT_ABI:-default}}
373 if use headers-only ; then
374 # Avoid mixing host's CC and target's CFLAGS_${ABI}:
375 # At this bootstrap stage we have only binutils for
376 # target but not compiler yet.
377 einfo "Skip CC ABI injection. We can't use (cross-)compiler yet."
381 local VAR=CFLAGS_${ABI}
382 # We need to export CFLAGS with abi information in them because glibc's
383 # configure script checks CFLAGS for some targets (like mips). Keep
384 # around the original clean value to avoid appending multiple ABIs on
386 : ${__GLIBC_CC:=$(tc-getCC ${CTARGET_OPT:-${CTARGET}})}
387 export __GLIBC_CC CC="${__GLIBC_CC} ${!VAR}"
388 einfo " $(printf '%15s' 'Manual CC:') ${CC}"
396 if use multilib ; then
397 abilist=$(get_install_abis)
399 abilist=${DEFAULT_ABI}
402 for ABI in ${abilist:-default} ; do
404 einfo "Running $1 for ABI ${ABI}"
412 is_crosscompile && use headers-only
416 local b="Gentoo ${PVR}"
417 [[ -n ${SNAP_VER} ]] && b+=" snapshot ${SNAP_VER}"
418 [[ -n ${BRANCH_UPDATE} ]] && b+=" branch ${BRANCH_UPDATE}"
419 [[ -n ${PATCH_VER} ]] && ! use vanilla && b+=" p${PATCH_VER}"
425 glibc_compile_test() {
426 local ret save_cflags=${CFLAGS}
430 pushd "${T}" >/dev/null
433 printf '%b' "$*" > glibc-test.c
435 _nonfatal emake -s glibc-test
440 CFLAGS=${save_cflags}
447 if [[ ${EMERGE_FROM} == "binary" ]] ; then
448 # ignore build failures when installing a binary package #324685
449 glibc_compile_test "" "$@" 2>/dev/null || return 0
451 if ! glibc_compile_test "" "$@" ; then
452 ewarn "Simple build failed ... assuming this is desired #324685"
457 pushd "${T}" >/dev/null
469 # Make sure devpts is mounted correctly for use w/out setuid pt_chown.
471 # If merely building the binary package, then there's nothing to verify.
472 [[ ${MERGE_TYPE} == "buildonly" ]] && return
474 # Only sanity check when installing the native glibc.
475 [[ ${ROOT} != "/" ]] && return
477 # Older versions always installed setuid, so no need to check.
478 in_iuse suid || return
480 # If they're opting in to the old suid code, then no need to check.
483 if awk '$3 == "devpts" && $4 ~ /[, ]gid=5[, ]/ { exit 1 }' /proc/mounts ; then
484 eerror "In order to use glibc with USE=-suid, you must make sure that"
485 eerror "you have devpts mounted at /dev/pts with the gid=5 option."
486 eerror "Openrc should do this for you, so you should check /etc/fstab"
487 eerror "and make sure you do not have any invalid settings there."
488 # Do not die on older kernels as devpts did not export these settings #489520.
489 if version_is_at_least 2.6.25 $(uname -r) ; then
490 die "mount & fix your /dev/pts settings"
495 toolchain-glibc_pkg_pretend() {
496 if [[ ${EAPI:-0} == 6 ]]; then
497 eerror "We're moving code back to the ebuilds to get away from the ancient EAPI cruft."
498 eerror "From EAPI=6 on you'll have to define the phases in the glibc ebuilds."
499 die "Silly overlay authors..."
502 # For older EAPIs, this is run in pkg_preinst.
503 if [[ ${EAPI:-0} != [0123] ]] ; then
507 # Prevent native builds from downgrading.
508 if [[ ${MERGE_TYPE} != "buildonly" ]] && \
509 [[ ${ROOT} == "/" ]] && \
510 [[ ${CBUILD} == ${CHOST} ]] && \
511 [[ ${CHOST} == ${CTARGET} ]] ; then
512 # The high rev # is to allow people to downgrade between -r# versions.
513 # We want to block 2.20->2.19, but 2.20-r3->2.20-r2 should be fine.
514 # Hopefully we never actually use a r# this high.
515 if has_version ">${CATEGORY}/${P}-r10000" ; then
516 eerror "Sanity check to keep you from breaking your system:"
517 eerror " Downgrading glibc is not supported and a sure way to destruction"
518 die "aborting to save your system"
521 if ! glibc_run_test '#include <pwd.h>\nint main(){return getpwuid(0)==0;}\n'
523 eerror "Your patched vendor kernel is broken. You need to get an"
524 eerror "update from whoever is providing the kernel to you."
525 eerror "https://sourceware.org/bugzilla/show_bug.cgi?id=5227"
526 eerror "http://bugs.gentoo.org/262698"
527 die "keeping your system alive, say thank you"
530 if ! glibc_run_test '#include <unistd.h>\n#include <sys/syscall.h>\nint main(){return syscall(1000)!=-1;}\n'
532 eerror "Your old kernel is broken. You need to update it to"
533 eerror "a newer version as syscall(<bignum>) will break."
534 eerror "http://bugs.gentoo.org/279260"
535 die "keeping your system alive, say thank you"
539 # users have had a chance to phase themselves, time to give em the boot
540 if [[ -e ${EROOT}/etc/locale.gen ]] && [[ -e ${EROOT}/etc/locales.build ]] ; then
541 eerror "You still haven't deleted ${EROOT}/etc/locales.build."
542 eerror "Do so now after making sure ${EROOT}/etc/locale.gen is kosher."
543 die "lazy upgrader detected"
546 if [[ ${CTARGET} == i386-* ]] ; then
547 eerror "i386 CHOSTs are no longer supported."
548 eerror "Chances are you don't actually want/need i386."
549 eerror "Please read http://www.gentoo.org/doc/en/change-chost.xml"
550 die "please fix your CHOST"
553 if [[ -e /proc/xen ]] && [[ $(tc-arch) == "x86" ]] && ! is-flag -mno-tls-direct-seg-refs ; then
554 ewarn "You are using Xen but don't have -mno-tls-direct-seg-refs in your CFLAGS."
555 ewarn "This will result in a 50% performance penalty when running with a 32bit"
556 ewarn "hypervisor, which is probably not what you want."
559 use hardened && ! tc-enables-pie && \
560 ewarn "PIE hardening not applied, as your compiler doesn't default to PIE"
562 # Make sure host system is up to date #394453
563 if has_version '<sys-libs/glibc-2.13' && \
564 [[ -n $(scanelf -qys__guard -F'#s%F' "${EROOT}"/lib*/l*-*.so) ]]
566 ebegin "Scanning system for __guard to see if you need to rebuild first ..."
568 scanelf -qys__guard -F'#s%F' \
571 "${EROOT}"/usr/*bin/ \
572 "${EROOT}"/usr/lib* | \
574 -e "^${EROOT}/lib.*/(libc|ld)-2.*.so$" \
575 -e "^${EROOT}/sbin/(ldconfig|sln)$"
579 eerror "Your system still has old SSP __guard symbols. You need to"
580 eerror "rebuild all the packages that provide these files first:"
582 die "old __guard detected"
587 toolchain-glibc_pkg_setup() {
588 [[ ${EAPI:-0} == [0123] ]] && toolchain-glibc_pkg_pretend
592 local version=$1 major minor micro
593 major=$((version / 65536))
594 minor=$(((version % 65536) / 256))
595 micro=$((version % 256))
596 echo ${major}.${minor}.${micro}
600 [[ $(KV_to_int $1) -ge $(KV_to_int $2) ]]
604 get_kheader_version() {
605 printf '#include <linux/version.h>\nLINUX_VERSION_CODE\n' | \
606 $(tc-getCPP ${CTARGET}) -I "$(alt_build_headers)" - | \
610 check_nptl_support() {
611 # don't care about the compiler here as we aren't using it
612 just_headers && return
614 local run_kv build_kv want_kv
615 run_kv=$(int_to_KV $(get_KV))
616 build_kv=$(int_to_KV $(get_kheader_version))
617 want_kv=${NPTL_KERN_VER}
619 ebegin "Checking gcc for __thread support"
620 if ! eend $(want__thread ; echo $?) ; then
622 eerror "Could not find a gcc that supports the __thread directive!"
623 eerror "Please update your binutils/gcc and try again."
624 die "No __thread support in gcc!"
627 if ! is_crosscompile && ! tc-is-cross-compiler ; then
628 # Building fails on an non-supporting kernel
629 ebegin "Checking kernel version (${run_kv} >= ${want_kv})"
630 if ! eend_KV ${run_kv} ${want_kv} ; then
632 eerror "You need a kernel of at least ${want_kv} for NPTL support!"
633 die "Kernel version too low!"
637 ebegin "Checking linux-headers version (${build_kv} >= ${want_kv})"
638 if ! eend_KV ${build_kv} ${want_kv} ; then
640 eerror "You need linux-headers of at least ${want_kv} for NPTL support!"
641 die "linux-headers version too low!"
647 [[ -n ${SNAP_VER} ]] && a="${a}-${RELEASE_VER}"
648 [[ -n $1 ]] && a="${a}-$1"
649 if [[ -n ${SNAP_VER} ]] ; then
652 if [[ -n $2 ]] ; then
655 a="${a}-${RELEASE_VER}"
658 if has ${a}.tar.xz ${A} ; then
663 [[ -n $1 ]] && { mv ${a} $1 || die ; }
666 toolchain-glibc_do_src_unpack() {
667 # Check NPTL support _before_ we unpack things to save some time
668 want_nptl && check_nptl_support
673 touch locale/C-translit.h #185476 #218003
674 [[ -n ${LT_VER} ]] && unpack_pkg linuxthreads ${LT_VER}
675 [[ -n ${PORTS_VER} ]] && unpack_pkg ports ${PORTS_VER}
676 [[ -n ${LIBIDN_VER} ]] && unpack_pkg libidn
678 if [[ -n ${PATCH_VER} ]] ; then
680 unpack glibc-${RELEASE_VER}-patches-${PATCH_VER}.tar.bz2
681 # pull out all the addons
683 for d in extra/*/configure ; do
685 [[ -d ${S}/${d} ]] && die "${d} already exists in \${S}"
686 mv "${d}" "${S}" || die "moving ${d} failed"
691 toolchain-glibc_src_unpack() {
694 toolchain-glibc_do_src_unpack
695 [[ ${EAPI:-0} == [01] ]] && cd "${S}" && toolchain-glibc_src_prepare
698 toolchain-glibc_src_prepare() {
699 # XXX: We should do the branchupdate, before extracting the manpages and
700 # infopages else it does not help much (mtimes change if there is a change
701 # to them with branchupdate)
702 if [[ -n ${BRANCH_UPDATE} ]] ; then
703 epatch "${DISTDIR}"/glibc-${RELEASE_VER}-branch-update-${BRANCH_UPDATE}.patch.bz2
705 # Snapshot date patch
706 einfo "Patching version to display snapshot date ..."
707 sed -i -e "s:\(#define RELEASE\).*:\1 \"${BRANCH_UPDATE}\":" version.h
711 if ! version_is_at_least 2.17 ; then
712 [[ -e csu/Banner ]] && die "need new banner location"
713 glibc_banner > csu/Banner
715 if [[ -n ${PATCH_VER} ]] && ! use vanilla ; then
716 EPATCH_MULTI_MSG="Applying Gentoo Glibc Patchset ${RELEASE_VER}-${PATCH_VER} ..." \
717 EPATCH_EXCLUDE=${GLIBC_PATCH_EXCLUDE} \
718 EPATCH_SUFFIX="patch" \
720 epatch "${WORKDIR}"/patches
723 if just_headers ; then
724 if [[ -e ports/sysdeps/mips/preconfigure ]] ; then
725 # mips peeps like to screw with us. if building headers,
726 # we don't have a real compiler, so we can't let them
727 # insert -mabi on us.
728 sed -i '/CPPFLAGS=.*-mabi/s|.*|:|' ports/sysdeps/mips/preconfigure || die
729 find ports/sysdeps/mips/ -name Makefile -exec sed -i '/^CC.*-mabi=/s:-mabi=.*:-D_MIPS_SZPTR=32:' {} +
737 # Glibc is stupid sometimes, and doesn't realize that with a
738 # static C-Only gcc, -lgcc_eh doesn't exist.
739 # https://sourceware.org/ml/libc-alpha/2003-09/msg00100.html
740 # https://sourceware.org/ml/libc-alpha/2005-02/msg00042.html
741 # But! Finally fixed in recent versions:
742 # https://sourceware.org/ml/libc-alpha/2012-05/msg01865.html
743 if ! version_is_at_least 2.16 ; then
744 echo 'int main(){}' > "${T}"/gcc_eh_test.c
745 if ! $(tc-getCC ${CTARGET}) ${CFLAGS} ${LDFLAGS} "${T}"/gcc_eh_test.c -lgcc_eh 2>/dev/null ; then
746 sed -i -e 's:-lgcc_eh::' Makeconfig || die "sed gcc_eh"
751 find . -type f '(' -size 0 -o -name "*.orig" ')' -delete
752 find . -name configure -exec touch {} +
754 eprefixify extra/locale/locale-gen
756 # Fix permissions on some of the scripts.
757 chmod u+x "${S}"/scripts/*.sh
759 dump_toolchain_settings() {
765 for v in ABI CBUILD CHOST CTARGET CBUILD_OPT CTARGET_OPT CC LD {AS,C,CPP,CXX,LD}FLAGS ; do
766 einfo " $(printf '%15s' ${v}:) ${!v}"
769 # The glibc configure script doesn't properly use LDFLAGS all the time.
770 export CC="$(tc-getCC ${CTARGET}) ${LDFLAGS}"
771 einfo " $(printf '%15s' 'Manual CC:') ${CC}"
775 glibc_do_configure() {
776 # Glibc does not work with gold (for various reasons) #269274.
779 dump_toolchain_settings "Configuring glibc for $1"
784 pushd "${S}" > /dev/null
785 local addons=$(echo */configure | sed \
786 -e 's:/configure::g' \
787 -e 's:\(linuxthreads\|nptl\|rtkaio\|glibc-compat\)\( \|$\)::g' \
792 [[ -d ports ]] && addons+=",ports"
795 if has_version '<sys-libs/glibc-2.13' ; then
796 myconf+=( --enable-old-ssp-compat )
799 if version_is_at_least 2.25 ; then
802 # dlopen() detects stack smash on mips n32 ABI.
803 # Cause is unknown: https://bugs.gentoo.org/640130
804 myconf+=( --enable-stack-protector=no )
807 # Currently gcc on powerpc32 generates invalid code for
808 # __builtin_return_address(0) calls. Normally programs
809 # don't do that but malloc hooks in glibc do:
810 # https://gcc.gnu.org/PR81996
811 # https://bugs.gentoo.org/629054
812 myconf+=( --enable-stack-protector=no )
815 myconf+=( --enable-stack-protector=all )
820 # Keep a whitelist of targets supporing IFUNC. glibc's ./configure
821 # is not robust enough to detect proper support:
822 # https://bugs.gentoo.org/641216
823 # https://sourceware.org/PR22634#c0
824 case $(tc-arch ${CTARGET}) in
825 # Keep whitelist of targets where autodetection mostly works.
826 amd64|x86|sparc|ppc|ppc64|arm|arm64|s390) ;;
827 # Blacklist everywhere else
828 *) myconf+=( libc_cv_ld_gnu_indirect_function=no ) ;;
831 if version_is_at_least 2.25 ; then
832 myconf+=( --enable-stackguard-randomization )
834 myconf+=( $(use_enable hardened stackguard-randomization) )
837 [[ $(tc-is-softfloat) == "yes" ]] && myconf+=( --without-fp )
839 if [[ $1 == "linuxthreads" ]] ; then
841 myconf+=( --with-tls )
843 if ! want__thread || use glibc-compat20 || [[ ${LT_KER_VER} == 2.[02].* ]] ; then
844 myconf+=( --without-__thread )
846 myconf+=( --with-__thread )
849 myconf+=( --without-tls --without-__thread )
852 myconf+=( --disable-sanity-checks )
853 addons="linuxthreads${addons}"
854 myconf+=( --enable-kernel=${LT_KER_VER} )
855 elif [[ $1 == "nptl" ]] ; then
856 # Newer versions require nptl, so there is no addon for it.
857 version_is_at_least 2.20 || addons="nptl${addons}"
858 myconf+=( --enable-kernel=${NPTL_KERN_VER} )
860 die "invalid pthread option"
862 myconf+=( --enable-add-ons="${addons#,}" )
864 # Since SELinux support is only required for nscd, only enable it if:
866 # 2. only for the primary ABI on multilib systems
867 # 3. Not a crosscompile
868 if ! is_crosscompile && use selinux ; then
869 if use multilib ; then
870 if is_final_abi ; then
871 myconf+=( --with-selinux )
873 myconf+=( --without-selinux )
876 myconf+=( --with-selinux )
879 myconf+=( --without-selinux )
882 # Force a few tests where we always know the answer but
883 # configure is incapable of finding it.
884 if is_crosscompile ; then
886 libc_cv_c_cleanup=yes \
887 libc_cv_forced_unwind=yes
894 --build=${CBUILD_OPT:-${CBUILD}}
895 --host=${CTARGET_OPT:-${CTARGET}}
896 $(use_enable profile)
898 --with-headers=$(alt_build_headers)
899 --prefix="${EPREFIX}/usr"
900 --sysconfdir="${EPREFIX}/etc"
901 --localstatedir="${EPREFIX}/var"
902 --libdir='$(prefix)'/$(get_libdir)
903 --mandir='$(prefix)'/share/man
904 --infodir='$(prefix)'/share/info
905 --libexecdir='$(libdir)'/misc/glibc
906 --with-bugurl=http://bugs.gentoo.org/
907 --with-pkgversion="$(glibc_banner)"
908 $(use_multiarch || echo --disable-multi-arch)
909 $(in_iuse rpc && use_enable rpc obsolete-rpc || echo --enable-obsolete-rpc)
910 $(in_iuse systemtap && use_enable systemtap)
911 $(in_iuse nscd && use_enable nscd)
915 # We rely on sys-libs/timezone-data for timezone tools normally.
916 if version_is_at_least 2.23 ; then
917 myconf+=( $(use_enable vanilla timezone-tools) )
920 # These libs don't have configure flags.
921 ac_cv_lib_audit_audit_log_user_avc_message=$(in_iuse audit && usex audit || echo no)
922 ac_cv_lib_cap_cap_init=$(in_iuse caps && usex caps || echo no)
924 # There is no configure option for this and we need to export it
925 # since the glibc build will re-run configure on itself
926 export libc_cv_rootsbindir="${EPREFIX}/sbin"
927 export libc_cv_slibdir="${EPREFIX}/$(get_libdir)"
929 # We take care of patching our binutils to use both hash styles,
930 # and many people like to force gnu hash style only, so disable
931 # this overriding check. #347761
932 export libc_cv_hashstyle=no
934 # Overtime, generating info pages can be painful. So disable this for
935 # versions older than the latest stable to avoid the issue (this ver
936 # should be updated from time to time). #464394 #465816
937 if ! version_is_at_least 2.17 ; then
938 export ac_cv_prog_MAKEINFO=:
941 local builddir=$(builddir "$1")
942 mkdir -p "${builddir}"
944 set -- "${S}"/configure "${myconf[@]}"
946 "$@" || die "failed to configure glibc"
948 # ia64 static cross-compilers are a pita in so much that they
949 # can't produce static ELFs (as the libgcc.a is broken). so
950 # disable building of the programs for those targets if it
952 # XXX: We could turn this into a compiler test, but ia64 is
953 # the only one that matters, so this should be fine for now.
954 if is_crosscompile && [[ ${CTARGET} == ia64* ]] ; then
955 sed -i '1i+link-static = touch $@' config.make
958 # If we're trying to migrate between ABI sets, we need
959 # to lie and use a local copy of gcc. Like if the system
960 # is built with MULTILIB_ABIS="amd64 x86" but we want to
961 # add x32 to it, gcc/glibc don't yet support x32.
962 if [[ -n ${GCC_BOOTSTRAP_VER} ]] && use multilib ; then
963 echo 'main(){}' > "${T}"/test.c
964 if ! $(tc-getCC ${CTARGET}) ${CFLAGS} ${LDFLAGS} "${T}"/test.c -Wl,-emain -lgcc 2>/dev/null ; then
965 sed -i -e '/^CC = /s:$: -B$(objdir)/../'"gcc-${GCC_BOOTSTRAP_VER}/${ABI}:" config.make || die
967 cp $(which rpcgen) sunrpc/cross-rpcgen || die
968 touch -t 202001010101 sunrpc/cross-rpcgen || die
973 toolchain-glibc_headers_configure() {
976 local builddir=$(builddir "headers")
977 mkdir -p "${builddir}"
980 # if we don't have a compiler yet, we can't really test it now ...
981 # hopefully they don't affect header generation, so let's hope for
984 ac_cv_header_cpuid_h=yes
985 libc_cv_{386,390,alpha,arm,hppa,ia64,mips,{powerpc,sparc}{,32,64},sh,x86_64}_tls=yes
986 libc_cv_asm_cfi_directives=yes
987 libc_cv_broken_visibility_attribute=no
988 libc_cv_c_cleanup=yes
989 libc_cv_forced_unwind=yes
990 libc_cv_gcc___thread=yes
991 libc_cv_mlong_double_128=yes
992 libc_cv_mlong_double_128ibm=yes
993 libc_cv_ppc_machine=yes
994 libc_cv_ppc_rel16=yes
995 libc_cv_predef_fortify_source=no
996 libc_cv_visibility_attribute=yes
997 libc_cv_z_combreloc=yes
998 libc_cv_z_execstack=yes
999 libc_cv_z_initfirst=yes
1000 libc_cv_z_nodelete=yes
1001 libc_cv_z_nodlopen=yes
1003 libc_mips_abi=${ABI}
1004 libc_mips_float=$([[ $(tc-is-softfloat) == "yes" ]] && echo soft || echo hard)
1005 # These libs don't have configure flags.
1006 ac_cv_lib_audit_audit_log_user_avc_message=no
1007 ac_cv_lib_cap_cap_init=no
1009 if ! version_is_at_least 2.25 ; then
1011 libc_cv_predef_stack_protector=no
1014 einfo "Forcing cached settings:"
1015 for v in "${vars[@]}" ; do
1020 # Blow away some random CC settings that screw things up. #550192
1021 if [[ -d ${S}/sysdeps/mips ]]; then
1022 pushd "${S}"/sysdeps/mips >/dev/null
1023 sed -i -e '/^CC +=/s:=.*:= -D_MIPS_SZPTR=32:' mips32/Makefile mips64/n32/Makefile || die
1024 sed -i -e '/^CC +=/s:=.*:= -D_MIPS_SZPTR=64:' mips64/n64/Makefile || die
1025 if version_is_at_least 2.21 ; then
1026 # Force the mips ABI to the default. This is OK because the set of
1027 # installed headers in this phase is the same between the 3 ABIs.
1028 # If this ever changes, this hack will break, but that's unlikely
1029 # as glibc discourages that behavior.
1030 # https://crbug.com/647033
1031 sed -i -e 's:abiflag=.*:abiflag=_ABIO32:' preconfigure || die
1038 --disable-sanity-checks
1039 --enable-hacker-mode
1043 --build=${CBUILD_OPT:-${CBUILD}}
1044 --host=${CTARGET_OPT:-${CTARGET}}
1045 --with-headers=$(alt_build_headers)
1046 --prefix="${EPREFIX}/usr"
1051 [[ -d ${S}/ports ]] && addons+=",ports"
1052 # Newer versions require nptl, so there is no addon for it.
1053 version_is_at_least 2.20 || addons+=",nptl"
1054 myconf+=( --enable-add-ons="${addons#,}" )
1056 # Nothing is compiled here which would affect the headers for the target.
1057 # So forcing CC/CFLAGS is sane.
1058 set -- "${S}"/configure "${myconf[@]}"
1060 CC="$(tc-getBUILD_CC)" \
1061 CFLAGS="-O1 -pipe" \
1062 CPPFLAGS="-U_FORTIFY_SOURCE" \
1064 "$@" || die "failed to configure glibc"
1067 toolchain-glibc_do_src_configure() {
1068 if just_headers ; then
1069 toolchain-glibc_headers_configure
1071 want_linuxthreads && glibc_do_configure linuxthreads
1072 want_nptl && glibc_do_configure nptl
1076 toolchain-glibc_src_configure() {
1077 foreach_abi toolchain-glibc_do_src_configure
1080 toolchain-glibc_do_src_compile() {
1082 for t in linuxthreads nptl ; do
1084 [[ ${EAPI:-0} == [01] ]] && glibc_do_configure ${t}
1085 emake -C "$(builddir ${t})" || die "make ${t} for ${ABI} failed"
1090 toolchain-glibc_src_compile() {
1091 if just_headers ; then
1092 [[ ${EAPI:-0} == [01] ]] && toolchain-glibc_headers_configure
1096 foreach_abi toolchain-glibc_do_src_compile
1101 nonfatal emake -j1 check && return 0
1102 einfo "make check failed - re-running with --keep-going to get the rest of the results"
1103 nonfatal emake -j1 -k check
1104 ewarn "make check failed for ${ABI}-${CTARGET}-$1"
1108 toolchain-glibc_do_src_test() {
1110 for t in linuxthreads nptl ; do
1119 toolchain-glibc_src_test() {
1120 # Give tests more time to complete.
1121 export TIMEOUTFACTOR=5
1123 foreach_abi toolchain-glibc_do_src_test || die "tests failed"
1126 toolchain-glibc_do_src_install() {
1127 local builddir=$(builddir $(want_linuxthreads && echo linuxthreads || echo nptl))
1130 emake install_root="${D}$(alt_prefix)" install || die
1132 if want_linuxthreads && want_nptl ; then
1133 einfo "Installing NPTL to $(alt_libdir)/tls/..."
1134 cd "$(builddir nptl)"
1135 dodir $(alt_libdir)/tls $(alt_usrlibdir)/nptl
1138 for l in libc libm librt libpthread libthread_db ; do
1139 # take care of shared lib first ...
1141 if [[ -e ${l} ]] ; then
1144 src_lib=$(eval echo */${l})
1146 cp -a ${src_lib} "${ED}"$(alt_libdir)/tls/${l} || die "copying nptl ${l}"
1147 fperms a+rx $(alt_libdir)/tls/${l}
1148 dosym ${l} $(alt_libdir)/tls/$(scanelf -qSF'%S#F' ${src_lib})
1150 # then grab the linker script or the symlink ...
1151 if [[ -L ${ED}$(alt_usrlibdir)/${l} ]] ; then
1152 dosym $(alt_libdir)/tls/${l} $(alt_usrlibdir)/nptl/${l}
1155 -e "s:/${l}:/tls/${l}:g" \
1156 -e "s:/${l/%.so/_nonshared.a}:/nptl/${l/%.so/_nonshared.a}:g" \
1157 "${ED}"$(alt_usrlibdir)/${l} > "${ED}"$(alt_usrlibdir)/nptl/${l}
1160 # then grab the static lib ...
1161 src_lib=${src_lib/%.so/.a}
1162 [[ ! -e ${src_lib} ]] && src_lib=${src_lib/%.a/_pic.a}
1163 cp -a ${src_lib} "${ED}"$(alt_usrlibdir)/nptl/ || die "copying nptl ${src_lib}"
1164 src_lib=${src_lib/%.a/_nonshared.a}
1165 if [[ -e ${src_lib} ]] ; then
1166 cp -a ${src_lib} "${ED}"$(alt_usrlibdir)/nptl/ || die "copying nptl ${src_lib}"
1170 # use the nptl linker instead of the linuxthreads one as the linuxthreads
1171 # one may lack TLS support and that can be really bad for business
1172 cp -a elf/ld.so "${ED}"$(alt_libdir)/$(scanelf -qSF'%S#F' elf/ld.so) || die "copying nptl interp"
1175 # Normally real_pv is ${PV}. Live ebuilds are exception, there we need
1176 # to infer upstream version:
1177 # '#define VERSION "2.26.90"' -> '2.26.90'
1178 local upstream_pv=$(sed -n -r 's/#define VERSION "(.*)"/\1/p' "${S}"/version.h)
1179 # Newer versions get fancy with libm linkage to include vectorized support.
1180 # While we don't really need a ldscript here, portage QA checks get upset.
1181 if [[ -e ${ED}$(alt_usrlibdir)/libm-${upstream_pv}.a ]] ; then
1182 dosym ../../$(get_libdir)/libm-${upstream_pv}.so $(alt_usrlibdir)/libm-${upstream_pv}.so
1185 # We'll take care of the cache ourselves
1186 rm -f "${ED}"/etc/ld.so.cache
1188 # Everything past this point just needs to be done once ...
1189 is_final_abi || return 0
1191 # Make sure the non-native interp can be found on multilib systems even
1192 # if the main library set isn't installed into the right place. Maybe
1193 # we should query the active gcc for info instead of hardcoding it ?
1194 local i ldso_abi ldso_name
1195 local ldso_abi_list=(
1197 amd64 /lib64/ld-linux-x86-64.so.2
1198 x32 /libx32/ld-linux-x32.so.2
1199 x86 /lib/ld-linux.so.2
1206 ppc64 /lib64/ld64.so.1
1209 s390x /lib/ld64.so.1
1211 sparc32 /lib/ld-linux.so.2
1212 sparc64 /lib64/ld-linux.so.2
1214 case $(tc-endian) in
1218 arm64 /lib/ld-linux-aarch64.so.1
1224 arm64 /lib/ld-linux-aarch64_be.so.1
1228 if [[ ${SYMLINK_LIB} == "yes" ]] && [[ ! -e ${ED}/$(alt_prefix)/lib ]] ; then
1229 dosym $(get_abi_LIBDIR ${DEFAULT_ABI}) $(alt_prefix)/lib
1231 for (( i = 0; i < ${#ldso_abi_list[@]}; i += 2 )) ; do
1232 ldso_abi=${ldso_abi_list[i]}
1233 has ${ldso_abi} $(get_install_abis) || continue
1235 ldso_name="$(alt_prefix)${ldso_abi_list[i+1]}"
1236 if [[ ! -L ${ED}/${ldso_name} && ! -e ${ED}/${ldso_name} ]] ; then
1237 dosym ../$(get_abi_LIBDIR ${ldso_abi})/${ldso_name##*/} ${ldso_name}
1241 # With devpts under Linux mounted properly, we do not need the pt_chown
1242 # binary to be setuid. This is because the default owners/perms will be
1243 # exactly what we want.
1244 if in_iuse suid && ! use suid ; then
1245 find "${ED}" -name pt_chown -exec chmod -s {} +
1248 #################################################################
1249 # EVERYTHING AFTER THIS POINT IS FOR NATIVE GLIBC INSTALLS ONLY #
1250 # Make sure we install some symlink hacks so that when we build
1251 # a 2nd stage cross-compiler, gcc finds the target system
1252 # headers correctly. See gcc/doc/gccinstall.info
1253 if is_crosscompile ; then
1254 # We need to make sure that /lib and /usr/lib always exists.
1255 # gcc likes to use relative paths to get to its multilibs like
1256 # /usr/lib/../lib64/. So while we don't install any files into
1257 # /usr/lib/, we do need it to exist.
1258 cd "${ED}"$(alt_libdir)/..
1259 [[ -e lib ]] || mkdir lib
1260 cd "${ED}"$(alt_usrlibdir)/..
1261 [[ -e lib ]] || mkdir lib
1263 dosym usr/include $(alt_prefix)/sys-include
1267 # Files for Debian-style locale updating
1268 dodir /usr/share/i18n
1271 -e "/SUPPORTED-LOCALES=/d" \
1272 -e "s: \\\\::g" -e "s:/: :g" \
1273 "${S}"/localedata/SUPPORTED > "${ED}"/usr/share/i18n/SUPPORTED \
1274 || die "generating /usr/share/i18n/SUPPORTED failed"
1275 cd "${WORKDIR}"/extra/locale
1276 dosbin locale-gen || die
1279 doins locale.gen || die
1281 # Make sure all the ABI's can find the locales and so we only
1282 # have to generate one set
1284 keepdir /usr/$(get_libdir)/locale
1285 for a in $(get_install_abis) ; do
1286 if [[ ! -e ${ED}/usr/$(get_abi_LIBDIR ${a})/locale ]] ; then
1287 dosym /usr/$(get_libdir)/locale /usr/$(get_abi_LIBDIR ${a})/locale
1293 # Install misc network config files
1295 doins nscd/nscd.conf posix/gai.conf nss/nsswitch.conf || die
1296 doins "${WORKDIR}"/extra/etc/*.conf || die
1298 if ! in_iuse nscd || use nscd ; then
1299 doinitd "$(prefixify_ro "${WORKDIR}"/extra/etc/nscd)" || die
1302 -e "s:@PIDFILE@:$(strings "${ED}"/usr/sbin/nscd | grep nscd.pid):"
1304 version_is_at_least 2.16 || nscd_args+=( -e 's: --foreground : :' )
1305 sed -i "${nscd_args[@]}" "${ED}"/etc/init.d/nscd
1307 # Newer versions of glibc include the nscd.service themselves.
1308 # TODO: Drop the $FILESDIR copy once 2.19 goes stable.
1309 if version_is_at_least 2.19 ; then
1310 systemd_dounit nscd/nscd.service || die
1311 systemd_newtmpfilesd nscd/nscd.tmpfiles nscd.conf || die
1313 systemd_dounit "${FILESDIR}"/nscd.service || die
1314 systemd_newtmpfilesd "${FILESDIR}"/nscd.tmpfilesd nscd.conf || die
1317 # Do this since extra/etc/*.conf above might have nscd.conf.
1318 rm -f "${ED}"/etc/nscd.conf
1321 echo 'LDPATH="include ld.so.conf.d/*.conf"' > "${T}"/00glibc
1322 doenvd "${T}"/00glibc || die
1324 for d in BUGS ChangeLog* CONFORMANCE FAQ NEWS NOTES PROJECTS README* ; do
1325 [[ -s ${d} ]] && dodoc ${d}
1328 # Prevent overwriting of the /etc/localtime symlink. We'll handle the
1329 # creation of the "factory" symlink in pkg_postinst().
1330 rm -f "${ED}"/etc/localtime
1333 toolchain-glibc_headers_install() {
1334 local builddir=$(builddir "headers")
1336 emake install_root="${D}$(alt_prefix)" install-headers || die
1337 if ! version_is_at_least 2.16 ; then
1338 insinto $(alt_headers)/bits
1339 doins bits/stdio_lim.h || die
1341 insinto $(alt_headers)/gnu
1342 doins "${S}"/include/gnu/stubs.h || die "doins include gnu"
1343 # Make sure we install the sys-include symlink so that when
1344 # we build a 2nd stage cross-compiler, gcc finds the target
1345 # system headers correctly. See gcc/doc/gccinstall.info
1346 dosym usr/include $(alt_prefix)/sys-include
1350 # gdb is lame and requires some debugging information to remain in
1351 # libpthread, so we need to strip it by hand. libthread_db makes no
1352 # sense stripped as it is only used when debugging.
1353 local pthread=$(has splitdebug ${FEATURES} && echo "libthread_db" || echo "lib{pthread,thread_db}")
1357 STRIP_MASK="/*/{,tls/}${pthread}*" \
1359 # if user has stripping enabled and does not have split debug turned on,
1360 # then leave the debugging sections in libpthread.
1361 if ! has nostrip ${FEATURES} && ! has splitdebug ${FEATURES} ; then
1362 ${STRIP:-${CTARGET}-strip} --strip-debug "${ED}"/*/libpthread-*.so
1366 toolchain-glibc_src_install() {
1367 if just_headers ; then
1369 toolchain-glibc_headers_install
1373 foreach_abi toolchain-glibc_do_src_install
1377 # Simple test to make sure our new glibc isn't completely broken.
1378 # Make sure we don't test with statically built binaries since
1379 # they will fail. Also, skip if this glibc is a cross compiler.
1381 # If coreutils is built with USE=multicall, some of these files
1382 # will just be wrapper scripts, not actual ELFs we can test.
1383 glibc_sanity_check() {
1386 # We enter ${ED} so to avoid trouble if the path contains
1387 # special characters; for instance if the path contains the
1388 # colon character (:), then the linker will try to split it
1389 # and look for the libraries in an unexpected place. This can
1390 # lead to unsafe code execution if the generated prefix is
1391 # within a world-writable directory.
1392 # (e.g. /var/tmp/portage:${HOSTNAME})
1393 pushd "${ED}"/$(get_libdir) >/dev/null
1396 for x in cal date env free ls true uname uptime ; do
1398 [[ -z ${x} || ${x} != ${EPREFIX}/* ]] && continue
1399 striptest=$(LC_ALL="C" file -L ${x} 2>/dev/null) || continue
1400 case ${striptest} in
1401 *"statically linked"*) continue;;
1402 *"ASCII text"*) continue;;
1404 # We need to clear the locale settings as the upgrade might want
1405 # incompatible locale data. This test is not for verifying that.
1407 ./ld-*.so --library-path . ${x} > /dev/null \
1408 || die "simple run test (${x}) failed"
1414 toolchain-glibc_pkg_preinst() {
1415 # nothing to do if just installing headers
1416 just_headers && return
1418 # prepare /etc/ld.so.conf.d/ for files
1419 mkdir -p "${EROOT}"/etc/ld.so.conf.d
1421 # Default /etc/hosts.conf:multi to on for systems with small dbs.
1422 if [[ $(wc -l < "${EROOT}"/etc/hosts) -lt 1000 ]] ; then
1423 sed -i '/^multi off/s:off:on:' "${ED}"/etc/host.conf
1424 elog "Defaulting /etc/host.conf:multi to on"
1427 [[ ${ROOT} != "/" ]] && return 0
1428 [[ -d ${ED}/$(get_libdir) ]] || return 0
1429 [[ -z ${BOOTSTRAP_RAP} ]] && glibc_sanity_check
1431 # For newer EAPIs, this was run in pkg_pretend.
1432 if [[ ${EAPI:-0} == [0123] ]] ; then
1437 toolchain-glibc_pkg_postinst() {
1438 # nothing to do if just installing headers
1439 just_headers && return
1441 if ! tc-is-cross-compiler && [[ -x ${EROOT}/usr/sbin/iconvconfig ]] ; then
1442 # Generate fastloading iconv module configuration file.
1443 "${EROOT}"/usr/sbin/iconvconfig --prefix="${ROOT}"
1446 if ! is_crosscompile && [[ ${ROOT} == "/" ]] ; then
1447 # Reload init ... if in a chroot or a diff init package, ignore
1448 # errors from this step #253697
1449 /sbin/telinit U 2>/dev/null
1451 # if the host locales.gen contains no entries, we'll install everything
1452 local locale_list="${EROOT}etc/locale.gen"
1453 if [[ -z $(locale-gen --list --config "${locale_list}") ]] ; then
1454 ewarn "Generating all locales; edit /etc/locale.gen to save time/space"
1455 locale_list="${EROOT}usr/share/i18n/SUPPORTED"
1457 locale-gen -j $(makeopts_jobs) --config "${locale_list}"
1461 _TOOLCHAIN_GLIBC_ECLASS=1