Gentoo Archives: gentoo-commits

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