Gentoo Archives: gentoo-commits

From: "Andreas K. Hüttel" <dilfridge@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-libs/glibc/
Date: Tue, 17 May 2022 21:18:57
Message-Id: 1652822322.40aa70ae06da9420817e4c843fd2da016c4d6d79.dilfridge@gentoo
1 commit: 40aa70ae06da9420817e4c843fd2da016c4d6d79
2 Author: Andreas K. Hüttel <dilfridge <AT> gentoo <DOT> org>
3 AuthorDate: Tue May 17 21:18:28 2022 +0000
4 Commit: Andreas K. Hüttel <dilfridge <AT> gentoo <DOT> org>
5 CommitDate: Tue May 17 21:18:42 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=40aa70ae
7
8 sys-libs/glibc: 2.35 patchlevel revbump; untested, no keywords
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.35-r5.ebuild | 1596 +++++++++++++++++++++++++++++++++++
15 2 files changed, 1597 insertions(+)
16
17 diff --git a/sys-libs/glibc/Manifest b/sys-libs/glibc/Manifest
18 index a1bf7ef861c3..1d438fcb361c 100644
19 --- a/sys-libs/glibc/Manifest
20 +++ b/sys-libs/glibc/Manifest
21 @@ -17,6 +17,7 @@ DIST glibc-2.34-patches-17.tar.xz 241584 BLAKE2B e4eea130c331f64ba66e14a6ba31885
22 DIST glibc-2.34.tar.xz 17301232 BLAKE2B 874031192f2f5a3b35c3f5b044a467d4be4e67e8593e070e5b49b901ce8ea6bde2f8d2f6c92fa33b3f61eb723572a9e5f2b45e56064168df80a96d3fdb6fa30c SHA512 15252affd9ef4523a8001db16d497f4fdcb3ddf4cde7fe80e075df0bd3cc6524dc29fbe20229dbf5f97af580556e6b1fac0de321a5fe25322bc3e72f93beb624
23 DIST glibc-2.35-loongarch-patches-20220422.tar.xz 44804 BLAKE2B b93720e45d23c8d17918ffaa480351499f4748bc08ab6e1f1fd3c681fcc0b08a3381188f5d4f14e6706baa5eb45c787bc635d0e8ea59712514012caf93992222 SHA512 28e2d02f07fcf61f76585dd59627314ed20ebe29ecd7ae7f5aea8db0704482fc024fee744cbee1776e666d14b80b1393f64cd2283e3c39be4c97ebe09efcdee2
24 DIST glibc-2.35-patches-6.tar.xz 57236 BLAKE2B a03845733e2f0ebe179523458695963d729b4211b4ce14310d55163cd33aff502f9e14a4bb0068410777e9b9bb5be4ef7ad1a1fd51debf9191dcf89dc9ff08b8 SHA512 59c5e1669677e969873f5bba38958316a3b32523cac628b97513aed864e191da10499edac77bb5e9a07179d14cf3c75073fd03e8427f7bcfd68fedcedc35083e
25 +DIST glibc-2.35-patches-7.tar.xz 163840 BLAKE2B 55352eeaf70f74fd8fcd21bd7f3ba14121b496dcfb59e06b5a73be36838dda4b39fc22201c4320c0c38a454c7f1539aae7f3307107e460bede25be33c0525c11 SHA512 d39bb2fecad8cd9213c61e279823f89c3daf9a4f630ac71503df2e9bfb74e019c996bed9a93aaad89083a729a1d3792e7ed8313ac54d757f47d5614ac3469e59
26 DIST glibc-2.35.tar.xz 18165952 BLAKE2B 623c728884f070cd87ffeb9203f74206197c52405ac9bc44f3dd519a3468b8e8ae2536c883e5d17d94417dbd1e91775de2e674314e4ff7424f9720026d6b7063 SHA512 e7336ce27561be5d7c217832a1136fb327e057bd8d3f92925b35c97e3e9f9e486948b5a1e03e5e4090772ef06437a074d10b82e68f17f1ad8f22077ee39e1b66
27 DIST glibc-systemd-20210729.tar.gz 1480 BLAKE2B 37722c7579df782d890e44dbab99c3de52ab466eb9de80d82405e9bb5620bf39ffc8c5f466a435bdb86ef6d36dd7019c0736573916bda6c67d02a2581e0ec979 SHA512 efd75af58b50522c28cdac7abd1fc56555bc1bb042512c90d8340c1ec09c5791b3872a305bf83723252bbde5855b75d958c041083457765c4cfd170732d09238
28 DIST glibc-systemd-20210814.tar.gz 1469 BLAKE2B 10fa7bcb46d4fdce9c0ab353cbd30871e9b09a347a13a9c9a3b5777f931aa3c826c158d2e49532c604d4a834f2fab4089b67495fb88d0398945dc50d45ad9ef1 SHA512 5346a9ea459a1e6ccf665389f2a294de1e16f1e3e05cdf07e3dd99ed0e4f6f8b52cc333d4bff3c75ac90ab6ce70cd4ab2b3e126f920ce7979abd6dda56315efc
29
30 diff --git a/sys-libs/glibc/glibc-2.35-r5.ebuild b/sys-libs/glibc/glibc-2.35-r5.ebuild
31 new file mode 100644
32 index 000000000000..f94584823dcc
33 --- /dev/null
34 +++ b/sys-libs/glibc/glibc-2.35-r5.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 +PYTHON_COMPAT=( python3_{8..10} )
45 +TMPFILES_OPTIONAL=1
46 +
47 +inherit python-any-r1 prefix preserve-libs toolchain-funcs flag-o-matic gnuconfig \
48 + multilib systemd multiprocessing tmpfiles
49 +
50 +DESCRIPTION="GNU libc C library"
51 +HOMEPAGE="https://www.gnu.org/software/libc/"
52 +LICENSE="LGPL-2.1+ BSD HPND ISC inner-net rc PCRE"
53 +SLOT="2.2"
54 +
55 +EMULTILIB_PKG="true"
56 +
57 +# Gentoo patchset (ignored for live ebuilds)
58 +PATCH_VER=7
59 +PATCH_DEV=dilfridge
60 +
61 +if [[ ${PV} == 9999* ]]; then
62 + inherit git-r3
63 +else
64 + #KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86"
65 + SRC_URI="mirror://gnu/glibc/${P}.tar.xz"
66 + SRC_URI+=" https://dev.gentoo.org/~${PATCH_DEV}/distfiles/${P}-patches-${PATCH_VER}.tar.xz"
67 + SRC_URI+=" experimental-loong? ( https://dev.gentoo.org/~xen0n/distfiles/glibc-2.35-loongarch-patches-20220422.tar.xz )"
68 +fi
69 +
70 +RELEASE_VER=${PV}
71 +
72 +GCC_BOOTSTRAP_VER=20201208
73 +
74 +LOCALE_GEN_VER=2.22
75 +
76 +GLIBC_SYSTEMD_VER=20210729
77 +
78 +SRC_URI+=" https://gitweb.gentoo.org/proj/locale-gen.git/snapshot/locale-gen-${LOCALE_GEN_VER}.tar.gz"
79 +SRC_URI+=" multilib-bootstrap? ( https://dev.gentoo.org/~dilfridge/distfiles/gcc-multilib-bootstrap-${GCC_BOOTSTRAP_VER}.tar.xz )"
80 +SRC_URI+=" systemd? ( https://gitweb.gentoo.org/proj/toolchain/glibc-systemd.git/snapshot/glibc-systemd-${GLIBC_SYSTEMD_VER}.tar.gz )"
81 +
82 +IUSE="audit caps cet +clone3 compile-locales +crypt custom-cflags doc experimental-loong gd headers-only +multiarch multilib multilib-bootstrap nscd profile selinux +ssp +static-libs suid systemd systemtap test vanilla"
83 +
84 +# Minimum kernel version that glibc requires
85 +MIN_KERN_VER="3.2.0"
86 +# Minimum pax-utils version needed (which contains any new syscall changes for
87 +# its seccomp filter!). Please double check this!
88 +MIN_PAX_UTILS_VER="1.3.3"
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-${MIN_PAX_UTILS_VER}
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-${MIN_PAX_UTILS_VER}
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.2
184 + )"
185 + [[ ${CATEGORY} == *-linux* ]] && DEPEND+=" ${CATEGORY}/linux-headers"
186 +else
187 + BDEPEND+="
188 + >=sys-devel/binutils-2.27
189 + >=sys-devel/gcc-6.2
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 + # buggy test, assumes /dev/ and /dev/null on a single filesystem
206 + # 'mount --bind /dev/null /chroot/dev/null' breaks it.
207 + # https://sourceware.org/PR25909
208 + tst-support_descriptors
209 +
210 + # The following tests fail only inside portage
211 + # https://bugs.gentoo.org/831267
212 + tst-system
213 + tst-strerror
214 + tst-strsignal
215 +)
216 +
217 +#
218 +# Small helper functions
219 +#
220 +
221 +is_crosscompile() {
222 + [[ ${CHOST} != ${CTARGET} ]]
223 +}
224 +
225 +just_headers() {
226 + is_crosscompile && use headers-only
227 +}
228 +
229 +alt_prefix() {
230 + is_crosscompile && echo /usr/${CTARGET}
231 +}
232 +
233 +# This prefix is applicable to CHOST when building against this
234 +# glibc. It is baked into the library at configure time.
235 +host_eprefix() {
236 + is_crosscompile || echo "${EPREFIX}"
237 +}
238 +
239 +# This prefix is applicable to CBUILD when building against this
240 +# glibc. It determines the destination path at install time.
241 +build_eprefix() {
242 + is_crosscompile && echo "${EPREFIX}"
243 +}
244 +
245 +# We need to be able to set alternative headers for compiling for non-native
246 +# platform. Will also become useful for testing kernel-headers without screwing
247 +# up the whole system.
248 +alt_headers() {
249 + echo ${ALT_HEADERS:=$(alt_prefix)/usr/include}
250 +}
251 +
252 +alt_build_headers() {
253 + if [[ -z ${ALT_BUILD_HEADERS} ]] ; then
254 + ALT_BUILD_HEADERS="$(host_eprefix)$(alt_headers)"
255 + if tc-is-cross-compiler ; then
256 + ALT_BUILD_HEADERS=${SYSROOT}$(alt_headers)
257 + if [[ ! -e ${ALT_BUILD_HEADERS}/linux/version.h ]] ; then
258 + local header_path=$(echo '#include <linux/version.h>' | $(tc-getCPP ${CTARGET}) ${CFLAGS} 2>&1 | grep -o '[^"]*linux/version.h')
259 + ALT_BUILD_HEADERS=${header_path%/linux/version.h}
260 + fi
261 + fi
262 + fi
263 + echo "${ALT_BUILD_HEADERS}"
264 +}
265 +
266 +alt_libdir() {
267 + echo $(alt_prefix)/$(get_libdir)
268 +}
269 +alt_usrlibdir() {
270 + echo $(alt_prefix)/usr/$(get_libdir)
271 +}
272 +
273 +builddir() {
274 + echo "${WORKDIR}/build-${ABI}-${CTARGET}-$1"
275 +}
276 +
277 +do_compile_test() {
278 + local ret save_cflags=${CFLAGS}
279 + CFLAGS+=" $1"
280 + shift
281 +
282 + pushd "${T}" >/dev/null
283 +
284 + rm -f glibc-test*
285 + printf '%b' "$*" > glibc-test.c
286 +
287 + # We assume CC is already set up.
288 + nonfatal emake glibc-test
289 + ret=$?
290 +
291 + popd >/dev/null
292 +
293 + CFLAGS=${save_cflags}
294 + return ${ret}
295 +}
296 +
297 +do_run_test() {
298 + local ret
299 +
300 + if [[ ${MERGE_TYPE} == "binary" ]] ; then
301 + # ignore build failures when installing a binary package #324685
302 + do_compile_test "" "$@" 2>/dev/null || return 0
303 + else
304 + if ! do_compile_test "" "$@" ; then
305 + ewarn "Simple build failed ... assuming this is desired #324685"
306 + return 0
307 + fi
308 + fi
309 +
310 + pushd "${T}" >/dev/null
311 +
312 + ./glibc-test
313 + ret=$?
314 + rm -f glibc-test*
315 +
316 + popd >/dev/null
317 +
318 + return ${ret}
319 +}
320 +
321 +setup_target_flags() {
322 + # This largely mucks with compiler flags. None of which should matter
323 + # when building up just the headers.
324 + just_headers && return 0
325 +
326 + case $(tc-arch) in
327 + x86)
328 + # -march needed for #185404 #199334
329 + # TODO: When creating the first glibc cross-compile, this test will
330 + # always fail as it does a full link which in turn requires glibc.
331 + # Probably also applies when changing multilib profile settings (e.g.
332 + # enabling x86 when the profile was amd64-only previously).
333 + # We could change main to _start and pass -nostdlib here so that we
334 + # only test the gcc code compilation. Or we could do a compile and
335 + # then look for the symbol via scanelf.
336 + 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
337 + local t=${CTARGET_OPT:-${CTARGET}}
338 + t=${t%%-*}
339 + filter-flags '-march=*'
340 + export CFLAGS="-march=${t} ${CFLAGS}"
341 + einfo "Auto adding -march=${t} to CFLAGS #185404"
342 + fi
343 + ;;
344 + amd64)
345 + # -march needed for #185404 #199334
346 + # TODO: See cross-compile issues listed above for x86.
347 + [[ ${ABI} == x86 ]] &&
348 + 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
349 + local t=${CTARGET_OPT:-${CTARGET}}
350 + t=${t%%-*}
351 + # Normally the target is x86_64-xxx, so turn that into the -march that
352 + # gcc actually accepts. #528708
353 + [[ ${t} == "x86_64" ]] && t="x86-64"
354 + filter-flags '-march=*'
355 + # ugly, ugly, ugly. ugly.
356 + CFLAGS_x86=$(CFLAGS=${CFLAGS_x86} filter-flags '-march=*'; echo "${CFLAGS}")
357 + export CFLAGS_x86="${CFLAGS_x86} -march=${t}"
358 + einfo "Auto adding -march=${t} to CFLAGS_x86 #185404 (ABI=${ABI})"
359 + fi
360 + ;;
361 + mips)
362 + # The mips abi cannot support the GNU style hashes. #233233
363 + filter-ldflags -Wl,--hash-style=gnu -Wl,--hash-style=both
364 + ;;
365 + ppc|ppc64)
366 + # Many arch-specific implementations do not work on ppc with
367 + # cache-block not equal to 128 bytes. This breaks memset:
368 + # https://sourceware.org/PR26522
369 + # https://bugs.gentoo.org/737996
370 + # Use default -mcpu=. For ppc it means non-multiarch setup.
371 + filter-flags '-mcpu=*'
372 + ;;
373 + sparc)
374 + # Both sparc and sparc64 can use -fcall-used-g6. -g7 is bad, though.
375 + filter-flags "-fcall-used-g7"
376 + append-flags "-fcall-used-g6"
377 +
378 + local cpu
379 + case ${CTARGET} in
380 + sparc64-*)
381 + cpu="sparc64"
382 + case $(get-flag mcpu) in
383 + v9)
384 + # We need to force at least v9a because the base build doesn't
385 + # work with just v9.
386 + # https://sourceware.org/bugzilla/show_bug.cgi?id=19477
387 + append-flags "-Wa,-xarch=v9a"
388 + ;;
389 + esac
390 + ;;
391 + sparc-*)
392 + case $(get-flag mcpu) in
393 + v8|supersparc|hypersparc|leon|leon3)
394 + cpu="sparcv8"
395 + ;;
396 + *)
397 + cpu="sparcv9"
398 + ;;
399 + esac
400 + ;;
401 + esac
402 + [[ -n ${cpu} ]] && CTARGET_OPT="${cpu}-${CTARGET#*-}"
403 + ;;
404 + esac
405 +}
406 +
407 +setup_flags() {
408 + # Make sure host make.conf doesn't pollute us
409 + if is_crosscompile || tc-is-cross-compiler ; then
410 + CHOST=${CTARGET} strip-unsupported-flags
411 + fi
412 +
413 + # Store our CFLAGS because it's changed depending on which CTARGET
414 + # we are building when pulling glibc on a multilib profile
415 + CFLAGS_BASE=${CFLAGS_BASE-${CFLAGS}}
416 + CFLAGS=${CFLAGS_BASE}
417 + CXXFLAGS_BASE=${CXXFLAGS_BASE-${CXXFLAGS}}
418 + CXXFLAGS=${CXXFLAGS_BASE}
419 + ASFLAGS_BASE=${ASFLAGS_BASE-${ASFLAGS}}
420 + ASFLAGS=${ASFLAGS_BASE}
421 +
422 + # Allow users to explicitly avoid flag sanitization via
423 + # USE=custom-cflags.
424 + if ! use custom-cflags; then
425 + # Over-zealous CFLAGS can often cause problems. What may work for one
426 + # person may not work for another. To avoid a large influx of bugs
427 + # relating to failed builds, we strip most CFLAGS out to ensure as few
428 + # problems as possible.
429 + strip-flags
430 + # Lock glibc at -O2; we want to be conservative here.
431 + filter-flags '-O?'
432 + append-flags -O2
433 + fi
434 +
435 + strip-unsupported-flags
436 + filter-flags -m32 -m64 '-mabi=*'
437 +
438 + # glibc aborts if rpath is set by LDFLAGS
439 + filter-ldflags '-Wl,-rpath=*'
440 +
441 + # ld can't use -r & --relax at the same time, bug #788901
442 + # https://sourceware.org/PR27837
443 + filter-ldflags '-Wl,--relax'
444 +
445 + # #492892
446 + filter-flags -frecord-gcc-switches
447 +
448 + # #829583
449 + filter-lfs-flags
450 +
451 + unset CBUILD_OPT CTARGET_OPT
452 + if use multilib ; then
453 + CTARGET_OPT=$(get_abi_CTARGET)
454 + [[ -z ${CTARGET_OPT} ]] && CTARGET_OPT=$(get_abi_CHOST)
455 + fi
456 +
457 + setup_target_flags
458 +
459 + if [[ -n ${CTARGET_OPT} && ${CBUILD} == ${CHOST} ]] && ! is_crosscompile; then
460 + CBUILD_OPT=${CTARGET_OPT}
461 + fi
462 +
463 + # glibc's headers disallow -O0 and fail at build time:
464 + # include/libc-symbols.h:75:3: #error "glibc cannot be compiled without optimization"
465 + replace-flags -O0 -O1
466 +
467 + filter-flags '-fstack-protector*'
468 +
469 + # See end of bug #830454; we handle this via USE=cet
470 + filter-flags '-fcf-protection='
471 +}
472 +
473 +use_multiarch() {
474 + # Allow user to disable runtime arch detection in multilib.
475 + use multiarch || return 1
476 + # Make sure binutils is new enough to support indirect functions,
477 + # #336792. This funky sed supports gold and bfd linkers.
478 + local bver nver
479 + bver=$($(tc-getLD ${CTARGET}) -v | sed -n -r '1{s:[^0-9]*::;s:^([0-9.]*).*:\1:;p}')
480 + case $(tc-arch ${CTARGET}) in
481 + amd64|x86) nver="2.20" ;;
482 + arm) nver="2.22" ;;
483 + hppa) nver="2.23" ;;
484 + ppc|ppc64) nver="2.20" ;;
485 + # ifunc support was added in 2.23, but glibc also needs
486 + # machinemode which is in 2.24.
487 + s390) nver="2.24" ;;
488 + sparc) nver="2.21" ;;
489 + *) return 1 ;;
490 + esac
491 + ver_test ${bver} -ge ${nver}
492 +}
493 +
494 +# Setup toolchain variables that had historically been defined in the
495 +# profiles for these archs.
496 +setup_env() {
497 + # silly users
498 + unset LD_RUN_PATH
499 + unset LD_ASSUME_KERNEL
500 +
501 + if is_crosscompile || tc-is-cross-compiler ; then
502 + multilib_env ${CTARGET_OPT:-${CTARGET}}
503 +
504 + if ! use multilib ; then
505 + MULTILIB_ABIS=${DEFAULT_ABI}
506 + else
507 + MULTILIB_ABIS=${MULTILIB_ABIS:-${DEFAULT_ABI}}
508 + fi
509 +
510 + # If the user has CFLAGS_<CTARGET> in their make.conf, use that,
511 + # and fall back on CFLAGS.
512 + local VAR=CFLAGS_${CTARGET//[-.]/_}
513 + CFLAGS=${!VAR-${CFLAGS}}
514 + einfo " $(printf '%15s' 'Manual CFLAGS:') ${CFLAGS}"
515 + fi
516 +
517 + setup_flags
518 +
519 + export ABI=${ABI:-${DEFAULT_ABI:-default}}
520 +
521 + if just_headers ; then
522 + # Avoid mixing host's CC and target's CFLAGS_${ABI}:
523 + # At this bootstrap stage we have only binutils for
524 + # target but not compiler yet.
525 + einfo "Skip CC ABI injection. We can't use (cross-)compiler yet."
526 + return 0
527 + fi
528 +
529 + # Glibc does not work with gold (for various reasons) #269274.
530 + tc-ld-disable-gold
531 +
532 + if use doc ; then
533 + export MAKEINFO=makeinfo
534 + else
535 + export MAKEINFO=/dev/null
536 + fi
537 +
538 + # Reset CC and CXX to the value at start of emerge
539 + export CC=${__ORIG_CC:-${CC:-$(tc-getCC ${CTARGET})}}
540 + export CXX=${__ORIG_CXX:-${CXX:-$(tc-getCXX ${CTARGET})}}
541 +
542 + # and make sure __ORIC_CC and __ORIG_CXX is defined now.
543 + export __ORIG_CC=${CC}
544 + export __ORIG_CXX=${CXX}
545 +
546 + if tc-is-clang && ! use custom-cflags && ! is_crosscompile ; then
547 +
548 + # If we are running in an otherwise clang/llvm environment, we need to
549 + # recover the proper gcc and binutils settings here, at least until glibc
550 + # is finally building with clang. So let's override everything that is
551 + # set in the clang profiles.
552 + # Want to shoot yourself into the foot? Set USE=custom-cflags, that's always
553 + # a good start into that direction.
554 + # Also, if you're crosscompiling, let's assume you know what you are doing.
555 + # Hopefully.
556 + # Last, we need the settings of the *build* environment, not of the
557 + # target environment...
558 +
559 + local current_binutils_path=$(env ROOT="${BROOT}" binutils-config -B)
560 + local current_gcc_path=$(env ROOT="${BROOT}" gcc-config -B)
561 + einfo "Overriding clang configuration, since it won't work here"
562 +
563 + export CC="${current_gcc_path}/gcc"
564 + export CXX="${current_gcc_path}/g++"
565 + export LD="${current_binutils_path}/ld.bfd"
566 + export AR="${current_binutils_path}/ar"
567 + export AS="${current_binutils_path}/as"
568 + export NM="${current_binutils_path}/nm"
569 + export STRIP="${current_binutils_path}/strip"
570 + export RANLIB="${current_binutils_path}/ranlib"
571 + export OBJCOPY="${current_binutils_path}/objcopy"
572 + export STRINGS="${current_binutils_path}/strings"
573 + export OBJDUMP="${current_binutils_path}/objdump"
574 + export READELF="${current_binutils_path}/readelf"
575 + export ADDR2LINE="${current_binutils_path}/addr2line"
576 +
577 + # do we need to also do flags munging here? yes! at least...
578 + filter-flags '-fuse-ld=*'
579 + filter-flags '-D_FORTIFY_SOURCE=*'
580 +
581 + else
582 +
583 + # this is the "normal" case
584 +
585 + export CC="$(tc-getCC ${CTARGET})"
586 + export CXX="$(tc-getCXX ${CTARGET})"
587 +
588 + # Always use tuple-prefixed toolchain. For non-native ABI glibc's configure
589 + # can't detect them automatically due to ${CHOST} mismatch and fallbacks
590 + # to unprefixed tools. Similar to multilib.eclass:multilib_toolchain_setup().
591 + export NM="$(tc-getNM ${CTARGET})"
592 + export READELF="$(tc-getREADELF ${CTARGET})"
593 +
594 + fi
595 +
596 + # We need to export CFLAGS with abi information in them because glibc's
597 + # configure script checks CFLAGS for some targets (like mips). Keep
598 + # around the original clean value to avoid appending multiple ABIs on
599 + # top of each other. (Why does the comment talk about CFLAGS if the code
600 + # acts on CC?)
601 + export __GLIBC_CC=${CC}
602 + export __GLIBC_CXX=${CXX}
603 +
604 + export __abi_CFLAGS="$(get_abi_CFLAGS)"
605 +
606 + # CFLAGS can contain ABI-specific flags like -mfpu=neon, see bug #657760
607 + # To build .S (assembly) files with the same ABI-specific flags
608 + # upstream currently recommends adding CFLAGS to CC/CXX:
609 + # https://sourceware.org/PR23273
610 + # Note: Passing CFLAGS via CPPFLAGS overrides glibc's arch-specific CFLAGS
611 + # and breaks multiarch support. See 659030#c3 for an example.
612 + # The glibc configure script doesn't properly use LDFLAGS all the time.
613 + export CC="${__GLIBC_CC} ${__abi_CFLAGS} ${CFLAGS} ${LDFLAGS}"
614 +
615 + # Some of the tests are written in C++, so we need to force our multlib abis in, bug 623548
616 + export CXX="${__GLIBC_CXX} ${__abi_CFLAGS} ${CFLAGS}"
617 +
618 + if is_crosscompile; then
619 + # Assume worst-case bootstrap: glibc is buil first time
620 + # when ${CTARGET}-g++ is not available yet. We avoid
621 + # building auxiliary programs that require C++: bug #683074
622 + # It should not affect final result.
623 + export libc_cv_cxx_link_ok=no
624 + # The line above has the same effect. We set CXX explicitly
625 + # to make build logs less confusing.
626 + export CXX=
627 + fi
628 +}
629 +
630 +foreach_abi() {
631 + setup_env
632 +
633 + local ret=0
634 + local abilist=""
635 + if use multilib ; then
636 + abilist=$(get_install_abis)
637 + else
638 + abilist=${DEFAULT_ABI}
639 + fi
640 + local -x ABI
641 + for ABI in ${abilist:-default} ; do
642 + setup_env
643 + einfo "Running $1 for ABI ${ABI}"
644 + $1
645 + : $(( ret |= $? ))
646 + done
647 + return ${ret}
648 +}
649 +
650 +glibc_banner() {
651 + local b="Gentoo ${PVR}"
652 + [[ -n ${PATCH_VER} ]] && ! use vanilla && b+=" p${PATCH_VER}"
653 + echo "${b}"
654 +}
655 +
656 +# The following Kernel version handling functions are mostly copied from portage
657 +# source. It's better not to use linux-info.eclass here since a) it adds too
658 +# much magic, see bug 326693 for some of the arguments, and b) some of the
659 +# functions are just not provided.
660 +
661 +g_get_running_KV() {
662 + uname -r
663 + return $?
664 +}
665 +
666 +g_KV_major() {
667 + [[ -z $1 ]] && return 1
668 + local KV=$@
669 + echo "${KV%%.*}"
670 +}
671 +
672 +g_KV_minor() {
673 + [[ -z $1 ]] && return 1
674 + local KV=$@
675 + KV=${KV#*.}
676 + echo "${KV%%.*}"
677 +}
678 +
679 +g_KV_micro() {
680 + [[ -z $1 ]] && return 1
681 + local KV=$@
682 + KV=${KV#*.*.}
683 + echo "${KV%%[^[:digit:]]*}"
684 +}
685 +
686 +g_KV_to_int() {
687 + [[ -z $1 ]] && return 1
688 + local KV_MAJOR=$(g_KV_major "$1")
689 + local KV_MINOR=$(g_KV_minor "$1")
690 + local KV_MICRO=$(g_KV_micro "$1")
691 + local KV_int=$(( KV_MAJOR * 65536 + KV_MINOR * 256 + KV_MICRO ))
692 +
693 + # We make version 2.2.0 the minimum version we will handle as
694 + # a sanity check ... if its less, we fail ...
695 + if [[ ${KV_int} -ge 131584 ]] ; then
696 + echo "${KV_int}"
697 + return 0
698 + fi
699 + return 1
700 +}
701 +
702 +g_int_to_KV() {
703 + local version=$1 major minor micro
704 + major=$((version / 65536))
705 + minor=$(((version % 65536) / 256))
706 + micro=$((version % 256))
707 + echo ${major}.${minor}.${micro}
708 +}
709 +
710 +eend_KV() {
711 + [[ $(g_KV_to_int $1) -ge $(g_KV_to_int $2) ]]
712 + eend $?
713 +}
714 +
715 +get_kheader_version() {
716 + printf '#include <linux/version.h>\nLINUX_VERSION_CODE\n' | \
717 + $(tc-getCPP ${CTARGET}) -I "$(build_eprefix)$(alt_build_headers)" - | \
718 + tail -n 1
719 +}
720 +
721 +# We collect all sanity checks here. Consistency is not guranteed between
722 +# pkg_ and src_ phases, so we call this function both in pkg_pretend and in
723 +# src_unpack.
724 +sanity_prechecks() {
725 + # Prevent native builds from downgrading
726 + if [[ ${MERGE_TYPE} != "buildonly" ]] && \
727 + [[ -z ${ROOT} ]] && \
728 + [[ ${CBUILD} == ${CHOST} ]] && \
729 + [[ ${CHOST} == ${CTARGET} ]] ; then
730 +
731 + # The high rev # is to allow people to downgrade between -r#
732 + # versions. We want to block 2.20->2.19, but 2.20-r3->2.20-r2
733 + # should be fine. Hopefully we never actually use a r# this
734 + # high.
735 + if has_version ">${CATEGORY}/${P}-r10000" ; then
736 + eerror "Sanity check to keep you from breaking your system:"
737 + eerror " Downgrading glibc is not supported and a sure way to destruction."
738 + [[ ${I_ALLOW_TO_BREAK_MY_SYSTEM} = yes ]] || die "Aborting to save your system."
739 + fi
740 +
741 + if ! do_run_test '#include <unistd.h>\n#include <sys/syscall.h>\nint main(){return syscall(1000)!=-1;}\n' ; then
742 + eerror "Your old kernel is broken. You need to update it to a newer"
743 + eerror "version as syscall(<bignum>) will break. See bug 279260."
744 + die "Old and broken kernel."
745 + fi
746 + fi
747 +
748 + # Users have had a chance to phase themselves, time to give em the boot
749 + if [[ -e ${EROOT}/etc/locale.gen ]] && [[ -e ${EROOT}/etc/locales.build ]] ; then
750 + eerror "You still haven't deleted ${EROOT}/etc/locales.build."
751 + eerror "Do so now after making sure ${EROOT}/etc/locale.gen is kosher."
752 + die "Lazy upgrader detected"
753 + fi
754 +
755 + if [[ ${CTARGET} == i386-* ]] ; then
756 + eerror "i386 CHOSTs are no longer supported."
757 + eerror "Chances are you don't actually want/need i386."
758 + eerror "Please read https://www.gentoo.org/doc/en/change-chost.xml"
759 + die "Please fix your CHOST"
760 + fi
761 +
762 + if [[ -e /proc/xen ]] && [[ $(tc-arch) == "x86" ]] && ! is-flag -mno-tls-direct-seg-refs ; then
763 + ewarn "You are using Xen but don't have -mno-tls-direct-seg-refs in your CFLAGS."
764 + ewarn "This will result in a 50% performance penalty when running with a 32bit"
765 + ewarn "hypervisor, which is probably not what you want."
766 + fi
767 +
768 + # ABI-specific checks follow here. Hey, we have a lot more specific conditions that
769 + # we test for...
770 + if ! is_crosscompile ; then
771 + if use amd64 && use multilib && [[ ${MERGE_TYPE} != "binary" ]] ; then
772 + ebegin "Checking that IA32 emulation is enabled in the running kernel"
773 + echo 'int main(){return 0;}' > "${T}/check-ia32-emulation.c"
774 + local STAT
775 + if ${CC-${CHOST}-gcc} ${CFLAGS_x86} "${T}/check-ia32-emulation.c" -o "${T}/check-ia32-emulation.elf32"; then
776 + "${T}/check-ia32-emulation.elf32"
777 + STAT=$?
778 + else
779 + # Don't fail here to allow single->multi ABI switch
780 + # or recover from breakage like bug #646424
781 + ewarn "Failed to compile the ABI test. Broken host glibc?"
782 + STAT=0
783 + fi
784 + rm -f "${T}/check-ia32-emulation.elf32"
785 + eend $STAT
786 + [[ $STAT -eq 0 ]] || die "CONFIG_IA32_EMULATION must be enabled in the kernel to compile a multilib glibc."
787 + fi
788 +
789 + fi
790 +
791 + # When we actually have to compile something...
792 + if ! just_headers && [[ ${MERGE_TYPE} != "binary" ]] ; then
793 + if [[ -d "${ESYSROOT}"/usr/lib/include ]] ; then
794 + # bug #833620, bug #643302
795 + eerror "Found ${ESYSROOT}/usr/lib/include directory!"
796 + eerror "This is known to break glibc's build."
797 + eerror "Please backup its contents then remove the directory."
798 + die "Found directory (${ESYSROOT}/usr/lib/include) which will break build (bug #833620)!"
799 + fi
800 +
801 + if [[ ${CTARGET} == *-linux* ]] ; then
802 + local run_kv build_kv want_kv
803 +
804 + run_kv=$(g_get_running_KV)
805 + build_kv=$(g_int_to_KV $(get_kheader_version))
806 + want_kv=${MIN_KERN_VER}
807 +
808 + if ! is_crosscompile && ! tc-is-cross-compiler ; then
809 + # Building fails on an non-supporting kernel
810 + ebegin "Checking running kernel version (${run_kv} >= ${want_kv})"
811 + if ! eend_KV ${run_kv} ${want_kv} ; then
812 + echo
813 + eerror "You need a kernel of at least ${want_kv}!"
814 + die "Kernel version too low!"
815 + fi
816 + fi
817 +
818 + ebegin "Checking linux-headers version (${build_kv} >= ${want_kv})"
819 + if ! eend_KV ${build_kv} ${want_kv} ; then
820 + echo
821 + eerror "You need linux-headers of at least ${want_kv}!"
822 + die "linux-headers version too low!"
823 + fi
824 + fi
825 + fi
826 +}
827 +
828 +upgrade_warning() {
829 + if [[ ${MERGE_TYPE} != buildonly && -n ${REPLACING_VERSIONS} && -z ${ROOT} ]]; then
830 + local oldv newv=$(ver_cut 1-2 ${PV})
831 + for oldv in ${REPLACING_VERSIONS}; do
832 + if ver_test ${oldv} -lt ${newv}; then
833 + ewarn "After upgrading glibc, please restart all running processes."
834 + ewarn "Be sure to include init (telinit u) or systemd (systemctl daemon-reexec)."
835 + ewarn "Alternatively, reboot your system."
836 + ewarn "(See bug #660556, bug #741116, bug #823756, etc)"
837 + break
838 + fi
839 + done
840 + fi
841 +}
842 +
843 +#
844 +# the phases
845 +#
846 +
847 +# pkg_pretend
848 +
849 +pkg_pretend() {
850 + upgrade_warning
851 +}
852 +
853 +pkg_setup() {
854 + # see bug 682570
855 + [[ -z ${BOOTSTRAP_RAP} ]] && python-any-r1_pkg_setup
856 +}
857 +
858 +# src_unpack
859 +
860 +src_unpack() {
861 + setup_env
862 +
863 + einfo "Checking general environment sanity."
864 + sanity_prechecks
865 +
866 + use multilib-bootstrap && unpack gcc-multilib-bootstrap-${GCC_BOOTSTRAP_VER}.tar.xz
867 +
868 + if [[ ${PV} == 9999* ]] ; then
869 + EGIT_REPO_URI="https://anongit.gentoo.org/git/proj/toolchain/glibc-patches.git"
870 + EGIT_CHECKOUT_DIR=${WORKDIR}/patches-git
871 + git-r3_src_unpack
872 + mv patches-git/9999 patches || die
873 +
874 + EGIT_REPO_URI="https://sourceware.org/git/glibc.git"
875 + EGIT_CHECKOUT_DIR=${S}
876 + git-r3_src_unpack
877 + else
878 + unpack ${P}.tar.xz
879 +
880 + cd "${WORKDIR}" || die
881 + unpack glibc-${RELEASE_VER}-patches-${PATCH_VER}.tar.xz
882 + use experimental-loong && unpack glibc-2.35-loongarch-patches-20220422.tar.xz
883 + fi
884 +
885 + cd "${WORKDIR}" || die
886 + unpack locale-gen-${LOCALE_GEN_VER}.tar.gz
887 + use systemd && unpack glibc-systemd-${GLIBC_SYSTEMD_VER}.tar.gz
888 +}
889 +
890 +src_prepare() {
891 + local patchsetname
892 + if ! use vanilla ; then
893 + if [[ ${PV} == 9999* ]] ; then
894 + patchsetname="from git master"
895 + else
896 + patchsetname="${RELEASE_VER}-${PATCH_VER}"
897 + fi
898 + einfo "Applying Gentoo Glibc Patchset ${patchsetname}"
899 + eapply "${WORKDIR}"/patches
900 + einfo "Done."
901 +
902 + if use experimental-loong ; then
903 + einfo "Applying experimental LoongArch patchset"
904 + eapply "${WORKDIR}"/loongarch-2.35
905 + einfo "Done."
906 + fi
907 + fi
908 +
909 + if use clone3 ; then
910 + append-cppflags -DGENTOO_USE_CLONE3
911 + else
912 + # See e.g. bug #827386, bug #819045.
913 + elog "Disabling the clone3 syscall for compatibility with older Electron apps."
914 + elog "Please re-enable this flag before filing bugs!"
915 + fi
916 +
917 + default
918 +
919 + gnuconfig_update
920 +
921 + cd "${WORKDIR}"
922 + find . -name configure -exec touch {} +
923 +
924 + # move the external locale-gen to its old place
925 + mkdir extra || die
926 + mv locale-gen-${LOCALE_GEN_VER} extra/locale || die
927 +
928 + eprefixify extra/locale/locale-gen
929 +
930 + # Fix permissions on some of the scripts.
931 + chmod u+x "${S}"/scripts/*.sh
932 +
933 + cd "${S}"
934 +}
935 +
936 +glibc_do_configure() {
937 +
938 + local v
939 + for v in ABI CBUILD CHOST CTARGET CBUILD_OPT CTARGET_OPT CC CXX LD {AS,C,CPP,CXX,LD}FLAGS MAKEINFO NM AR AS STRIP RANLIB OBJCOPY STRINGS OBJDUMP READELF; do
940 + einfo " $(printf '%15s' ${v}:) ${!v}"
941 + done
942 +
943 + echo
944 + local myconf=()
945 +
946 + # Use '=strong' instead of '=all' to protect only functions
947 + # worth protecting from stack smashes.
948 + myconf+=( --enable-stack-protector=$(usex ssp strong no) )
949 +
950 + # Keep a whitelist of targets supporing IFUNC. glibc's ./configure
951 + # is not robust enough to detect proper support:
952 + # https://bugs.gentoo.org/641216
953 + # https://sourceware.org/PR22634#c0
954 + case $(tc-arch ${CTARGET}) in
955 + # Keep whitelist of targets where autodetection mostly works.
956 + amd64|x86|sparc|ppc|ppc64|arm|arm64|s390) ;;
957 + # Blacklist everywhere else
958 + *) myconf+=( libc_cv_ld_gnu_indirect_function=no ) ;;
959 + esac
960 +
961 + # Enable Intel Control-flow Enforcement Technology on amd64 if requested
962 + case ${CTARGET} in
963 + x86_64-*) myconf+=( $(use_enable cet) ) ;;
964 + *) ;;
965 + esac
966 +
967 + [[ $(tc-is-softfloat) == "yes" ]] && myconf+=( --without-fp )
968 +
969 + myconf+=( --enable-kernel=${MIN_KERN_VER} )
970 +
971 + # Since SELinux support is only required for nscd, only enable it if:
972 + # 1. USE selinux
973 + # 2. only for the primary ABI on multilib systems
974 + # 3. Not a crosscompile
975 + if ! is_crosscompile && use selinux ; then
976 + if use multilib ; then
977 + if is_final_abi ; then
978 + myconf+=( --with-selinux )
979 + else
980 + myconf+=( --without-selinux )
981 + fi
982 + else
983 + myconf+=( --with-selinux )
984 + fi
985 + else
986 + myconf+=( --without-selinux )
987 + fi
988 +
989 + # Force a few tests where we always know the answer but
990 + # configure is incapable of finding it.
991 + if is_crosscompile ; then
992 + export \
993 + libc_cv_c_cleanup=yes \
994 + libc_cv_forced_unwind=yes
995 + fi
996 +
997 + myconf+=(
998 + --disable-werror
999 + --enable-bind-now
1000 + --build=${CBUILD_OPT:-${CBUILD}}
1001 + --host=${CTARGET_OPT:-${CTARGET}}
1002 + $(use_enable profile)
1003 + $(use_with gd)
1004 + --with-headers=$(build_eprefix)$(alt_build_headers)
1005 + --prefix="$(host_eprefix)/usr"
1006 + --sysconfdir="$(host_eprefix)/etc"
1007 + --localstatedir="$(host_eprefix)/var"
1008 + --libdir='$(prefix)'/$(get_libdir)
1009 + --mandir='$(prefix)'/share/man
1010 + --infodir='$(prefix)'/share/info
1011 + --libexecdir='$(libdir)'/misc/glibc
1012 + --with-bugurl=https://bugs.gentoo.org/
1013 + --with-pkgversion="$(glibc_banner)"
1014 + $(use_enable crypt)
1015 + $(use_multiarch || echo --disable-multi-arch)
1016 + $(use_enable systemtap)
1017 + $(use_enable nscd)
1018 +
1019 + # locale data is arch-independent
1020 + # https://bugs.gentoo.org/753740
1021 + libc_cv_complocaledir='${exec_prefix}/lib/locale'
1022 +
1023 + # -march= option tricks build system to infer too
1024 + # high ISA level: https://sourceware.org/PR27318
1025 + libc_cv_include_x86_isa_level=no
1026 + # Explicit override of https://sourceware.org/PR27991
1027 + # exposes a bug in glibc's configure:
1028 + # https://sourceware.org/PR27991
1029 + libc_cv_have_x86_lahf_sahf=no
1030 + libc_cv_have_x86_movbe=no
1031 +
1032 + ${EXTRA_ECONF}
1033 + )
1034 +
1035 + # We rely on sys-libs/timezone-data for timezone tools normally.
1036 + myconf+=( $(use_enable vanilla timezone-tools) )
1037 +
1038 + # These libs don't have configure flags.
1039 + ac_cv_lib_audit_audit_log_user_avc_message=$(usex audit || echo no)
1040 + ac_cv_lib_cap_cap_init=$(usex caps || echo no)
1041 +
1042 + # There is no configure option for this and we need to export it
1043 + # since the glibc build will re-run configure on itself
1044 + export libc_cv_rootsbindir="$(host_eprefix)/sbin"
1045 + export libc_cv_slibdir="$(host_eprefix)/$(get_libdir)"
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 + --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 grep -E -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 +}