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