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