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