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