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