Gentoo Archives: gentoo-commits

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