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