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