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