Gentoo Archives: gentoo-commits

From: "Andreas K. Hüttel" <dilfridge@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-libs/glibc/
Date: Tue, 05 Jul 2022 04:12:44
Message-Id: 1656994347.386e65695cf6804a315f1a5f01e7ec29a7faf4b9.dilfridge@gentoo
1 commit: 386e65695cf6804a315f1a5f01e7ec29a7faf4b9
2 Author: Andreas K. Hüttel <dilfridge <AT> gentoo <DOT> org>
3 AuthorDate: Tue Jul 5 04:11:46 2022 +0000
4 Commit: Andreas K. Hüttel <dilfridge <AT> gentoo <DOT> org>
5 CommitDate: Tue Jul 5 04:12:27 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=386e6569
7
8 sys-libs/glibc: 2.35 patchset bump, untested, no keywords
9
10 Signed-off-by: Andreas K. Hüttel <dilfridge <AT> gentoo.org>
11
12 sys-libs/glibc/Manifest | 1 +
13 sys-libs/glibc/glibc-2.35-r8.ebuild | 1604 +++++++++++++++++++++++++++++++++++
14 2 files changed, 1605 insertions(+)
15
16 diff --git a/sys-libs/glibc/Manifest b/sys-libs/glibc/Manifest
17 index 83ff9fc22d84..3ba78c344c4b 100644
18 --- a/sys-libs/glibc/Manifest
19 +++ b/sys-libs/glibc/Manifest
20 @@ -20,6 +20,7 @@ DIST glibc-2.35-loongarch-patches-20220522.tar.xz 44728 BLAKE2B 09e7a061f3269ebd
21 DIST glibc-2.35-patches-6.tar.xz 57236 BLAKE2B a03845733e2f0ebe179523458695963d729b4211b4ce14310d55163cd33aff502f9e14a4bb0068410777e9b9bb5be4ef7ad1a1fd51debf9191dcf89dc9ff08b8 SHA512 59c5e1669677e969873f5bba38958316a3b32523cac628b97513aed864e191da10499edac77bb5e9a07179d14cf3c75073fd03e8427f7bcfd68fedcedc35083e
22 DIST glibc-2.35-patches-7.tar.xz 163840 BLAKE2B 55352eeaf70f74fd8fcd21bd7f3ba14121b496dcfb59e06b5a73be36838dda4b39fc22201c4320c0c38a454c7f1539aae7f3307107e460bede25be33c0525c11 SHA512 d39bb2fecad8cd9213c61e279823f89c3daf9a4f630ac71503df2e9bfb74e019c996bed9a93aaad89083a729a1d3792e7ed8313ac54d757f47d5614ac3469e59
23 DIST glibc-2.35-patches-8.tar.xz 178384 BLAKE2B 89ca0ab51f60a25b0d0c00e619f35e71cb18f1794f3656c5e10d87e41f461c43aca51e40f3d8375014d485100098e18f333d3f99888e062f54e632eabd6ebc31 SHA512 cb0945eda142eebb71315b0fcf570e9410acce3b1153fdc3a9148151a7a37624d4cfb91d06ecf20b4045c70051d4c297f0f58f57ba56d9b0a4304b6b7ce2783f
24 +DIST glibc-2.35-patches-9.tar.xz 183612 BLAKE2B 921664953ed39560ab850754209dbda1f71fbcc5bcc9ec21c187385ea659b90ea055e60961eca266ab3cc81213ed04747aa925dd96a352676fa19d2e63306968 SHA512 24c9ecb6ad890c95bc0e7db3e0c1f20768c728ac0590450fad05aed578623bc33d256d2c4d14a8d8e5c5e9fed7acfab3683053d236f51886cd5a6de93f925ddc
25 DIST glibc-2.35.tar.xz 18165952 BLAKE2B 623c728884f070cd87ffeb9203f74206197c52405ac9bc44f3dd519a3468b8e8ae2536c883e5d17d94417dbd1e91775de2e674314e4ff7424f9720026d6b7063 SHA512 e7336ce27561be5d7c217832a1136fb327e057bd8d3f92925b35c97e3e9f9e486948b5a1e03e5e4090772ef06437a074d10b82e68f17f1ad8f22077ee39e1b66
26 DIST glibc-systemd-20210729.tar.gz 1480 BLAKE2B 37722c7579df782d890e44dbab99c3de52ab466eb9de80d82405e9bb5620bf39ffc8c5f466a435bdb86ef6d36dd7019c0736573916bda6c67d02a2581e0ec979 SHA512 efd75af58b50522c28cdac7abd1fc56555bc1bb042512c90d8340c1ec09c5791b3872a305bf83723252bbde5855b75d958c041083457765c4cfd170732d09238
27 DIST glibc-systemd-20210814.tar.gz 1469 BLAKE2B 10fa7bcb46d4fdce9c0ab353cbd30871e9b09a347a13a9c9a3b5777f931aa3c826c158d2e49532c604d4a834f2fab4089b67495fb88d0398945dc50d45ad9ef1 SHA512 5346a9ea459a1e6ccf665389f2a294de1e16f1e3e05cdf07e3dd99ed0e4f6f8b52cc333d4bff3c75ac90ab6ce70cd4ab2b3e126f920ce7979abd6dda56315efc
28
29 diff --git a/sys-libs/glibc/glibc-2.35-r8.ebuild b/sys-libs/glibc/glibc-2.35-r8.ebuild
30 new file mode 100644
31 index 000000000000..5310e14a026f
32 --- /dev/null
33 +++ b/sys-libs/glibc/glibc-2.35-r8.ebuild
34 @@ -0,0 +1,1604 @@
35 +# Copyright 1999-2022 Gentoo Authors
36 +# Distributed under the terms of the GNU General Public License v2
37 +
38 +EAPI=7
39 +
40 +# Bumping notes: https://wiki.gentoo.org/wiki/Project:Toolchain/sys-libs/glibc
41 +# Please read & adapt the page as necessary if obsolete.
42 +
43 +PYTHON_COMPAT=( python3_{8..11} )
44 +TMPFILES_OPTIONAL=1
45 +
46 +inherit python-any-r1 prefix preserve-libs toolchain-funcs flag-o-matic gnuconfig \
47 + multilib systemd multiprocessing tmpfiles
48 +
49 +DESCRIPTION="GNU libc C library"
50 +HOMEPAGE="https://www.gnu.org/software/libc/"
51 +LICENSE="LGPL-2.1+ BSD HPND ISC inner-net rc PCRE"
52 +SLOT="2.2"
53 +
54 +EMULTILIB_PKG="true"
55 +
56 +# Gentoo patchset (ignored for live ebuilds)
57 +PATCH_VER=9
58 +PATCH_DEV=dilfridge
59 +
60 +if [[ ${PV} == 9999* ]]; then
61 + inherit git-r3
62 +else
63 + #KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86"
64 + SRC_URI="mirror://gnu/glibc/${P}.tar.xz"
65 + SRC_URI+=" https://dev.gentoo.org/~${PATCH_DEV}/distfiles/${P}-patches-${PATCH_VER}.tar.xz"
66 + SRC_URI+=" experimental-loong? ( https://dev.gentoo.org/~xen0n/distfiles/glibc-2.35-loongarch-patches-20220522.tar.xz )"
67 +fi
68 +
69 +RELEASE_VER=${PV}
70 +
71 +GCC_BOOTSTRAP_VER=20201208
72 +
73 +LOCALE_GEN_VER=2.22
74 +
75 +GLIBC_SYSTEMD_VER=20210729
76 +
77 +SRC_URI+=" https://gitweb.gentoo.org/proj/locale-gen.git/snapshot/locale-gen-${LOCALE_GEN_VER}.tar.gz"
78 +SRC_URI+=" multilib-bootstrap? ( https://dev.gentoo.org/~dilfridge/distfiles/gcc-multilib-bootstrap-${GCC_BOOTSTRAP_VER}.tar.xz )"
79 +SRC_URI+=" systemd? ( https://gitweb.gentoo.org/proj/toolchain/glibc-systemd.git/snapshot/glibc-systemd-${GLIBC_SYSTEMD_VER}.tar.gz )"
80 +
81 +IUSE="audit caps cet +clone3 compile-locales +crypt custom-cflags doc experimental-loong gd headers-only +multiarch multilib multilib-bootstrap nscd profile selinux +ssp stack-realign +static-libs suid systemd systemtap test vanilla"
82 +
83 +# Minimum kernel version that glibc requires
84 +MIN_KERN_VER="3.2.0"
85 +# Minimum pax-utils version needed (which contains any new syscall changes for
86 +# its seccomp filter!). Please double check this!
87 +MIN_PAX_UTILS_VER="1.3.3"
88 +
89 +# Here's how the cross-compile logic breaks down ...
90 +# CTARGET - machine that will target the binaries
91 +# CHOST - machine that will host the binaries
92 +# CBUILD - machine that will build the binaries
93 +# If CTARGET != CHOST, it means you want a libc for cross-compiling.
94 +# If CHOST != CBUILD, it means you want to cross-compile the libc.
95 +# CBUILD = CHOST = CTARGET - native build/install
96 +# CBUILD != (CHOST = CTARGET) - cross-compile a native build
97 +# (CBUILD = CHOST) != CTARGET - libc for cross-compiler
98 +# CBUILD != CHOST != CTARGET - cross-compile a libc for a cross-compiler
99 +# For install paths:
100 +# CHOST = CTARGET - install into /
101 +# CHOST != CTARGET - install into /usr/CTARGET/
102 +#
103 +export CBUILD=${CBUILD:-${CHOST}}
104 +export CTARGET=${CTARGET:-${CHOST}}
105 +if [[ ${CTARGET} == ${CHOST} ]] ; then
106 + if [[ ${CATEGORY} == cross-* ]] ; then
107 + export CTARGET=${CATEGORY#cross-}
108 + fi
109 +fi
110 +
111 +# Note [Disable automatic stripping]
112 +# Disabling automatic stripping for a few reasons:
113 +# - portage's attempt to strip breaks non-native binaries at least on
114 +# arm: bug #697428
115 +# - portage's attempt to strip libpthread.so.0 breaks gdb thread
116 +# enumeration: bug #697910. This is quite subtle:
117 +# * gdb uses glibc's libthread_db-1.0.so to enumerate threads.
118 +# * libthread_db-1.0.so needs access to libpthread.so.0 local symbols
119 +# via 'ps_pglobal_lookup' symbol defined in gdb.
120 +# * 'ps_pglobal_lookup' uses '.symtab' section table to resolve all
121 +# known symbols in 'libpthread.so.0'. Specifically 'nptl_version'
122 +# (unexported) is used to sanity check compatibility before enabling
123 +# debugging.
124 +# Also see https://sourceware.org/gdb/wiki/FAQ#GDB_does_not_see_any_threads_besides_the_one_in_which_crash_occurred.3B_or_SIGTRAP_kills_my_program_when_I_set_a_breakpoint
125 +# * normal 'strip' command trims '.symtab'
126 +# Thus our main goal here is to prevent 'libpthread.so.0' from
127 +# losing it's '.symtab' entries.
128 +# As Gentoo's strip does not allow us to pass less aggressive stripping
129 +# options and does not check the machine target we strip selectively.
130 +
131 +# We need a new-enough binutils/gcc to match upstream baseline.
132 +# Also we need to make sure our binutils/gcc supports TLS,
133 +# and that gcc already contains the hardened patches.
134 +# Lastly, let's avoid some openssh nastiness, bug 708224, as
135 +# convenience to our users.
136 +
137 +# gzip, grep, awk are needed by locale-gen, bug 740750
138 +
139 +BDEPEND="
140 + ${PYTHON_DEPS}
141 + >=app-misc/pax-utils-${MIN_PAX_UTILS_VER}
142 + sys-devel/bison
143 + doc? ( sys-apps/texinfo )
144 + !compile-locales? (
145 + app-arch/gzip
146 + sys-apps/grep
147 + virtual/awk
148 + )
149 +"
150 +COMMON_DEPEND="
151 + gd? ( media-libs/gd:2= )
152 + nscd? ( selinux? (
153 + audit? ( sys-process/audit )
154 + caps? ( sys-libs/libcap )
155 + ) )
156 + suid? ( caps? ( sys-libs/libcap ) )
157 + selinux? ( sys-libs/libselinux )
158 + systemtap? ( dev-util/systemtap )
159 +"
160 +DEPEND="${COMMON_DEPEND}
161 + compile-locales? (
162 + app-arch/gzip
163 + sys-apps/grep
164 + virtual/awk
165 + )
166 + test? ( >=net-dns/libidn2-2.3.0 )
167 +"
168 +RDEPEND="${COMMON_DEPEND}
169 + app-arch/gzip
170 + sys-apps/grep
171 + virtual/awk
172 + sys-apps/gentoo-functions
173 + !<app-misc/pax-utils-${MIN_PAX_UTILS_VER}
174 + !<net-misc/openssh-8.1_p1-r2
175 +"
176 +
177 +RESTRICT="!test? ( test )"
178 +
179 +if [[ ${CATEGORY} == cross-* ]] ; then
180 + BDEPEND+=" !headers-only? (
181 + >=${CATEGORY}/binutils-2.27
182 + >=${CATEGORY}/gcc-6.2
183 + )"
184 + [[ ${CATEGORY} == *-linux* ]] && DEPEND+=" ${CATEGORY}/linux-headers"
185 +else
186 + BDEPEND+="
187 + >=sys-devel/binutils-2.27
188 + >=sys-devel/gcc-6.2
189 + "
190 + DEPEND+=" virtual/os-headers "
191 + RDEPEND+="
192 + >=net-dns/libidn2-2.3.0
193 + vanilla? ( !sys-libs/timezone-data )
194 + "
195 + PDEPEND+=" !vanilla? ( sys-libs/timezone-data )"
196 +fi
197 +
198 +# Ignore tests whitelisted below
199 +GENTOO_GLIBC_XFAIL_TESTS="${GENTOO_GLIBC_XFAIL_TESTS:-yes}"
200 +
201 +# The following tests fail due to the Gentoo build system and are thus
202 +# executed but ignored:
203 +XFAIL_TEST_LIST=(
204 + # buggy test, assumes /dev/ and /dev/null on a single filesystem
205 + # 'mount --bind /dev/null /chroot/dev/null' breaks it.
206 + # https://sourceware.org/PR25909
207 + tst-support_descriptors
208 +
209 + # The following tests fail only inside portage
210 + # https://bugs.gentoo.org/831267
211 + tst-system
212 + tst-strerror
213 + tst-strsignal
214 +)
215 +
216 +#
217 +# Small helper functions
218 +#
219 +
220 +is_crosscompile() {
221 + [[ ${CHOST} != ${CTARGET} ]]
222 +}
223 +
224 +just_headers() {
225 + is_crosscompile && use headers-only
226 +}
227 +
228 +alt_prefix() {
229 + is_crosscompile && echo /usr/${CTARGET}
230 +}
231 +
232 +# This prefix is applicable to CHOST when building against this
233 +# glibc. It is baked into the library at configure time.
234 +host_eprefix() {
235 + is_crosscompile || echo "${EPREFIX}"
236 +}
237 +
238 +# This prefix is applicable to CBUILD when building against this
239 +# glibc. It determines the destination path at install time.
240 +build_eprefix() {
241 + is_crosscompile && echo "${EPREFIX}"
242 +}
243 +
244 +# We need to be able to set alternative headers for compiling for non-native
245 +# platform. Will also become useful for testing kernel-headers without screwing
246 +# up the whole system.
247 +alt_headers() {
248 + echo ${ALT_HEADERS:=$(alt_prefix)/usr/include}
249 +}
250 +
251 +alt_build_headers() {
252 + if [[ -z ${ALT_BUILD_HEADERS} ]] ; then
253 + ALT_BUILD_HEADERS="$(host_eprefix)$(alt_headers)"
254 + if tc-is-cross-compiler ; then
255 + ALT_BUILD_HEADERS=${SYSROOT}$(alt_headers)
256 + if [[ ! -e ${ALT_BUILD_HEADERS}/linux/version.h ]] ; then
257 + local header_path=$(echo '#include <linux/version.h>' | $(tc-getCPP ${CTARGET}) ${CFLAGS} 2>&1 | grep -o '[^"]*linux/version.h')
258 + ALT_BUILD_HEADERS=${header_path%/linux/version.h}
259 + fi
260 + fi
261 + fi
262 + echo "${ALT_BUILD_HEADERS}"
263 +}
264 +
265 +alt_libdir() {
266 + echo $(alt_prefix)/$(get_libdir)
267 +}
268 +alt_usrlibdir() {
269 + echo $(alt_prefix)/usr/$(get_libdir)
270 +}
271 +
272 +builddir() {
273 + echo "${WORKDIR}/build-${ABI}-${CTARGET}-$1"
274 +}
275 +
276 +do_compile_test() {
277 + local ret save_cflags=${CFLAGS}
278 + CFLAGS+=" $1"
279 + shift
280 +
281 + pushd "${T}" >/dev/null
282 +
283 + rm -f glibc-test*
284 + printf '%b' "$*" > glibc-test.c
285 +
286 + # We assume CC is already set up.
287 + nonfatal emake glibc-test
288 + ret=$?
289 +
290 + popd >/dev/null
291 +
292 + CFLAGS=${save_cflags}
293 + return ${ret}
294 +}
295 +
296 +do_run_test() {
297 + local ret
298 +
299 + if [[ ${MERGE_TYPE} == "binary" ]] ; then
300 + # ignore build failures when installing a binary package #324685
301 + do_compile_test "" "$@" 2>/dev/null || return 0
302 + else
303 + if ! do_compile_test "" "$@" ; then
304 + ewarn "Simple build failed ... assuming this is desired #324685"
305 + return 0
306 + fi
307 + fi
308 +
309 + pushd "${T}" >/dev/null
310 +
311 + ./glibc-test
312 + ret=$?
313 + rm -f glibc-test*
314 +
315 + popd >/dev/null
316 +
317 + return ${ret}
318 +}
319 +
320 +setup_target_flags() {
321 + # This largely mucks with compiler flags. None of which should matter
322 + # when building up just the headers.
323 + just_headers && return 0
324 +
325 + case $(tc-arch) in
326 + x86)
327 + # -march needed for #185404 #199334
328 + # TODO: When creating the first glibc cross-compile, this test will
329 + # always fail as it does a full link which in turn requires glibc.
330 + # Probably also applies when changing multilib profile settings (e.g.
331 + # enabling x86 when the profile was amd64-only previously).
332 + # We could change main to _start and pass -nostdlib here so that we
333 + # only test the gcc code compilation. Or we could do a compile and
334 + # then look for the symbol via scanelf.
335 + 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'; then
336 + local t=${CTARGET_OPT:-${CTARGET}}
337 + t=${t%%-*}
338 + filter-flags '-march=*'
339 + export CFLAGS="-march=${t} ${CFLAGS}"
340 + einfo "Auto adding -march=${t} to CFLAGS #185404"
341 + fi
342 + # For compatibility with older binaries at slight performance cost.
343 + use stack-realign && export CFLAGS+=" -mstackrealign"
344 + ;;
345 + amd64)
346 + # -march needed for #185404 #199334
347 + # TODO: See cross-compile issues listed above for x86.
348 + if [[ ${ABI} == x86 ]]; then
349 + 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'; then
350 + local t=${CTARGET_OPT:-${CTARGET}}
351 + t=${t%%-*}
352 + # Normally the target is x86_64-xxx, so turn that into the -march that
353 + # gcc actually accepts. #528708
354 + [[ ${t} == "x86_64" ]] && t="x86-64"
355 + filter-flags '-march=*'
356 + # ugly, ugly, ugly. ugly.
357 + CFLAGS_x86=$(CFLAGS=${CFLAGS_x86} filter-flags '-march=*'; echo "${CFLAGS}")
358 + export CFLAGS_x86="${CFLAGS_x86} -march=${t}"
359 + einfo "Auto adding -march=${t} to CFLAGS_x86 #185404 (ABI=${ABI})"
360 + fi
361 + # For compatibility with older binaries at slight performance cost.
362 + use stack-realign && export CFLAGS_x86+=" -mstackrealign"
363 + fi
364 + ;;
365 + mips)
366 + # The mips abi cannot support the GNU style hashes. #233233
367 + filter-ldflags -Wl,--hash-style=gnu -Wl,--hash-style=both
368 + ;;
369 + ppc|ppc64)
370 + # Many arch-specific implementations do not work on ppc with
371 + # cache-block not equal to 128 bytes. This breaks memset:
372 + # https://sourceware.org/PR26522
373 + # https://bugs.gentoo.org/737996
374 + # Use default -mcpu=. For ppc it means non-multiarch setup.
375 + filter-flags '-mcpu=*'
376 + ;;
377 + sparc)
378 + # Both sparc and sparc64 can use -fcall-used-g6. -g7 is bad, though.
379 + filter-flags "-fcall-used-g7"
380 + append-flags "-fcall-used-g6"
381 +
382 + local cpu
383 + case ${CTARGET} in
384 + sparc64-*)
385 + cpu="sparc64"
386 + case $(get-flag mcpu) in
387 + v9)
388 + # We need to force at least v9a because the base build doesn't
389 + # work with just v9.
390 + # https://sourceware.org/bugzilla/show_bug.cgi?id=19477
391 + append-flags "-Wa,-xarch=v9a"
392 + ;;
393 + esac
394 + ;;
395 + sparc-*)
396 + case $(get-flag mcpu) in
397 + v8|supersparc|hypersparc|leon|leon3)
398 + cpu="sparcv8"
399 + ;;
400 + *)
401 + cpu="sparcv9"
402 + ;;
403 + esac
404 + ;;
405 + esac
406 + [[ -n ${cpu} ]] && CTARGET_OPT="${cpu}-${CTARGET#*-}"
407 + ;;
408 + esac
409 +}
410 +
411 +setup_flags() {
412 + # Make sure host make.conf doesn't pollute us
413 + if is_crosscompile || tc-is-cross-compiler ; then
414 + CHOST=${CTARGET} strip-unsupported-flags
415 + fi
416 +
417 + # Store our CFLAGS because it's changed depending on which CTARGET
418 + # we are building when pulling glibc on a multilib profile
419 + CFLAGS_BASE=${CFLAGS_BASE-${CFLAGS}}
420 + CFLAGS=${CFLAGS_BASE}
421 + CXXFLAGS_BASE=${CXXFLAGS_BASE-${CXXFLAGS}}
422 + CXXFLAGS=${CXXFLAGS_BASE}
423 + ASFLAGS_BASE=${ASFLAGS_BASE-${ASFLAGS}}
424 + ASFLAGS=${ASFLAGS_BASE}
425 +
426 + # Allow users to explicitly avoid flag sanitization via
427 + # USE=custom-cflags.
428 + if ! use custom-cflags; then
429 + # Over-zealous CFLAGS can often cause problems. What may work for one
430 + # person may not work for another. To avoid a large influx of bugs
431 + # relating to failed builds, we strip most CFLAGS out to ensure as few
432 + # problems as possible.
433 + strip-flags
434 + # Lock glibc at -O2; we want to be conservative here.
435 + filter-flags '-O?'
436 + append-flags -O2
437 + fi
438 +
439 + strip-unsupported-flags
440 + filter-flags -m32 -m64 '-mabi=*'
441 +
442 + # glibc aborts if rpath is set by LDFLAGS
443 + filter-ldflags '-Wl,-rpath=*'
444 +
445 + # ld can't use -r & --relax at the same time, bug #788901
446 + # https://sourceware.org/PR27837
447 + filter-ldflags '-Wl,--relax'
448 +
449 + # #492892
450 + filter-flags -frecord-gcc-switches
451 +
452 + # #829583
453 + filter-lfs-flags
454 +
455 + unset CBUILD_OPT CTARGET_OPT
456 + if use multilib ; then
457 + CTARGET_OPT=$(get_abi_CTARGET)
458 + [[ -z ${CTARGET_OPT} ]] && CTARGET_OPT=$(get_abi_CHOST)
459 + fi
460 +
461 + setup_target_flags
462 +
463 + if [[ -n ${CTARGET_OPT} && ${CBUILD} == ${CHOST} ]] && ! is_crosscompile; then
464 + CBUILD_OPT=${CTARGET_OPT}
465 + fi
466 +
467 + # glibc's headers disallow -O0 and fail at build time:
468 + # include/libc-symbols.h:75:3: #error "glibc cannot be compiled without optimization"
469 + replace-flags -O0 -O1
470 +
471 + filter-flags '-fstack-protector*'
472 +
473 + # See end of bug #830454; we handle this via USE=cet
474 + filter-flags '-fcf-protection='
475 +}
476 +
477 +use_multiarch() {
478 + # Allow user to disable runtime arch detection in multilib.
479 + use multiarch || return 1
480 + # Make sure binutils is new enough to support indirect functions,
481 + # #336792. This funky sed supports gold and bfd linkers.
482 + local bver nver
483 + bver=$($(tc-getLD ${CTARGET}) -v | sed -n -r '1{s:[^0-9]*::;s:^([0-9.]*).*:\1:;p}')
484 + case $(tc-arch ${CTARGET}) in
485 + amd64|x86) nver="2.20" ;;
486 + arm) nver="2.22" ;;
487 + hppa) nver="2.23" ;;
488 + ppc|ppc64) nver="2.20" ;;
489 + # ifunc support was added in 2.23, but glibc also needs
490 + # machinemode which is in 2.24.
491 + s390) nver="2.24" ;;
492 + sparc) nver="2.21" ;;
493 + *) return 1 ;;
494 + esac
495 + ver_test ${bver} -ge ${nver}
496 +}
497 +
498 +# Setup toolchain variables that had historically been defined in the
499 +# profiles for these archs.
500 +setup_env() {
501 + # silly users
502 + unset LD_RUN_PATH
503 + unset LD_ASSUME_KERNEL
504 +
505 + if is_crosscompile || tc-is-cross-compiler ; then
506 + multilib_env ${CTARGET_OPT:-${CTARGET}}
507 +
508 + if ! use multilib ; then
509 + MULTILIB_ABIS=${DEFAULT_ABI}
510 + else
511 + MULTILIB_ABIS=${MULTILIB_ABIS:-${DEFAULT_ABI}}
512 + fi
513 +
514 + # If the user has CFLAGS_<CTARGET> in their make.conf, use that,
515 + # and fall back on CFLAGS.
516 + local VAR=CFLAGS_${CTARGET//[-.]/_}
517 + CFLAGS=${!VAR-${CFLAGS}}
518 + einfo " $(printf '%15s' 'Manual CFLAGS:') ${CFLAGS}"
519 + fi
520 +
521 + setup_flags
522 +
523 + export ABI=${ABI:-${DEFAULT_ABI:-default}}
524 +
525 + if just_headers ; then
526 + # Avoid mixing host's CC and target's CFLAGS_${ABI}:
527 + # At this bootstrap stage we have only binutils for
528 + # target but not compiler yet.
529 + einfo "Skip CC ABI injection. We can't use (cross-)compiler yet."
530 + return 0
531 + fi
532 +
533 + # Glibc does not work with gold (for various reasons) #269274.
534 + tc-ld-disable-gold
535 +
536 + if use doc ; then
537 + export MAKEINFO=makeinfo
538 + else
539 + export MAKEINFO=/dev/null
540 + fi
541 +
542 + # Reset CC and CXX to the value at start of emerge
543 + export CC=${__ORIG_CC:-${CC:-$(tc-getCC ${CTARGET})}}
544 + export CXX=${__ORIG_CXX:-${CXX:-$(tc-getCXX ${CTARGET})}}
545 +
546 + # and make sure __ORIC_CC and __ORIG_CXX is defined now.
547 + export __ORIG_CC=${CC}
548 + export __ORIG_CXX=${CXX}
549 +
550 + if tc-is-clang && ! use custom-cflags && ! is_crosscompile ; then
551 +
552 + # If we are running in an otherwise clang/llvm environment, we need to
553 + # recover the proper gcc and binutils settings here, at least until glibc
554 + # is finally building with clang. So let's override everything that is
555 + # set in the clang profiles.
556 + # Want to shoot yourself into the foot? Set USE=custom-cflags, that's always
557 + # a good start into that direction.
558 + # Also, if you're crosscompiling, let's assume you know what you are doing.
559 + # Hopefully.
560 + # Last, we need the settings of the *build* environment, not of the
561 + # target environment...
562 +
563 + local current_binutils_path=$(env ROOT="${BROOT}" binutils-config -B)
564 + local current_gcc_path=$(env ROOT="${BROOT}" gcc-config -B)
565 + einfo "Overriding clang configuration, since it won't work here"
566 +
567 + export CC="${current_gcc_path}/gcc"
568 + export CXX="${current_gcc_path}/g++"
569 + export LD="${current_binutils_path}/ld.bfd"
570 + export AR="${current_binutils_path}/ar"
571 + export AS="${current_binutils_path}/as"
572 + export NM="${current_binutils_path}/nm"
573 + export STRIP="${current_binutils_path}/strip"
574 + export RANLIB="${current_binutils_path}/ranlib"
575 + export OBJCOPY="${current_binutils_path}/objcopy"
576 + export STRINGS="${current_binutils_path}/strings"
577 + export OBJDUMP="${current_binutils_path}/objdump"
578 + export READELF="${current_binutils_path}/readelf"
579 + export ADDR2LINE="${current_binutils_path}/addr2line"
580 +
581 + # do we need to also do flags munging here? yes! at least...
582 + filter-flags '-fuse-ld=*'
583 + filter-flags '-D_FORTIFY_SOURCE=*'
584 +
585 + else
586 +
587 + # this is the "normal" case
588 +
589 + export CC="$(tc-getCC ${CTARGET})"
590 + export CXX="$(tc-getCXX ${CTARGET})"
591 +
592 + # Always use tuple-prefixed toolchain. For non-native ABI glibc's configure
593 + # can't detect them automatically due to ${CHOST} mismatch and fallbacks
594 + # to unprefixed tools. Similar to multilib.eclass:multilib_toolchain_setup().
595 + export NM="$(tc-getNM ${CTARGET})"
596 + export READELF="$(tc-getREADELF ${CTARGET})"
597 +
598 + fi
599 +
600 + # We need to export CFLAGS with abi information in them because glibc's
601 + # configure script checks CFLAGS for some targets (like mips). Keep
602 + # around the original clean value to avoid appending multiple ABIs on
603 + # top of each other. (Why does the comment talk about CFLAGS if the code
604 + # acts on CC?)
605 + export __GLIBC_CC=${CC}
606 + export __GLIBC_CXX=${CXX}
607 +
608 + export __abi_CFLAGS="$(get_abi_CFLAGS)"
609 +
610 + # CFLAGS can contain ABI-specific flags like -mfpu=neon, see bug #657760
611 + # To build .S (assembly) files with the same ABI-specific flags
612 + # upstream currently recommends adding CFLAGS to CC/CXX:
613 + # https://sourceware.org/PR23273
614 + # Note: Passing CFLAGS via CPPFLAGS overrides glibc's arch-specific CFLAGS
615 + # and breaks multiarch support. See 659030#c3 for an example.
616 + # The glibc configure script doesn't properly use LDFLAGS all the time.
617 + export CC="${__GLIBC_CC} ${__abi_CFLAGS} ${CFLAGS} ${LDFLAGS}"
618 +
619 + # Some of the tests are written in C++, so we need to force our multlib abis in, bug 623548
620 + export CXX="${__GLIBC_CXX} ${__abi_CFLAGS} ${CFLAGS}"
621 +
622 + if is_crosscompile; then
623 + # Assume worst-case bootstrap: glibc is buil first time
624 + # when ${CTARGET}-g++ is not available yet. We avoid
625 + # building auxiliary programs that require C++: bug #683074
626 + # It should not affect final result.
627 + export libc_cv_cxx_link_ok=no
628 + # The line above has the same effect. We set CXX explicitly
629 + # to make build logs less confusing.
630 + export CXX=
631 + fi
632 +}
633 +
634 +foreach_abi() {
635 + setup_env
636 +
637 + local ret=0
638 + local abilist=""
639 + if use multilib ; then
640 + abilist=$(get_install_abis)
641 + else
642 + abilist=${DEFAULT_ABI}
643 + fi
644 + local -x ABI
645 + for ABI in ${abilist:-default} ; do
646 + setup_env
647 + einfo "Running $1 for ABI ${ABI}"
648 + $1
649 + : $(( ret |= $? ))
650 + done
651 + return ${ret}
652 +}
653 +
654 +glibc_banner() {
655 + local b="Gentoo ${PVR}"
656 + [[ -n ${PATCH_VER} ]] && ! use vanilla && b+=" p${PATCH_VER}"
657 + echo "${b}"
658 +}
659 +
660 +# The following Kernel version handling functions are mostly copied from portage
661 +# source. It's better not to use linux-info.eclass here since a) it adds too
662 +# much magic, see bug 326693 for some of the arguments, and b) some of the
663 +# functions are just not provided.
664 +
665 +g_get_running_KV() {
666 + uname -r
667 + return $?
668 +}
669 +
670 +g_KV_major() {
671 + [[ -z $1 ]] && return 1
672 + local KV=$@
673 + echo "${KV%%.*}"
674 +}
675 +
676 +g_KV_minor() {
677 + [[ -z $1 ]] && return 1
678 + local KV=$@
679 + KV=${KV#*.}
680 + echo "${KV%%.*}"
681 +}
682 +
683 +g_KV_micro() {
684 + [[ -z $1 ]] && return 1
685 + local KV=$@
686 + KV=${KV#*.*.}
687 + echo "${KV%%[^[:digit:]]*}"
688 +}
689 +
690 +g_KV_to_int() {
691 + [[ -z $1 ]] && return 1
692 + local KV_MAJOR=$(g_KV_major "$1")
693 + local KV_MINOR=$(g_KV_minor "$1")
694 + local KV_MICRO=$(g_KV_micro "$1")
695 + local KV_int=$(( KV_MAJOR * 65536 + KV_MINOR * 256 + KV_MICRO ))
696 +
697 + # We make version 2.2.0 the minimum version we will handle as
698 + # a sanity check ... if its less, we fail ...
699 + if [[ ${KV_int} -ge 131584 ]] ; then
700 + echo "${KV_int}"
701 + return 0
702 + fi
703 + return 1
704 +}
705 +
706 +g_int_to_KV() {
707 + local version=$1 major minor micro
708 + major=$((version / 65536))
709 + minor=$(((version % 65536) / 256))
710 + micro=$((version % 256))
711 + echo ${major}.${minor}.${micro}
712 +}
713 +
714 +eend_KV() {
715 + [[ $(g_KV_to_int $1) -ge $(g_KV_to_int $2) ]]
716 + eend $?
717 +}
718 +
719 +get_kheader_version() {
720 + printf '#include <linux/version.h>\nLINUX_VERSION_CODE\n' | \
721 + $(tc-getCPP ${CTARGET}) -I "$(build_eprefix)$(alt_build_headers)" - | \
722 + tail -n 1
723 +}
724 +
725 +# We collect all sanity checks here. Consistency is not guranteed between
726 +# pkg_ and src_ phases, so we call this function both in pkg_pretend and in
727 +# src_unpack.
728 +sanity_prechecks() {
729 + # Prevent native builds from downgrading
730 + if [[ ${MERGE_TYPE} != "buildonly" ]] && \
731 + [[ -z ${ROOT} ]] && \
732 + [[ ${CBUILD} == ${CHOST} ]] && \
733 + [[ ${CHOST} == ${CTARGET} ]] ; then
734 +
735 + # The high rev # is to allow people to downgrade between -r#
736 + # versions. We want to block 2.20->2.19, but 2.20-r3->2.20-r2
737 + # should be fine. Hopefully we never actually use a r# this
738 + # high.
739 + if has_version ">${CATEGORY}/${P}-r10000" ; then
740 + eerror "Sanity check to keep you from breaking your system:"
741 + eerror " Downgrading glibc is not supported and a sure way to destruction."
742 + [[ ${I_ALLOW_TO_BREAK_MY_SYSTEM} = yes ]] || die "Aborting to save your system."
743 + fi
744 +
745 + if ! do_run_test '#include <unistd.h>\n#include <sys/syscall.h>\nint main(){return syscall(1000)!=-1;}\n' ; then
746 + eerror "Your old kernel is broken. You need to update it to a newer"
747 + eerror "version as syscall(<bignum>) will break. See bug 279260."
748 + die "Old and broken kernel."
749 + fi
750 + fi
751 +
752 + # Users have had a chance to phase themselves, time to give em the boot
753 + if [[ -e ${EROOT}/etc/locale.gen ]] && [[ -e ${EROOT}/etc/locales.build ]] ; then
754 + eerror "You still haven't deleted ${EROOT}/etc/locales.build."
755 + eerror "Do so now after making sure ${EROOT}/etc/locale.gen is kosher."
756 + die "Lazy upgrader detected"
757 + fi
758 +
759 + if [[ ${CTARGET} == i386-* ]] ; then
760 + eerror "i386 CHOSTs are no longer supported."
761 + eerror "Chances are you don't actually want/need i386."
762 + eerror "Please read https://www.gentoo.org/doc/en/change-chost.xml"
763 + die "Please fix your CHOST"
764 + fi
765 +
766 + if [[ -e /proc/xen ]] && [[ $(tc-arch) == "x86" ]] && ! is-flag -mno-tls-direct-seg-refs ; then
767 + ewarn "You are using Xen but don't have -mno-tls-direct-seg-refs in your CFLAGS."
768 + ewarn "This will result in a 50% performance penalty when running with a 32bit"
769 + ewarn "hypervisor, which is probably not what you want."
770 + fi
771 +
772 + # ABI-specific checks follow here. Hey, we have a lot more specific conditions that
773 + # we test for...
774 + if ! is_crosscompile ; then
775 + if use amd64 && use multilib && [[ ${MERGE_TYPE} != "binary" ]] ; then
776 + ebegin "Checking that IA32 emulation is enabled in the running kernel"
777 + echo 'int main(){return 0;}' > "${T}/check-ia32-emulation.c"
778 + local STAT
779 + if ${CC-${CHOST}-gcc} ${CFLAGS_x86} "${T}/check-ia32-emulation.c" -o "${T}/check-ia32-emulation.elf32"; then
780 + "${T}/check-ia32-emulation.elf32"
781 + STAT=$?
782 + else
783 + # Don't fail here to allow single->multi ABI switch
784 + # or recover from breakage like bug #646424
785 + ewarn "Failed to compile the ABI test. Broken host glibc?"
786 + STAT=0
787 + fi
788 + rm -f "${T}/check-ia32-emulation.elf32"
789 + eend $STAT
790 + [[ $STAT -eq 0 ]] || die "CONFIG_IA32_EMULATION must be enabled in the kernel to compile a multilib glibc."
791 + fi
792 +
793 + fi
794 +
795 + # When we actually have to compile something...
796 + if ! just_headers && [[ ${MERGE_TYPE} != "binary" ]] ; then
797 + if [[ -d "${ESYSROOT}"/usr/lib/include ]] ; then
798 + # bug #833620, bug #643302
799 + eerror "Found ${ESYSROOT}/usr/lib/include directory!"
800 + eerror "This is known to break glibc's build."
801 + eerror "Please backup its contents then remove the directory."
802 + die "Found directory (${ESYSROOT}/usr/lib/include) which will break build (bug #833620)!"
803 + fi
804 +
805 + if [[ ${CTARGET} == *-linux* ]] ; then
806 + local run_kv build_kv want_kv
807 +
808 + run_kv=$(g_get_running_KV)
809 + build_kv=$(g_int_to_KV $(get_kheader_version))
810 + want_kv=${MIN_KERN_VER}
811 +
812 + if ! is_crosscompile && ! tc-is-cross-compiler ; then
813 + # Building fails on an non-supporting kernel
814 + ebegin "Checking running kernel version (${run_kv} >= ${want_kv})"
815 + if ! eend_KV ${run_kv} ${want_kv} ; then
816 + echo
817 + eerror "You need a kernel of at least ${want_kv}!"
818 + die "Kernel version too low!"
819 + fi
820 + fi
821 +
822 + ebegin "Checking linux-headers version (${build_kv} >= ${want_kv})"
823 + if ! eend_KV ${build_kv} ${want_kv} ; then
824 + echo
825 + eerror "You need linux-headers of at least ${want_kv}!"
826 + die "linux-headers version too low!"
827 + fi
828 + fi
829 + fi
830 +}
831 +
832 +upgrade_warning() {
833 + if [[ ${MERGE_TYPE} != buildonly && -n ${REPLACING_VERSIONS} && -z ${ROOT} ]]; then
834 + local oldv newv=$(ver_cut 1-2 ${PV})
835 + for oldv in ${REPLACING_VERSIONS}; do
836 + if ver_test ${oldv} -lt ${newv}; then
837 + ewarn "After upgrading glibc, please restart all running processes."
838 + ewarn "Be sure to include init (telinit u) or systemd (systemctl daemon-reexec)."
839 + ewarn "Alternatively, reboot your system."
840 + ewarn "(See bug #660556, bug #741116, bug #823756, etc)"
841 + break
842 + fi
843 + done
844 + fi
845 +}
846 +
847 +#
848 +# the phases
849 +#
850 +
851 +# pkg_pretend
852 +
853 +pkg_pretend() {
854 + upgrade_warning
855 +}
856 +
857 +pkg_setup() {
858 + # see bug 682570
859 + [[ -z ${BOOTSTRAP_RAP} ]] && python-any-r1_pkg_setup
860 +}
861 +
862 +# src_unpack
863 +
864 +src_unpack() {
865 + setup_env
866 +
867 + einfo "Checking general environment sanity."
868 + sanity_prechecks
869 +
870 + use multilib-bootstrap && unpack gcc-multilib-bootstrap-${GCC_BOOTSTRAP_VER}.tar.xz
871 +
872 + if [[ ${PV} == 9999* ]] ; then
873 + EGIT_REPO_URI="https://anongit.gentoo.org/git/proj/toolchain/glibc-patches.git"
874 + EGIT_CHECKOUT_DIR=${WORKDIR}/patches-git
875 + git-r3_src_unpack
876 + mv patches-git/9999 patches || die
877 +
878 + EGIT_REPO_URI="https://sourceware.org/git/glibc.git"
879 + EGIT_CHECKOUT_DIR=${S}
880 + git-r3_src_unpack
881 + else
882 + unpack ${P}.tar.xz
883 +
884 + cd "${WORKDIR}" || die
885 + unpack glibc-${RELEASE_VER}-patches-${PATCH_VER}.tar.xz
886 + use experimental-loong && unpack glibc-2.35-loongarch-patches-20220522.tar.xz
887 + fi
888 +
889 + cd "${WORKDIR}" || die
890 + unpack locale-gen-${LOCALE_GEN_VER}.tar.gz
891 + use systemd && unpack glibc-systemd-${GLIBC_SYSTEMD_VER}.tar.gz
892 +}
893 +
894 +src_prepare() {
895 + local patchsetname
896 + if ! use vanilla ; then
897 + if [[ ${PV} == 9999* ]] ; then
898 + patchsetname="from git master"
899 + else
900 + patchsetname="${RELEASE_VER}-${PATCH_VER}"
901 + fi
902 + einfo "Applying Gentoo Glibc Patchset ${patchsetname}"
903 + eapply "${WORKDIR}"/patches
904 + einfo "Done."
905 +
906 + if use experimental-loong ; then
907 + einfo "Applying experimental LoongArch patchset"
908 + eapply "${WORKDIR}"/loongarch-2.35
909 + einfo "Done."
910 + fi
911 + fi
912 +
913 + if use clone3 ; then
914 + append-cppflags -DGENTOO_USE_CLONE3
915 + else
916 + # See e.g. bug #827386, bug #819045.
917 + elog "Disabling the clone3 syscall for compatibility with older Electron apps."
918 + elog "Please re-enable this flag before filing bugs!"
919 + fi
920 +
921 + default
922 +
923 + gnuconfig_update
924 +
925 + cd "${WORKDIR}"
926 + find . -name configure -exec touch {} +
927 +
928 + # move the external locale-gen to its old place
929 + mkdir extra || die
930 + mv locale-gen-${LOCALE_GEN_VER} extra/locale || die
931 +
932 + eprefixify extra/locale/locale-gen
933 +
934 + # Fix permissions on some of the scripts.
935 + chmod u+x "${S}"/scripts/*.sh
936 +
937 + cd "${S}"
938 +}
939 +
940 +glibc_do_configure() {
941 +
942 + local v
943 + for v in ABI CBUILD CHOST CTARGET CBUILD_OPT CTARGET_OPT CC CXX LD {AS,C,CPP,CXX,LD}FLAGS MAKEINFO NM AR AS STRIP RANLIB OBJCOPY STRINGS OBJDUMP READELF; do
944 + einfo " $(printf '%15s' ${v}:) ${!v}"
945 + done
946 +
947 + echo
948 + local myconf=()
949 +
950 + # Use '=strong' instead of '=all' to protect only functions
951 + # worth protecting from stack smashes.
952 + myconf+=( --enable-stack-protector=$(usex ssp strong no) )
953 +
954 + # Keep a whitelist of targets supporing IFUNC. glibc's ./configure
955 + # is not robust enough to detect proper support:
956 + # https://bugs.gentoo.org/641216
957 + # https://sourceware.org/PR22634#c0
958 + case $(tc-arch ${CTARGET}) in
959 + # Keep whitelist of targets where autodetection mostly works.
960 + amd64|x86|sparc|ppc|ppc64|arm|arm64|s390) ;;
961 + # Blacklist everywhere else
962 + *) myconf+=( libc_cv_ld_gnu_indirect_function=no ) ;;
963 + esac
964 +
965 + # Enable Intel Control-flow Enforcement Technology on amd64 if requested
966 + case ${CTARGET} in
967 + x86_64-*) myconf+=( $(use_enable cet) ) ;;
968 + *) ;;
969 + esac
970 +
971 + [[ $(tc-is-softfloat) == "yes" ]] && myconf+=( --without-fp )
972 +
973 + myconf+=( --enable-kernel=${MIN_KERN_VER} )
974 +
975 + # Since SELinux support is only required for nscd, only enable it if:
976 + # 1. USE selinux
977 + # 2. only for the primary ABI on multilib systems
978 + # 3. Not a crosscompile
979 + if ! is_crosscompile && use selinux ; then
980 + if use multilib ; then
981 + if is_final_abi ; then
982 + myconf+=( --with-selinux )
983 + else
984 + myconf+=( --without-selinux )
985 + fi
986 + else
987 + myconf+=( --with-selinux )
988 + fi
989 + else
990 + myconf+=( --without-selinux )
991 + fi
992 +
993 + # Force a few tests where we always know the answer but
994 + # configure is incapable of finding it.
995 + if is_crosscompile ; then
996 + export \
997 + libc_cv_c_cleanup=yes \
998 + libc_cv_forced_unwind=yes
999 + fi
1000 +
1001 + myconf+=(
1002 + --disable-werror
1003 + --enable-bind-now
1004 + --build=${CBUILD_OPT:-${CBUILD}}
1005 + --host=${CTARGET_OPT:-${CTARGET}}
1006 + $(use_enable profile)
1007 + $(use_with gd)
1008 + --with-headers=$(build_eprefix)$(alt_build_headers)
1009 + --prefix="$(host_eprefix)/usr"
1010 + --sysconfdir="$(host_eprefix)/etc"
1011 + --localstatedir="$(host_eprefix)/var"
1012 + --libdir='$(prefix)'/$(get_libdir)
1013 + --mandir='$(prefix)'/share/man
1014 + --infodir='$(prefix)'/share/info
1015 + --libexecdir='$(libdir)'/misc/glibc
1016 + --with-bugurl=https://bugs.gentoo.org/
1017 + --with-pkgversion="$(glibc_banner)"
1018 + $(use_enable crypt)
1019 + $(use_multiarch || echo --disable-multi-arch)
1020 + $(use_enable systemtap)
1021 + $(use_enable nscd)
1022 +
1023 + # locale data is arch-independent
1024 + # https://bugs.gentoo.org/753740
1025 + libc_cv_complocaledir='${exec_prefix}/lib/locale'
1026 +
1027 + # -march= option tricks build system to infer too
1028 + # high ISA level: https://sourceware.org/PR27318
1029 + libc_cv_include_x86_isa_level=no
1030 + # Explicit override of https://sourceware.org/PR27991
1031 + # exposes a bug in glibc's configure:
1032 + # https://sourceware.org/PR27991
1033 + libc_cv_have_x86_lahf_sahf=no
1034 + libc_cv_have_x86_movbe=no
1035 +
1036 + ${EXTRA_ECONF}
1037 + )
1038 +
1039 + # We rely on sys-libs/timezone-data for timezone tools normally.
1040 + myconf+=( $(use_enable vanilla timezone-tools) )
1041 +
1042 + # These libs don't have configure flags.
1043 + ac_cv_lib_audit_audit_log_user_avc_message=$(usex audit || echo no)
1044 + ac_cv_lib_cap_cap_init=$(usex caps || echo no)
1045 +
1046 + # There is no configure option for this and we need to export it
1047 + # since the glibc build will re-run configure on itself
1048 + export libc_cv_rootsbindir="$(host_eprefix)/sbin"
1049 + export libc_cv_slibdir="$(host_eprefix)/$(get_libdir)"
1050 +
1051 + local builddir=$(builddir nptl)
1052 + mkdir -p "${builddir}"
1053 + cd "${builddir}"
1054 + set -- "${S}"/configure "${myconf[@]}"
1055 + echo "$@"
1056 + "$@" || die "failed to configure glibc"
1057 +
1058 + # ia64 static cross-compilers are a pita in so much that they
1059 + # can't produce static ELFs (as the libgcc.a is broken). so
1060 + # disable building of the programs for those targets if it
1061 + # doesn't work.
1062 + # XXX: We could turn this into a compiler test, but ia64 is
1063 + # the only one that matters, so this should be fine for now.
1064 + if is_crosscompile && [[ ${CTARGET} == ia64* ]] ; then
1065 + sed -i '1i+link-static = touch $@' config.make
1066 + fi
1067 +
1068 + # If we're trying to migrate between ABI sets, we need
1069 + # to lie and use a local copy of gcc. Like if the system
1070 + # is built with MULTILIB_ABIS="amd64 x86" but we want to
1071 + # add x32 to it, gcc/glibc don't yet support x32.
1072 + #
1073 + if [[ -n ${GCC_BOOTSTRAP_VER} ]] && use multilib-bootstrap ; then
1074 + echo 'main(){}' > "${T}"/test.c
1075 + if ! $(tc-getCC ${CTARGET}) ${CFLAGS} ${LDFLAGS} "${T}"/test.c -Wl,-emain -lgcc 2>/dev/null ; then
1076 + sed -i -e '/^CC = /s:$: -B$(objdir)/../'"gcc-multilib-bootstrap-${GCC_BOOTSTRAP_VER}/${ABI}:" config.make || die
1077 + fi
1078 + fi
1079 +}
1080 +
1081 +glibc_headers_configure() {
1082 + export ABI=default
1083 +
1084 + local builddir=$(builddir "headers")
1085 + mkdir -p "${builddir}"
1086 + cd "${builddir}"
1087 +
1088 + # if we don't have a compiler yet, we can't really test it now ...
1089 + # hopefully they don't affect header generation, so let's hope for
1090 + # the best here ...
1091 + local v vars=(
1092 + ac_cv_header_cpuid_h=yes
1093 + libc_cv_{386,390,alpha,arm,hppa,ia64,mips,{powerpc,sparc}{,32,64},sh,x86_64}_tls=yes
1094 + libc_cv_asm_cfi_directives=yes
1095 + libc_cv_broken_visibility_attribute=no
1096 + libc_cv_c_cleanup=yes
1097 + libc_cv_compiler_powerpc64le_binary128_ok=yes
1098 + libc_cv_forced_unwind=yes
1099 + libc_cv_gcc___thread=yes
1100 + libc_cv_mlong_double_128=yes
1101 + libc_cv_mlong_double_128ibm=yes
1102 + libc_cv_ppc_machine=yes
1103 + libc_cv_ppc_rel16=yes
1104 + libc_cv_predef_fortify_source=no
1105 + libc_cv_target_power8_ok=yes
1106 + libc_cv_visibility_attribute=yes
1107 + libc_cv_z_combreloc=yes
1108 + libc_cv_z_execstack=yes
1109 + libc_cv_z_initfirst=yes
1110 + libc_cv_z_nodelete=yes
1111 + libc_cv_z_nodlopen=yes
1112 + libc_cv_z_relro=yes
1113 + libc_mips_abi=${ABI}
1114 + libc_mips_float=$([[ $(tc-is-softfloat) == "yes" ]] && echo soft || echo hard)
1115 + # These libs don't have configure flags.
1116 + ac_cv_lib_audit_audit_log_user_avc_message=no
1117 + ac_cv_lib_cap_cap_init=no
1118 + )
1119 +
1120 + einfo "Forcing cached settings:"
1121 + for v in "${vars[@]}" ; do
1122 + einfo " ${v}"
1123 + export ${v}
1124 + done
1125 +
1126 + local headers_only_arch_CPPFLAGS=()
1127 +
1128 + # Blow away some random CC settings that screw things up. #550192
1129 + if [[ -d ${S}/sysdeps/mips ]]; then
1130 + pushd "${S}"/sysdeps/mips >/dev/null
1131 + sed -i -e '/^CC +=/s:=.*:= -D_MIPS_SZPTR=32:' mips32/Makefile mips64/n32/Makefile || die
1132 + sed -i -e '/^CC +=/s:=.*:= -D_MIPS_SZPTR=64:' mips64/n64/Makefile || die
1133 +
1134 + # Force the mips ABI to the default. This is OK because the set of
1135 + # installed headers in this phase is the same between the 3 ABIs.
1136 + # If this ever changes, this hack will break, but that's unlikely
1137 + # as glibc discourages that behavior.
1138 + # https://crbug.com/647033
1139 + sed -i -e 's:abiflag=.*:abiflag=_ABIO32:' preconfigure || die
1140 +
1141 + popd >/dev/null
1142 + fi
1143 +
1144 + case ${CTARGET} in
1145 + riscv*)
1146 + # RISC-V interrogates the compiler to determine which target to
1147 + # build. If building the headers then we don't strictly need a
1148 + # RISC-V compiler, so the built-in definitions that are provided
1149 + # along with all RISC-V compiler might not exist. This causes
1150 + # glibc's RISC-V preconfigure script to blow up. Since we're just
1151 + # building the headers any value will actually work here, so just
1152 + # pick the standard one (rv64g/lp64d) to make the build scripts
1153 + # happy for now -- the headers are all the same anyway so it
1154 + # doesn't matter.
1155 + headers_only_arch_CPPFLAGS+=(
1156 + -D__riscv_xlen=64
1157 + -D__riscv_flen=64
1158 + -D__riscv_float_abi_double=1
1159 + -D__riscv_atomic=1
1160 + ) ;;
1161 + esac
1162 +
1163 + local myconf=()
1164 + myconf+=(
1165 + --disable-sanity-checks
1166 + --enable-hacker-mode
1167 + --disable-werror
1168 + --enable-bind-now
1169 + --build=${CBUILD_OPT:-${CBUILD}}
1170 + --host=${CTARGET_OPT:-${CTARGET}}
1171 + --with-headers=$(build_eprefix)$(alt_build_headers)
1172 + --prefix="$(host_eprefix)/usr"
1173 + ${EXTRA_ECONF}
1174 + )
1175 +
1176 + # Nothing is compiled here which would affect the headers for the target.
1177 + # So forcing CC/CFLAGS is sane.
1178 + local headers_only_CC=$(tc-getBUILD_CC)
1179 + local headers_only_CFLAGS="-O1 -pipe"
1180 + local headers_only_CPPFLAGS="-U_FORTIFY_SOURCE ${headers_only_arch_CPPFLAGS[*]}"
1181 + local headers_only_LDFLAGS=""
1182 + set -- "${S}"/configure "${myconf[@]}"
1183 + echo \
1184 + "CC=${headers_only_CC}" \
1185 + "CFLAGS=${headers_only_CFLAGS}" \
1186 + "CPPFLAGS=${headers_only_CPPFLAGS}" \
1187 + "LDFLAGS=${headers_only_LDFLAGS}" \
1188 + "$@"
1189 + CC=${headers_only_CC} \
1190 + CFLAGS=${headers_only_CFLAGS} \
1191 + CPPFLAGS=${headers_only_CPPFLAGS} \
1192 + LDFLAGS="" \
1193 + "$@" || die "failed to configure glibc"
1194 +}
1195 +
1196 +do_src_configure() {
1197 + if just_headers ; then
1198 + glibc_headers_configure
1199 + else
1200 + glibc_do_configure nptl
1201 + fi
1202 +}
1203 +
1204 +src_configure() {
1205 + foreach_abi do_src_configure
1206 +}
1207 +
1208 +do_src_compile() {
1209 + emake -C "$(builddir nptl)"
1210 +}
1211 +
1212 +src_compile() {
1213 + if just_headers ; then
1214 + return
1215 + fi
1216 +
1217 + foreach_abi do_src_compile
1218 +}
1219 +
1220 +glibc_src_test() {
1221 + cd "$(builddir nptl)"
1222 +
1223 + local myxfailparams=""
1224 + if [[ "${GENTOO_GLIBC_XFAIL_TESTS}" == "yes" ]] ; then
1225 + for myt in ${XFAIL_TEST_LIST[@]} ; do
1226 + myxfailparams+="test-xfail-${myt}=yes "
1227 + done
1228 + fi
1229 +
1230 + # sandbox does not understand unshare() and prevents
1231 + # writes to /proc/, which makes many tests fail
1232 +
1233 + # we give the tests a bit more time to avoid spurious
1234 + # bug reports on slow arches
1235 +
1236 + SANDBOX_ON=0 LD_PRELOAD= TIMEOUTFACTOR=16 emake ${myxfailparams} check
1237 +}
1238 +
1239 +do_src_test() {
1240 + local ret=0
1241 +
1242 + glibc_src_test
1243 + : $(( ret |= $? ))
1244 +
1245 + return ${ret}
1246 +}
1247 +
1248 +src_test() {
1249 + if just_headers ; then
1250 + return
1251 + fi
1252 +
1253 + # Give tests more time to complete.
1254 + export TIMEOUTFACTOR=5
1255 +
1256 + foreach_abi do_src_test || die "tests failed"
1257 +}
1258 +
1259 +run_locale_gen() {
1260 + # if the host locales.gen contains no entries, we'll install everything
1261 + local root="$1"
1262 + local inplace=""
1263 +
1264 + if [[ "${root}" == "--inplace-glibc" ]] ; then
1265 + inplace="--inplace-glibc"
1266 + root="$2"
1267 + fi
1268 +
1269 + local locale_list="${root%/}/etc/locale.gen"
1270 +
1271 + pushd "${ED}"/$(get_libdir) >/dev/null
1272 +
1273 + if [[ -z $(locale-gen --list --config "${locale_list}") ]] ; then
1274 + [[ -z ${inplace} ]] && ewarn "Generating all locales; edit /etc/locale.gen to save time/space"
1275 + locale_list="${root%/}/usr/share/i18n/SUPPORTED"
1276 + fi
1277 +
1278 + set -- locale-gen ${inplace} --jobs $(makeopts_jobs) --config "${locale_list}" \
1279 + --destdir "${root}"
1280 + echo "$@"
1281 + "$@"
1282 +
1283 + popd >/dev/null
1284 +}
1285 +
1286 +glibc_do_src_install() {
1287 + local builddir=$(builddir nptl)
1288 + cd "${builddir}"
1289 +
1290 + emake install_root="${D}/$(build_eprefix)$(alt_prefix)" install
1291 +
1292 + # This version (2.26) provides some compatibility libraries for the NIS/NIS+ support
1293 + # which come without headers etc. Only needed for binary packages since the
1294 + # external net-libs/libnsl has increased soversion. Keep only versioned libraries.
1295 + find "${D}" -name "libnsl.a" -delete
1296 + find "${D}" -name "libnsl.so" -delete
1297 +
1298 + # Normally upstream_pv is ${PV}. Live ebuilds are exception, there we need
1299 + # to infer upstream version:
1300 + # '#define VERSION "2.26.90"' -> '2.26.90'
1301 + local upstream_pv=$(sed -n -r 's/#define VERSION "(.*)"/\1/p' "${S}"/version.h)
1302 +
1303 + # Avoid stripping binaries not targeted by ${CHOST}. Or else
1304 + # ${CHOST}-strip would break binaries build for ${CTARGET}.
1305 + is_crosscompile && dostrip -x /
1306 + # gdb thread introspection relies on local libpthreas symbols. stripping breaks it
1307 + # See Note [Disable automatic stripping]
1308 + dostrip -x $(alt_libdir)/libpthread-${upstream_pv}.so
1309 +
1310 + if [[ -e ${ED}/$(alt_usrlibdir)/libm-${upstream_pv}.a ]] ; then
1311 + # Move versioned .a file out of libdir to evade portage QA checks
1312 + # instead of using gen_usr_ldscript(). We fix ldscript as:
1313 + # "GROUP ( /usr/lib64/libm-<pv>.a ..." -> "GROUP ( /usr/lib64/glibc-<pv>/libm-<pv>.a ..."
1314 + sed -i "s@\(libm-${upstream_pv}.a\)@${P}/\1@" "${ED}"/$(alt_usrlibdir)/libm.a || die
1315 + dodir $(alt_usrlibdir)/${P}
1316 + mv "${ED}"/$(alt_usrlibdir)/libm-${upstream_pv}.a "${ED}"/$(alt_usrlibdir)/${P}/libm-${upstream_pv}.a || die
1317 + fi
1318 +
1319 + # We'll take care of the cache ourselves
1320 + rm -f "${ED}"/etc/ld.so.cache
1321 +
1322 + # Everything past this point just needs to be done once ...
1323 + is_final_abi || return 0
1324 +
1325 + # Make sure the non-native interp can be found on multilib systems even
1326 + # if the main library set isn't installed into the right place. Maybe
1327 + # we should query the active gcc for info instead of hardcoding it ?
1328 + local i ldso_abi ldso_name
1329 + local ldso_abi_list=(
1330 + # x86
1331 + amd64 /lib64/ld-linux-x86-64.so.2
1332 + x32 /libx32/ld-linux-x32.so.2
1333 + x86 /lib/ld-linux.so.2
1334 + # mips
1335 + o32 /lib/ld.so.1
1336 + n32 /lib32/ld.so.1
1337 + n64 /lib64/ld.so.1
1338 + # powerpc
1339 + ppc /lib/ld.so.1
1340 + # riscv
1341 + ilp32d /lib/ld-linux-riscv32-ilp32d.so.1
1342 + ilp32 /lib/ld-linux-riscv32-ilp32.so.1
1343 + lp64d /lib/ld-linux-riscv64-lp64d.so.1
1344 + lp64 /lib/ld-linux-riscv64-lp64.so.1
1345 + # s390
1346 + s390 /lib/ld.so.1
1347 + s390x /lib/ld64.so.1
1348 + # sparc
1349 + sparc32 /lib/ld-linux.so.2
1350 + sparc64 /lib64/ld-linux.so.2
1351 + )
1352 + case $(tc-endian) in
1353 + little)
1354 + ldso_abi_list+=(
1355 + # arm
1356 + arm64 /lib/ld-linux-aarch64.so.1
1357 + # ELFv2 (glibc does not support ELFv1 on LE)
1358 + ppc64 /lib64/ld64.so.2
1359 + )
1360 + ;;
1361 + big)
1362 + ldso_abi_list+=(
1363 + # arm
1364 + arm64 /lib/ld-linux-aarch64_be.so.1
1365 + # ELFv1 (glibc does not support ELFv2 on BE)
1366 + ppc64 /lib64/ld64.so.1
1367 + )
1368 + ;;
1369 + esac
1370 + if [[ ${SYMLINK_LIB} == "yes" ]] && [[ ! -e ${ED}/$(alt_prefix)/lib ]] ; then
1371 + dosym $(get_abi_LIBDIR ${DEFAULT_ABI}) $(alt_prefix)/lib
1372 + fi
1373 + for (( i = 0; i < ${#ldso_abi_list[@]}; i += 2 )) ; do
1374 + ldso_abi=${ldso_abi_list[i]}
1375 + has ${ldso_abi} $(get_install_abis) || continue
1376 +
1377 + ldso_name="$(alt_prefix)${ldso_abi_list[i+1]}"
1378 + if [[ ! -L ${ED}/${ldso_name} && ! -e ${ED}/${ldso_name} ]] ; then
1379 + dosym ../$(get_abi_LIBDIR ${ldso_abi})/${ldso_name##*/} ${ldso_name}
1380 + fi
1381 + done
1382 +
1383 + # In the LSB 5.0 definition, someone had the excellent idea to "standardize"
1384 + # the runtime loader name, see also https://xkcd.com/927/
1385 + # Normally, in Gentoo one should never come across executables that require this.
1386 + # However, binary commercial packages are known to adhere to weird practices.
1387 + # https://refspecs.linuxfoundation.org/LSB_5.0.0/LSB-Core-AMD64/LSB-Core-AMD64.html#BASELIB
1388 + local lsb_ldso_name native_ldso_name lsb_ldso_abi
1389 + local lsb_ldso_abi_list=(
1390 + # x86
1391 + amd64 ld-linux-x86-64.so.2 ld-lsb-x86-64.so.3
1392 + )
1393 + for (( i = 0; i < ${#lsb_ldso_abi_list[@]}; i += 3 )) ; do
1394 + lsb_ldso_abi=${lsb_ldso_abi_list[i]}
1395 + native_ldso_name=${lsb_ldso_abi_list[i+1]}
1396 + lsb_ldso_name=${lsb_ldso_abi_list[i+2]}
1397 + has ${lsb_ldso_abi} $(get_install_abis) || continue
1398 +
1399 + if [[ ! -L ${ED}/$(get_abi_LIBDIR ${lsb_ldso_abi})/${lsb_ldso_name} && ! -e ${ED}/$(get_abi_LIBDIR ${lsb_ldso_abi})/${lsb_ldso_name} ]] ; then
1400 + dosym ${native_ldso_name} "$(alt_prefix)/$(get_abi_LIBDIR ${lsb_ldso_abi})/${lsb_ldso_name}"
1401 + fi
1402 + done
1403 +
1404 + # With devpts under Linux mounted properly, we do not need the pt_chown
1405 + # binary to be setuid. This is because the default owners/perms will be
1406 + # exactly what we want.
1407 + if ! use suid ; then
1408 + find "${ED}" -name pt_chown -exec chmod -s {} +
1409 + fi
1410 +
1411 + #################################################################
1412 + # EVERYTHING AFTER THIS POINT IS FOR NATIVE GLIBC INSTALLS ONLY #
1413 + # Make sure we install some symlink hacks so that when we build
1414 + # a 2nd stage cross-compiler, gcc finds the target system
1415 + # headers correctly. See gcc/doc/gccinstall.info
1416 + if is_crosscompile ; then
1417 + # We need to make sure that /lib and /usr/lib always exists.
1418 + # gcc likes to use relative paths to get to its multilibs like
1419 + # /usr/lib/../lib64/. So while we don't install any files into
1420 + # /usr/lib/, we do need it to exist.
1421 + keepdir $(alt_prefix)/lib
1422 + keepdir $(alt_prefix)/usr/lib
1423 +
1424 + dosym usr/include $(alt_prefix)/sys-include
1425 + return 0
1426 + fi
1427 +
1428 + # Files for Debian-style locale updating
1429 + dodir /usr/share/i18n
1430 + sed \
1431 + -e "/^#/d" \
1432 + -e "/SUPPORTED-LOCALES=/d" \
1433 + -e "s: \\\\::g" -e "s:/: :g" \
1434 + "${S}"/localedata/SUPPORTED > "${ED}"/usr/share/i18n/SUPPORTED \
1435 + || die "generating /usr/share/i18n/SUPPORTED failed"
1436 + cd "${WORKDIR}"/extra/locale
1437 + dosbin locale-gen
1438 + doman *.[0-8]
1439 + insinto /etc
1440 + doins locale.gen
1441 +
1442 + keepdir /usr/lib/locale
1443 +
1444 + cd "${S}"
1445 +
1446 + # Install misc network config files
1447 + insinto /etc
1448 + doins posix/gai.conf
1449 +
1450 + if use systemd ; then
1451 + doins "${WORKDIR}/glibc-systemd-${GLIBC_SYSTEMD_VER}/gentoo-config/nsswitch.conf"
1452 + else
1453 + doins nss/nsswitch.conf
1454 + fi
1455 +
1456 + # Gentoo-specific
1457 + newins "${FILESDIR}"/host.conf-1 host.conf
1458 +
1459 + if use nscd ; then
1460 + doins nscd/nscd.conf
1461 +
1462 + newinitd "$(prefixify_ro "${FILESDIR}"/nscd-1)" nscd
1463 +
1464 + local nscd_args=(
1465 + -e "s:@PIDFILE@:$(strings "${ED}"/usr/sbin/nscd | grep nscd.pid):"
1466 + )
1467 +
1468 + sed -i "${nscd_args[@]}" "${ED}"/etc/init.d/nscd
1469 +
1470 + use systemd && systemd_dounit nscd/nscd.service
1471 + newtmpfiles nscd/nscd.tmpfiles nscd.conf
1472 + fi
1473 +
1474 + echo 'LDPATH="include ld.so.conf.d/*.conf"' > "${T}"/00glibc
1475 + doenvd "${T}"/00glibc
1476 +
1477 + for d in BUGS ChangeLog CONFORMANCE FAQ NEWS NOTES PROJECTS README* ; do
1478 + [[ -s ${d} ]] && dodoc ${d}
1479 + done
1480 + dodoc -r ChangeLog.old
1481 +
1482 + # Prevent overwriting of the /etc/localtime symlink. We'll handle the
1483 + # creation of the "factory" symlink in pkg_postinst().
1484 + rm -f "${ED}"/etc/localtime
1485 +
1486 + # Generate all locales if this is a native build as locale generation
1487 + if use compile-locales && ! is_crosscompile ; then
1488 + run_locale_gen --inplace-glibc "${ED}/"
1489 + sed -e 's:COMPILED_LOCALES="":COMPILED_LOCALES="1":' -i "${ED}"/usr/sbin/locale-gen || die
1490 + fi
1491 +}
1492 +
1493 +glibc_headers_install() {
1494 + local builddir=$(builddir "headers")
1495 + cd "${builddir}"
1496 + emake install_root="${D}/$(build_eprefix)$(alt_prefix)" install-headers
1497 +
1498 + insinto $(alt_headers)/gnu
1499 + doins "${S}"/include/gnu/stubs.h
1500 +
1501 + # Make sure we install the sys-include symlink so that when
1502 + # we build a 2nd stage cross-compiler, gcc finds the target
1503 + # system headers correctly. See gcc/doc/gccinstall.info
1504 + dosym usr/include $(alt_prefix)/sys-include
1505 +}
1506 +
1507 +src_install() {
1508 + if just_headers ; then
1509 + export ABI=default
1510 + glibc_headers_install
1511 + return
1512 + fi
1513 +
1514 + foreach_abi glibc_do_src_install
1515 +
1516 + if ! use static-libs ; then
1517 + einfo "Not installing static glibc libraries"
1518 + find "${ED}" -name "*.a" -and -not -name "*_nonshared.a" -delete
1519 + fi
1520 +}
1521 +
1522 +# Simple test to make sure our new glibc isn't completely broken.
1523 +# Make sure we don't test with statically built binaries since
1524 +# they will fail. Also, skip if this glibc is a cross compiler.
1525 +#
1526 +# If coreutils is built with USE=multicall, some of these files
1527 +# will just be wrapper scripts, not actual ELFs we can test.
1528 +glibc_sanity_check() {
1529 + cd / #228809
1530 +
1531 + # We enter ${ED} so to avoid trouble if the path contains
1532 + # special characters; for instance if the path contains the
1533 + # colon character (:), then the linker will try to split it
1534 + # and look for the libraries in an unexpected place. This can
1535 + # lead to unsafe code execution if the generated prefix is
1536 + # within a world-writable directory.
1537 + # (e.g. /var/tmp/portage:${HOSTNAME})
1538 + pushd "${ED}"/$(get_libdir) >/dev/null
1539 +
1540 + # first let's find the actual dynamic linker here
1541 + # symlinks may point to the wrong abi
1542 + local newldso=$(find . -maxdepth 1 -name 'ld*so.?' -type f -print -quit)
1543 +
1544 + einfo Last-minute run tests with ${newldso} in /$(get_libdir) ...
1545 +
1546 + local x striptest
1547 + for x in cal date env free ls true uname uptime ; do
1548 + x=$(type -p ${x})
1549 + [[ -z ${x} || ${x} != ${EPREFIX}/* ]] && continue
1550 + striptest=$(LC_ALL="C" file -L ${x} 2>/dev/null) || continue
1551 + case ${striptest} in
1552 + *"statically linked"*) continue;;
1553 + *"ASCII text"*) continue;;
1554 + esac
1555 + # We need to clear the locale settings as the upgrade might want
1556 + # incompatible locale data. This test is not for verifying that.
1557 + LC_ALL=C \
1558 + ${newldso} --library-path . ${x} > /dev/null \
1559 + || die "simple run test (${x}) failed"
1560 + done
1561 +
1562 + popd >/dev/null
1563 +}
1564 +
1565 +pkg_preinst() {
1566 + # nothing to do if just installing headers
1567 + just_headers && return
1568 +
1569 + # prepare /etc/ld.so.conf.d/ for files
1570 + mkdir -p "${EROOT}"/etc/ld.so.conf.d
1571 +
1572 + # Default /etc/hosts.conf:multi to on for systems with small dbs.
1573 + if [[ $(wc -l < "${EROOT}"/etc/hosts) -lt 1000 ]] ; then
1574 + sed -i '/^multi off/s:off:on:' "${ED}"/etc/host.conf
1575 + einfo "Defaulting /etc/host.conf:multi to on"
1576 + fi
1577 +
1578 + [[ -n ${ROOT} ]] && return 0
1579 + [[ -d ${ED}/$(get_libdir) ]] || return 0
1580 + [[ -z ${BOOTSTRAP_RAP} ]] && glibc_sanity_check
1581 +
1582 + if [[ -L ${EROOT}/usr/lib/locale ]]; then
1583 + # Help portage migrate this to a directory
1584 + # https://bugs.gentoo.org/753740
1585 + rm "${EROOT}"/usr/lib/locale || die
1586 + fi
1587 +
1588 + # Keep around libcrypt so that Perl doesn't break when merging libxcrypt
1589 + # (libxcrypt is the new provider for now of libcrypt.so.{1,2}).
1590 + # bug #802207
1591 + if ! use crypt && has_version "${CATEGORY}/${PN}[crypt]" && ! has preserve-libs ${FEATURES}; then
1592 + PRESERVED_OLD_LIBCRYPT=1
1593 + cp -p "${EROOT}/$(get_libdir)/libcrypt$(get_libname 1)" "${T}/libcrypt$(get_libname 1)" || die
1594 + else
1595 + PRESERVED_OLD_LIBCRYPT=0
1596 + fi
1597 +}
1598 +
1599 +pkg_postinst() {
1600 + # nothing to do if just installing headers
1601 + just_headers && return
1602 +
1603 + if ! tc-is-cross-compiler && [[ -x ${EROOT}/usr/sbin/iconvconfig ]] ; then
1604 + # Generate fastloading iconv module configuration file.
1605 + "${EROOT}"/usr/sbin/iconvconfig --prefix="${ROOT}/"
1606 + fi
1607 +
1608 + if ! is_crosscompile && [[ -z ${ROOT} ]] ; then
1609 + use compile-locales || run_locale_gen "${EROOT}/"
1610 + fi
1611 +
1612 + upgrade_warning
1613 +
1614 + # Check for sanity of /etc/nsswitch.conf, take 2
1615 + if [[ -e ${EROOT}/etc/nsswitch.conf ]] && ! has_version sys-auth/libnss-nis ; then
1616 + local entry
1617 + for entry in passwd group shadow; do
1618 + if grep -E -q "^[ \t]*${entry}:.*nis" "${EROOT}"/etc/nsswitch.conf; then
1619 + ewarn ""
1620 + ewarn "Your ${EROOT}/etc/nsswitch.conf uses NIS. Support for that has been"
1621 + ewarn "removed from glibc and is now provided by the package"
1622 + ewarn " sys-auth/libnss-nis"
1623 + ewarn "Install it now to keep your NIS setup working."
1624 + ewarn ""
1625 + fi
1626 + done
1627 + fi
1628 +
1629 + if [[ ${PRESERVED_OLD_LIBCRYPT} -eq 1 ]] ; then
1630 + cp -p "${T}/libcrypt$(get_libname 1)" "${EROOT}/$(get_libdir)/libcrypt$(get_libname 1)" || die
1631 + preserve_old_lib_notify /$(get_libdir)/libcrypt$(get_libname 1)
1632 +
1633 + elog "Please ignore a possible later error message about a file collision involving"
1634 + elog "${EROOT}/$(get_libdir)/libcrypt$(get_libname 1). We need to preserve this file for the moment to keep"
1635 + elog "the upgrade working, but it also needs to be overwritten when"
1636 + elog "sys-libs/libxcrypt is installed. See bug 802210 for more details."
1637 + fi
1638 +}