Gentoo Archives: gentoo-commits

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