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