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