Gentoo Archives: gentoo-commits

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