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