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