Gentoo Archives: gentoo-commits

From: "Andreas Hüttel" <dilfridge@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-libs/glibc/
Date: Sat, 05 May 2018 18:24:39
Message-Id: 1525544664.de37b19ab38f31db07f9aaa761fd7cc0e7748f5c.dilfridge@gentoo
1 commit: de37b19ab38f31db07f9aaa761fd7cc0e7748f5c
2 Author: Andreas K. Hüttel <dilfridge <AT> gentoo <DOT> org>
3 AuthorDate: Sat May 5 18:24:24 2018 +0000
4 Commit: Andreas Hüttel <dilfridge <AT> gentoo <DOT> org>
5 CommitDate: Sat May 5 18:24:24 2018 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=de37b19a
7
8 sys-libs/glibc: Remove old
9
10 Package-Manager: Portage-2.3.36, Repoman-2.3.9
11
12 sys-libs/glibc/glibc-2.27-r1.ebuild | 1428 -----------------------------------
13 1 file changed, 1428 deletions(-)
14
15 diff --git a/sys-libs/glibc/glibc-2.27-r1.ebuild b/sys-libs/glibc/glibc-2.27-r1.ebuild
16 deleted file mode 100644
17 index fe60c1f83c3..00000000000
18 --- a/sys-libs/glibc/glibc-2.27-r1.ebuild
19 +++ /dev/null
20 @@ -1,1428 +0,0 @@
21 -# Copyright 1999-2018 Gentoo Foundation
22 -# Distributed under the terms of the GNU General Public License v2
23 -
24 -EAPI=6
25 -
26 -inherit prefix eutils versionator toolchain-funcs flag-o-matic gnuconfig \
27 - multilib systemd multiprocessing
28 -
29 -DESCRIPTION="GNU libc C library"
30 -HOMEPAGE="https://www.gnu.org/software/libc/"
31 -LICENSE="LGPL-2.1+ BSD HPND ISC inner-net rc PCRE"
32 -RESTRICT="strip" # Strip ourself #46186
33 -SLOT="2.2"
34 -
35 -EMULTILIB_PKG="true"
36 -
37 -if [[ ${PV} == 9999* ]]; then
38 - EGIT_REPO_URI="https://sourceware.org/git/glibc.git"
39 - inherit git-r3
40 -else
41 - # KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86"
42 - KEYWORDS=""
43 - SRC_URI="mirror://gnu/glibc/${P}.tar.xz"
44 -fi
45 -
46 -RELEASE_VER=${PV}
47 -
48 -GCC_BOOTSTRAP_VER="4.7.3-r1"
49 -
50 -# Gentoo patchset
51 -PATCH_VER=1
52 -
53 -SRC_URI+=" https://dev.gentoo.org/~dilfridge/distfiles/${P}-patches-${PATCH_VER}.tar.bz2"
54 -SRC_URI+=" multilib? ( https://dev.gentoo.org/~dilfridge/distfiles/gcc-${GCC_BOOTSTRAP_VER}-multilib-bootstrap.tar.bz2 )"
55 -
56 -IUSE="audit caps compile-locales debug doc gd hardened headers-only multilib nscd profile selinux suid systemtap vanilla"
57 -
58 -# Minimum kernel version that glibc requires
59 -MIN_KERN_VER="3.2.0"
60 -
61 -# Here's how the cross-compile logic breaks down ...
62 -# CTARGET - machine that will target the binaries
63 -# CHOST - machine that will host the binaries
64 -# CBUILD - machine that will build the binaries
65 -# If CTARGET != CHOST, it means you want a libc for cross-compiling.
66 -# If CHOST != CBUILD, it means you want to cross-compile the libc.
67 -# CBUILD = CHOST = CTARGET - native build/install
68 -# CBUILD != (CHOST = CTARGET) - cross-compile a native build
69 -# (CBUILD = CHOST) != CTARGET - libc for cross-compiler
70 -# CBUILD != CHOST != CTARGET - cross-compile a libc for a cross-compiler
71 -# For install paths:
72 -# CHOST = CTARGET - install into /
73 -# CHOST != CTARGET - install into /usr/CTARGET/
74 -#
75 -export CBUILD=${CBUILD:-${CHOST}}
76 -export CTARGET=${CTARGET:-${CHOST}}
77 -if [[ ${CTARGET} == ${CHOST} ]] ; then
78 - if [[ ${CATEGORY} == cross-* ]] ; then
79 - export CTARGET=${CATEGORY#cross-}
80 - fi
81 -fi
82 -
83 -# We need a new-enough binutils/gcc to match upstream baseline.
84 -# Also we need to make sure our binutils/gcc supports TLS.
85 -COMMON_DEPEND="
86 - nscd? ( selinux? (
87 - audit? ( sys-process/audit )
88 - caps? ( sys-libs/libcap )
89 - ) )
90 - suid? ( caps? ( sys-libs/libcap ) )
91 - selinux? ( sys-libs/libselinux )
92 - systemtap? ( dev-util/systemtap )
93 -"
94 -DEPEND="${COMMON_DEPEND}
95 - >=app-misc/pax-utils-0.1.10
96 - !<sys-apps/sandbox-1.6
97 - !<sys-apps/portage-2.1.2
98 - !<sys-devel/bison-2.7
99 - doc? ( sys-apps/texinfo )
100 -"
101 -RDEPEND="${COMMON_DEPEND}
102 - sys-apps/gentoo-functions
103 - !sys-kernel/ps3-sources
104 - !sys-libs/nss-db
105 -"
106 -
107 -if [[ ${CATEGORY} == cross-* ]] ; then
108 - DEPEND+=" !headers-only? (
109 - >=${CATEGORY}/binutils-2.24
110 - >=${CATEGORY}/gcc-4.9
111 - )"
112 - [[ ${CATEGORY} == *-linux* ]] && DEPEND+=" ${CATEGORY}/linux-headers"
113 -else
114 - DEPEND+="
115 - >=sys-devel/binutils-2.24
116 - >=sys-devel/gcc-4.9
117 - virtual/os-headers
118 - "
119 - RDEPEND+=" vanilla? ( !sys-libs/timezone-data )"
120 - PDEPEND+=" !vanilla? ( sys-libs/timezone-data )"
121 -fi
122 -
123 -#
124 -# Small helper functions
125 -#
126 -
127 -is_crosscompile() {
128 - [[ ${CHOST} != ${CTARGET} ]]
129 -}
130 -
131 -just_headers() {
132 - is_crosscompile && use headers-only
133 -}
134 -
135 -alt_prefix() {
136 - is_crosscompile && echo /usr/${CTARGET}
137 -}
138 -
139 -# We need to be able to set alternative headers for compiling for non-native
140 -# platform. Will also become useful for testing kernel-headers without screwing
141 -# up the whole system.
142 -alt_headers() {
143 - echo ${ALT_HEADERS:=$(alt_prefix)/usr/include}
144 -}
145 -
146 -alt_build_headers() {
147 - if [[ -z ${ALT_BUILD_HEADERS} ]] ; then
148 - ALT_BUILD_HEADERS="${EPREFIX}$(alt_headers)"
149 - if tc-is-cross-compiler ; then
150 - ALT_BUILD_HEADERS=${SYSROOT}$(alt_headers)
151 - if [[ ! -e ${ALT_BUILD_HEADERS}/linux/version.h ]] ; then
152 - local header_path=$(echo '#include <linux/version.h>' | $(tc-getCPP ${CTARGET}) ${CFLAGS} 2>&1 | grep -o '[^"]*linux/version.h')
153 - ALT_BUILD_HEADERS=${header_path%/linux/version.h}
154 - fi
155 - fi
156 - fi
157 - echo "${ALT_BUILD_HEADERS}"
158 -}
159 -
160 -alt_libdir() {
161 - echo $(alt_prefix)/$(get_libdir)
162 -}
163 -alt_usrlibdir() {
164 - echo $(alt_prefix)/usr/$(get_libdir)
165 -}
166 -
167 -builddir() {
168 - echo "${WORKDIR}/build-${ABI}-${CTARGET}-$1"
169 -}
170 -
171 -do_compile_test() {
172 - local ret save_cflags=${CFLAGS}
173 - CFLAGS+=" $1"
174 - shift
175 -
176 - pushd "${T}" >/dev/null
177 -
178 - rm -f glibc-test*
179 - printf '%b' "$*" > glibc-test.c
180 -
181 - nonfatal emake -s glibc-test
182 - ret=$?
183 -
184 - popd >/dev/null
185 -
186 - CFLAGS=${save_cflags}
187 - return ${ret}
188 -}
189 -
190 -do_run_test() {
191 - local ret
192 -
193 - if [[ ${MERGE_TYPE} == "binary" ]] ; then
194 - # ignore build failures when installing a binary package #324685
195 - do_compile_test "" "$@" 2>/dev/null || return 0
196 - else
197 - if ! do_compile_test "" "$@" ; then
198 - ewarn "Simple build failed ... assuming this is desired #324685"
199 - return 0
200 - fi
201 - fi
202 -
203 - pushd "${T}" >/dev/null
204 -
205 - ./glibc-test
206 - ret=$?
207 - rm -f glibc-test*
208 -
209 - popd >/dev/null
210 -
211 - return ${ret}
212 -}
213 -
214 -setup_target_flags() {
215 - # This largely mucks with compiler flags. None of which should matter
216 - # when building up just the headers.
217 - just_headers && return 0
218 -
219 - case $(tc-arch) in
220 - x86)
221 - # -march needed for #185404 #199334
222 - # TODO: When creating the first glibc cross-compile, this test will
223 - # always fail as it does a full link which in turn requires glibc.
224 - # Probably also applies when changing multilib profile settings (e.g.
225 - # enabling x86 when the profile was amd64-only previously).
226 - # We could change main to _start and pass -nostdlib here so that we
227 - # only test the gcc code compilation. Or we could do a compile and
228 - # then look for the symbol via scanelf.
229 - 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
230 - local t=${CTARGET_OPT:-${CTARGET}}
231 - t=${t%%-*}
232 - filter-flags '-march=*'
233 - export CFLAGS="-march=${t} ${CFLAGS}"
234 - einfo "Auto adding -march=${t} to CFLAGS #185404"
235 - fi
236 - ;;
237 - amd64)
238 - # -march needed for #185404 #199334
239 - # Note: This test only matters when the x86 ABI is enabled, so we could
240 - # optimize a bit and elide it.
241 - # TODO: See cross-compile issues listed above for x86.
242 - 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
243 - local t=${CTARGET_OPT:-${CTARGET}}
244 - t=${t%%-*}
245 - # Normally the target is x86_64-xxx, so turn that into the -march that
246 - # gcc actually accepts. #528708
247 - [[ ${t} == "x86_64" ]] && t="x86-64"
248 - filter-flags '-march=*'
249 - # ugly, ugly, ugly. ugly.
250 - CFLAGS_x86=$(CFLAGS=${CFLAGS_x86} filter-flags '-march=*'; echo "${CFLAGS}")
251 - export CFLAGS_x86="${CFLAGS_x86} -march=${t}"
252 - einfo "Auto adding -march=${t} to CFLAGS_x86 #185404"
253 - fi
254 - ;;
255 - mips)
256 - # The mips abi cannot support the GNU style hashes. #233233
257 - filter-ldflags -Wl,--hash-style=gnu -Wl,--hash-style=both
258 - ;;
259 - sparc)
260 - # Both sparc and sparc64 can use -fcall-used-g6. -g7 is bad, though.
261 - filter-flags "-fcall-used-g7"
262 - append-flags "-fcall-used-g6"
263 -
264 - # If the CHOST is the basic one (e.g. not sparcv9-xxx already),
265 - # try to pick a better one so glibc can use cpu-specific .S files.
266 - # We key off the CFLAGS to get a good value. Also need to handle
267 - # version skew.
268 - # We can't force users to set their CHOST to their exact machine
269 - # as many of these are not recognized by config.sub/gcc and such :(.
270 - # Note: If the mcpu values don't scale, we might try probing CPP defines.
271 - # Note: Should we factor in -Wa,-AvXXX flags too ? Or -mvis/etc... ?
272 -
273 - local cpu
274 - case ${CTARGET} in
275 - sparc64-*)
276 - case $(get-flag mcpu) in
277 - niagara[234])
278 - if version_is_at_least 2.8 ; then
279 - cpu="sparc64v2"
280 - elif version_is_at_least 2.4 ; then
281 - cpu="sparc64v"
282 - elif version_is_at_least 2.2.3 ; then
283 - cpu="sparc64b"
284 - fi
285 - ;;
286 - niagara)
287 - if version_is_at_least 2.4 ; then
288 - cpu="sparc64v"
289 - elif version_is_at_least 2.2.3 ; then
290 - cpu="sparc64b"
291 - fi
292 - ;;
293 - ultrasparc3)
294 - cpu="sparc64b"
295 - ;;
296 - *)
297 - # We need to force at least v9a because the base build doesn't
298 - # work with just v9.
299 - # https://sourceware.org/bugzilla/show_bug.cgi?id=19477
300 - [[ -z ${cpu} ]] && append-flags "-Wa,-xarch=v9a"
301 - ;;
302 - esac
303 - ;;
304 - sparc-*)
305 - case $(get-flag mcpu) in
306 - niagara[234])
307 - if version_is_at_least 2.8 ; then
308 - cpu="sparcv9v2"
309 - elif version_is_at_least 2.4 ; then
310 - cpu="sparcv9v"
311 - elif version_is_at_least 2.2.3 ; then
312 - cpu="sparcv9b"
313 - else
314 - cpu="sparcv9"
315 - fi
316 - ;;
317 - niagara)
318 - if version_is_at_least 2.4 ; then
319 - cpu="sparcv9v"
320 - elif version_is_at_least 2.2.3 ; then
321 - cpu="sparcv9b"
322 - else
323 - cpu="sparcv9"
324 - fi
325 - ;;
326 - ultrasparc3)
327 - cpu="sparcv9b"
328 - ;;
329 - v9|ultrasparc)
330 - cpu="sparcv9"
331 - ;;
332 - v8|supersparc|hypersparc|leon|leon3)
333 - cpu="sparcv8"
334 - ;;
335 - esac
336 - ;;
337 - esac
338 - [[ -n ${cpu} ]] && CTARGET_OPT="${cpu}-${CTARGET#*-}"
339 - ;;
340 - esac
341 -}
342 -
343 -setup_flags() {
344 - # Make sure host make.conf doesn't pollute us
345 - if is_crosscompile || tc-is-cross-compiler ; then
346 - CHOST=${CTARGET} strip-unsupported-flags
347 - fi
348 -
349 - # Store our CFLAGS because it's changed depending on which CTARGET
350 - # we are building when pulling glibc on a multilib profile
351 - CFLAGS_BASE=${CFLAGS_BASE-${CFLAGS}}
352 - CFLAGS=${CFLAGS_BASE}
353 - CXXFLAGS_BASE=${CXXFLAGS_BASE-${CXXFLAGS}}
354 - CXXFLAGS=${CXXFLAGS_BASE}
355 - ASFLAGS_BASE=${ASFLAGS_BASE-${ASFLAGS}}
356 - ASFLAGS=${ASFLAGS_BASE}
357 -
358 - # Over-zealous CFLAGS can often cause problems. What may work for one
359 - # person may not work for another. To avoid a large influx of bugs
360 - # relating to failed builds, we strip most CFLAGS out to ensure as few
361 - # problems as possible.
362 - strip-flags
363 - strip-unsupported-flags
364 - filter-flags -m32 -m64 '-mabi=*'
365 -
366 - # glibc aborts if rpath is set by LDFLAGS
367 - filter-ldflags '-Wl,-rpath=*'
368 -
369 - # #492892
370 - filter-flags -frecord-gcc-switches
371 -
372 - unset CBUILD_OPT CTARGET_OPT
373 - if use multilib ; then
374 - CTARGET_OPT=$(get_abi_CTARGET)
375 - [[ -z ${CTARGET_OPT} ]] && CTARGET_OPT=$(get_abi_CHOST)
376 - fi
377 -
378 - setup_target_flags
379 -
380 - if [[ -n ${CTARGET_OPT} && ${CBUILD} == ${CHOST} ]] && ! is_crosscompile; then
381 - CBUILD_OPT=${CTARGET_OPT}
382 - fi
383 -
384 - # Lock glibc at -O2; we want to be conservative here.
385 - # -fno-strict-aliasing is to work around #155906.
386 - filter-flags '-O?'
387 - append-flags -O2 -fno-strict-aliasing
388 -
389 - filter-flags '-fstack-protector*'
390 -
391 - # Starting with gcc-6 (and fully upstreamed pie patches) we control
392 - # default enabled/disabled pie via use flags. So nothing to do
393 - # here then. #618160
394 - if [[ $(gcc-major-version) -lt 6 ]]; then
395 - if use hardened && tc-enables-pie ; then
396 - # Force PIC macro definition for all compilations since they're all
397 - # either -fPIC or -fPIE with the default-PIE compiler.
398 - append-cppflags -DPIC
399 - else
400 - # Don't build -fPIE without the default-PIE compiler and the
401 - # hardened-pie patch
402 - filter-flags -fPIE
403 - fi
404 - fi
405 -}
406 -
407 -want_tls() {
408 - # Archs that can use TLS (Thread Local Storage)
409 - case $(tc-arch) in
410 - x86)
411 - # requires i486 or better #106556
412 - [[ ${CTARGET} == i[4567]86* ]] && return 0
413 - return 1
414 - ;;
415 - esac
416 - return 0
417 -}
418 -
419 -want__thread() {
420 - want_tls || return 1
421 -
422 - # For some reason --with-tls --with__thread is causing segfaults on sparc32.
423 - [[ ${PROFILE_ARCH} == "sparc" ]] && return 1
424 -
425 - [[ -n ${WANT__THREAD} ]] && return ${WANT__THREAD}
426 -
427 - # only test gcc -- can't test linking yet
428 - tc-has-tls -c ${CTARGET}
429 - WANT__THREAD=$?
430 -
431 - return ${WANT__THREAD}
432 -}
433 -
434 -use_multiarch() {
435 - # Make sure binutils is new enough to support indirect functions,
436 - # #336792. This funky sed supports gold and bfd linkers.
437 - local bver nver
438 - bver=$($(tc-getLD ${CTARGET}) -v | sed -n -r '1{s:[^0-9]*::;s:^([0-9.]*).*:\1:;p}')
439 - case $(tc-arch ${CTARGET}) in
440 - amd64|x86) nver="2.20" ;;
441 - arm) nver="2.22" ;;
442 - hppa) nver="2.23" ;;
443 - ppc|ppc64) nver="2.20" ;;
444 - # ifunc support was added in 2.23, but glibc also needs
445 - # machinemode which is in 2.24.
446 - s390) nver="2.24" ;;
447 - sparc) nver="2.21" ;;
448 - *) return 1 ;;
449 - esac
450 - version_is_at_least ${nver} ${bver}
451 -}
452 -
453 -# Setup toolchain variables that had historically been defined in the
454 -# profiles for these archs.
455 -setup_env() {
456 - # silly users
457 - unset LD_RUN_PATH
458 - unset LD_ASSUME_KERNEL
459 -
460 - if is_crosscompile || tc-is-cross-compiler ; then
461 - multilib_env ${CTARGET_OPT:-${CTARGET}}
462 -
463 - if ! use multilib ; then
464 - MULTILIB_ABIS=${DEFAULT_ABI}
465 - else
466 - MULTILIB_ABIS=${MULTILIB_ABIS:-${DEFAULT_ABI}}
467 - fi
468 -
469 - # If the user has CFLAGS_<CTARGET> in their make.conf, use that,
470 - # and fall back on CFLAGS.
471 - local VAR=CFLAGS_${CTARGET//[-.]/_}
472 - CFLAGS=${!VAR-${CFLAGS}}
473 - einfo " $(printf '%15s' 'Manual CFLAGS:') ${CFLAGS}"
474 - fi
475 -
476 - setup_flags
477 -
478 - export ABI=${ABI:-${DEFAULT_ABI:-default}}
479 -
480 - if use headers-only ; then
481 - # Avoid mixing host's CC and target's CFLAGS_${ABI}:
482 - # At this bootstrap stage we have only binutils for
483 - # target but not compiler yet.
484 - einfo "Skip CC ABI injection. We can't use (cross-)compiler yet."
485 - return 0
486 - fi
487 - local VAR=CFLAGS_${ABI}
488 - # We need to export CFLAGS with abi information in them because glibc's
489 - # configure script checks CFLAGS for some targets (like mips). Keep
490 - # around the original clean value to avoid appending multiple ABIs on
491 - # top of each other.
492 - : ${__GLIBC_CC:=$(tc-getCC ${CTARGET_OPT:-${CTARGET}})}
493 - export __GLIBC_CC CC="${__GLIBC_CC} ${!VAR}"
494 - einfo " $(printf '%15s' 'Manual CC:') ${CC}"
495 -}
496 -
497 -foreach_abi() {
498 - setup_env
499 -
500 - local ret=0
501 - local abilist=""
502 - if use multilib ; then
503 - abilist=$(get_install_abis)
504 - else
505 - abilist=${DEFAULT_ABI}
506 - fi
507 - local -x ABI
508 - for ABI in ${abilist:-default} ; do
509 - setup_env
510 - einfo "Running $1 for ABI ${ABI}"
511 - $1
512 - : $(( ret |= $? ))
513 - done
514 - return ${ret}
515 -}
516 -
517 -glibc_banner() {
518 - local b="Gentoo ${PVR}"
519 - [[ -n ${PATCH_VER} ]] && ! use vanilla && b+=" p${PATCH_VER}"
520 - echo "${b}"
521 -}
522 -
523 -check_devpts() {
524 - # Make sure devpts is mounted correctly for use w/out setuid pt_chown.
525 -
526 - # If merely building the binary package, then there's nothing to verify.
527 - [[ ${MERGE_TYPE} == "buildonly" ]] && return
528 -
529 - # Only sanity check when installing the native glibc.
530 - [[ ${ROOT} != "/" ]] && return
531 -
532 - # If they're opting in to the old suid code, then no need to check.
533 - use suid && return
534 -
535 - if awk '$3 == "devpts" && $4 ~ /[, ]gid=5[, ]/ { exit 1 }' /proc/mounts ; then
536 - eerror "In order to use glibc with USE=-suid, you must make sure that"
537 - eerror "you have devpts mounted at /dev/pts with the gid=5 option."
538 - eerror "Openrc should do this for you, so you should check /etc/fstab"
539 - eerror "and make sure you do not have any invalid settings there."
540 - die "mount & fix your /dev/pts settings"
541 - fi
542 -}
543 -
544 -# The following Kernel version handling functions are mostly copied from portage
545 -# source. It's better not to use linux-info.eclass here since a) it adds too
546 -# much magic, see bug 326693 for some of the arguments, and b) some of the
547 -# functions are just not provided.
548 -
549 -g_get_running_KV() {
550 - uname -r
551 - return $?
552 -}
553 -
554 -g_KV_major() {
555 - [[ -z $1 ]] && return 1
556 - local KV=$@
557 - echo "${KV%%.*}"
558 -}
559 -
560 -g_KV_minor() {
561 - [[ -z $1 ]] && return 1
562 - local KV=$@
563 - KV=${KV#*.}
564 - echo "${KV%%.*}"
565 -}
566 -
567 -g_KV_micro() {
568 - [[ -z $1 ]] && return 1
569 - local KV=$@
570 - KV=${KV#*.*.}
571 - echo "${KV%%[^[:digit:]]*}"
572 -}
573 -
574 -g_KV_to_int() {
575 - [[ -z $1 ]] && return 1
576 - local KV_MAJOR=$(g_KV_major "$1")
577 - local KV_MINOR=$(g_KV_minor "$1")
578 - local KV_MICRO=$(g_KV_micro "$1")
579 - local KV_int=$(( KV_MAJOR * 65536 + KV_MINOR * 256 + KV_MICRO ))
580 -
581 - # We make version 2.2.0 the minimum version we will handle as
582 - # a sanity check ... if its less, we fail ...
583 - if [[ ${KV_int} -ge 131584 ]] ; then
584 - echo "${KV_int}"
585 - return 0
586 - fi
587 - return 1
588 -}
589 -
590 -g_int_to_KV() {
591 - local version=$1 major minor micro
592 - major=$((version / 65536))
593 - minor=$(((version % 65536) / 256))
594 - micro=$((version % 256))
595 - echo ${major}.${minor}.${micro}
596 -}
597 -
598 -eend_KV() {
599 - [[ $(g_KV_to_int $1) -ge $(g_KV_to_int $2) ]]
600 - eend $?
601 -}
602 -
603 -get_kheader_version() {
604 - printf '#include <linux/version.h>\nLINUX_VERSION_CODE\n' | \
605 - $(tc-getCPP ${CTARGET}) -I "${EPREFIX}/$(alt_build_headers)" - | \
606 - tail -n 1
607 -}
608 -
609 -# We collect all sanity checks here. Consistency is not guranteed between
610 -# pkg_ and src_ phases, so we call this function both in pkg_pretend and in
611 -# src_unpack.
612 -sanity_prechecks() {
613 - # Make sure devpts is mounted correctly for use w/out setuid pt_chown
614 - check_devpts
615 -
616 - # Prevent native builds from downgrading
617 - if [[ ${MERGE_TYPE} != "buildonly" ]] && \
618 - [[ ${ROOT} == "/" ]] && \
619 - [[ ${CBUILD} == ${CHOST} ]] && \
620 - [[ ${CHOST} == ${CTARGET} ]] ; then
621 -
622 - # The high rev # is to allow people to downgrade between -r#
623 - # versions. We want to block 2.20->2.19, but 2.20-r3->2.20-r2
624 - # should be fine. Hopefully we never actually use a r# this
625 - # high.
626 - if has_version ">${CATEGORY}/${P}-r10000" ; then
627 - eerror "Sanity check to keep you from breaking your system:"
628 - eerror " Downgrading glibc is not supported and a sure way to destruction."
629 - die "Aborting to save your system."
630 - fi
631 -
632 - if ! do_run_test '#include <unistd.h>\n#include <sys/syscall.h>\nint main(){return syscall(1000)!=-1;}\n' ; then
633 - eerror "Your old kernel is broken. You need to update it to a newer"
634 - eerror "version as syscall(<bignum>) will break. See bug 279260."
635 - die "Old and broken kernel."
636 - fi
637 - fi
638 -
639 - # Users have had a chance to phase themselves, time to give em the boot
640 - if [[ -e ${EROOT}/etc/locale.gen ]] && [[ -e ${EROOT}/etc/locales.build ]] ; then
641 - eerror "You still haven't deleted ${EROOT}/etc/locales.build."
642 - eerror "Do so now after making sure ${EROOT}/etc/locale.gen is kosher."
643 - die "Lazy upgrader detected"
644 - fi
645 -
646 - if [[ ${CTARGET} == i386-* ]] ; then
647 - eerror "i386 CHOSTs are no longer supported."
648 - eerror "Chances are you don't actually want/need i386."
649 - eerror "Please read https://www.gentoo.org/doc/en/change-chost.xml"
650 - die "Please fix your CHOST"
651 - fi
652 -
653 - if [[ -e /proc/xen ]] && [[ $(tc-arch) == "x86" ]] && ! is-flag -mno-tls-direct-seg-refs ; then
654 - ewarn "You are using Xen but don't have -mno-tls-direct-seg-refs in your CFLAGS."
655 - ewarn "This will result in a 50% performance penalty when running with a 32bit"
656 - ewarn "hypervisor, which is probably not what you want."
657 - fi
658 -
659 - use hardened && ! tc-enables-pie && \
660 - ewarn "PIE hardening not applied, as your compiler doesn't default to PIE"
661 -
662 - # Check for sanity of /etc/nsswitch.conf
663 - if [[ -e ${EROOT}/etc/nsswitch.conf ]] ; then
664 - local entry
665 - for entry in passwd group shadow; do
666 - if ! egrep -q "^[ \t]*${entry}:.*files" "${EROOT}"/etc/nsswitch.conf; then
667 - eerror "Your ${EROOT}/etc/nsswitch.conf is out of date."
668 - eerror "Please make sure you have 'files' entries for"
669 - eerror "'passwd:', 'group:' and 'shadow:' databases."
670 - eerror "For more details see:"
671 - eerror " https://wiki.gentoo.org/wiki/Project:Toolchain/nsswitch.conf_in_glibc-2.26"
672 - die "nsswitch.conf has no 'files' provider in '${entry}'."
673 - fi
674 - done
675 - fi
676 -
677 - # ABI-specific checks follow here. Hey, we have a lot more specific conditions that
678 - # we test for...
679 - if ! is_crosscompile ; then
680 - if use amd64 && use multilib && [[ ${MERGE_TYPE} != "binary" ]] ; then
681 - ebegin "Checking that IA32 emulation is enabled in the running kernel"
682 - echo 'int main(){return 0;}' > "${T}/check-ia32-emulation.c"
683 - local STAT
684 - if "${CC-${CHOST}-gcc}" ${CFLAGS_x86} "${T}/check-ia32-emulation.c" -o "${T}/check-ia32-emulation.elf32"; then
685 - "${T}/check-ia32-emulation.elf32"
686 - STAT=$?
687 - else
688 - # Don't fail here to allow single->multi ABI switch
689 - # or recover from breakage like bug #646424
690 - ewarn "Failed to compile the ABI test. Broken host glibc?"
691 - STAT=0
692 - fi
693 - rm -f "${T}/check-ia32-emulation.elf32"
694 - eend $STAT
695 - [[ $STAT -eq 0 ]] || die "CONFIG_IA32_EMULATION must be enabled in the kernel to compile a multilib glibc."
696 - fi
697 -
698 - fi
699 -
700 - # When we actually have to compile something...
701 - if ! just_headers ; then
702 - local run_kv build_kv want_kv
703 -
704 - run_kv=$(g_get_running_KV)
705 - build_kv=$(g_int_to_KV $(get_kheader_version))
706 - want_kv=${MIN_KERN_VER}
707 -
708 - ebegin "Checking gcc for __thread support"
709 - if ! eend $(want__thread ; echo $?) ; then
710 - echo
711 - eerror "Could not find a gcc that supports the __thread directive!"
712 - eerror "Please update your binutils/gcc and try again."
713 - die "No __thread support in gcc!"
714 - fi
715 -
716 - if ! is_crosscompile && ! tc-is-cross-compiler ; then
717 - # Building fails on an non-supporting kernel
718 - ebegin "Checking running kernel version (${run_kv} >= ${want_kv})"
719 - if ! eend_KV ${run_kv} ${want_kv} ; then
720 - echo
721 - eerror "You need a kernel of at least ${want_kv}!"
722 - die "Kernel version too low!"
723 - fi
724 - fi
725 -
726 - ebegin "Checking linux-headers version (${build_kv} >= ${want_kv})"
727 - if ! eend_KV ${build_kv} ${want_kv} ; then
728 - echo
729 - eerror "You need linux-headers of at least ${want_kv}!"
730 - die "linux-headers version too low!"
731 - fi
732 - fi
733 -}
734 -
735 -#
736 -# the phases
737 -#
738 -
739 -# pkg_pretend
740 -
741 -pkg_pretend() {
742 - # All the checks...
743 - einfo "Checking general environment sanity."
744 - sanity_prechecks
745 -}
746 -
747 -# src_unpack
748 -
749 -src_unpack() {
750 - # Consistency is not guaranteed between pkg_ and src_ ...
751 - sanity_prechecks
752 -
753 - use multilib && unpack gcc-${GCC_BOOTSTRAP_VER}-multilib-bootstrap.tar.bz2
754 -
755 - setup_env
756 -
757 - if [[ -n ${EGIT_REPO_URI} ]] ; then
758 - git-r3_src_unpack
759 - else
760 - unpack ${P}.tar.xz
761 - fi
762 -
763 - cd "${S}" || die
764 - touch locale/C-translit.h || die #185476 #218003
765 -
766 - cd "${WORKDIR}" || die
767 - unpack glibc-${RELEASE_VER}-patches-${PATCH_VER}.tar.bz2
768 -}
769 -
770 -src_prepare() {
771 - if ! use vanilla ; then
772 - elog "Applying Gentoo Glibc Patchset ${RELEASE_VER}-${PATCH_VER}"
773 - eapply "${WORKDIR}"/patches
774 - einfo "Done."
775 - fi
776 -
777 - default
778 -
779 - gnuconfig_update
780 -
781 - cd "${WORKDIR}"
782 - find . -name configure -exec touch {} +
783 -
784 - eprefixify extra/locale/locale-gen
785 -
786 - # Fix permissions on some of the scripts.
787 - chmod u+x "${S}"/scripts/*.sh
788 -
789 - cd "${S}"
790 -
791 - if use hardened ; then
792 - # We don't enable these for non-hardened as the output is very terse --
793 - # it only states that a crash happened. The default upstream behavior
794 - # includes backtraces and symbols.
795 - einfo "Installing Hardened Gentoo SSP and FORTIFY_SOURCE handler"
796 - cp "${FILESDIR}"/2.20/glibc-2.20-gentoo-stack_chk_fail.c debug/stack_chk_fail.c || die
797 - cp "${FILESDIR}"/2.25/glibc-2.25-gentoo-chk_fail.c debug/chk_fail.c || die
798 -
799 - if use debug ; then
800 - # Allow SIGABRT to dump core on non-hardened systems, or when debug is requested.
801 - sed -i \
802 - -e '/^CFLAGS-backtrace.c/ iCPPFLAGS-stack_chk_fail.c = -DSSP_SMASH_DUMPS_CORE' \
803 - -e '/^CFLAGS-backtrace.c/ iCPPFLAGS-chk_fail.c = -DSSP_SMASH_DUMPS_CORE' \
804 - debug/Makefile || die
805 - fi
806 - fi
807 -}
808 -
809 -glibc_do_configure() {
810 - # Glibc does not work with gold (for various reasons) #269274.
811 - tc-ld-disable-gold
812 -
813 - # CXX isnt handled by the multilib system, so if we dont unset here
814 - # we accumulate crap across abis
815 - unset CXX
816 -
817 - einfo "Configuring glibc for nptl"
818 -
819 - if use doc ; then
820 - export MAKEINFO=makeinfo
821 - else
822 - export MAKEINFO=/dev/null
823 - fi
824 -
825 - local v
826 - for v in ABI CBUILD CHOST CTARGET CBUILD_OPT CTARGET_OPT CC CXX LD {AS,C,CPP,CXX,LD}FLAGS MAKEINFO ; do
827 - einfo " $(printf '%15s' ${v}:) ${!v}"
828 - done
829 -
830 - # The glibc configure script doesn't properly use LDFLAGS all the time.
831 - export CC="$(tc-getCC ${CTARGET}) ${LDFLAGS}"
832 - einfo " $(printf '%15s' 'Manual CC:') ${CC}"
833 -
834 - # Some of the tests are written in C++, so we need to force our multlib abis in, bug 623548
835 - export CXX="$(tc-getCXX ${CTARGET}) $(get_abi_CFLAGS)"
836 - einfo " $(printf '%15s' 'Manual CXX:') ${CXX}"
837 -
838 - echo
839 -
840 - local myconf=()
841 -
842 - case ${CTARGET} in
843 - powerpc-*)
844 - # Currently gcc on powerpc32 generates invalid code for
845 - # __builtin_return_address(0) calls. Normally programs
846 - # don't do that but malloc hooks in glibc do:
847 - # https://gcc.gnu.org/PR81996
848 - # https://bugs.gentoo.org/629054
849 - myconf+=( --enable-stack-protector=no )
850 - ;;
851 - *)
852 - myconf+=( --enable-stack-protector=all )
853 - ;;
854 - esac
855 - myconf+=( --enable-stackguard-randomization )
856 -
857 - # Keep a whitelist of targets supporing IFUNC. glibc's ./configure
858 - # is not robust enough to detect proper support:
859 - # https://bugs.gentoo.org/641216
860 - # https://sourceware.org/PR22634#c0
861 - case $(tc-arch ${CTARGET}) in
862 - # Keep whitelist of targets where autodetection mostly works.
863 - amd64|x86|sparc|ppc|ppc64|arm|arm64|s390) ;;
864 - # Blacklist everywhere else
865 - *) myconf+=( libc_cv_ld_gnu_indirect_function=no ) ;;
866 - esac
867 -
868 - [[ $(tc-is-softfloat) == "yes" ]] && myconf+=( --without-fp )
869 -
870 - myconf+=( --enable-kernel=${MIN_KERN_VER} )
871 -
872 - # Since SELinux support is only required for nscd, only enable it if:
873 - # 1. USE selinux
874 - # 2. only for the primary ABI on multilib systems
875 - # 3. Not a crosscompile
876 - if ! is_crosscompile && use selinux ; then
877 - if use multilib ; then
878 - if is_final_abi ; then
879 - myconf+=( --with-selinux )
880 - else
881 - myconf+=( --without-selinux )
882 - fi
883 - else
884 - myconf+=( --with-selinux )
885 - fi
886 - else
887 - myconf+=( --without-selinux )
888 - fi
889 -
890 - # Force a few tests where we always know the answer but
891 - # configure is incapable of finding it.
892 - if is_crosscompile ; then
893 - export \
894 - libc_cv_c_cleanup=yes \
895 - libc_cv_forced_unwind=yes
896 - fi
897 -
898 - myconf+=(
899 - --without-cvs
900 - --disable-werror
901 - --enable-bind-now
902 - --build=${CBUILD_OPT:-${CBUILD}}
903 - --host=${CTARGET_OPT:-${CTARGET}}
904 - $(use_enable profile)
905 - $(use_with gd)
906 - --with-headers=$(alt_build_headers)
907 - --prefix="${EPREFIX}/usr"
908 - --sysconfdir="${EPREFIX}/etc"
909 - --localstatedir="${EPREFIX}/var"
910 - --libdir='$(prefix)'/$(get_libdir)
911 - --mandir='$(prefix)'/share/man
912 - --infodir='$(prefix)'/share/info
913 - --libexecdir='$(libdir)'/misc/glibc
914 - --with-bugurl=https://bugs.gentoo.org/
915 - --with-pkgversion="$(glibc_banner)"
916 - $(use_multiarch || echo --disable-multi-arch)
917 - $(in_iuse systemtap && use_enable systemtap)
918 - $(in_iuse nscd && use_enable nscd)
919 - ${EXTRA_ECONF}
920 - )
921 -
922 - # We rely on sys-libs/timezone-data for timezone tools normally.
923 - myconf+=( $(use_enable vanilla timezone-tools) )
924 -
925 - # These libs don't have configure flags.
926 - ac_cv_lib_audit_audit_log_user_avc_message=$(in_iuse audit && usex audit || echo no)
927 - ac_cv_lib_cap_cap_init=$(in_iuse caps && usex caps || echo no)
928 -
929 - # There is no configure option for this and we need to export it
930 - # since the glibc build will re-run configure on itself
931 - export libc_cv_rootsbindir="${EPREFIX}/sbin"
932 - export libc_cv_slibdir="${EPREFIX}/$(get_libdir)"
933 -
934 - # We take care of patching our binutils to use both hash styles,
935 - # and many people like to force gnu hash style only, so disable
936 - # this overriding check. #347761
937 - export libc_cv_hashstyle=no
938 -
939 - local builddir=$(builddir nptl)
940 - mkdir -p "${builddir}"
941 - cd "${builddir}"
942 - set -- "${S}"/configure "${myconf[@]}"
943 - echo "$@"
944 - "$@" || die "failed to configure glibc"
945 -
946 - # ia64 static cross-compilers are a pita in so much that they
947 - # can't produce static ELFs (as the libgcc.a is broken). so
948 - # disable building of the programs for those targets if it
949 - # doesn't work.
950 - # XXX: We could turn this into a compiler test, but ia64 is
951 - # the only one that matters, so this should be fine for now.
952 - if is_crosscompile && [[ ${CTARGET} == ia64* ]] ; then
953 - sed -i '1i+link-static = touch $@' config.make
954 - fi
955 -
956 - # If we're trying to migrate between ABI sets, we need
957 - # to lie and use a local copy of gcc. Like if the system
958 - # is built with MULTILIB_ABIS="amd64 x86" but we want to
959 - # add x32 to it, gcc/glibc don't yet support x32.
960 - #
961 - if [[ -n ${GCC_BOOTSTRAP_VER} ]] && use multilib ; then
962 - echo 'main(){}' > "${T}"/test.c
963 - if ! $(tc-getCC ${CTARGET}) ${CFLAGS} ${LDFLAGS} "${T}"/test.c -Wl,-emain -lgcc 2>/dev/null ; then
964 - sed -i -e '/^CC = /s:$: -B$(objdir)/../'"gcc-${GCC_BOOTSTRAP_VER}/${ABI}:" config.make || die
965 - fi
966 - fi
967 -}
968 -
969 -glibc_headers_configure() {
970 - export ABI=default
971 -
972 - local builddir=$(builddir "headers")
973 - mkdir -p "${builddir}"
974 - cd "${builddir}"
975 -
976 - # if we don't have a compiler yet, we can't really test it now ...
977 - # hopefully they don't affect header generation, so let's hope for
978 - # the best here ...
979 - local v vars=(
980 - ac_cv_header_cpuid_h=yes
981 - libc_cv_{386,390,alpha,arm,hppa,ia64,mips,{powerpc,sparc}{,32,64},sh,x86_64}_tls=yes
982 - libc_cv_asm_cfi_directives=yes
983 - libc_cv_broken_visibility_attribute=no
984 - libc_cv_c_cleanup=yes
985 - libc_cv_compiler_powerpc64le_binary128_ok=yes
986 - libc_cv_forced_unwind=yes
987 - libc_cv_gcc___thread=yes
988 - libc_cv_mlong_double_128=yes
989 - libc_cv_mlong_double_128ibm=yes
990 - libc_cv_ppc_machine=yes
991 - libc_cv_ppc_rel16=yes
992 - libc_cv_predef_fortify_source=no
993 - libc_cv_target_power8_ok=yes
994 - libc_cv_visibility_attribute=yes
995 - libc_cv_z_combreloc=yes
996 - libc_cv_z_execstack=yes
997 - libc_cv_z_initfirst=yes
998 - libc_cv_z_nodelete=yes
999 - libc_cv_z_nodlopen=yes
1000 - libc_cv_z_relro=yes
1001 - libc_mips_abi=${ABI}
1002 - libc_mips_float=$([[ $(tc-is-softfloat) == "yes" ]] && echo soft || echo hard)
1003 - # These libs don't have configure flags.
1004 - ac_cv_lib_audit_audit_log_user_avc_message=no
1005 - ac_cv_lib_cap_cap_init=no
1006 - )
1007 -
1008 - einfo "Forcing cached settings:"
1009 - for v in "${vars[@]}" ; do
1010 - einfo " ${v}"
1011 - export ${v}
1012 - done
1013 -
1014 - local headers_only_arch_CPPFLAGS=()
1015 -
1016 - # Blow away some random CC settings that screw things up. #550192
1017 - if [[ -d ${S}/sysdeps/mips ]]; then
1018 - pushd "${S}"/sysdeps/mips >/dev/null
1019 - sed -i -e '/^CC +=/s:=.*:= -D_MIPS_SZPTR=32:' mips32/Makefile mips64/n32/Makefile || die
1020 - sed -i -e '/^CC +=/s:=.*:= -D_MIPS_SZPTR=64:' mips64/n64/Makefile || die
1021 -
1022 - # Force the mips ABI to the default. This is OK because the set of
1023 - # installed headers in this phase is the same between the 3 ABIs.
1024 - # If this ever changes, this hack will break, but that's unlikely
1025 - # as glibc discourages that behavior.
1026 - # https://crbug.com/647033
1027 - sed -i -e 's:abiflag=.*:abiflag=_ABIO32:' preconfigure || die
1028 -
1029 - popd >/dev/null
1030 - fi
1031 -
1032 - case ${CTARGET} in
1033 - riscv*)
1034 - # RISC-V interrogates the compiler to determine which target to
1035 - # build. If building the headers then we don't strictly need a
1036 - # RISC-V compiler, so the built-in definitions that are provided
1037 - # along with all RISC-V compiler might not exist. This causes
1038 - # glibc's RISC-V preconfigure script to blow up. Since we're just
1039 - # building the headers any value will actually work here, so just
1040 - # pick the standard one (rv64g/lp64d) to make the build scripts
1041 - # happy for now -- the headers are all the same anyway so it
1042 - # doesn't matter.
1043 - headers_only_arch_CPPFLAGS+=(
1044 - -D__riscv_xlen=64
1045 - -D__riscv_flen=64
1046 - -D__riscv_float_abi_double=1
1047 - -D__riscv_atomic=1
1048 - ) ;;
1049 - esac
1050 -
1051 - local myconf=()
1052 - myconf+=(
1053 - --disable-sanity-checks
1054 - --enable-hacker-mode
1055 - --without-cvs
1056 - --disable-werror
1057 - --enable-bind-now
1058 - --build=${CBUILD_OPT:-${CBUILD}}
1059 - --host=${CTARGET_OPT:-${CTARGET}}
1060 - --with-headers=$(alt_build_headers)
1061 - --prefix="${EPREFIX}/usr"
1062 - ${EXTRA_ECONF}
1063 - )
1064 -
1065 - # Nothing is compiled here which would affect the headers for the target.
1066 - # So forcing CC/CFLAGS is sane.
1067 - local headers_only_CC=$(tc-getBUILD_CC)
1068 - local headers_only_CFLAGS="-O1 -pipe"
1069 - local headers_only_CPPFLAGS="-U_FORTIFY_SOURCE ${headers_only_arch_CPPFLAGS[*]}"
1070 - local headers_only_LDFLAGS=""
1071 - set -- "${S}"/configure "${myconf[@]}"
1072 - echo \
1073 - "CC=${headers_only_CC}" \
1074 - "CFLAGS=${headers_only_CFLAGS}" \
1075 - "CPPFLAGS=${headers_only_CPPFLAGS}" \
1076 - "LDFLAGS=${headers_only_LDFLAGS}" \
1077 - "$@"
1078 - CC=${headers_only_CC} \
1079 - CFLAGS=${headers_only_CFLAGS} \
1080 - CPPFLAGS=${headers_only_CPPFLAGS} \
1081 - LDFLAGS="" \
1082 - "$@" || die "failed to configure glibc"
1083 -}
1084 -
1085 -do_src_configure() {
1086 - if just_headers ; then
1087 - glibc_headers_configure
1088 - else
1089 - glibc_do_configure nptl
1090 - fi
1091 -}
1092 -
1093 -src_configure() {
1094 - foreach_abi do_src_configure
1095 -}
1096 -
1097 -do_src_compile() {
1098 - emake -C "$(builddir nptl)" || die "make nptl for ${ABI} failed"
1099 -}
1100 -
1101 -src_compile() {
1102 - if just_headers ; then
1103 - return
1104 - fi
1105 -
1106 - foreach_abi do_src_compile
1107 -}
1108 -
1109 -glibc_src_test() {
1110 - cd "$(builddir nptl)"
1111 - emake check
1112 -}
1113 -
1114 -do_src_test() {
1115 - local ret=0
1116 -
1117 - glibc_src_test
1118 - : $(( ret |= $? ))
1119 -
1120 - return ${ret}
1121 -}
1122 -
1123 -src_test() {
1124 - if just_headers ; then
1125 - return
1126 - fi
1127 -
1128 - # Give tests more time to complete.
1129 - export TIMEOUTFACTOR=5
1130 -
1131 - foreach_abi do_src_test || die "tests failed"
1132 -}
1133 -
1134 -run_locale_gen() {
1135 - # if the host locales.gen contains no entries, we'll install everything
1136 - local root="$1"
1137 - local locale_list="${root}/etc/locale.gen"
1138 - if [[ -z $(locale-gen --list --config "${locale_list}") ]] ; then
1139 - ewarn "Generating all locales; edit /etc/locale.gen to save time/space"
1140 - locale_list="${root}/usr/share/i18n/SUPPORTED"
1141 - fi
1142 -
1143 - locale-gen --jobs $(makeopts_jobs) --config "${locale_list}" \
1144 - --destdir "${root}"
1145 -}
1146 -
1147 -glibc_do_src_install() {
1148 - local builddir=$(builddir nptl)
1149 - cd "${builddir}"
1150 -
1151 - emake install_root="${D}$(alt_prefix)" install || die
1152 -
1153 - # This version (2.26) provides some compatibility libraries for the NIS/NIS+ support
1154 - # which come without headers etc. Only needed for binary packages since the
1155 - # external net-libs/libnsl has increased soversion. Keep only versioned libraries.
1156 - find "${D}" -name "libnsl.a" -delete
1157 - find "${D}" -name "libnsl.so" -delete
1158 -
1159 - # Normally upstream_pv is ${PV}. Live ebuilds are exception, there we need
1160 - # to infer upstream version:
1161 - # '#define VERSION "2.26.90"' -> '2.26.90'
1162 - local upstream_pv=$(sed -n -r 's/#define VERSION "(.*)"/\1/p' "${S}"/version.h)
1163 -
1164 - if [[ -e ${ED}$(alt_usrlibdir)/libm-${upstream_pv}.a ]] ; then
1165 - # Move versioned .a file out of libdir to evade portage QA checks
1166 - # instead of using gen_usr_ldscript(). We fix ldscript as:
1167 - # "GROUP ( /usr/lib64/libm-<pv>.a ..." -> "GROUP ( /usr/lib64/glibc-<pv>/libm-<pv>.a ..."
1168 - sed -i "s@\(libm-${upstream_pv}.a\)@${P}/\1@" "${ED}"$(alt_usrlibdir)/libm.a || die
1169 - dodir $(alt_usrlibdir)/${P}
1170 - mv "${ED}"$(alt_usrlibdir)/libm-${upstream_pv}.a "${ED}"$(alt_usrlibdir)/${P}/libm-${upstream_pv}.a || die
1171 - fi
1172 -
1173 - # We'll take care of the cache ourselves
1174 - rm -f "${ED}"/etc/ld.so.cache
1175 -
1176 - # Everything past this point just needs to be done once ...
1177 - is_final_abi || return 0
1178 -
1179 - # Make sure the non-native interp can be found on multilib systems even
1180 - # if the main library set isn't installed into the right place. Maybe
1181 - # we should query the active gcc for info instead of hardcoding it ?
1182 - local i ldso_abi ldso_name
1183 - local ldso_abi_list=(
1184 - # x86
1185 - amd64 /lib64/ld-linux-x86-64.so.2
1186 - x32 /libx32/ld-linux-x32.so.2
1187 - x86 /lib/ld-linux.so.2
1188 - # mips
1189 - o32 /lib/ld.so.1
1190 - n32 /lib32/ld.so.1
1191 - n64 /lib64/ld.so.1
1192 - # powerpc
1193 - ppc /lib/ld.so.1
1194 - ppc64 /lib64/ld64.so.1
1195 - # s390
1196 - s390 /lib/ld.so.1
1197 - s390x /lib/ld64.so.1
1198 - # sparc
1199 - sparc32 /lib/ld-linux.so.2
1200 - sparc64 /lib64/ld-linux.so.2
1201 - )
1202 - case $(tc-endian) in
1203 - little)
1204 - ldso_abi_list+=(
1205 - # arm
1206 - arm64 /lib/ld-linux-aarch64.so.1
1207 - )
1208 - ;;
1209 - big)
1210 - ldso_abi_list+=(
1211 - # arm
1212 - arm64 /lib/ld-linux-aarch64_be.so.1
1213 - )
1214 - ;;
1215 - esac
1216 - if [[ ${SYMLINK_LIB} == "yes" ]] && [[ ! -e ${ED}/$(alt_prefix)/lib ]] ; then
1217 - dosym $(get_abi_LIBDIR ${DEFAULT_ABI}) $(alt_prefix)/lib
1218 - fi
1219 - for (( i = 0; i < ${#ldso_abi_list[@]}; i += 2 )) ; do
1220 - ldso_abi=${ldso_abi_list[i]}
1221 - has ${ldso_abi} $(get_install_abis) || continue
1222 -
1223 - ldso_name="$(alt_prefix)${ldso_abi_list[i+1]}"
1224 - if [[ ! -L ${ED}/${ldso_name} && ! -e ${ED}/${ldso_name} ]] ; then
1225 - dosym ../$(get_abi_LIBDIR ${ldso_abi})/${ldso_name##*/} ${ldso_name}
1226 - fi
1227 - done
1228 -
1229 - # With devpts under Linux mounted properly, we do not need the pt_chown
1230 - # binary to be setuid. This is because the default owners/perms will be
1231 - # exactly what we want.
1232 - if in_iuse suid && ! use suid ; then
1233 - find "${ED}" -name pt_chown -exec chmod -s {} +
1234 - fi
1235 -
1236 - #################################################################
1237 - # EVERYTHING AFTER THIS POINT IS FOR NATIVE GLIBC INSTALLS ONLY #
1238 - # Make sure we install some symlink hacks so that when we build
1239 - # a 2nd stage cross-compiler, gcc finds the target system
1240 - # headers correctly. See gcc/doc/gccinstall.info
1241 - if is_crosscompile ; then
1242 - # We need to make sure that /lib and /usr/lib always exists.
1243 - # gcc likes to use relative paths to get to its multilibs like
1244 - # /usr/lib/../lib64/. So while we don't install any files into
1245 - # /usr/lib/, we do need it to exist.
1246 - cd "${ED}"$(alt_libdir)/..
1247 - [[ -e lib ]] || mkdir lib
1248 - cd "${ED}"$(alt_usrlibdir)/..
1249 - [[ -e lib ]] || mkdir lib
1250 -
1251 - dosym usr/include $(alt_prefix)/sys-include
1252 - return 0
1253 - fi
1254 -
1255 - # Files for Debian-style locale updating
1256 - dodir /usr/share/i18n
1257 - sed \
1258 - -e "/^#/d" \
1259 - -e "/SUPPORTED-LOCALES=/d" \
1260 - -e "s: \\\\::g" -e "s:/: :g" \
1261 - "${S}"/localedata/SUPPORTED > "${ED}"/usr/share/i18n/SUPPORTED \
1262 - || die "generating /usr/share/i18n/SUPPORTED failed"
1263 - cd "${WORKDIR}"/extra/locale
1264 - dosbin locale-gen
1265 - doman *.[0-8]
1266 - insinto /etc
1267 - doins locale.gen
1268 -
1269 - # Make sure all the ABI's can find the locales and so we only
1270 - # have to generate one set
1271 - local a
1272 - keepdir /usr/$(get_libdir)/locale
1273 - for a in $(get_install_abis) ; do
1274 - if [[ ! -e ${ED}/usr/$(get_abi_LIBDIR ${a})/locale ]] ; then
1275 - dosym ../$(get_libdir)/locale /usr/$(get_abi_LIBDIR ${a})/locale
1276 - fi
1277 - done
1278 -
1279 - cd "${S}"
1280 -
1281 - # Install misc network config files
1282 - insinto /etc
1283 - doins nscd/nscd.conf posix/gai.conf nss/nsswitch.conf
1284 - doins "${WORKDIR}"/extra/etc/*.conf
1285 -
1286 - if use nscd ; then
1287 - doinitd "$(prefixify_ro "${WORKDIR}"/extra/etc/nscd)"
1288 -
1289 - local nscd_args=(
1290 - -e "s:@PIDFILE@:$(strings "${ED}"/usr/sbin/nscd | grep nscd.pid):"
1291 - )
1292 -
1293 - sed -i "${nscd_args[@]}" "${ED}"/etc/init.d/nscd
1294 -
1295 - systemd_dounit nscd/nscd.service
1296 - systemd_newtmpfilesd nscd/nscd.tmpfiles nscd.conf
1297 - else
1298 - # Do this since extra/etc/*.conf above might have nscd.conf.
1299 - rm -f "${ED}"/etc/nscd.conf
1300 - fi
1301 -
1302 - echo 'LDPATH="include ld.so.conf.d/*.conf"' > "${T}"/00glibc
1303 - doenvd "${T}"/00glibc
1304 -
1305 - for d in BUGS ChangeLog CONFORMANCE FAQ NEWS NOTES PROJECTS README* ; do
1306 - [[ -s ${d} ]] && dodoc ${d}
1307 - done
1308 - dodoc -r ChangeLog.old
1309 -
1310 - # Prevent overwriting of the /etc/localtime symlink. We'll handle the
1311 - # creation of the "factory" symlink in pkg_postinst().
1312 - rm -f "${ED}"/etc/localtime
1313 -
1314 - # Generate all locales if this is a native build as locale generation
1315 - if use compile-locales && ! is_crosscompile ; then
1316 - run_locale_gen "${ED}"
1317 - fi
1318 -}
1319 -
1320 -glibc_headers_install() {
1321 - local builddir=$(builddir "headers")
1322 - cd "${builddir}"
1323 - emake install_root="${D}$(alt_prefix)" install-headers
1324 -
1325 - insinto $(alt_headers)/gnu
1326 - doins "${S}"/include/gnu/stubs.h
1327 -
1328 - # Make sure we install the sys-include symlink so that when
1329 - # we build a 2nd stage cross-compiler, gcc finds the target
1330 - # system headers correctly. See gcc/doc/gccinstall.info
1331 - dosym usr/include $(alt_prefix)/sys-include
1332 -}
1333 -
1334 -src_strip() {
1335 - # gdb is lame and requires some debugging information to remain in
1336 - # libpthread, so we need to strip it by hand. libthread_db makes no
1337 - # sense stripped as it is only used when debugging.
1338 - local pthread=$(has splitdebug ${FEATURES} && echo "libthread_db" || echo "lib{pthread,thread_db}")
1339 - env \
1340 - -uRESTRICT \
1341 - CHOST=${CTARGET} \
1342 - STRIP_MASK="/*/{,tls/}${pthread}*" \
1343 - prepallstrip
1344 - # if user has stripping enabled and does not have split debug turned on,
1345 - # then leave the debugging sections in libpthread.
1346 - if ! has nostrip ${FEATURES} && ! has splitdebug ${FEATURES} ; then
1347 - ${STRIP:-${CTARGET}-strip} --strip-debug "${ED}"$(alt_prefix)/*/libpthread-*.so
1348 - fi
1349 -}
1350 -
1351 -src_install() {
1352 - if just_headers ; then
1353 - export ABI=default
1354 - glibc_headers_install
1355 - return
1356 - fi
1357 -
1358 - foreach_abi glibc_do_src_install
1359 - src_strip
1360 -}
1361 -
1362 -# Simple test to make sure our new glibc isn't completely broken.
1363 -# Make sure we don't test with statically built binaries since
1364 -# they will fail. Also, skip if this glibc is a cross compiler.
1365 -#
1366 -# If coreutils is built with USE=multicall, some of these files
1367 -# will just be wrapper scripts, not actual ELFs we can test.
1368 -glibc_sanity_check() {
1369 - cd / #228809
1370 -
1371 - # We enter ${ED} so to avoid trouble if the path contains
1372 - # special characters; for instance if the path contains the
1373 - # colon character (:), then the linker will try to split it
1374 - # and look for the libraries in an unexpected place. This can
1375 - # lead to unsafe code execution if the generated prefix is
1376 - # within a world-writable directory.
1377 - # (e.g. /var/tmp/portage:${HOSTNAME})
1378 - pushd "${ED}"/$(get_libdir) >/dev/null
1379 -
1380 - local x striptest
1381 - for x in cal date env free ls true uname uptime ; do
1382 - x=$(type -p ${x})
1383 - [[ -z ${x} || ${x} != ${EPREFIX}/* ]] && continue
1384 - striptest=$(LC_ALL="C" file -L ${x} 2>/dev/null) || continue
1385 - case ${striptest} in
1386 - *"statically linked"*) continue;;
1387 - *"ASCII text"*) continue;;
1388 - esac
1389 - # We need to clear the locale settings as the upgrade might want
1390 - # incompatible locale data. This test is not for verifying that.
1391 - LC_ALL=C \
1392 - ./ld-*.so --library-path . ${x} > /dev/null \
1393 - || die "simple run test (${x}) failed"
1394 - done
1395 -
1396 - popd >/dev/null
1397 -}
1398 -
1399 -pkg_preinst() {
1400 - # nothing to do if just installing headers
1401 - just_headers && return
1402 -
1403 - # prepare /etc/ld.so.conf.d/ for files
1404 - mkdir -p "${EROOT}"/etc/ld.so.conf.d
1405 -
1406 - # Default /etc/hosts.conf:multi to on for systems with small dbs.
1407 - if [[ $(wc -l < "${EROOT}"/etc/hosts) -lt 1000 ]] ; then
1408 - sed -i '/^multi off/s:off:on:' "${ED}"/etc/host.conf
1409 - einfo "Defaulting /etc/host.conf:multi to on"
1410 - fi
1411 -
1412 - [[ ${ROOT} != "/" ]] && return 0
1413 - [[ -d ${ED}/$(get_libdir) ]] || return 0
1414 - [[ -z ${BOOTSTRAP_RAP} ]] && glibc_sanity_check
1415 -}
1416 -
1417 -pkg_postinst() {
1418 - # nothing to do if just installing headers
1419 - just_headers && return
1420 -
1421 - if ! tc-is-cross-compiler && [[ -x ${EROOT}/usr/sbin/iconvconfig ]] ; then
1422 - # Generate fastloading iconv module configuration file.
1423 - "${EROOT}"/usr/sbin/iconvconfig --prefix="${ROOT}"
1424 - fi
1425 -
1426 - if ! is_crosscompile && [[ ${ROOT} == "/" ]] ; then
1427 - # Reload init ... if in a chroot or a diff init package, ignore
1428 - # errors from this step #253697
1429 - /sbin/telinit U 2>/dev/null
1430 -
1431 - use compile-locales || run_locale_gen "${EROOT}"
1432 - fi
1433 -
1434 - # Check for sanity of /etc/nsswitch.conf, take 2
1435 - if [[ -e ${EROOT}/etc/nsswitch.conf ]] && ! has_version sys-auth/libnss-nis ; then
1436 - local entry
1437 - for entry in passwd group shadow; do
1438 - if egrep -q "^[ \t]*${entry}:.*nis" "${EROOT}"/etc/nsswitch.conf; then
1439 - ewarn ""
1440 - ewarn "Your ${EROOT}/etc/nsswitch.conf uses NIS. Support for that has been"
1441 - ewarn "removed from glibc and is now provided by the package"
1442 - ewarn " sys-auth/libnss-nis"
1443 - ewarn "Install it now to keep your NIS setup working."
1444 - ewarn ""
1445 - fi
1446 - done
1447 - fi
1448 -}