Gentoo Archives: gentoo-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-dev@l.g.o
Cc: qa@g.o, toolchain@g.o, "Michał Górny" <mgorny@g.o>
Subject: [gentoo-dev] [PATCH] sys-libs/glibc: Convert from eblits to eclass, #586422
Date: Thu, 16 Mar 2017 13:49:41
Message-Id: 20170316134921.12138-1-mgorny@gentoo.org
1 //
2 note: i'm in process of testing [building binpkgs] of all glibc versions
3 to confirm i didn't accidentally break anything. -9999 fails in compile
4 phase both before and after the change.
5
6 ---
7 eclass/toolchain-glibc.eclass | 1404 +++++++++++++++++++++++
8 sys-libs/glibc/files/eblits/common.eblit | 380 ------
9 sys-libs/glibc/files/eblits/pkg_postinst.eblit | 26 -
10 sys-libs/glibc/files/eblits/pkg_preinst.eblit | 62 -
11 sys-libs/glibc/files/eblits/pkg_pretend.eblit | 158 ---
12 sys-libs/glibc/files/eblits/pkg_setup.eblit | 8 -
13 sys-libs/glibc/files/eblits/src_compile.eblit | 23 -
14 sys-libs/glibc/files/eblits/src_configure.eblit | 281 -----
15 sys-libs/glibc/files/eblits/src_install.eblit | 249 ----
16 sys-libs/glibc/files/eblits/src_prepare.eblit | 64 --
17 sys-libs/glibc/files/eblits/src_test.eblit | 29 -
18 sys-libs/glibc/files/eblits/src_unpack.eblit | 120 --
19 sys-libs/glibc/glibc-2.17.ebuild | 61 +-
20 sys-libs/glibc/glibc-2.18-r1.ebuild | 61 +-
21 sys-libs/glibc/glibc-2.19-r1.ebuild | 60 +-
22 sys-libs/glibc/glibc-2.20-r2.ebuild | 59 +-
23 sys-libs/glibc/glibc-2.21-r2.ebuild | 59 +-
24 sys-libs/glibc/glibc-2.22-r4.ebuild | 61 +-
25 sys-libs/glibc/glibc-2.23-r3.ebuild | 59 +-
26 sys-libs/glibc/glibc-2.24-r1.ebuild | 59 +-
27 sys-libs/glibc/glibc-2.25.ebuild | 59 +-
28 sys-libs/glibc/glibc-9999.ebuild | 59 +-
29 22 files changed, 1467 insertions(+), 1934 deletions(-)
30 create mode 100644 eclass/toolchain-glibc.eclass
31 delete mode 100644 sys-libs/glibc/files/eblits/common.eblit
32 delete mode 100644 sys-libs/glibc/files/eblits/pkg_postinst.eblit
33 delete mode 100644 sys-libs/glibc/files/eblits/pkg_preinst.eblit
34 delete mode 100644 sys-libs/glibc/files/eblits/pkg_pretend.eblit
35 delete mode 100644 sys-libs/glibc/files/eblits/pkg_setup.eblit
36 delete mode 100644 sys-libs/glibc/files/eblits/src_compile.eblit
37 delete mode 100644 sys-libs/glibc/files/eblits/src_configure.eblit
38 delete mode 100644 sys-libs/glibc/files/eblits/src_install.eblit
39 delete mode 100644 sys-libs/glibc/files/eblits/src_prepare.eblit
40 delete mode 100644 sys-libs/glibc/files/eblits/src_test.eblit
41 delete mode 100644 sys-libs/glibc/files/eblits/src_unpack.eblit
42
43 diff --git a/eclass/toolchain-glibc.eclass b/eclass/toolchain-glibc.eclass
44 new file mode 100644
45 index 000000000000..d410775759df
46 --- /dev/null
47 +++ b/eclass/toolchain-glibc.eclass
48 @@ -0,0 +1,1404 @@
49 +# Copyright 1999-2017 Gentoo Foundation
50 +# Distributed under the terms of the GNU General Public License v2
51 +
52 +# @ECLASS: toolchain-glibc.eclass
53 +# @MAINTAINER:
54 +# <toolchain@g.o>
55 +# @BLURB: Common code for sys-libs/glibc ebuilds
56 +# @DESCRIPTION:
57 +# This eclass contains the common phase functions migrated from
58 +# sys-libs/glibc eblits.
59 +
60 +if [[ -z ${_TOOLCHAIN_GLIBC_ECLASS} ]]; then
61 +
62 +inherit eutils versionator toolchain-funcs flag-o-matic gnuconfig \
63 + multilib systemd unpacker multiprocessing prefix
64 +
65 +case ${EAPI:-0} in
66 + 0|1|2|3) EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_test \
67 + src_install pkg_preinst pkg_postinst;;
68 + 2|3) EXPORT_FUNCTIONS pkg_setup src_unpack src_prepare src_configure \
69 + src_compile src_test src_install pkg_preinst pkg_postinst;;
70 + 4|5|6) EXPORT_FUNCTIONS pkg_pretend pkg_setup src_unpack src_prepare \
71 + src_configure src_compile src_test src_install \
72 + pkg_preinst pkg_postinst;;
73 + *) die "Unsupported EAPI=${EAPI}";;
74 +esac
75 +
76 +# == common ==
77 +
78 +alt_prefix() {
79 + is_crosscompile && echo /usr/${CTARGET}
80 +}
81 +
82 +if [[ ${EAPI:-0} == [012] ]] ; then
83 + : ${ED:=${D}}
84 + : ${EROOT:=${ROOT}}
85 +fi
86 +# This indirection is for binpkgs. #523332
87 +_nonfatal() { nonfatal "$@" ; }
88 +if [[ ${EAPI:-0} == [0123] ]] ; then
89 + nonfatal() { "$@" ; }
90 + _nonfatal() { "$@" ; }
91 +fi
92 +
93 +# We need to be able to set alternative headers for
94 +# compiling for non-native platform
95 +# Will also become useful for testing kernel-headers without screwing up
96 +# the whole system.
97 +# note: intentionally undocumented.
98 +alt_headers() {
99 + echo ${ALT_HEADERS:=$(alt_prefix)/usr/include}
100 +}
101 +alt_build_headers() {
102 + if [[ -z ${ALT_BUILD_HEADERS} ]] ; then
103 + ALT_BUILD_HEADERS="${EPREFIX}$(alt_headers)"
104 + if tc-is-cross-compiler ; then
105 + ALT_BUILD_HEADERS=${SYSROOT}$(alt_headers)
106 + if [[ ! -e ${ALT_BUILD_HEADERS}/linux/version.h ]] ; then
107 + local header_path=$(echo '#include <linux/version.h>' | $(tc-getCPP ${CTARGET}) ${CFLAGS} 2>&1 | grep -o '[^"]*linux/version.h')
108 + ALT_BUILD_HEADERS=${header_path%/linux/version.h}
109 + fi
110 + fi
111 + fi
112 + echo "${ALT_BUILD_HEADERS}"
113 +}
114 +
115 +alt_libdir() {
116 + echo $(alt_prefix)/$(get_libdir)
117 +}
118 +alt_usrlibdir() {
119 + echo $(alt_prefix)/usr/$(get_libdir)
120 +}
121 +
122 +builddir() {
123 + echo "${WORKDIR}/build-${ABI}-${CTARGET}-$1"
124 +}
125 +
126 +setup_target_flags() {
127 + # This largely mucks with compiler flags. None of which should matter
128 + # when building up just the headers.
129 + just_headers && return 0
130 +
131 + case $(tc-arch) in
132 + x86)
133 + # -march needed for #185404 #199334
134 + # TODO: When creating the first glibc cross-compile, this test will
135 + # always fail as it does a full link which in turn requires glibc.
136 + # Probably also applies when changing multilib profile settings (e.g.
137 + # enabling x86 when the profile was amd64-only previously).
138 + # We could change main to _start and pass -nostdlib here so that we
139 + # only test the gcc code compilation. Or we could do a compile and
140 + # then look for the symbol via scanelf.
141 + 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
142 + local t=${CTARGET_OPT:-${CTARGET}}
143 + t=${t%%-*}
144 + filter-flags '-march=*'
145 + export CFLAGS="-march=${t} ${CFLAGS}"
146 + einfo "Auto adding -march=${t} to CFLAGS #185404"
147 + fi
148 + ;;
149 + amd64)
150 + # -march needed for #185404 #199334
151 + # Note: This test only matters when the x86 ABI is enabled, so we could
152 + # optimize a bit and elide it.
153 + # TODO: See cross-compile issues listed above for x86.
154 + 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
155 + local t=${CTARGET_OPT:-${CTARGET}}
156 + t=${t%%-*}
157 + # Normally the target is x86_64-xxx, so turn that into the -march that
158 + # gcc actually accepts. #528708
159 + [[ ${t} == "x86_64" ]] && t="x86-64"
160 + filter-flags '-march=*'
161 + # ugly, ugly, ugly. ugly.
162 + CFLAGS_x86=$(CFLAGS=${CFLAGS_x86} filter-flags '-march=*'; echo "${CFLAGS}")
163 + export CFLAGS_x86="${CFLAGS_x86} -march=${t}"
164 + einfo "Auto adding -march=${t} to CFLAGS_x86 #185404"
165 + fi
166 + ;;
167 + mips)
168 + # The mips abi cannot support the GNU style hashes. #233233
169 + filter-ldflags -Wl,--hash-style=gnu -Wl,--hash-style=both
170 + ;;
171 + ppc)
172 + append-flags "-freorder-blocks"
173 + ;;
174 + sparc)
175 + # Both sparc and sparc64 can use -fcall-used-g6. -g7 is bad, though.
176 + filter-flags "-fcall-used-g7"
177 + append-flags "-fcall-used-g6"
178 +
179 + # If the CHOST is the basic one (e.g. not sparcv9-xxx already),
180 + # try to pick a better one so glibc can use cpu-specific .S files.
181 + # We key off the CFLAGS to get a good value. Also need to handle
182 + # version skew.
183 + # We can't force users to set their CHOST to their exact machine
184 + # as many of these are not recognized by config.sub/gcc and such :(.
185 + # Note: If the mcpu values don't scale, we might try probing CPP defines.
186 + # Note: Should we factor in -Wa,-AvXXX flags too ? Or -mvis/etc... ?
187 +
188 + local cpu
189 + case ${CTARGET} in
190 + sparc64-*)
191 + case $(get-flag mcpu) in
192 + niagara[234])
193 + if version_is_at_least 2.8 ; then
194 + cpu="sparc64v2"
195 + elif version_is_at_least 2.4 ; then
196 + cpu="sparc64v"
197 + elif version_is_at_least 2.2.3 ; then
198 + cpu="sparc64b"
199 + fi
200 + ;;
201 + niagara)
202 + if version_is_at_least 2.4 ; then
203 + cpu="sparc64v"
204 + elif version_is_at_least 2.2.3 ; then
205 + cpu="sparc64b"
206 + fi
207 + ;;
208 + ultrasparc3)
209 + cpu="sparc64b"
210 + ;;
211 + *)
212 + # We need to force at least v9a because the base build doesn't
213 + # work with just v9.
214 + # https://sourceware.org/bugzilla/show_bug.cgi?id=19477
215 + [[ -z ${cpu} ]] && append-flags "-Wa,-xarch=v9a"
216 + ;;
217 + esac
218 + ;;
219 + sparc-*)
220 + case $(get-flag mcpu) in
221 + niagara[234])
222 + if version_is_at_least 2.8 ; then
223 + cpu="sparcv9v2"
224 + elif version_is_at_least 2.4 ; then
225 + cpu="sparcv9v"
226 + elif version_is_at_least 2.2.3 ; then
227 + cpu="sparcv9b"
228 + else
229 + cpu="sparcv9"
230 + fi
231 + ;;
232 + niagara)
233 + if version_is_at_least 2.4 ; then
234 + cpu="sparcv9v"
235 + elif version_is_at_least 2.2.3 ; then
236 + cpu="sparcv9b"
237 + else
238 + cpu="sparcv9"
239 + fi
240 + ;;
241 + ultrasparc3)
242 + cpu="sparcv9b"
243 + ;;
244 + v9|ultrasparc)
245 + cpu="sparcv9"
246 + ;;
247 + v8|supersparc|hypersparc|leon|leon3)
248 + cpu="sparcv8"
249 + ;;
250 + esac
251 + ;;
252 + esac
253 + [[ -n ${cpu} ]] && CTARGET_OPT="${cpu}-${CTARGET#*-}"
254 + ;;
255 + esac
256 +}
257 +
258 +setup_flags() {
259 + # Make sure host make.conf doesn't pollute us
260 + if is_crosscompile || tc-is-cross-compiler ; then
261 + CHOST=${CTARGET} strip-unsupported-flags
262 + fi
263 +
264 + # Store our CFLAGS because it's changed depending on which CTARGET
265 + # we are building when pulling glibc on a multilib profile
266 + CFLAGS_BASE=${CFLAGS_BASE-${CFLAGS}}
267 + CFLAGS=${CFLAGS_BASE}
268 + CXXFLAGS_BASE=${CXXFLAGS_BASE-${CXXFLAGS}}
269 + CXXFLAGS=${CXXFLAGS_BASE}
270 + ASFLAGS_BASE=${ASFLAGS_BASE-${ASFLAGS}}
271 + ASFLAGS=${ASFLAGS_BASE}
272 +
273 + # Over-zealous CFLAGS can often cause problems. What may work for one
274 + # person may not work for another. To avoid a large influx of bugs
275 + # relating to failed builds, we strip most CFLAGS out to ensure as few
276 + # problems as possible.
277 + strip-flags
278 + strip-unsupported-flags
279 + filter-flags -m32 -m64 -mabi=*
280 +
281 + # Bug 492892.
282 + filter-flags -frecord-gcc-switches
283 +
284 + unset CBUILD_OPT CTARGET_OPT
285 + if use multilib ; then
286 + CTARGET_OPT=$(get_abi_CTARGET)
287 + [[ -z ${CTARGET_OPT} ]] && CTARGET_OPT=$(get_abi_CHOST)
288 + fi
289 +
290 + setup_target_flags
291 +
292 + if [[ -n ${CTARGET_OPT} && ${CBUILD} == ${CHOST} ]] && ! is_crosscompile; then
293 + CBUILD_OPT=${CTARGET_OPT}
294 + fi
295 +
296 + # Lock glibc at -O2 -- linuxthreads needs it and we want to be
297 + # conservative here. -fno-strict-aliasing is to work around #155906
298 + filter-flags -O?
299 + append-flags -O2 -fno-strict-aliasing
300 +
301 + # Can't build glibc itself with fortify code. Newer versions add
302 + # this flag for us, so no need to do it manually.
303 + version_is_at_least 2.16 ${PV} || append-cppflags -U_FORTIFY_SOURCE
304 +
305 + # building glibc with SSP is fraught with difficulty, especially
306 + # due to __stack_chk_fail_local which would mean significant changes
307 + # to the glibc build process. See bug #94325 #293721
308 + # Note we have to handle both user-given CFLAGS and gcc defaults via
309 + # spec rules here. We can't simply add -fno-stack-protector as it gets
310 + # added before user flags, and we can't just filter-flags because
311 + # _filter_hardened doesn't support globs.
312 + filter-flags -fstack-protector*
313 + gcc-specs-ssp && append-flags $(test-flags -fno-stack-protector)
314 +
315 + if use hardened && gcc-specs-pie ; then
316 + # Force PIC macro definition for all compilations since they're all
317 + # either -fPIC or -fPIE with the default-PIE compiler.
318 + append-cppflags -DPIC
319 + else
320 + # Don't build -fPIE without the default-PIE compiler and the
321 + # hardened-pie patch
322 + filter-flags -fPIE
323 + fi
324 +}
325 +
326 +want_nptl() {
327 + [[ -z ${LT_VER} ]] && return 0
328 + want_tls || return 1
329 + use nptl || return 1
330 +
331 + # Older versions of glibc had incomplete arch support for nptl.
332 + # But if you're building those now, you can handle USE=nptl yourself.
333 + return 0
334 +}
335 +
336 +want_linuxthreads() {
337 + [[ -z ${LT_VER} ]] && return 1
338 + use linuxthreads
339 +}
340 +
341 +want_tls() {
342 + # Archs that can use TLS (Thread Local Storage)
343 + case $(tc-arch) in
344 + x86)
345 + # requires i486 or better #106556
346 + [[ ${CTARGET} == i[4567]86* ]] && return 0
347 + return 1
348 + ;;
349 + esac
350 +
351 + return 0
352 +}
353 +
354 +want__thread() {
355 + want_tls || return 1
356 +
357 + # For some reason --with-tls --with__thread is causing segfaults on sparc32.
358 + [[ ${PROFILE_ARCH} == "sparc" ]] && return 1
359 +
360 + [[ -n ${WANT__THREAD} ]] && return ${WANT__THREAD}
361 +
362 + # only test gcc -- cant test linking yet
363 + tc-has-tls -c ${CTARGET}
364 + WANT__THREAD=$?
365 +
366 + return ${WANT__THREAD}
367 +}
368 +
369 +use_multiarch() {
370 + # Make sure binutils is new enough to support indirect functions #336792
371 + # This funky sed supports gold and bfd linkers.
372 + local bver nver
373 + bver=$($(tc-getLD ${CTARGET}) -v | sed -n -r '1{s:[^0-9]*::;s:^([0-9.]*).*:\1:;p}')
374 + case $(tc-arch ${CTARGET}) in
375 + amd64|x86) nver="2.20" ;;
376 + arm) nver="2.22" ;;
377 + hppa) nver="2.23" ;;
378 + ppc|ppc64) nver="2.20" ;;
379 + # ifunc was added in 2.23, but glibc also needs machinemode which is in 2.24.
380 + s390) nver="2.24" ;;
381 + sparc) nver="2.21" ;;
382 + *) return 1 ;;
383 + esac
384 + version_is_at_least ${nver} ${bver}
385 +}
386 +
387 +# Setup toolchain variables that had historically
388 +# been defined in the profiles for these archs.
389 +setup_env() {
390 + # silly users
391 + unset LD_RUN_PATH
392 + unset LD_ASSUME_KERNEL
393 +
394 + if is_crosscompile || tc-is-cross-compiler ; then
395 + multilib_env ${CTARGET_OPT:-${CTARGET}}
396 +
397 + if ! use multilib ; then
398 + MULTILIB_ABIS=${DEFAULT_ABI}
399 + else
400 + MULTILIB_ABIS=${MULTILIB_ABIS:-${DEFAULT_ABI}}
401 + fi
402 +
403 + # If the user has CFLAGS_<CTARGET> in their make.conf, use that,
404 + # and fall back on CFLAGS.
405 + local VAR=CFLAGS_${CTARGET//[-.]/_}
406 + CFLAGS=${!VAR-${CFLAGS}}
407 + fi
408 +
409 + setup_flags
410 +
411 + export ABI=${ABI:-${DEFAULT_ABI:-default}}
412 +
413 + local VAR=CFLAGS_${ABI}
414 + # We need to export CFLAGS with abi information in them because glibc's
415 + # configure script checks CFLAGS for some targets (like mips). Keep
416 + # around the original clean value to avoid appending multiple ABIs on
417 + # top of each other.
418 + : ${__GLIBC_CC:=$(tc-getCC ${CTARGET_OPT:-${CTARGET}})}
419 + export __GLIBC_CC CC="${__GLIBC_CC} ${!VAR}"
420 +}
421 +
422 +foreach_abi() {
423 + setup_env
424 +
425 + local ret=0
426 + local abilist=""
427 + if use multilib ; then
428 + abilist=$(get_install_abis)
429 + else
430 + abilist=${DEFAULT_ABI}
431 + fi
432 + evar_push ABI
433 + export ABI
434 + for ABI in ${abilist:-default} ; do
435 + setup_env
436 + einfo "Running $1 for ABI ${ABI}"
437 + $1
438 + : $(( ret |= $? ))
439 + done
440 + evar_pop
441 + return ${ret}
442 +}
443 +
444 +just_headers() {
445 + is_crosscompile && use crosscompile_opts_headers-only
446 +}
447 +
448 +glibc_banner() {
449 + local b="Gentoo ${PVR}"
450 + [[ -n ${SNAP_VER} ]] && b+=" snapshot ${SNAP_VER}"
451 + [[ -n ${BRANCH_UPDATE} ]] && b+=" branch ${BRANCH_UPDATE}"
452 + [[ -n ${PATCH_VER} ]] && ! use vanilla && b+=" p${PATCH_VER}"
453 + echo "${b}"
454 +}
455 +
456 +# == phases ==
457 +
458 +glibc_compile_test() {
459 + local ret save_cflags=${CFLAGS}
460 + CFLAGS+=" $1"
461 + shift
462 +
463 + pushd "${T}" >/dev/null
464 +
465 + rm -f glibc-test*
466 + printf '%b' "$*" > glibc-test.c
467 +
468 + _nonfatal emake -s glibc-test
469 + ret=$?
470 +
471 + popd >/dev/null
472 +
473 + CFLAGS=${save_cflags}
474 + return ${ret}
475 +}
476 +
477 +glibc_run_test() {
478 + local ret
479 +
480 + if [[ ${EMERGE_FROM} == "binary" ]] ; then
481 + # ignore build failures when installing a binary package #324685
482 + glibc_compile_test "" "$@" 2>/dev/null || return 0
483 + else
484 + if ! glibc_compile_test "" "$@" ; then
485 + ewarn "Simple build failed ... assuming this is desired #324685"
486 + return 0
487 + fi
488 + fi
489 +
490 + pushd "${T}" >/dev/null
491 +
492 + ./glibc-test
493 + ret=$?
494 + rm -f glibc-test*
495 +
496 + popd >/dev/null
497 +
498 + return ${ret}
499 +}
500 +
501 +check_devpts() {
502 + # Make sure devpts is mounted correctly for use w/out setuid pt_chown.
503 +
504 + # If merely building the binary package, then there's nothing to verify.
505 + [[ ${MERGE_TYPE} == "buildonly" ]] && return
506 +
507 + # Only sanity check when installing the native glibc.
508 + [[ ${ROOT} != "/" ]] && return
509 +
510 + # Older versions always installed setuid, so no need to check.
511 + in_iuse suid || return
512 +
513 + # If they're opting in to the old suid code, then no need to check.
514 + use suid && return
515 +
516 + if awk '$3 == "devpts" && $4 ~ /[, ]gid=5[, ]/ { exit 1 }' /proc/mounts ; then
517 + eerror "In order to use glibc with USE=-suid, you must make sure that"
518 + eerror "you have devpts mounted at /dev/pts with the gid=5 option."
519 + eerror "Openrc should do this for you, so you should check /etc/fstab"
520 + eerror "and make sure you do not have any invalid settings there."
521 + # Do not die on older kernels as devpts did not export these settings #489520.
522 + if version_is_at_least 2.6.25 $(uname -r) ; then
523 + die "mount & fix your /dev/pts settings"
524 + fi
525 + fi
526 +}
527 +
528 +toolchain-glibc_pkg_pretend() {
529 + # For older EAPIs, this is run in pkg_preinst.
530 + if [[ ${EAPI:-0} != [0123] ]] ; then
531 + check_devpts
532 + fi
533 +
534 + # Prevent native builds from downgrading.
535 + if [[ ${MERGE_TYPE} != "buildonly" ]] && \
536 + [[ ${ROOT} == "/" ]] && \
537 + [[ ${CBUILD} == ${CHOST} ]] && \
538 + [[ ${CHOST} == ${CTARGET} ]] ; then
539 + # The high rev # is to allow people to downgrade between -r# versions.
540 + # We want to block 2.20->2.19, but 2.20-r3->2.20-r2 should be fine.
541 + # Hopefully we never actually use a r# this high.
542 + if has_version ">${CATEGORY}/${P}-r10000" ; then
543 + eerror "Sanity check to keep you from breaking your system:"
544 + eerror " Downgrading glibc is not supported and a sure way to destruction"
545 + die "aborting to save your system"
546 + fi
547 +
548 + if ! glibc_run_test '#include <pwd.h>\nint main(){return getpwuid(0)==0;}\n'
549 + then
550 + eerror "Your patched vendor kernel is broken. You need to get an"
551 + eerror "update from whoever is providing the kernel to you."
552 + eerror "https://sourceware.org/bugzilla/show_bug.cgi?id=5227"
553 + eerror "http://bugs.gentoo.org/262698"
554 + die "keeping your system alive, say thank you"
555 + fi
556 +
557 + if ! glibc_run_test '#include <unistd.h>\n#include <sys/syscall.h>\nint main(){return syscall(1000)!=-1;}\n'
558 + then
559 + eerror "Your old kernel is broken. You need to update it to"
560 + eerror "a newer version as syscall(<bignum>) will break."
561 + eerror "http://bugs.gentoo.org/279260"
562 + die "keeping your system alive, say thank you"
563 + fi
564 + fi
565 +
566 + # users have had a chance to phase themselves, time to give em the boot
567 + if [[ -e ${EROOT}/etc/locale.gen ]] && [[ -e ${EROOT}/etc/locales.build ]] ; then
568 + eerror "You still haven't deleted ${EROOT}/etc/locales.build."
569 + eerror "Do so now after making sure ${EROOT}/etc/locale.gen is kosher."
570 + die "lazy upgrader detected"
571 + fi
572 +
573 + if [[ ${CTARGET} == i386-* ]] ; then
574 + eerror "i386 CHOSTs are no longer supported."
575 + eerror "Chances are you don't actually want/need i386."
576 + eerror "Please read http://www.gentoo.org/doc/en/change-chost.xml"
577 + die "please fix your CHOST"
578 + fi
579 +
580 + if [[ -e /proc/xen ]] && [[ $(tc-arch) == "x86" ]] && ! is-flag -mno-tls-direct-seg-refs ; then
581 + ewarn "You are using Xen but don't have -mno-tls-direct-seg-refs in your CFLAGS."
582 + ewarn "This will result in a 50% performance penalty when running with a 32bit"
583 + ewarn "hypervisor, which is probably not what you want."
584 + fi
585 +
586 + use hardened && ! gcc-specs-pie && \
587 + ewarn "PIE hardening not applied, as your compiler doesn't default to PIE"
588 +
589 + # Make sure host system is up to date #394453
590 + if has_version '<sys-libs/glibc-2.13' && \
591 + [[ -n $(scanelf -qys__guard -F'#s%F' "${EROOT}"/lib*/l*-*.so) ]]
592 + then
593 + ebegin "Scanning system for __guard to see if you need to rebuild first ..."
594 + local files=$(
595 + scanelf -qys__guard -F'#s%F' \
596 + "${EROOT}"/*bin/ \
597 + "${EROOT}"/lib* \
598 + "${EROOT}"/usr/*bin/ \
599 + "${EROOT}"/usr/lib* | \
600 + egrep -v \
601 + -e "^${EROOT}/lib.*/(libc|ld)-2.*.so$" \
602 + -e "^${EROOT}/sbin/(ldconfig|sln)$"
603 + )
604 + [[ -z ${files} ]]
605 + if ! eend $? ; then
606 + eerror "Your system still has old SSP __guard symbols. You need to"
607 + eerror "rebuild all the packages that provide these files first:"
608 + eerror "${files}"
609 + die "old __guard detected"
610 + fi
611 + fi
612 +}
613 +
614 +toolchain-glibc_pkg_setup() {
615 + [[ ${EAPI:-0} == [0123] ]] && toolchain-glibc_pkg_pretend
616 +}
617 +
618 +int_to_KV() {
619 + local version=$1 major minor micro
620 + major=$((version / 65536))
621 + minor=$(((version % 65536) / 256))
622 + micro=$((version % 256))
623 + echo ${major}.${minor}.${micro}
624 +}
625 +
626 +eend_KV() {
627 + [[ $(KV_to_int $1) -ge $(KV_to_int $2) ]]
628 + eend $?
629 +}
630 +
631 +get_kheader_version() {
632 + printf '#include <linux/version.h>\nLINUX_VERSION_CODE\n' | \
633 + $(tc-getCPP ${CTARGET}) -I "${EPREFIX}/$(alt_build_headers)" - | \
634 + tail -n 1
635 +}
636 +
637 +check_nptl_support() {
638 + # don't care about the compiler here as we arent using it
639 + just_headers && return
640 +
641 + local run_kv build_kv want_kv
642 + run_kv=$(int_to_KV $(get_KV))
643 + build_kv=$(int_to_KV $(get_kheader_version))
644 + want_kv=${NPTL_KERN_VER}
645 +
646 + ebegin "Checking gcc for __thread support"
647 + if ! eend $(want__thread ; echo $?) ; then
648 + echo
649 + eerror "Could not find a gcc that supports the __thread directive!"
650 + eerror "Please update your binutils/gcc and try again."
651 + die "No __thread support in gcc!"
652 + fi
653 +
654 + if ! is_crosscompile && ! tc-is-cross-compiler ; then
655 + # Building fails on an non-supporting kernel
656 + ebegin "Checking kernel version (${run_kv} >= ${want_kv})"
657 + if ! eend_KV ${run_kv} ${want_kv} ; then
658 + echo
659 + eerror "You need a kernel of at least ${want_kv} for NPTL support!"
660 + die "Kernel version too low!"
661 + fi
662 + fi
663 +
664 + ebegin "Checking linux-headers version (${build_kv} >= ${want_kv})"
665 + if ! eend_KV ${build_kv} ${want_kv} ; then
666 + echo
667 + eerror "You need linux-headers of at least ${want_kv} for NPTL support!"
668 + die "linux-headers version too low!"
669 + fi
670 +}
671 +
672 +unpack_pkg() {
673 + local a=${PN}
674 + [[ -n ${SNAP_VER} ]] && a="${a}-${RELEASE_VER}"
675 + [[ -n $1 ]] && a="${a}-$1"
676 + if [[ -n ${SNAP_VER} ]] ; then
677 + a="${a}-${SNAP_VER}"
678 + else
679 + if [[ -n $2 ]] ; then
680 + a="${a}-$2"
681 + else
682 + a="${a}-${RELEASE_VER}"
683 + fi
684 + fi
685 + if has ${a}.tar.xz ${A} ; then
686 + unpacker ${a}.tar.xz
687 + else
688 + unpack ${a}.tar.bz2
689 + fi
690 + [[ -n $1 ]] && { mv ${a} $1 || die ; }
691 +}
692 +
693 +toolchain-glibc_do_src_unpack() {
694 + # Check NPTL support _before_ we unpack things to save some time
695 + want_nptl && check_nptl_support
696 +
697 + if [[ -n ${EGIT_REPO_URIS} ]] ; then
698 + local i d
699 + for ((i=0; i<${#EGIT_REPO_URIS[@]}; ++i)) ; do
700 + EGIT_REPO_URI=${EGIT_REPO_URIS[$i]}
701 + EGIT_SOURCEDIR=${EGIT_SOURCEDIRS[$i]}
702 + git-2_src_unpack
703 + done
704 + else
705 + unpack_pkg
706 + fi
707 +
708 + cd "${S}"
709 + touch locale/C-translit.h #185476 #218003
710 + [[ -n ${LT_VER} ]] && unpack_pkg linuxthreads ${LT_VER}
711 + [[ -n ${PORTS_VER} ]] && unpack_pkg ports ${PORTS_VER}
712 + [[ -n ${LIBIDN_VER} ]] && unpack_pkg libidn
713 +
714 + if [[ -n ${PATCH_VER} ]] ; then
715 + cd "${WORKDIR}"
716 + unpack glibc-${RELEASE_VER}-patches-${PATCH_VER}.tar.bz2
717 + # pull out all the addons
718 + local d
719 + for d in extra/*/configure ; do
720 + d=${d%/configure}
721 + [[ -d ${S}/${d} ]] && die "${d} already exists in \${S}"
722 + mv "${d}" "${S}" || die "moving ${d} failed"
723 + done
724 + fi
725 +}
726 +
727 +toolchain-glibc_src_unpack() {
728 + setup_env
729 +
730 + toolchain-glibc_do_src_unpack
731 + [[ ${EAPI:-0} == [01] ]] && cd "${S}" && toolchain-glibc_src_prepare
732 +}
733 +
734 +toolchain-glibc_src_prepare() {
735 + # XXX: We should do the branchupdate, before extracting the manpages and
736 + # infopages else it does not help much (mtimes change if there is a change
737 + # to them with branchupdate)
738 + if [[ -n ${BRANCH_UPDATE} ]] ; then
739 + epatch "${DISTDIR}"/glibc-${RELEASE_VER}-branch-update-${BRANCH_UPDATE}.patch.bz2
740 +
741 + # Snapshot date patch
742 + einfo "Patching version to display snapshot date ..."
743 + sed -i -e "s:\(#define RELEASE\).*:\1 \"${BRANCH_UPDATE}\":" version.h
744 + fi
745 +
746 + # tag, glibc is it
747 + if ! version_is_at_least 2.17 ; then
748 + [[ -e csu/Banner ]] && die "need new banner location"
749 + glibc_banner > csu/Banner
750 + fi
751 + if [[ -n ${PATCH_VER} ]] && ! use vanilla ; then
752 + EPATCH_MULTI_MSG="Applying Gentoo Glibc Patchset ${RELEASE_VER}-${PATCH_VER} ..." \
753 + EPATCH_EXCLUDE=${GLIBC_PATCH_EXCLUDE} \
754 + EPATCH_SUFFIX="patch" \
755 + ARCH=$(tc-arch) \
756 + epatch "${WORKDIR}"/patches
757 + fi
758 +
759 + if just_headers ; then
760 + if [[ -e ports/sysdeps/mips/preconfigure ]] ; then
761 + # mips peeps like to screw with us. if building headers,
762 + # we don't have a real compiler, so we can't let them
763 + # insert -mabi on us.
764 + sed -i '/CPPFLAGS=.*-mabi/s|.*|:|' ports/sysdeps/mips/preconfigure || die
765 + find ports/sysdeps/mips/ -name Makefile -exec sed -i '/^CC.*-mabi=/s:-mabi=.*:-D_MIPS_SZPTR=32:' {} +
766 + fi
767 + fi
768 +
769 + epatch_user
770 +
771 + gnuconfig_update
772 +
773 + # Glibc is stupid sometimes, and doesn't realize that with a
774 + # static C-Only gcc, -lgcc_eh doesn't exist.
775 + # https://sourceware.org/ml/libc-alpha/2003-09/msg00100.html
776 + # https://sourceware.org/ml/libc-alpha/2005-02/msg00042.html
777 + # But! Finally fixed in recent versions:
778 + # https://sourceware.org/ml/libc-alpha/2012-05/msg01865.html
779 + if ! version_is_at_least 2.16 ; then
780 + echo 'int main(){}' > "${T}"/gcc_eh_test.c
781 + if ! $(tc-getCC ${CTARGET}) ${CFLAGS} ${LDFLAGS} "${T}"/gcc_eh_test.c -lgcc_eh 2>/dev/null ; then
782 + sed -i -e 's:-lgcc_eh::' Makeconfig || die "sed gcc_eh"
783 + fi
784 + fi
785 +
786 + cd "${WORKDIR}"
787 + find . -type f '(' -size 0 -o -name "*.orig" ')' -delete
788 + find . -name configure -exec touch {} +
789 +
790 + eprefixify extra/locale/locale-gen
791 +
792 + # Fix permissions on some of the scripts.
793 + chmod u+x "${S}"/scripts/*.sh
794 +}
795 +dump_toolchain_settings() {
796 + echo
797 +
798 + einfo "$*"
799 +
800 + local v
801 + for v in ABI CBUILD CHOST CTARGET CBUILD_OPT CTARGET_OPT CC LD {AS,C,CPP,CXX,LD}FLAGS ; do
802 + einfo " $(printf '%15s' ${v}:) ${!v}"
803 + done
804 +
805 + # The glibc configure script doesn't properly use LDFLAGS all the time.
806 + export CC="$(tc-getCC ${CTARGET}) ${LDFLAGS}"
807 + einfo " $(printf '%15s' 'Manual CC:') ${CC}"
808 + echo
809 +}
810 +
811 +glibc_do_configure() {
812 + # Glibc does not work with gold (for various reasons) #269274.
813 + tc-ld-disable-gold
814 +
815 + dump_toolchain_settings "Configuring glibc for $1"
816 +
817 + local myconf=()
818 +
819 + # set addons
820 + pushd "${S}" > /dev/null
821 + local addons=$(echo */configure | sed \
822 + -e 's:/configure::g' \
823 + -e 's:\(linuxthreads\|nptl\|rtkaio\|glibc-compat\)\( \|$\)::g' \
824 + -e 's: \+$::' \
825 + -e 's! !,!g' \
826 + -e 's!^!,!' \
827 + -e '/^,\*$/d')
828 + [[ -d ports ]] && addons+=",ports"
829 + popd > /dev/null
830 +
831 + myconf+=( $(use_enable hardened stackguard-randomization) )
832 + if has_version '<sys-libs/glibc-2.13' ; then
833 + myconf+=( --enable-old-ssp-compat )
834 + fi
835 +
836 + [[ $(tc-is-softfloat) == "yes" ]] && myconf+=( --without-fp )
837 +
838 + if [[ $1 == "linuxthreads" ]] ; then
839 + if want_tls ; then
840 + myconf+=( --with-tls )
841 +
842 + if ! want__thread || use glibc-compat20 || [[ ${LT_KER_VER} == 2.[02].* ]] ; then
843 + myconf+=( --without-__thread )
844 + else
845 + myconf+=( --with-__thread )
846 + fi
847 + else
848 + myconf+=( --without-tls --without-__thread )
849 + fi
850 +
851 + myconf+=( --disable-sanity-checks )
852 + addons="linuxthreads${addons}"
853 + myconf+=( --enable-kernel=${LT_KER_VER} )
854 + elif [[ $1 == "nptl" ]] ; then
855 + # Newer versions require nptl, so there is no addon for it.
856 + version_is_at_least 2.20 || addons="nptl${addons}"
857 + myconf+=( --enable-kernel=${NPTL_KERN_VER} )
858 + else
859 + die "invalid pthread option"
860 + fi
861 + myconf+=( --enable-add-ons="${addons#,}" )
862 +
863 + # Since SELinux support is only required for nscd, only enable it if:
864 + # 1. USE selinux
865 + # 2. only for the primary ABI on multilib systems
866 + # 3. Not a crosscompile
867 + if ! is_crosscompile && use selinux ; then
868 + if use multilib ; then
869 + if is_final_abi ; then
870 + myconf+=( --with-selinux )
871 + else
872 + myconf+=( --without-selinux )
873 + fi
874 + else
875 + myconf+=( --with-selinux )
876 + fi
877 + else
878 + myconf+=( --without-selinux )
879 + fi
880 +
881 + # Force a few tests where we always know the answer but
882 + # configure is incapable of finding it.
883 + if is_crosscompile ; then
884 + export \
885 + libc_cv_c_cleanup=yes \
886 + libc_cv_forced_unwind=yes
887 + fi
888 +
889 + myconf+=(
890 + --without-cvs
891 + --disable-werror
892 + --enable-bind-now
893 + --build=${CBUILD_OPT:-${CBUILD}}
894 + --host=${CTARGET_OPT:-${CTARGET}}
895 + $(use_enable profile)
896 + $(use_with gd)
897 + --with-headers=$(alt_build_headers)
898 + --prefix="${EPREFIX}/usr"
899 + --sysconfdir="${EPREFIX}/etc"
900 + --localstatedir="${EPREFIX}/var"
901 + --libdir='$(prefix)'/$(get_libdir)
902 + --mandir='$(prefix)'/share/man
903 + --infodir='$(prefix)'/share/info
904 + --libexecdir='$(libdir)'/misc/glibc
905 + --with-bugurl=http://bugs.gentoo.org/
906 + --with-pkgversion="$(glibc_banner)"
907 + $(use_multiarch || echo --disable-multi-arch)
908 + $(in_iuse rpc && use_enable rpc obsolete-rpc || echo --enable-obsolete-rpc)
909 + $(in_iuse systemtap && use_enable systemtap)
910 + $(in_iuse nscd && use_enable nscd)
911 + ${EXTRA_ECONF}
912 + )
913 +
914 + # We rely on sys-libs/timezone-data for timezone tools normally.
915 + if version_is_at_least 2.23 ; then
916 + myconf+=( $(use_enable vanilla timezone-tools) )
917 + fi
918 +
919 + # These libs don't have configure flags.
920 + ac_cv_lib_audit_audit_log_user_avc_message=$(in_iuse audit && usex audit || echo no)
921 + ac_cv_lib_cap_cap_init=$(in_iuse caps && usex caps || echo no)
922 +
923 + # There is no configure option for this and we need to export it
924 + # since the glibc build will re-run configure on itself
925 + export libc_cv_rootsbindir="${EPREFIX}/sbin"
926 + export libc_cv_slibdir="${EPREFIX}/$(get_libdir)"
927 +
928 + # We take care of patching our binutils to use both hash styles,
929 + # and many people like to force gnu hash style only, so disable
930 + # this overriding check. #347761
931 + export libc_cv_hashstyle=no
932 +
933 + # Overtime, generating info pages can be painful. So disable this for
934 + # versions older than the latest stable to avoid the issue (this ver
935 + # should be updated from time to time). #464394 #465816
936 + if ! version_is_at_least 2.17 ; then
937 + export ac_cv_prog_MAKEINFO=:
938 + fi
939 +
940 + local builddir=$(builddir "$1")
941 + mkdir -p "${builddir}"
942 + cd "${builddir}"
943 + set -- "${S}"/configure "${myconf[@]}"
944 + echo "$@"
945 + "$@" || die "failed to configure glibc"
946 +
947 + # ia64 static cross-compilers are a pita in so much that they
948 + # can't produce static ELFs (as the libgcc.a is broken). so
949 + # disable building of the programs for those targets if it
950 + # doesn't work.
951 + # XXX: We could turn this into a compiler test, but ia64 is
952 + # the only one that matters, so this should be fine for now.
953 + if is_crosscompile && [[ ${CTARGET} == ia64* ]] ; then
954 + sed -i '1i+link-static = touch $@' config.make
955 + fi
956 +
957 + # If we're trying to migrate between ABI sets, we need
958 + # to lie and use a local copy of gcc. Like if the system
959 + # is built with MULTILIB_ABIS="amd64 x86" but we want to
960 + # add x32 to it, gcc/glibc don't yet support x32.
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 + mkdir -p sunrpc
966 + cp $(which rpcgen) sunrpc/cross-rpcgen || die
967 + touch -t 202001010101 sunrpc/cross-rpcgen || die
968 + fi
969 + fi
970 +}
971 +
972 +toolchain-glibc_headers_configure() {
973 + export ABI=default
974 +
975 + local builddir=$(builddir "headers")
976 + mkdir -p "${builddir}"
977 + cd "${builddir}"
978 +
979 + # if we don't have a compiler yet, we cant really test it now ...
980 + # hopefully they don't affect header geneation, so let's hope for
981 + # the best here ...
982 + local v vars=(
983 + ac_cv_header_cpuid_h=yes
984 + libc_cv_{386,390,alpha,arm,hppa,ia64,mips,{powerpc,sparc}{,32,64},sh,x86_64}_tls=yes
985 + libc_cv_asm_cfi_directives=yes
986 + libc_cv_broken_visibility_attribute=no
987 + libc_cv_c_cleanup=yes
988 + libc_cv_forced_unwind=yes
989 + libc_cv_gcc___thread=yes
990 + libc_cv_mlong_double_128=yes
991 + libc_cv_mlong_double_128ibm=yes
992 + libc_cv_ppc_machine=yes
993 + libc_cv_ppc_rel16=yes
994 + libc_cv_predef_{fortify_source,stack_protector}=no
995 + libc_cv_visibility_attribute=yes
996 + libc_cv_z_combreloc=yes
997 + libc_cv_z_execstack=yes
998 + libc_cv_z_initfirst=yes
999 + libc_cv_z_nodelete=yes
1000 + libc_cv_z_nodlopen=yes
1001 + libc_cv_z_relro=yes
1002 + libc_mips_abi=${ABI}
1003 + libc_mips_float=$([[ $(tc-is-softfloat) == "yes" ]] && echo soft || echo hard)
1004 + # These libs don't have configure flags.
1005 + ac_cv_lib_audit_audit_log_user_avc_message=no
1006 + ac_cv_lib_cap_cap_init=no
1007 + )
1008 + einfo "Forcing cached settings:"
1009 + for v in "${vars[@]}" ; do
1010 + einfo " ${v}"
1011 + export ${v}
1012 + done
1013 +
1014 + # Blow away some random CC settings that screw things up. #550192
1015 + if [[ -d ${S}/sysdeps/mips ]]; then
1016 + pushd "${S}"/sysdeps/mips >/dev/null
1017 + sed -i -e '/^CC +=/s:=.*:= -D_MIPS_SZPTR=32:' mips32/Makefile mips64/n32/Makefile || die
1018 + sed -i -e '/^CC +=/s:=.*:= -D_MIPS_SZPTR=64:' mips64/n64/Makefile || die
1019 + if version_is_at_least 2.21 ; then
1020 + # Force the mips ABI to the default. This is OK because the set of
1021 + # installed headers in this phase is the same between the 3 ABIs.
1022 + # If this ever changes, this hack will break, but that's unlikely
1023 + # as glibc discourages that behavior.
1024 + # https://crbug.com/647033
1025 + sed -i -e 's:abiflag=.*:abiflag=_ABIO32:' preconfigure || die
1026 + fi
1027 + popd >/dev/null
1028 + fi
1029 +
1030 + local myconf=()
1031 + myconf+=(
1032 + --disable-sanity-checks
1033 + --enable-hacker-mode
1034 + --without-cvs
1035 + --disable-werror
1036 + --enable-bind-now
1037 + --build=${CBUILD_OPT:-${CBUILD}}
1038 + --host=${CTARGET_OPT:-${CTARGET}}
1039 + --with-headers=$(alt_build_headers)
1040 + --prefix="${EPREFIX}/usr"
1041 + ${EXTRA_ECONF}
1042 + )
1043 +
1044 + local addons
1045 + [[ -d ${S}/ports ]] && addons+=",ports"
1046 + # Newer versions require nptl, so there is no addon for it.
1047 + version_is_at_least 2.20 || addons+=",nptl"
1048 + myconf+=( --enable-add-ons="${addons#,}" )
1049 +
1050 + # Nothing is compiled here which would affect the headers for the target.
1051 + # So forcing CC/CFLAGS is sane.
1052 + set -- "${S}"/configure "${myconf[@]}"
1053 + echo "$@"
1054 + CC="$(tc-getBUILD_CC)" \
1055 + CFLAGS="-O1 -pipe" \
1056 + CPPFLAGS="-U_FORTIFY_SOURCE" \
1057 + LDFLAGS="" \
1058 + "$@" || die "failed to configure glibc"
1059 +}
1060 +
1061 +toolchain-glibc_do_src_configure() {
1062 + if just_headers ; then
1063 + toolchain-glibc_headers_configure
1064 + else
1065 + want_linuxthreads && glibc_do_configure linuxthreads
1066 + want_nptl && glibc_do_configure nptl
1067 + fi
1068 +}
1069 +
1070 +toolchain-glibc_src_configure() {
1071 + foreach_abi toolchain-glibc_do_src_configure
1072 +}
1073 +
1074 +toolchain-glibc_do_src_compile() {
1075 + local t
1076 + for t in linuxthreads nptl ; do
1077 + if want_${t} ; then
1078 + [[ ${EAPI:-0} == [01] ]] && glibc_do_configure ${t}
1079 + emake -C "$(builddir ${t})" || die "make ${t} for ${ABI} failed"
1080 + fi
1081 + done
1082 +}
1083 +
1084 +toolchain-glibc_src_compile() {
1085 + if just_headers ; then
1086 + [[ ${EAPI:-0} == [01] ]] && toolchain-glibc_headers_configure
1087 + return
1088 + fi
1089 +
1090 + foreach_abi toolchain-glibc_do_src_compile
1091 +}
1092 +
1093 +glibc_src_test() {
1094 + cd "$(builddir $1)"
1095 + nonfatal emake -j1 check && return 0
1096 + einfo "make check failed - re-running with --keep-going to get the rest of the results"
1097 + nonfatal emake -j1 -k check
1098 + ewarn "make check failed for ${ABI}-${CTARGET}-$1"
1099 + return 1
1100 +}
1101 +
1102 +toolchain-glibc_do_src_test() {
1103 + local ret=0 t
1104 + for t in linuxthreads nptl ; do
1105 + if want_${t} ; then
1106 + glibc_src_test ${t}
1107 + : $(( ret |= $? ))
1108 + fi
1109 + done
1110 + return ${ret}
1111 +}
1112 +
1113 +toolchain-glibc_src_test() {
1114 + # Give tests more time to complete.
1115 + export TIMEOUTFACTOR=5
1116 +
1117 + foreach_abi toolchain-glibc_do_src_test || die "tests failed"
1118 +}
1119 +
1120 +toolchain-glibc_do_src_install() {
1121 + local builddir=$(builddir $(want_linuxthreads && echo linuxthreads || echo nptl))
1122 + cd "${builddir}"
1123 +
1124 + emake install_root="${D}$(alt_prefix)" install || die
1125 +
1126 + if want_linuxthreads && want_nptl ; then
1127 + einfo "Installing NPTL to $(alt_libdir)/tls/..."
1128 + cd "$(builddir nptl)"
1129 + dodir $(alt_libdir)/tls $(alt_usrlibdir)/nptl
1130 +
1131 + local l src_lib
1132 + for l in libc libm librt libpthread libthread_db ; do
1133 + # take care of shared lib first ...
1134 + l=${l}.so
1135 + if [[ -e ${l} ]] ; then
1136 + src_lib=${l}
1137 + else
1138 + src_lib=$(eval echo */${l})
1139 + fi
1140 + cp -a ${src_lib} "${ED}"$(alt_libdir)/tls/${l} || die "copying nptl ${l}"
1141 + fperms a+rx $(alt_libdir)/tls/${l}
1142 + dosym ${l} $(alt_libdir)/tls/$(scanelf -qSF'%S#F' ${src_lib})
1143 +
1144 + # then grab the linker script or the symlink ...
1145 + if [[ -L ${ED}$(alt_usrlibdir)/${l} ]] ; then
1146 + dosym $(alt_libdir)/tls/${l} $(alt_usrlibdir)/nptl/${l}
1147 + else
1148 + sed \
1149 + -e "s:/${l}:/tls/${l}:g" \
1150 + -e "s:/${l/%.so/_nonshared.a}:/nptl/${l/%.so/_nonshared.a}:g" \
1151 + "${ED}"$(alt_usrlibdir)/${l} > "${ED}"$(alt_usrlibdir)/nptl/${l}
1152 + fi
1153 +
1154 + # then grab the static lib ...
1155 + src_lib=${src_lib/%.so/.a}
1156 + [[ ! -e ${src_lib} ]] && src_lib=${src_lib/%.a/_pic.a}
1157 + cp -a ${src_lib} "${ED}"$(alt_usrlibdir)/nptl/ || die "copying nptl ${src_lib}"
1158 + src_lib=${src_lib/%.a/_nonshared.a}
1159 + if [[ -e ${src_lib} ]] ; then
1160 + cp -a ${src_lib} "${ED}"$(alt_usrlibdir)/nptl/ || die "copying nptl ${src_lib}"
1161 + fi
1162 + done
1163 +
1164 + # use the nptl linker instead of the linuxthreads one as the linuxthreads
1165 + # one may lack TLS support and that can be really bad for business
1166 + cp -a elf/ld.so "${ED}"$(alt_libdir)/$(scanelf -qSF'%S#F' elf/ld.so) || die "copying nptl interp"
1167 + fi
1168 +
1169 + # Newer versions get fancy with libm linkage to include vectorized support.
1170 + # While we don't really need a ldscript here, portage QA checks get upset.
1171 + if [[ -e ${ED}$(alt_usrlibdir)/libm-${PV}.a ]] ; then
1172 + dosym ../../$(get_libdir)/libm-${PV}.so $(alt_usrlibdir)/libm-${PV}.so
1173 + fi
1174 +
1175 + # We'll take care of the cache ourselves
1176 + rm -f "${ED}"/etc/ld.so.cache
1177 +
1178 + # Everything past this point just needs to be done once ...
1179 + is_final_abi || return 0
1180 +
1181 + # Make sure the non-native interp can be found on multilib systems even
1182 + # if the main library set isn't installed into the right place. Maybe
1183 + # we should query the active gcc for info instead of hardcoding it ?
1184 + local i ldso_abi ldso_name
1185 + local ldso_abi_list=(
1186 + # x86
1187 + amd64 /lib64/ld-linux-x86-64.so.2
1188 + x32 /libx32/ld-linux-x32.so.2
1189 + x86 /lib/ld-linux.so.2
1190 + # mips
1191 + o32 /lib/ld.so.1
1192 + n32 /lib32/ld.so.1
1193 + n64 /lib64/ld.so.1
1194 + # powerpc
1195 + ppc /lib/ld.so.1
1196 + ppc64 /lib64/ld64.so.1
1197 + # s390
1198 + s390 /lib/ld.so.1
1199 + s390x /lib/ld64.so.1
1200 + # sparc
1201 + sparc32 /lib/ld-linux.so.2
1202 + sparc64 /lib64/ld-linux.so.2
1203 + )
1204 + case $(tc-endian) in
1205 + little)
1206 + ldso_abi_list+=(
1207 + # arm
1208 + arm64 /lib/ld-linux-aarch64.so.1
1209 + )
1210 + ;;
1211 + big)
1212 + ldso_abi_list+=(
1213 + # arm
1214 + arm64 /lib/ld-linux-aarch64_be.so.1
1215 + )
1216 + ;;
1217 + esac
1218 + if [[ ${SYMLINK_LIB} == "yes" ]] && [[ ! -e ${ED}/$(alt_prefix)/lib ]] ; then
1219 + dosym $(get_abi_LIBDIR ${DEFAULT_ABI}) $(alt_prefix)/lib
1220 + fi
1221 + for (( i = 0; i < ${#ldso_abi_list[@]}; i += 2 )) ; do
1222 + ldso_abi=${ldso_abi_list[i]}
1223 + has ${ldso_abi} $(get_install_abis) || continue
1224 +
1225 + ldso_name="$(alt_prefix)${ldso_abi_list[i+1]}"
1226 + if [[ ! -L ${ED}/${ldso_name} && ! -e ${ED}/${ldso_name} ]] ; then
1227 + dosym ../$(get_abi_LIBDIR ${ldso_abi})/${ldso_name##*/} ${ldso_name}
1228 + fi
1229 + done
1230 +
1231 + # With devpts under Linux mounted properly, we do not need the pt_chown
1232 + # binary to be setuid. This is because the default owners/perms will be
1233 + # exactly what we want.
1234 + if in_iuse suid && ! use suid ; then
1235 + find "${ED}" -name pt_chown -exec chmod -s {} +
1236 + fi
1237 +
1238 + #################################################################
1239 + # EVERYTHING AFTER THIS POINT IS FOR NATIVE GLIBC INSTALLS ONLY #
1240 + # Make sure we install some symlink hacks so that when we build
1241 + # a 2nd stage cross-compiler, gcc finds the target system
1242 + # headers correctly. See gcc/doc/gccinstall.info
1243 + if is_crosscompile ; then
1244 + # We need to make sure that /lib and /usr/lib always exists.
1245 + # gcc likes to use relative paths to get to its multilibs like
1246 + # /usr/lib/../lib64/. So while we don't install any files into
1247 + # /usr/lib/, we do need it to exist.
1248 + cd "${ED}"$(alt_libdir)/..
1249 + [[ -e lib ]] || mkdir lib
1250 + cd "${ED}"$(alt_usrlibdir)/..
1251 + [[ -e lib ]] || mkdir lib
1252 +
1253 + dosym usr/include $(alt_prefix)/sys-include
1254 + return 0
1255 + fi
1256 +
1257 + # Files for Debian-style locale updating
1258 + dodir /usr/share/i18n
1259 + sed \
1260 + -e "/^#/d" \
1261 + -e "/SUPPORTED-LOCALES=/d" \
1262 + -e "s: \\\\::g" -e "s:/: :g" \
1263 + "${S}"/localedata/SUPPORTED > "${ED}"/usr/share/i18n/SUPPORTED \
1264 + || die "generating /usr/share/i18n/SUPPORTED failed"
1265 + cd "${WORKDIR}"/extra/locale
1266 + dosbin locale-gen || die
1267 + doman *.[0-8]
1268 + insinto /etc
1269 + doins locale.gen || die
1270 +
1271 + # Make sure all the ABI's can find the locales and so we only
1272 + # have to generate one set
1273 + local a
1274 + keepdir /usr/$(get_libdir)/locale
1275 + for a in $(get_install_abis) ; do
1276 + if [[ ! -e ${ED}/usr/$(get_abi_LIBDIR ${a})/locale ]] ; then
1277 + dosym /usr/$(get_libdir)/locale /usr/$(get_abi_LIBDIR ${a})/locale
1278 + fi
1279 + done
1280 +
1281 + cd "${S}"
1282 +
1283 + # Install misc network config files
1284 + insinto /etc
1285 + doins nscd/nscd.conf posix/gai.conf nss/nsswitch.conf || die
1286 + doins "${WORKDIR}"/extra/etc/*.conf || die
1287 +
1288 + if ! in_iuse nscd || use nscd ; then
1289 + doinitd "${WORKDIR}"/extra/etc/nscd || die
1290 +
1291 + local nscd_args=(
1292 + -e "s:@PIDFILE@:$(strings "${ED}"/usr/sbin/nscd | grep nscd.pid):"
1293 + )
1294 + version_is_at_least 2.16 || nscd_args+=( -e 's: --foreground : :' )
1295 + sed -i "${nscd_args[@]}" "${ED}"/etc/init.d/nscd
1296 +
1297 + # Newer versions of glibc include the nscd.service themselves.
1298 + # TODO: Drop the $FILESDIR copy once 2.19 goes stable.
1299 + if version_is_at_least 2.19 ; then
1300 + systemd_dounit nscd/nscd.service || die
1301 + systemd_newtmpfilesd nscd/nscd.tmpfiles nscd.conf || die
1302 + else
1303 + systemd_dounit "${FILESDIR}"/nscd.service || die
1304 + systemd_newtmpfilesd "${FILESDIR}"/nscd.tmpfilesd nscd.conf || die
1305 + fi
1306 + else
1307 + # Do this since extra/etc/*.conf above might have nscd.conf.
1308 + rm -f "${ED}"/etc/nscd.conf
1309 + fi
1310 +
1311 + echo 'LDPATH="include ld.so.conf.d/*.conf"' > "${T}"/00glibc
1312 + doenvd "${T}"/00glibc || die
1313 +
1314 + for d in BUGS ChangeLog* CONFORMANCE FAQ NEWS NOTES PROJECTS README* ; do
1315 + [[ -s ${d} ]] && dodoc ${d}
1316 + done
1317 +
1318 + # Prevent overwriting of the /etc/localtime symlink. We'll handle the
1319 + # creation of the "factory" symlink in pkg_postinst().
1320 + rm -f "${ED}"/etc/localtime
1321 +}
1322 +
1323 +toolchain-glibc_headers_install() {
1324 + local builddir=$(builddir "headers")
1325 + cd "${builddir}"
1326 + emake install_root="${D}$(alt_prefix)" install-headers || die
1327 + if ! version_is_at_least 2.16 ; then
1328 + insinto $(alt_headers)/bits
1329 + doins bits/stdio_lim.h || die
1330 + fi
1331 + insinto $(alt_headers)/gnu
1332 + doins "${S}"/include/gnu/stubs.h || die "doins include gnu"
1333 + # Make sure we install the sys-include symlink so that when
1334 + # we build a 2nd stage cross-compiler, gcc finds the target
1335 + # system headers correctly. See gcc/doc/gccinstall.info
1336 + dosym usr/include $(alt_prefix)/sys-include
1337 +}
1338 +
1339 +src_strip() {
1340 + # gdb is lame and requires some debugging information to remain in
1341 + # libpthread, so we need to strip it by hand. libthread_db makes no
1342 + # sense stripped as it is only used when debugging.
1343 + local pthread=$(has splitdebug ${FEATURES} && echo "libthread_db" || echo "lib{pthread,thread_db}")
1344 + env \
1345 + -uRESTRICT \
1346 + CHOST=${CTARGET} \
1347 + STRIP_MASK="/*/{,tls/}${pthread}*" \
1348 + prepallstrip
1349 + # if user has stripping enabled and does not have split debug turned on,
1350 + # then leave the debugging sections in libpthread.
1351 + if ! has nostrip ${FEATURES} && ! has splitdebug ${FEATURES} ; then
1352 + ${STRIP:-${CTARGET}-strip} --strip-debug "${ED}"/*/libpthread-*.so
1353 + fi
1354 +}
1355 +
1356 +toolchain-glibc_src_install() {
1357 + if just_headers ; then
1358 + export ABI=default
1359 + toolchain-glibc_headers_install
1360 + return
1361 + fi
1362 +
1363 + foreach_abi toolchain-glibc_do_src_install
1364 + src_strip
1365 +}
1366 +
1367 +# Simple test to make sure our new glibc isnt completely broken.
1368 +# Make sure we don't test with statically built binaries since
1369 +# they will fail. Also, skip if this glibc is a cross compiler.
1370 +#
1371 +# If coreutils is built with USE=multicall, some of these files
1372 +# will just be wrapper scripts, not actual ELFs we can test.
1373 +glibc_sanity_check() {
1374 + cd / #228809
1375 +
1376 + # We enter ${ED} so to avoid trouble if the path contains
1377 + # special characters; for instance if the path contains the
1378 + # colon character (:), then the linker will try to split it
1379 + # and look for the libraries in an unexpected place. This can
1380 + # lead to unsafe code execution if the generated prefix is
1381 + # within a world-writable directory.
1382 + # (e.g. /var/tmp/portage:${HOSTNAME})
1383 + pushd "${ED}"/$(get_libdir) >/dev/null
1384 +
1385 + local x striptest
1386 + for x in cal date env free ls true uname uptime ; do
1387 + x=$(type -p ${x})
1388 + [[ -z ${x} || ${x} != ${EPREFIX}/* ]] && continue
1389 + striptest=$(LC_ALL="C" file -L ${x} 2>/dev/null) || continue
1390 + case ${striptest} in
1391 + *"statically linked"*) continue;;
1392 + *"ASCII text"*) continue;;
1393 + esac
1394 + # We need to clear the locale settings as the upgrade might want
1395 + # incompatible locale data. This test is not for verifying that.
1396 + LC_ALL=C \
1397 + ./ld-*.so --library-path . ${x} > /dev/null \
1398 + || die "simple run test (${x}) failed"
1399 + done
1400 +
1401 + popd >/dev/null
1402 +}
1403 +
1404 +toolchain-glibc_pkg_preinst() {
1405 + # nothing to do if just installing headers
1406 + just_headers && return
1407 +
1408 + # prepare /etc/ld.so.conf.d/ for files
1409 + mkdir -p "${EROOT}"/etc/ld.so.conf.d
1410 +
1411 + # Default /etc/hosts.conf:multi to on for systems with small dbs.
1412 + if [[ $(wc -l < "${EROOT}"/etc/hosts) -lt 1000 ]] ; then
1413 + sed -i '/^multi off/s:off:on:' "${ED}"/etc/host.conf
1414 + elog "Defaulting /etc/host.conf:multi to on"
1415 + fi
1416 +
1417 + [[ ${ROOT} != "/" ]] && return 0
1418 + [[ -d ${ED}/$(get_libdir) ]] || return 0
1419 + [[ -z ${BOOTSTRAP_RAP} ]] && glibc_sanity_check
1420 +
1421 + # For newer EAPIs, this was run in pkg_pretend.
1422 + if [[ ${EAPI:-0} == [0123] ]] ; then
1423 + check_devpts
1424 + fi
1425 +}
1426 +
1427 +toolchain-glibc_pkg_postinst() {
1428 + # nothing to do if just installing headers
1429 + just_headers && return
1430 +
1431 + if ! tc-is-cross-compiler && [[ -x ${EROOT}/usr/sbin/iconvconfig ]] ; then
1432 + # Generate fastloading iconv module configuration file.
1433 + "${EROOT}"/usr/sbin/iconvconfig --prefix="${ROOT}"
1434 + fi
1435 +
1436 + if ! is_crosscompile && [[ ${ROOT} == "/" ]] ; then
1437 + # Reload init ... if in a chroot or a diff init package, ignore
1438 + # errors from this step #253697
1439 + /sbin/telinit U 2>/dev/null
1440 +
1441 + # if the host locales.gen contains no entries, we'll install everything
1442 + local locale_list="${EROOT}etc/locale.gen"
1443 + if [[ -z $(locale-gen --list --config "${locale_list}") ]] ; then
1444 + ewarn "Generating all locales; edit /etc/locale.gen to save time/space"
1445 + locale_list="${EROOT}usr/share/i18n/SUPPORTED"
1446 + fi
1447 + locale-gen -j $(makeopts_jobs) --config "${locale_list}"
1448 + fi
1449 +}
1450 +
1451 +_TOOLCHAIN_GLIBC_ECLASS=1
1452 +fi
1453 diff --git a/sys-libs/glibc/files/eblits/common.eblit b/sys-libs/glibc/files/eblits/common.eblit
1454 deleted file mode 100644
1455 index 53121eff5730..000000000000
1456 --- a/sys-libs/glibc/files/eblits/common.eblit
1457 +++ /dev/null
1458 @@ -1,380 +0,0 @@
1459 -# Copyright 1999-2015 Gentoo Foundation
1460 -# Distributed under the terms of the GNU General Public License v2
1461 -
1462 -alt_prefix() {
1463 - is_crosscompile && echo /usr/${CTARGET}
1464 -}
1465 -
1466 -if [[ ${EAPI:-0} == [012] ]] ; then
1467 - : ${ED:=${D}}
1468 - : ${EROOT:=${ROOT}}
1469 -fi
1470 -# This indirection is for binpkgs. #523332
1471 -_nonfatal() { nonfatal "$@" ; }
1472 -if [[ ${EAPI:-0} == [0123] ]] ; then
1473 - nonfatal() { "$@" ; }
1474 - _nonfatal() { "$@" ; }
1475 -fi
1476 -
1477 -# We need to be able to set alternative headers for
1478 -# compiling for non-native platform
1479 -# Will also become useful for testing kernel-headers without screwing up
1480 -# the whole system.
1481 -# note: intentionally undocumented.
1482 -alt_headers() {
1483 - echo ${ALT_HEADERS:=$(alt_prefix)/usr/include}
1484 -}
1485 -alt_build_headers() {
1486 - if [[ -z ${ALT_BUILD_HEADERS} ]] ; then
1487 - ALT_BUILD_HEADERS="${EPREFIX}$(alt_headers)"
1488 - if tc-is-cross-compiler ; then
1489 - ALT_BUILD_HEADERS=${SYSROOT}$(alt_headers)
1490 - if [[ ! -e ${ALT_BUILD_HEADERS}/linux/version.h ]] ; then
1491 - local header_path=$(echo '#include <linux/version.h>' | $(tc-getCPP ${CTARGET}) ${CFLAGS} 2>&1 | grep -o '[^"]*linux/version.h')
1492 - ALT_BUILD_HEADERS=${header_path%/linux/version.h}
1493 - fi
1494 - fi
1495 - fi
1496 - echo "${ALT_BUILD_HEADERS}"
1497 -}
1498 -
1499 -alt_libdir() {
1500 - echo $(alt_prefix)/$(get_libdir)
1501 -}
1502 -alt_usrlibdir() {
1503 - echo $(alt_prefix)/usr/$(get_libdir)
1504 -}
1505 -
1506 -builddir() {
1507 - echo "${WORKDIR}/build-${ABI}-${CTARGET}-$1"
1508 -}
1509 -
1510 -setup_target_flags() {
1511 - # This largely mucks with compiler flags. None of which should matter
1512 - # when building up just the headers.
1513 - just_headers && return 0
1514 -
1515 - case $(tc-arch) in
1516 - x86)
1517 - # -march needed for #185404 #199334
1518 - # TODO: When creating the first glibc cross-compile, this test will
1519 - # always fail as it does a full link which in turn requires glibc.
1520 - # Probably also applies when changing multilib profile settings (e.g.
1521 - # enabling x86 when the profile was amd64-only previously).
1522 - # We could change main to _start and pass -nostdlib here so that we
1523 - # only test the gcc code compilation. Or we could do a compile and
1524 - # then look for the symbol via scanelf.
1525 - 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
1526 - local t=${CTARGET_OPT:-${CTARGET}}
1527 - t=${t%%-*}
1528 - filter-flags '-march=*'
1529 - export CFLAGS="-march=${t} ${CFLAGS}"
1530 - einfo "Auto adding -march=${t} to CFLAGS #185404"
1531 - fi
1532 - ;;
1533 - amd64)
1534 - # -march needed for #185404 #199334
1535 - # Note: This test only matters when the x86 ABI is enabled, so we could
1536 - # optimize a bit and elide it.
1537 - # TODO: See cross-compile issues listed above for x86.
1538 - 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
1539 - local t=${CTARGET_OPT:-${CTARGET}}
1540 - t=${t%%-*}
1541 - # Normally the target is x86_64-xxx, so turn that into the -march that
1542 - # gcc actually accepts. #528708
1543 - [[ ${t} == "x86_64" ]] && t="x86-64"
1544 - filter-flags '-march=*'
1545 - # ugly, ugly, ugly. ugly.
1546 - CFLAGS_x86=$(CFLAGS=${CFLAGS_x86} filter-flags '-march=*'; echo "${CFLAGS}")
1547 - export CFLAGS_x86="${CFLAGS_x86} -march=${t}"
1548 - einfo "Auto adding -march=${t} to CFLAGS_x86 #185404"
1549 - fi
1550 - ;;
1551 - mips)
1552 - # The mips abi cannot support the GNU style hashes. #233233
1553 - filter-ldflags -Wl,--hash-style=gnu -Wl,--hash-style=both
1554 - ;;
1555 - ppc)
1556 - append-flags "-freorder-blocks"
1557 - ;;
1558 - sparc)
1559 - # Both sparc and sparc64 can use -fcall-used-g6. -g7 is bad, though.
1560 - filter-flags "-fcall-used-g7"
1561 - append-flags "-fcall-used-g6"
1562 -
1563 - # If the CHOST is the basic one (e.g. not sparcv9-xxx already),
1564 - # try to pick a better one so glibc can use cpu-specific .S files.
1565 - # We key off the CFLAGS to get a good value. Also need to handle
1566 - # version skew.
1567 - # We can't force users to set their CHOST to their exact machine
1568 - # as many of these are not recognized by config.sub/gcc and such :(.
1569 - # Note: If the mcpu values don't scale, we might try probing CPP defines.
1570 - # Note: Should we factor in -Wa,-AvXXX flags too ? Or -mvis/etc... ?
1571 -
1572 - local cpu
1573 - case ${CTARGET} in
1574 - sparc64-*)
1575 - case $(get-flag mcpu) in
1576 - niagara[234])
1577 - if version_is_at_least 2.8 ; then
1578 - cpu="sparc64v2"
1579 - elif version_is_at_least 2.4 ; then
1580 - cpu="sparc64v"
1581 - elif version_is_at_least 2.2.3 ; then
1582 - cpu="sparc64b"
1583 - fi
1584 - ;;
1585 - niagara)
1586 - if version_is_at_least 2.4 ; then
1587 - cpu="sparc64v"
1588 - elif version_is_at_least 2.2.3 ; then
1589 - cpu="sparc64b"
1590 - fi
1591 - ;;
1592 - ultrasparc3)
1593 - cpu="sparc64b"
1594 - ;;
1595 - *)
1596 - # We need to force at least v9a because the base build doesn't
1597 - # work with just v9.
1598 - # https://sourceware.org/bugzilla/show_bug.cgi?id=19477
1599 - [[ -z ${cpu} ]] && append-flags "-Wa,-xarch=v9a"
1600 - ;;
1601 - esac
1602 - ;;
1603 - sparc-*)
1604 - case $(get-flag mcpu) in
1605 - niagara[234])
1606 - if version_is_at_least 2.8 ; then
1607 - cpu="sparcv9v2"
1608 - elif version_is_at_least 2.4 ; then
1609 - cpu="sparcv9v"
1610 - elif version_is_at_least 2.2.3 ; then
1611 - cpu="sparcv9b"
1612 - else
1613 - cpu="sparcv9"
1614 - fi
1615 - ;;
1616 - niagara)
1617 - if version_is_at_least 2.4 ; then
1618 - cpu="sparcv9v"
1619 - elif version_is_at_least 2.2.3 ; then
1620 - cpu="sparcv9b"
1621 - else
1622 - cpu="sparcv9"
1623 - fi
1624 - ;;
1625 - ultrasparc3)
1626 - cpu="sparcv9b"
1627 - ;;
1628 - v9|ultrasparc)
1629 - cpu="sparcv9"
1630 - ;;
1631 - v8|supersparc|hypersparc|leon|leon3)
1632 - cpu="sparcv8"
1633 - ;;
1634 - esac
1635 - ;;
1636 - esac
1637 - [[ -n ${cpu} ]] && CTARGET_OPT="${cpu}-${CTARGET#*-}"
1638 - ;;
1639 - esac
1640 -}
1641 -
1642 -setup_flags() {
1643 - # Make sure host make.conf doesn't pollute us
1644 - if is_crosscompile || tc-is-cross-compiler ; then
1645 - CHOST=${CTARGET} strip-unsupported-flags
1646 - fi
1647 -
1648 - # Store our CFLAGS because it's changed depending on which CTARGET
1649 - # we are building when pulling glibc on a multilib profile
1650 - CFLAGS_BASE=${CFLAGS_BASE-${CFLAGS}}
1651 - CFLAGS=${CFLAGS_BASE}
1652 - CXXFLAGS_BASE=${CXXFLAGS_BASE-${CXXFLAGS}}
1653 - CXXFLAGS=${CXXFLAGS_BASE}
1654 - ASFLAGS_BASE=${ASFLAGS_BASE-${ASFLAGS}}
1655 - ASFLAGS=${ASFLAGS_BASE}
1656 -
1657 - # Over-zealous CFLAGS can often cause problems. What may work for one
1658 - # person may not work for another. To avoid a large influx of bugs
1659 - # relating to failed builds, we strip most CFLAGS out to ensure as few
1660 - # problems as possible.
1661 - strip-flags
1662 - strip-unsupported-flags
1663 - filter-flags -m32 -m64 -mabi=*
1664 -
1665 - # Bug 492892.
1666 - filter-flags -frecord-gcc-switches
1667 -
1668 - unset CBUILD_OPT CTARGET_OPT
1669 - if use multilib ; then
1670 - CTARGET_OPT=$(get_abi_CTARGET)
1671 - [[ -z ${CTARGET_OPT} ]] && CTARGET_OPT=$(get_abi_CHOST)
1672 - fi
1673 -
1674 - setup_target_flags
1675 -
1676 - if [[ -n ${CTARGET_OPT} && ${CBUILD} == ${CHOST} ]] && ! is_crosscompile; then
1677 - CBUILD_OPT=${CTARGET_OPT}
1678 - fi
1679 -
1680 - # Lock glibc at -O2 -- linuxthreads needs it and we want to be
1681 - # conservative here. -fno-strict-aliasing is to work around #155906
1682 - filter-flags -O?
1683 - append-flags -O2 -fno-strict-aliasing
1684 -
1685 - # Can't build glibc itself with fortify code. Newer versions add
1686 - # this flag for us, so no need to do it manually.
1687 - version_is_at_least 2.16 ${PV} || append-cppflags -U_FORTIFY_SOURCE
1688 -
1689 - # building glibc with SSP is fraught with difficulty, especially
1690 - # due to __stack_chk_fail_local which would mean significant changes
1691 - # to the glibc build process. See bug #94325 #293721
1692 - # Note we have to handle both user-given CFLAGS and gcc defaults via
1693 - # spec rules here. We can't simply add -fno-stack-protector as it gets
1694 - # added before user flags, and we can't just filter-flags because
1695 - # _filter_hardened doesn't support globs.
1696 - filter-flags -fstack-protector*
1697 - gcc-specs-ssp && append-flags $(test-flags -fno-stack-protector)
1698 -
1699 - if use hardened && gcc-specs-pie ; then
1700 - # Force PIC macro definition for all compilations since they're all
1701 - # either -fPIC or -fPIE with the default-PIE compiler.
1702 - append-cppflags -DPIC
1703 - else
1704 - # Don't build -fPIE without the default-PIE compiler and the
1705 - # hardened-pie patch
1706 - filter-flags -fPIE
1707 - fi
1708 -}
1709 -
1710 -want_nptl() {
1711 - [[ -z ${LT_VER} ]] && return 0
1712 - want_tls || return 1
1713 - use nptl || return 1
1714 -
1715 - # Older versions of glibc had incomplete arch support for nptl.
1716 - # But if you're building those now, you can handle USE=nptl yourself.
1717 - return 0
1718 -}
1719 -
1720 -want_linuxthreads() {
1721 - [[ -z ${LT_VER} ]] && return 1
1722 - use linuxthreads
1723 -}
1724 -
1725 -want_tls() {
1726 - # Archs that can use TLS (Thread Local Storage)
1727 - case $(tc-arch) in
1728 - x86)
1729 - # requires i486 or better #106556
1730 - [[ ${CTARGET} == i[4567]86* ]] && return 0
1731 - return 1
1732 - ;;
1733 - esac
1734 -
1735 - return 0
1736 -}
1737 -
1738 -want__thread() {
1739 - want_tls || return 1
1740 -
1741 - # For some reason --with-tls --with__thread is causing segfaults on sparc32.
1742 - [[ ${PROFILE_ARCH} == "sparc" ]] && return 1
1743 -
1744 - [[ -n ${WANT__THREAD} ]] && return ${WANT__THREAD}
1745 -
1746 - # only test gcc -- cant test linking yet
1747 - tc-has-tls -c ${CTARGET}
1748 - WANT__THREAD=$?
1749 -
1750 - return ${WANT__THREAD}
1751 -}
1752 -
1753 -use_multiarch() {
1754 - # Make sure binutils is new enough to support indirect functions #336792
1755 - # This funky sed supports gold and bfd linkers.
1756 - local bver nver
1757 - bver=$($(tc-getLD ${CTARGET}) -v | sed -n -r '1{s:[^0-9]*::;s:^([0-9.]*).*:\1:;p}')
1758 - case $(tc-arch ${CTARGET}) in
1759 - amd64|x86) nver="2.20" ;;
1760 - arm) nver="2.22" ;;
1761 - hppa) nver="2.23" ;;
1762 - ppc|ppc64) nver="2.20" ;;
1763 - # ifunc was added in 2.23, but glibc also needs machinemode which is in 2.24.
1764 - s390) nver="2.24" ;;
1765 - sparc) nver="2.21" ;;
1766 - *) return 1 ;;
1767 - esac
1768 - version_is_at_least ${nver} ${bver}
1769 -}
1770 -
1771 -# Setup toolchain variables that had historically
1772 -# been defined in the profiles for these archs.
1773 -setup_env() {
1774 - # silly users
1775 - unset LD_RUN_PATH
1776 - unset LD_ASSUME_KERNEL
1777 -
1778 - if is_crosscompile || tc-is-cross-compiler ; then
1779 - multilib_env ${CTARGET_OPT:-${CTARGET}}
1780 -
1781 - if ! use multilib ; then
1782 - MULTILIB_ABIS=${DEFAULT_ABI}
1783 - else
1784 - MULTILIB_ABIS=${MULTILIB_ABIS:-${DEFAULT_ABI}}
1785 - fi
1786 -
1787 - # If the user has CFLAGS_<CTARGET> in their make.conf, use that,
1788 - # and fall back on CFLAGS.
1789 - local VAR=CFLAGS_${CTARGET//[-.]/_}
1790 - CFLAGS=${!VAR-${CFLAGS}}
1791 - fi
1792 -
1793 - setup_flags
1794 -
1795 - export ABI=${ABI:-${DEFAULT_ABI:-default}}
1796 -
1797 - local VAR=CFLAGS_${ABI}
1798 - # We need to export CFLAGS with abi information in them because glibc's
1799 - # configure script checks CFLAGS for some targets (like mips). Keep
1800 - # around the original clean value to avoid appending multiple ABIs on
1801 - # top of each other.
1802 - : ${__GLIBC_CC:=$(tc-getCC ${CTARGET_OPT:-${CTARGET}})}
1803 - export __GLIBC_CC CC="${__GLIBC_CC} ${!VAR}"
1804 -}
1805 -
1806 -foreach_abi() {
1807 - setup_env
1808 -
1809 - local ret=0
1810 - local abilist=""
1811 - if use multilib ; then
1812 - abilist=$(get_install_abis)
1813 - else
1814 - abilist=${DEFAULT_ABI}
1815 - fi
1816 - evar_push ABI
1817 - export ABI
1818 - for ABI in ${abilist:-default} ; do
1819 - setup_env
1820 - einfo "Running $1 for ABI ${ABI}"
1821 - $1
1822 - : $(( ret |= $? ))
1823 - done
1824 - evar_pop
1825 - return ${ret}
1826 -}
1827 -
1828 -just_headers() {
1829 - is_crosscompile && use crosscompile_opts_headers-only
1830 -}
1831 -
1832 -glibc_banner() {
1833 - local b="Gentoo ${PVR}"
1834 - [[ -n ${SNAP_VER} ]] && b+=" snapshot ${SNAP_VER}"
1835 - [[ -n ${BRANCH_UPDATE} ]] && b+=" branch ${BRANCH_UPDATE}"
1836 - [[ -n ${PATCH_VER} ]] && ! use vanilla && b+=" p${PATCH_VER}"
1837 - echo "${b}"
1838 -}
1839 diff --git a/sys-libs/glibc/files/eblits/pkg_postinst.eblit b/sys-libs/glibc/files/eblits/pkg_postinst.eblit
1840 deleted file mode 100644
1841 index 4887aede7548..000000000000
1842 --- a/sys-libs/glibc/files/eblits/pkg_postinst.eblit
1843 +++ /dev/null
1844 @@ -1,26 +0,0 @@
1845 -# Copyright 1999-2012 Gentoo Foundation
1846 -# Distributed under the terms of the GNU General Public License v2
1847 -
1848 -eblit-glibc-pkg_postinst() {
1849 - # nothing to do if just installing headers
1850 - just_headers && return
1851 -
1852 - if ! tc-is-cross-compiler && [[ -x ${EROOT}/usr/sbin/iconvconfig ]] ; then
1853 - # Generate fastloading iconv module configuration file.
1854 - "${EROOT}"/usr/sbin/iconvconfig --prefix="${ROOT}"
1855 - fi
1856 -
1857 - if ! is_crosscompile && [[ ${ROOT} == "/" ]] ; then
1858 - # Reload init ... if in a chroot or a diff init package, ignore
1859 - # errors from this step #253697
1860 - /sbin/telinit U 2>/dev/null
1861 -
1862 - # if the host locales.gen contains no entries, we'll install everything
1863 - local locale_list="${EROOT}etc/locale.gen"
1864 - if [[ -z $(locale-gen --list --config "${locale_list}") ]] ; then
1865 - ewarn "Generating all locales; edit /etc/locale.gen to save time/space"
1866 - locale_list="${EROOT}usr/share/i18n/SUPPORTED"
1867 - fi
1868 - locale-gen -j $(makeopts_jobs) --config "${locale_list}"
1869 - fi
1870 -}
1871 diff --git a/sys-libs/glibc/files/eblits/pkg_preinst.eblit b/sys-libs/glibc/files/eblits/pkg_preinst.eblit
1872 deleted file mode 100644
1873 index 0a2e84fdc3ce..000000000000
1874 --- a/sys-libs/glibc/files/eblits/pkg_preinst.eblit
1875 +++ /dev/null
1876 @@ -1,62 +0,0 @@
1877 -# Copyright 1999-2017 Gentoo Foundation
1878 -# Distributed under the terms of the GNU General Public License v2
1879 -
1880 -# Simple test to make sure our new glibc isnt completely broken.
1881 -# Make sure we don't test with statically built binaries since
1882 -# they will fail. Also, skip if this glibc is a cross compiler.
1883 -#
1884 -# If coreutils is built with USE=multicall, some of these files
1885 -# will just be wrapper scripts, not actual ELFs we can test.
1886 -glibc_sanity_check() {
1887 - cd / #228809
1888 -
1889 - # We enter ${ED} so to avoid trouble if the path contains
1890 - # special characters; for instance if the path contains the
1891 - # colon character (:), then the linker will try to split it
1892 - # and look for the libraries in an unexpected place. This can
1893 - # lead to unsafe code execution if the generated prefix is
1894 - # within a world-writable directory.
1895 - # (e.g. /var/tmp/portage:${HOSTNAME})
1896 - pushd "${ED}"/$(get_libdir) >/dev/null
1897 -
1898 - local x striptest
1899 - for x in cal date env free ls true uname uptime ; do
1900 - x=$(type -p ${x})
1901 - [[ -z ${x} || ${x} != ${EPREFIX}/* ]] && continue
1902 - striptest=$(LC_ALL="C" file -L ${x} 2>/dev/null) || continue
1903 - case ${striptest} in
1904 - *"statically linked"*) continue;;
1905 - *"ASCII text"*) continue;;
1906 - esac
1907 - # We need to clear the locale settings as the upgrade might want
1908 - # incompatible locale data. This test is not for verifying that.
1909 - LC_ALL=C \
1910 - ./ld-*.so --library-path . ${x} > /dev/null \
1911 - || die "simple run test (${x}) failed"
1912 - done
1913 -
1914 - popd >/dev/null
1915 -}
1916 -
1917 -eblit-glibc-pkg_preinst() {
1918 - # nothing to do if just installing headers
1919 - just_headers && return
1920 -
1921 - # prepare /etc/ld.so.conf.d/ for files
1922 - mkdir -p "${EROOT}"/etc/ld.so.conf.d
1923 -
1924 - # Default /etc/hosts.conf:multi to on for systems with small dbs.
1925 - if [[ $(wc -l < "${EROOT}"/etc/hosts) -lt 1000 ]] ; then
1926 - sed -i '/^multi off/s:off:on:' "${ED}"/etc/host.conf
1927 - elog "Defaulting /etc/host.conf:multi to on"
1928 - fi
1929 -
1930 - [[ ${ROOT} != "/" ]] && return 0
1931 - [[ -d ${ED}/$(get_libdir) ]] || return 0
1932 - [[ -z ${BOOTSTRAP_RAP} ]] && glibc_sanity_check
1933 -
1934 - # For newer EAPIs, this was run in pkg_pretend.
1935 - if [[ ${EAPI:-0} == [0123] ]] ; then
1936 - check_devpts
1937 - fi
1938 -}
1939 diff --git a/sys-libs/glibc/files/eblits/pkg_pretend.eblit b/sys-libs/glibc/files/eblits/pkg_pretend.eblit
1940 deleted file mode 100644
1941 index 73a3daa0ad77..000000000000
1942 --- a/sys-libs/glibc/files/eblits/pkg_pretend.eblit
1943 +++ /dev/null
1944 @@ -1,158 +0,0 @@
1945 -# Copyright 1999-2015 Gentoo Foundation
1946 -# Distributed under the terms of the GNU General Public License v2
1947 -
1948 -glibc_compile_test() {
1949 - local ret save_cflags=${CFLAGS}
1950 - CFLAGS+=" $1"
1951 - shift
1952 -
1953 - pushd "${T}" >/dev/null
1954 -
1955 - rm -f glibc-test*
1956 - printf '%b' "$*" > glibc-test.c
1957 -
1958 - _nonfatal emake -s glibc-test
1959 - ret=$?
1960 -
1961 - popd >/dev/null
1962 -
1963 - CFLAGS=${save_cflags}
1964 - return ${ret}
1965 -}
1966 -
1967 -glibc_run_test() {
1968 - local ret
1969 -
1970 - if [[ ${EMERGE_FROM} == "binary" ]] ; then
1971 - # ignore build failures when installing a binary package #324685
1972 - glibc_compile_test "" "$@" 2>/dev/null || return 0
1973 - else
1974 - if ! glibc_compile_test "" "$@" ; then
1975 - ewarn "Simple build failed ... assuming this is desired #324685"
1976 - return 0
1977 - fi
1978 - fi
1979 -
1980 - pushd "${T}" >/dev/null
1981 -
1982 - ./glibc-test
1983 - ret=$?
1984 - rm -f glibc-test*
1985 -
1986 - popd >/dev/null
1987 -
1988 - return ${ret}
1989 -}
1990 -
1991 -check_devpts() {
1992 - # Make sure devpts is mounted correctly for use w/out setuid pt_chown.
1993 -
1994 - # If merely building the binary package, then there's nothing to verify.
1995 - [[ ${MERGE_TYPE} == "buildonly" ]] && return
1996 -
1997 - # Only sanity check when installing the native glibc.
1998 - [[ ${ROOT} != "/" ]] && return
1999 -
2000 - # Older versions always installed setuid, so no need to check.
2001 - in_iuse suid || return
2002 -
2003 - # If they're opting in to the old suid code, then no need to check.
2004 - use suid && return
2005 -
2006 - if awk '$3 == "devpts" && $4 ~ /[, ]gid=5[, ]/ { exit 1 }' /proc/mounts ; then
2007 - eerror "In order to use glibc with USE=-suid, you must make sure that"
2008 - eerror "you have devpts mounted at /dev/pts with the gid=5 option."
2009 - eerror "Openrc should do this for you, so you should check /etc/fstab"
2010 - eerror "and make sure you do not have any invalid settings there."
2011 - # Do not die on older kernels as devpts did not export these settings #489520.
2012 - if version_is_at_least 2.6.25 $(uname -r) ; then
2013 - die "mount & fix your /dev/pts settings"
2014 - fi
2015 - fi
2016 -}
2017 -
2018 -eblit-glibc-pkg_pretend() {
2019 - # For older EAPIs, this is run in pkg_preinst.
2020 - if [[ ${EAPI:-0} != [0123] ]] ; then
2021 - check_devpts
2022 - fi
2023 -
2024 - # Prevent native builds from downgrading.
2025 - if [[ ${MERGE_TYPE} != "buildonly" ]] && \
2026 - [[ ${ROOT} == "/" ]] && \
2027 - [[ ${CBUILD} == ${CHOST} ]] && \
2028 - [[ ${CHOST} == ${CTARGET} ]] ; then
2029 - # The high rev # is to allow people to downgrade between -r# versions.
2030 - # We want to block 2.20->2.19, but 2.20-r3->2.20-r2 should be fine.
2031 - # Hopefully we never actually use a r# this high.
2032 - if has_version ">${CATEGORY}/${P}-r10000" ; then
2033 - eerror "Sanity check to keep you from breaking your system:"
2034 - eerror " Downgrading glibc is not supported and a sure way to destruction"
2035 - die "aborting to save your system"
2036 - fi
2037 -
2038 - if ! glibc_run_test '#include <pwd.h>\nint main(){return getpwuid(0)==0;}\n'
2039 - then
2040 - eerror "Your patched vendor kernel is broken. You need to get an"
2041 - eerror "update from whoever is providing the kernel to you."
2042 - eerror "https://sourceware.org/bugzilla/show_bug.cgi?id=5227"
2043 - eerror "http://bugs.gentoo.org/262698"
2044 - die "keeping your system alive, say thank you"
2045 - fi
2046 -
2047 - if ! glibc_run_test '#include <unistd.h>\n#include <sys/syscall.h>\nint main(){return syscall(1000)!=-1;}\n'
2048 - then
2049 - eerror "Your old kernel is broken. You need to update it to"
2050 - eerror "a newer version as syscall(<bignum>) will break."
2051 - eerror "http://bugs.gentoo.org/279260"
2052 - die "keeping your system alive, say thank you"
2053 - fi
2054 - fi
2055 -
2056 - # users have had a chance to phase themselves, time to give em the boot
2057 - if [[ -e ${EROOT}/etc/locale.gen ]] && [[ -e ${EROOT}/etc/locales.build ]] ; then
2058 - eerror "You still haven't deleted ${EROOT}/etc/locales.build."
2059 - eerror "Do so now after making sure ${EROOT}/etc/locale.gen is kosher."
2060 - die "lazy upgrader detected"
2061 - fi
2062 -
2063 - if [[ ${CTARGET} == i386-* ]] ; then
2064 - eerror "i386 CHOSTs are no longer supported."
2065 - eerror "Chances are you don't actually want/need i386."
2066 - eerror "Please read http://www.gentoo.org/doc/en/change-chost.xml"
2067 - die "please fix your CHOST"
2068 - fi
2069 -
2070 - if [[ -e /proc/xen ]] && [[ $(tc-arch) == "x86" ]] && ! is-flag -mno-tls-direct-seg-refs ; then
2071 - ewarn "You are using Xen but don't have -mno-tls-direct-seg-refs in your CFLAGS."
2072 - ewarn "This will result in a 50% performance penalty when running with a 32bit"
2073 - ewarn "hypervisor, which is probably not what you want."
2074 - fi
2075 -
2076 - use hardened && ! gcc-specs-pie && \
2077 - ewarn "PIE hardening not applied, as your compiler doesn't default to PIE"
2078 -
2079 - # Make sure host system is up to date #394453
2080 - if has_version '<sys-libs/glibc-2.13' && \
2081 - [[ -n $(scanelf -qys__guard -F'#s%F' "${EROOT}"/lib*/l*-*.so) ]]
2082 - then
2083 - ebegin "Scanning system for __guard to see if you need to rebuild first ..."
2084 - local files=$(
2085 - scanelf -qys__guard -F'#s%F' \
2086 - "${EROOT}"/*bin/ \
2087 - "${EROOT}"/lib* \
2088 - "${EROOT}"/usr/*bin/ \
2089 - "${EROOT}"/usr/lib* | \
2090 - egrep -v \
2091 - -e "^${EROOT}/lib.*/(libc|ld)-2.*.so$" \
2092 - -e "^${EROOT}/sbin/(ldconfig|sln)$"
2093 - )
2094 - [[ -z ${files} ]]
2095 - if ! eend $? ; then
2096 - eerror "Your system still has old SSP __guard symbols. You need to"
2097 - eerror "rebuild all the packages that provide these files first:"
2098 - eerror "${files}"
2099 - die "old __guard detected"
2100 - fi
2101 - fi
2102 -}
2103 diff --git a/sys-libs/glibc/files/eblits/pkg_setup.eblit b/sys-libs/glibc/files/eblits/pkg_setup.eblit
2104 deleted file mode 100644
2105 index e2955a893fe2..000000000000
2106 --- a/sys-libs/glibc/files/eblits/pkg_setup.eblit
2107 +++ /dev/null
2108 @@ -1,8 +0,0 @@
2109 -# Copyright 1999-2015 Gentoo Foundation
2110 -# Distributed under the terms of the GNU General Public License v2
2111 -
2112 -[[ ${EAPI:-0} == [0123] ]] && source "${FILESDIR}/eblits/pkg_pretend.eblit"
2113 -
2114 -eblit-glibc-pkg_setup() {
2115 - [[ ${EAPI:-0} == [0123] ]] && eblit-glibc-pkg_pretend
2116 -}
2117 diff --git a/sys-libs/glibc/files/eblits/src_compile.eblit b/sys-libs/glibc/files/eblits/src_compile.eblit
2118 deleted file mode 100644
2119 index f145466d7acc..000000000000
2120 --- a/sys-libs/glibc/files/eblits/src_compile.eblit
2121 +++ /dev/null
2122 @@ -1,23 +0,0 @@
2123 -# Copyright 1999-2014 Gentoo Foundation
2124 -# Distributed under the terms of the GNU General Public License v2
2125 -
2126 -[[ ${EAPI:-0} == [01] ]] && source "${FILESDIR}/eblits/src_configure.eblit"
2127 -
2128 -toolchain-glibc_src_compile() {
2129 - local t
2130 - for t in linuxthreads nptl ; do
2131 - if want_${t} ; then
2132 - [[ ${EAPI:-0} == [01] ]] && glibc_do_configure ${t}
2133 - emake -C "$(builddir ${t})" || die "make ${t} for ${ABI} failed"
2134 - fi
2135 - done
2136 -}
2137 -
2138 -eblit-glibc-src_compile() {
2139 - if just_headers ; then
2140 - [[ ${EAPI:-0} == [01] ]] && toolchain-glibc_headers_configure
2141 - return
2142 - fi
2143 -
2144 - foreach_abi toolchain-glibc_src_compile
2145 -}
2146 diff --git a/sys-libs/glibc/files/eblits/src_configure.eblit b/sys-libs/glibc/files/eblits/src_configure.eblit
2147 deleted file mode 100644
2148 index eae853f4441b..000000000000
2149 --- a/sys-libs/glibc/files/eblits/src_configure.eblit
2150 +++ /dev/null
2151 @@ -1,281 +0,0 @@
2152 -# Copyright 1999-2015 Gentoo Foundation
2153 -# Distributed under the terms of the GNU General Public License v2
2154 -
2155 -dump_toolchain_settings() {
2156 - echo
2157 -
2158 - einfo "$*"
2159 -
2160 - local v
2161 - for v in ABI CBUILD CHOST CTARGET CBUILD_OPT CTARGET_OPT CC LD {AS,C,CPP,CXX,LD}FLAGS ; do
2162 - einfo " $(printf '%15s' ${v}:) ${!v}"
2163 - done
2164 -
2165 - # The glibc configure script doesn't properly use LDFLAGS all the time.
2166 - export CC="$(tc-getCC ${CTARGET}) ${LDFLAGS}"
2167 - einfo " $(printf '%15s' 'Manual CC:') ${CC}"
2168 - echo
2169 -}
2170 -
2171 -glibc_do_configure() {
2172 - # Glibc does not work with gold (for various reasons) #269274.
2173 - tc-ld-disable-gold
2174 -
2175 - dump_toolchain_settings "Configuring glibc for $1"
2176 -
2177 - local myconf=()
2178 -
2179 - # set addons
2180 - pushd "${S}" > /dev/null
2181 - local addons=$(echo */configure | sed \
2182 - -e 's:/configure::g' \
2183 - -e 's:\(linuxthreads\|nptl\|rtkaio\|glibc-compat\)\( \|$\)::g' \
2184 - -e 's: \+$::' \
2185 - -e 's! !,!g' \
2186 - -e 's!^!,!' \
2187 - -e '/^,\*$/d')
2188 - [[ -d ports ]] && addons+=",ports"
2189 - popd > /dev/null
2190 -
2191 - myconf+=( $(use_enable hardened stackguard-randomization) )
2192 - if has_version '<sys-libs/glibc-2.13' ; then
2193 - myconf+=( --enable-old-ssp-compat )
2194 - fi
2195 -
2196 - [[ $(tc-is-softfloat) == "yes" ]] && myconf+=( --without-fp )
2197 -
2198 - if [[ $1 == "linuxthreads" ]] ; then
2199 - if want_tls ; then
2200 - myconf+=( --with-tls )
2201 -
2202 - if ! want__thread || use glibc-compat20 || [[ ${LT_KER_VER} == 2.[02].* ]] ; then
2203 - myconf+=( --without-__thread )
2204 - else
2205 - myconf+=( --with-__thread )
2206 - fi
2207 - else
2208 - myconf+=( --without-tls --without-__thread )
2209 - fi
2210 -
2211 - myconf+=( --disable-sanity-checks )
2212 - addons="linuxthreads${addons}"
2213 - myconf+=( --enable-kernel=${LT_KER_VER} )
2214 - elif [[ $1 == "nptl" ]] ; then
2215 - # Newer versions require nptl, so there is no addon for it.
2216 - version_is_at_least 2.20 || addons="nptl${addons}"
2217 - myconf+=( --enable-kernel=${NPTL_KERN_VER} )
2218 - else
2219 - die "invalid pthread option"
2220 - fi
2221 - myconf+=( --enable-add-ons="${addons#,}" )
2222 -
2223 - # Since SELinux support is only required for nscd, only enable it if:
2224 - # 1. USE selinux
2225 - # 2. only for the primary ABI on multilib systems
2226 - # 3. Not a crosscompile
2227 - if ! is_crosscompile && use selinux ; then
2228 - if use multilib ; then
2229 - if is_final_abi ; then
2230 - myconf+=( --with-selinux )
2231 - else
2232 - myconf+=( --without-selinux )
2233 - fi
2234 - else
2235 - myconf+=( --with-selinux )
2236 - fi
2237 - else
2238 - myconf+=( --without-selinux )
2239 - fi
2240 -
2241 - # Force a few tests where we always know the answer but
2242 - # configure is incapable of finding it.
2243 - if is_crosscompile ; then
2244 - export \
2245 - libc_cv_c_cleanup=yes \
2246 - libc_cv_forced_unwind=yes
2247 - fi
2248 -
2249 - myconf+=(
2250 - --without-cvs
2251 - --disable-werror
2252 - --enable-bind-now
2253 - --build=${CBUILD_OPT:-${CBUILD}}
2254 - --host=${CTARGET_OPT:-${CTARGET}}
2255 - $(use_enable profile)
2256 - $(use_with gd)
2257 - --with-headers=$(alt_build_headers)
2258 - --prefix="${EPREFIX}/usr"
2259 - --sysconfdir="${EPREFIX}/etc"
2260 - --localstatedir="${EPREFIX}/var"
2261 - --libdir='$(prefix)'/$(get_libdir)
2262 - --mandir='$(prefix)'/share/man
2263 - --infodir='$(prefix)'/share/info
2264 - --libexecdir='$(libdir)'/misc/glibc
2265 - --with-bugurl=http://bugs.gentoo.org/
2266 - --with-pkgversion="$(glibc_banner)"
2267 - $(use_multiarch || echo --disable-multi-arch)
2268 - $(in_iuse rpc && use_enable rpc obsolete-rpc || echo --enable-obsolete-rpc)
2269 - $(in_iuse systemtap && use_enable systemtap)
2270 - $(in_iuse nscd && use_enable nscd)
2271 - ${EXTRA_ECONF}
2272 - )
2273 -
2274 - # We rely on sys-libs/timezone-data for timezone tools normally.
2275 - if version_is_at_least 2.23 ; then
2276 - myconf+=( $(use_enable vanilla timezone-tools) )
2277 - fi
2278 -
2279 - # These libs don't have configure flags.
2280 - ac_cv_lib_audit_audit_log_user_avc_message=$(in_iuse audit && usex audit || echo no)
2281 - ac_cv_lib_cap_cap_init=$(in_iuse caps && usex caps || echo no)
2282 -
2283 - # There is no configure option for this and we need to export it
2284 - # since the glibc build will re-run configure on itself
2285 - export libc_cv_rootsbindir="${EPREFIX}/sbin"
2286 - export libc_cv_slibdir="${EPREFIX}/$(get_libdir)"
2287 -
2288 - # We take care of patching our binutils to use both hash styles,
2289 - # and many people like to force gnu hash style only, so disable
2290 - # this overriding check. #347761
2291 - export libc_cv_hashstyle=no
2292 -
2293 - # Overtime, generating info pages can be painful. So disable this for
2294 - # versions older than the latest stable to avoid the issue (this ver
2295 - # should be updated from time to time). #464394 #465816
2296 - if ! version_is_at_least 2.17 ; then
2297 - export ac_cv_prog_MAKEINFO=:
2298 - fi
2299 -
2300 - local builddir=$(builddir "$1")
2301 - mkdir -p "${builddir}"
2302 - cd "${builddir}"
2303 - set -- "${S}"/configure "${myconf[@]}"
2304 - echo "$@"
2305 - "$@" || die "failed to configure glibc"
2306 -
2307 - # ia64 static cross-compilers are a pita in so much that they
2308 - # can't produce static ELFs (as the libgcc.a is broken). so
2309 - # disable building of the programs for those targets if it
2310 - # doesn't work.
2311 - # XXX: We could turn this into a compiler test, but ia64 is
2312 - # the only one that matters, so this should be fine for now.
2313 - if is_crosscompile && [[ ${CTARGET} == ia64* ]] ; then
2314 - sed -i '1i+link-static = touch $@' config.make
2315 - fi
2316 -
2317 - # If we're trying to migrate between ABI sets, we need
2318 - # to lie and use a local copy of gcc. Like if the system
2319 - # is built with MULTILIB_ABIS="amd64 x86" but we want to
2320 - # add x32 to it, gcc/glibc don't yet support x32.
2321 - if [[ -n ${GCC_BOOTSTRAP_VER} ]] && use multilib ; then
2322 - echo 'main(){}' > "${T}"/test.c
2323 - if ! $(tc-getCC ${CTARGET}) ${CFLAGS} ${LDFLAGS} "${T}"/test.c -Wl,-emain -lgcc 2>/dev/null ; then
2324 - sed -i -e '/^CC = /s:$: -B$(objdir)/../'"gcc-${GCC_BOOTSTRAP_VER}/${ABI}:" config.make || die
2325 - mkdir -p sunrpc
2326 - cp $(which rpcgen) sunrpc/cross-rpcgen || die
2327 - touch -t 202001010101 sunrpc/cross-rpcgen || die
2328 - fi
2329 - fi
2330 -}
2331 -
2332 -toolchain-glibc_headers_configure() {
2333 - export ABI=default
2334 -
2335 - local builddir=$(builddir "headers")
2336 - mkdir -p "${builddir}"
2337 - cd "${builddir}"
2338 -
2339 - # if we don't have a compiler yet, we cant really test it now ...
2340 - # hopefully they don't affect header geneation, so let's hope for
2341 - # the best here ...
2342 - local v vars=(
2343 - ac_cv_header_cpuid_h=yes
2344 - libc_cv_{386,390,alpha,arm,hppa,ia64,mips,{powerpc,sparc}{,32,64},sh,x86_64}_tls=yes
2345 - libc_cv_asm_cfi_directives=yes
2346 - libc_cv_broken_visibility_attribute=no
2347 - libc_cv_c_cleanup=yes
2348 - libc_cv_forced_unwind=yes
2349 - libc_cv_gcc___thread=yes
2350 - libc_cv_mlong_double_128=yes
2351 - libc_cv_mlong_double_128ibm=yes
2352 - libc_cv_ppc_machine=yes
2353 - libc_cv_ppc_rel16=yes
2354 - libc_cv_predef_{fortify_source,stack_protector}=no
2355 - libc_cv_visibility_attribute=yes
2356 - libc_cv_z_combreloc=yes
2357 - libc_cv_z_execstack=yes
2358 - libc_cv_z_initfirst=yes
2359 - libc_cv_z_nodelete=yes
2360 - libc_cv_z_nodlopen=yes
2361 - libc_cv_z_relro=yes
2362 - libc_mips_abi=${ABI}
2363 - libc_mips_float=$([[ $(tc-is-softfloat) == "yes" ]] && echo soft || echo hard)
2364 - # These libs don't have configure flags.
2365 - ac_cv_lib_audit_audit_log_user_avc_message=no
2366 - ac_cv_lib_cap_cap_init=no
2367 - )
2368 - einfo "Forcing cached settings:"
2369 - for v in "${vars[@]}" ; do
2370 - einfo " ${v}"
2371 - export ${v}
2372 - done
2373 -
2374 - # Blow away some random CC settings that screw things up. #550192
2375 - if [[ -d ${S}/sysdeps/mips ]]; then
2376 - pushd "${S}"/sysdeps/mips >/dev/null
2377 - sed -i -e '/^CC +=/s:=.*:= -D_MIPS_SZPTR=32:' mips32/Makefile mips64/n32/Makefile || die
2378 - sed -i -e '/^CC +=/s:=.*:= -D_MIPS_SZPTR=64:' mips64/n64/Makefile || die
2379 - if version_is_at_least 2.21 ; then
2380 - # Force the mips ABI to the default. This is OK because the set of
2381 - # installed headers in this phase is the same between the 3 ABIs.
2382 - # If this ever changes, this hack will break, but that's unlikely
2383 - # as glibc discourages that behavior.
2384 - # https://crbug.com/647033
2385 - sed -i -e 's:abiflag=.*:abiflag=_ABIO32:' preconfigure || die
2386 - fi
2387 - popd >/dev/null
2388 - fi
2389 -
2390 - local myconf=()
2391 - myconf+=(
2392 - --disable-sanity-checks
2393 - --enable-hacker-mode
2394 - --without-cvs
2395 - --disable-werror
2396 - --enable-bind-now
2397 - --build=${CBUILD_OPT:-${CBUILD}}
2398 - --host=${CTARGET_OPT:-${CTARGET}}
2399 - --with-headers=$(alt_build_headers)
2400 - --prefix="${EPREFIX}/usr"
2401 - ${EXTRA_ECONF}
2402 - )
2403 -
2404 - local addons
2405 - [[ -d ${S}/ports ]] && addons+=",ports"
2406 - # Newer versions require nptl, so there is no addon for it.
2407 - version_is_at_least 2.20 || addons+=",nptl"
2408 - myconf+=( --enable-add-ons="${addons#,}" )
2409 -
2410 - # Nothing is compiled here which would affect the headers for the target.
2411 - # So forcing CC/CFLAGS is sane.
2412 - set -- "${S}"/configure "${myconf[@]}"
2413 - echo "$@"
2414 - CC="$(tc-getBUILD_CC)" \
2415 - CFLAGS="-O1 -pipe" \
2416 - CPPFLAGS="-U_FORTIFY_SOURCE" \
2417 - LDFLAGS="" \
2418 - "$@" || die "failed to configure glibc"
2419 -}
2420 -
2421 -toolchain-glibc_src_configure() {
2422 - if just_headers ; then
2423 - toolchain-glibc_headers_configure
2424 - else
2425 - want_linuxthreads && glibc_do_configure linuxthreads
2426 - want_nptl && glibc_do_configure nptl
2427 - fi
2428 -}
2429 -
2430 -eblit-glibc-src_configure() {
2431 - foreach_abi toolchain-glibc_src_configure
2432 -}
2433 diff --git a/sys-libs/glibc/files/eblits/src_install.eblit b/sys-libs/glibc/files/eblits/src_install.eblit
2434 deleted file mode 100644
2435 index 7d6fb7f43930..000000000000
2436 --- a/sys-libs/glibc/files/eblits/src_install.eblit
2437 +++ /dev/null
2438 @@ -1,249 +0,0 @@
2439 -# Copyright 1999-2014 Gentoo Foundation
2440 -# Distributed under the terms of the GNU General Public License v2
2441 -
2442 -toolchain-glibc_src_install() {
2443 - local builddir=$(builddir $(want_linuxthreads && echo linuxthreads || echo nptl))
2444 - cd "${builddir}"
2445 -
2446 - emake install_root="${D}$(alt_prefix)" install || die
2447 -
2448 - if want_linuxthreads && want_nptl ; then
2449 - einfo "Installing NPTL to $(alt_libdir)/tls/..."
2450 - cd "$(builddir nptl)"
2451 - dodir $(alt_libdir)/tls $(alt_usrlibdir)/nptl
2452 -
2453 - local l src_lib
2454 - for l in libc libm librt libpthread libthread_db ; do
2455 - # take care of shared lib first ...
2456 - l=${l}.so
2457 - if [[ -e ${l} ]] ; then
2458 - src_lib=${l}
2459 - else
2460 - src_lib=$(eval echo */${l})
2461 - fi
2462 - cp -a ${src_lib} "${ED}"$(alt_libdir)/tls/${l} || die "copying nptl ${l}"
2463 - fperms a+rx $(alt_libdir)/tls/${l}
2464 - dosym ${l} $(alt_libdir)/tls/$(scanelf -qSF'%S#F' ${src_lib})
2465 -
2466 - # then grab the linker script or the symlink ...
2467 - if [[ -L ${ED}$(alt_usrlibdir)/${l} ]] ; then
2468 - dosym $(alt_libdir)/tls/${l} $(alt_usrlibdir)/nptl/${l}
2469 - else
2470 - sed \
2471 - -e "s:/${l}:/tls/${l}:g" \
2472 - -e "s:/${l/%.so/_nonshared.a}:/nptl/${l/%.so/_nonshared.a}:g" \
2473 - "${ED}"$(alt_usrlibdir)/${l} > "${ED}"$(alt_usrlibdir)/nptl/${l}
2474 - fi
2475 -
2476 - # then grab the static lib ...
2477 - src_lib=${src_lib/%.so/.a}
2478 - [[ ! -e ${src_lib} ]] && src_lib=${src_lib/%.a/_pic.a}
2479 - cp -a ${src_lib} "${ED}"$(alt_usrlibdir)/nptl/ || die "copying nptl ${src_lib}"
2480 - src_lib=${src_lib/%.a/_nonshared.a}
2481 - if [[ -e ${src_lib} ]] ; then
2482 - cp -a ${src_lib} "${ED}"$(alt_usrlibdir)/nptl/ || die "copying nptl ${src_lib}"
2483 - fi
2484 - done
2485 -
2486 - # use the nptl linker instead of the linuxthreads one as the linuxthreads
2487 - # one may lack TLS support and that can be really bad for business
2488 - cp -a elf/ld.so "${ED}"$(alt_libdir)/$(scanelf -qSF'%S#F' elf/ld.so) || die "copying nptl interp"
2489 - fi
2490 -
2491 - # Newer versions get fancy with libm linkage to include vectorized support.
2492 - # While we don't really need a ldscript here, portage QA checks get upset.
2493 - if [[ -e ${ED}$(alt_usrlibdir)/libm-${PV}.a ]] ; then
2494 - dosym ../../$(get_libdir)/libm-${PV}.so $(alt_usrlibdir)/libm-${PV}.so
2495 - fi
2496 -
2497 - # We'll take care of the cache ourselves
2498 - rm -f "${ED}"/etc/ld.so.cache
2499 -
2500 - # Everything past this point just needs to be done once ...
2501 - is_final_abi || return 0
2502 -
2503 - # Make sure the non-native interp can be found on multilib systems even
2504 - # if the main library set isn't installed into the right place. Maybe
2505 - # we should query the active gcc for info instead of hardcoding it ?
2506 - local i ldso_abi ldso_name
2507 - local ldso_abi_list=(
2508 - # x86
2509 - amd64 /lib64/ld-linux-x86-64.so.2
2510 - x32 /libx32/ld-linux-x32.so.2
2511 - x86 /lib/ld-linux.so.2
2512 - # mips
2513 - o32 /lib/ld.so.1
2514 - n32 /lib32/ld.so.1
2515 - n64 /lib64/ld.so.1
2516 - # powerpc
2517 - ppc /lib/ld.so.1
2518 - ppc64 /lib64/ld64.so.1
2519 - # s390
2520 - s390 /lib/ld.so.1
2521 - s390x /lib/ld64.so.1
2522 - # sparc
2523 - sparc32 /lib/ld-linux.so.2
2524 - sparc64 /lib64/ld-linux.so.2
2525 - )
2526 - case $(tc-endian) in
2527 - little)
2528 - ldso_abi_list+=(
2529 - # arm
2530 - arm64 /lib/ld-linux-aarch64.so.1
2531 - )
2532 - ;;
2533 - big)
2534 - ldso_abi_list+=(
2535 - # arm
2536 - arm64 /lib/ld-linux-aarch64_be.so.1
2537 - )
2538 - ;;
2539 - esac
2540 - if [[ ${SYMLINK_LIB} == "yes" ]] && [[ ! -e ${ED}/$(alt_prefix)/lib ]] ; then
2541 - dosym $(get_abi_LIBDIR ${DEFAULT_ABI}) $(alt_prefix)/lib
2542 - fi
2543 - for (( i = 0; i < ${#ldso_abi_list[@]}; i += 2 )) ; do
2544 - ldso_abi=${ldso_abi_list[i]}
2545 - has ${ldso_abi} $(get_install_abis) || continue
2546 -
2547 - ldso_name="$(alt_prefix)${ldso_abi_list[i+1]}"
2548 - if [[ ! -L ${ED}/${ldso_name} && ! -e ${ED}/${ldso_name} ]] ; then
2549 - dosym ../$(get_abi_LIBDIR ${ldso_abi})/${ldso_name##*/} ${ldso_name}
2550 - fi
2551 - done
2552 -
2553 - # With devpts under Linux mounted properly, we do not need the pt_chown
2554 - # binary to be setuid. This is because the default owners/perms will be
2555 - # exactly what we want.
2556