Gentoo Archives: gentoo-commits

From: Sergei Trofimovich <slyfox@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-libs/glibc/
Date: Sat, 06 Feb 2021 18:27:27
Message-Id: 1612636032.ae161cc44591fdbc20c1a2c6cd38881a88161e45.slyfox@gentoo
1 commit: ae161cc44591fdbc20c1a2c6cd38881a88161e45
2 Author: Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
3 AuthorDate: Sat Feb 6 18:16:46 2021 +0000
4 Commit: Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
5 CommitDate: Sat Feb 6 18:27:12 2021 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ae161cc4
7
8 sys-libs/glibc: drop old
9
10 Package-Manager: Portage-3.0.14, Repoman-3.0.2
11 Signed-off-by: Sergei Trofimovich <slyfox <AT> gentoo.org>
12
13 sys-libs/glibc/Manifest | 1 -
14 sys-libs/glibc/glibc-2.30-r8.ebuild | 1465 ----------------------------------
15 sys-libs/glibc/glibc-2.31-r6.ebuild | 1495 -----------------------------------
16 3 files changed, 2961 deletions(-)
17
18 diff --git a/sys-libs/glibc/Manifest b/sys-libs/glibc/Manifest
19 index 3b19de759c1..6dd81be8c5d 100644
20 --- a/sys-libs/glibc/Manifest
21 +++ b/sys-libs/glibc/Manifest
22 @@ -9,7 +9,6 @@ DIST glibc-2.25.tar.xz 13873900 BLAKE2B 73ef792fff059f6ad154c9af2155ea15b7869ec1
23 DIST glibc-2.30-patches-10.tar.xz 72808 BLAKE2B a7a95c99482524b2896d15539766f1e6b1fe34a22f32119248c6dd44f42632076e86fdcbbdc2d604ec73ceccdd8a7f5936a62a6f4c3d039fae8f6901dfc6be77 SHA512 af5e213ff08bf38f6f529816c36b4e38df27207c2df254609ebe45b2f039ab553bbe563aa6f64b6667d328fd2c120dc21b6e2676540bdd94e58079237089eac3
24 DIST glibc-2.30-sparc-reg-fix-clobber.patch 6106 BLAKE2B cad6a4cbef5d529519ef486f4ef8e189cb4d43dd67fa8f8d50d67072cbb682f60474d482a5c5152d1317de92b98851d8a88eee6b331eb5bc22de065c03c58fde SHA512 a018ef1f196257f3888af20a5cbc97892c8382a4f489da042568e087c077f30cf4dda6ac711b573e1274317866ce97cf817d92a28cf55f18f5e8d32787e6cb3f
25 DIST glibc-2.30.tar.xz 16576920 BLAKE2B bd5aae4c9854f40785b91f83c3b632de6d48d811027ddfe61651cb1bc617db8017d7914c23a770cdd3feed06fcc316da841eea916cdba54179e7eace4ea45484 SHA512 37483990cd653685873e96c45dd1651b32b441b6d7919a68ebe3bae31a0c3f7ce183fc9b110f0b268b353f80312f18370559a1e7aecea0e5aa755c8f2aef1d6b
26 -DIST glibc-2.31-patches-8.tar.xz 60868 BLAKE2B c641a77cab0b3e5379a6911a548483266110d747300f6bd4c138754cc35aff266088be8682ba45ac105c946ee309db0bc094b0c3bc48fd4303c925a7594e17e2 SHA512 1bc069d487ff9d4cd33c5d293bb0789114f65af5179b3d9df8ff0a9f043d5ffbcd030d8eabc90b329c896dfdd0409c4b8dac371eafdd380ecc660b9540320637
27 DIST glibc-2.31-patches-9.tar.xz 74712 BLAKE2B 62991b67de4def4cca944e8420d2f0139f88b6754c6bc81072bb321c574c1db22641857345325848e1dfb551c10758f582e4425e687a7921cdbd4e7e7923a047 SHA512 699d898e3a8ed02b04573c675f572076e8f747767bfc577a033a49cd7d9078a7a60ac325acd4bd419a93b56edf90ce067baa7578ab315e27885f1f0e13916354
28 DIST glibc-2.31.tar.xz 16676764 BLAKE2B 91df1792345f157265eae405185a81fd4b8ce36d4c2388f44b0d5b1ae38174ea374cbc909cd260770b9f38ea58051da13766d4fa22abf41c2d4a2493257b179b SHA512 735e4c0ef10418b6ea945ad3906585e5bbd8b282d76f2131309dce4cec6b15066a5e4a3731773ce428a819b542579c9957867bb0abf05ed2030983fca4412306
29 DIST glibc-2.32-patches-2.tar.xz 8588 BLAKE2B 57a85241e3270d14df0332b039a933c5a7ee4d089684d85cca564eeec2d6796735de60b628c5746858757342922d58993d6cf7187ce1d7102b2299ca2cf8513f SHA512 45bbab9e2f813f55cb4a1438dcd9365170b8facff50b11648ba6022da06c20029bb65a4b06fd906af82aa7461b7374f85105fd7eedb7915cec3f1df3779b68a3
30
31 diff --git a/sys-libs/glibc/glibc-2.30-r8.ebuild b/sys-libs/glibc/glibc-2.30-r8.ebuild
32 deleted file mode 100644
33 index 86afb5aaac8..00000000000
34 --- a/sys-libs/glibc/glibc-2.30-r8.ebuild
35 +++ /dev/null
36 @@ -1,1465 +0,0 @@
37 -# Copyright 1999-2020 Gentoo Authors
38 -# Distributed under the terms of the GNU General Public License v2
39 -
40 -EAPI=7
41 -
42 -PYTHON_COMPAT=( python3_{7,8} )
43 -
44 -inherit python-any-r1 prefix eutils toolchain-funcs flag-o-matic gnuconfig \
45 - multilib systemd multiprocessing
46 -
47 -DESCRIPTION="GNU libc C library"
48 -HOMEPAGE="https://www.gnu.org/software/libc/"
49 -LICENSE="LGPL-2.1+ BSD HPND ISC inner-net rc PCRE"
50 -SLOT="2.2"
51 -
52 -EMULTILIB_PKG="true"
53 -
54 -if [[ ${PV} == 9999* ]]; then
55 - EGIT_REPO_URI="https://sourceware.org/git/glibc.git"
56 - inherit git-r3
57 -else
58 - KEYWORDS="~alpha amd64 arm arm64 hppa ~ia64 ~m68k ~mips ppc ppc64 ~riscv s390 sparc x86"
59 - SRC_URI="mirror://gnu/glibc/${P}.tar.xz"
60 -fi
61 -
62 -RELEASE_VER=${PV}
63 -
64 -GCC_BOOTSTRAP_VER=20180511
65 -
66 -# Gentoo patchset
67 -PATCH_VER=10
68 -PATCH_DEV=dilfridge
69 -
70 -SRC_URI+=" https://dev.gentoo.org/~${PATCH_DEV}/distfiles/${P}-patches-${PATCH_VER}.tar.xz"
71 -SRC_URI+=" multilib? ( https://dev.gentoo.org/~dilfridge/distfiles/gcc-multilib-bootstrap-${GCC_BOOTSTRAP_VER}.tar.xz )"
72 -
73 -IUSE="audit caps cet compile-locales +crypt custom-cflags doc gd headers-only +multiarch multilib nscd profile selinux +ssp +static-libs suid systemtap test vanilla"
74 -
75 -# Minimum kernel version that glibc requires
76 -MIN_KERN_VER="3.2.0"
77 -
78 -# Here's how the cross-compile logic breaks down ...
79 -# CTARGET - machine that will target the binaries
80 -# CHOST - machine that will host the binaries
81 -# CBUILD - machine that will build the binaries
82 -# If CTARGET != CHOST, it means you want a libc for cross-compiling.
83 -# If CHOST != CBUILD, it means you want to cross-compile the libc.
84 -# CBUILD = CHOST = CTARGET - native build/install
85 -# CBUILD != (CHOST = CTARGET) - cross-compile a native build
86 -# (CBUILD = CHOST) != CTARGET - libc for cross-compiler
87 -# CBUILD != CHOST != CTARGET - cross-compile a libc for a cross-compiler
88 -# For install paths:
89 -# CHOST = CTARGET - install into /
90 -# CHOST != CTARGET - install into /usr/CTARGET/
91 -#
92 -export CBUILD=${CBUILD:-${CHOST}}
93 -export CTARGET=${CTARGET:-${CHOST}}
94 -if [[ ${CTARGET} == ${CHOST} ]] ; then
95 - if [[ ${CATEGORY} == cross-* ]] ; then
96 - export CTARGET=${CATEGORY#cross-}
97 - fi
98 -fi
99 -
100 -# Note [Disable automatic stripping]
101 -# Disabling automatic stripping for a few reasons:
102 -# - portage's attempt to strip breaks non-native binaries at least on
103 -# arm: bug #697428
104 -# - portage's attempt to strip libpthread.so.0 breaks gdb thread
105 -# enumeration: bug #697910. This is quite subtle:
106 -# * gdb uses glibc's libthread_db-1.0.so to enumerate threads.
107 -# * libthread_db-1.0.so needs access to libpthread.so.0 local symbols
108 -# via 'ps_pglobal_lookup' symbol defined in gdb.
109 -# * 'ps_pglobal_lookup' uses '.symtab' section table to resolve all
110 -# known symbols in 'libpthread.so.0'. Specifically 'nptl_version'
111 -# (unexported) is used to sanity check compatibility before enabling
112 -# debugging.
113 -# 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
114 -# * normal 'strip' command trims '.symtab'
115 -# Thus our main goal here is to prevent 'libpthread.so.0' from
116 -# losing it's '.symtab' entries.
117 -# As Gentoo's strip does not allow us to pass less aggressive stripping
118 -# options and does not check the machine target we strip selectively.
119 -
120 -# We need a new-enough binutils/gcc to match upstream baseline.
121 -# Also we need to make sure our binutils/gcc supports TLS,
122 -# and that gcc already contains the hardened patches.
123 -BDEPEND="
124 - ${PYTHON_DEPS}
125 - >=app-misc/pax-utils-0.1.10
126 - sys-devel/bison
127 - doc? ( sys-apps/texinfo )
128 -"
129 -COMMON_DEPEND="
130 - gd? ( media-libs/gd:2= )
131 - nscd? ( selinux? (
132 - audit? ( sys-process/audit )
133 - caps? ( sys-libs/libcap )
134 - ) )
135 - suid? ( caps? ( sys-libs/libcap ) )
136 - selinux? ( sys-libs/libselinux )
137 - systemtap? ( dev-util/systemtap )
138 -"
139 -DEPEND="${COMMON_DEPEND}
140 - test? ( >=net-dns/libidn2-2.3.0 )
141 -"
142 -RDEPEND="${COMMON_DEPEND}
143 - sys-apps/gentoo-functions
144 -"
145 -
146 -RESTRICT="!test? ( test )"
147 -
148 -if [[ ${CATEGORY} == cross-* ]] ; then
149 - BDEPEND+=" !headers-only? (
150 - >=${CATEGORY}/binutils-2.24
151 - >=${CATEGORY}/gcc-6
152 - )"
153 - [[ ${CATEGORY} == *-linux* ]] && DEPEND+=" ${CATEGORY}/linux-headers"
154 -else
155 - BDEPEND+="
156 - >=sys-devel/binutils-2.24
157 - >=sys-devel/gcc-6
158 - "
159 - DEPEND+=" virtual/os-headers "
160 - RDEPEND+="
161 - >=net-dns/libidn2-2.3.0
162 - vanilla? ( !sys-libs/timezone-data )
163 - "
164 - PDEPEND+=" !vanilla? ( sys-libs/timezone-data )"
165 -fi
166 -
167 -# Ignore tests whitelisted below
168 -GENTOO_GLIBC_XFAIL_TESTS="${GENTOO_GLIBC_XFAIL_TESTS:-yes}"
169 -
170 -# The following tests fail due to the Gentoo build system and are thus
171 -# executed but ignored:
172 -XFAIL_TEST_LIST=(
173 - # 1) Sandbox
174 - tst-ldconfig-bad-aux-cache
175 - tst-pldd
176 - tst-mallocfork2
177 - tst-nss-db-endgrent
178 - tst-nss-db-endpwent
179 - tst-nss-files-hosts-long
180 - tst-nss-test3
181 - # 2) Namespaces and cgroup
182 - tst-locale-locpath
183 - # 9) Failures of unknown origin
184 - tst-latepthread
185 -
186 - # buggy test, fixed in glibc-2.31 in 70ba28f7ab29
187 - tst-pkey
188 -
189 - # buggy test, assumes /dev/ and /dev/null on a single filesystem
190 - # 'mount --bind /dev/null /chroot/dev/null' breaks it.
191 - # https://sourceware.org/PR25909
192 - tst-support_descriptors
193 -
194 - # Flaky test, known to fail occasionally:
195 - # https://sourceware.org/PR19329
196 - # https://bugs.gentoo.org/719674#c12
197 - tst-stack4
198 -)
199 -
200 -#
201 -# Small helper functions
202 -#
203 -
204 -is_crosscompile() {
205 - [[ ${CHOST} != ${CTARGET} ]]
206 -}
207 -
208 -just_headers() {
209 - is_crosscompile && use headers-only
210 -}
211 -
212 -alt_prefix() {
213 - is_crosscompile && echo /usr/${CTARGET}
214 -}
215 -
216 -# This prefix is applicable to CHOST when building against this
217 -# glibc. It is baked into the library at configure time.
218 -host_eprefix() {
219 - is_crosscompile || echo "${EPREFIX}"
220 -}
221 -
222 -# This prefix is applicable to CBUILD when building against this
223 -# glibc. It determines the destination path at install time.
224 -build_eprefix() {
225 - is_crosscompile && echo "${EPREFIX}"
226 -}
227 -
228 -# We need to be able to set alternative headers for compiling for non-native
229 -# platform. Will also become useful for testing kernel-headers without screwing
230 -# up the whole system.
231 -alt_headers() {
232 - echo ${ALT_HEADERS:=$(alt_prefix)/usr/include}
233 -}
234 -
235 -alt_build_headers() {
236 - if [[ -z ${ALT_BUILD_HEADERS} ]] ; then
237 - ALT_BUILD_HEADERS="$(host_eprefix)$(alt_headers)"
238 - if tc-is-cross-compiler ; then
239 - ALT_BUILD_HEADERS=${SYSROOT}$(alt_headers)
240 - if [[ ! -e ${ALT_BUILD_HEADERS}/linux/version.h ]] ; then
241 - local header_path=$(echo '#include <linux/version.h>' | $(tc-getCPP ${CTARGET}) ${CFLAGS} 2>&1 | grep -o '[^"]*linux/version.h')
242 - ALT_BUILD_HEADERS=${header_path%/linux/version.h}
243 - fi
244 - fi
245 - fi
246 - echo "${ALT_BUILD_HEADERS}"
247 -}
248 -
249 -alt_libdir() {
250 - echo $(alt_prefix)/$(get_libdir)
251 -}
252 -alt_usrlibdir() {
253 - echo $(alt_prefix)/usr/$(get_libdir)
254 -}
255 -
256 -builddir() {
257 - echo "${WORKDIR}/build-${ABI}-${CTARGET}-$1"
258 -}
259 -
260 -do_compile_test() {
261 - local ret save_cflags=${CFLAGS}
262 - CFLAGS+=" $1"
263 - shift
264 -
265 - pushd "${T}" >/dev/null
266 -
267 - rm -f glibc-test*
268 - printf '%b' "$*" > glibc-test.c
269 -
270 - nonfatal emake glibc-test
271 - ret=$?
272 -
273 - popd >/dev/null
274 -
275 - CFLAGS=${save_cflags}
276 - return ${ret}
277 -}
278 -
279 -do_run_test() {
280 - local ret
281 -
282 - if [[ ${MERGE_TYPE} == "binary" ]] ; then
283 - # ignore build failures when installing a binary package #324685
284 - do_compile_test "" "$@" 2>/dev/null || return 0
285 - else
286 - if ! do_compile_test "" "$@" ; then
287 - ewarn "Simple build failed ... assuming this is desired #324685"
288 - return 0
289 - fi
290 - fi
291 -
292 - pushd "${T}" >/dev/null
293 -
294 - ./glibc-test
295 - ret=$?
296 - rm -f glibc-test*
297 -
298 - popd >/dev/null
299 -
300 - return ${ret}
301 -}
302 -
303 -setup_target_flags() {
304 - # This largely mucks with compiler flags. None of which should matter
305 - # when building up just the headers.
306 - just_headers && return 0
307 -
308 - case $(tc-arch) in
309 - x86)
310 - # -march needed for #185404 #199334
311 - # TODO: When creating the first glibc cross-compile, this test will
312 - # always fail as it does a full link which in turn requires glibc.
313 - # Probably also applies when changing multilib profile settings (e.g.
314 - # enabling x86 when the profile was amd64-only previously).
315 - # We could change main to _start and pass -nostdlib here so that we
316 - # only test the gcc code compilation. Or we could do a compile and
317 - # then look for the symbol via scanelf.
318 - 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
319 - local t=${CTARGET_OPT:-${CTARGET}}
320 - t=${t%%-*}
321 - filter-flags '-march=*'
322 - export CFLAGS="-march=${t} ${CFLAGS}"
323 - einfo "Auto adding -march=${t} to CFLAGS #185404"
324 - fi
325 - ;;
326 - amd64)
327 - # -march needed for #185404 #199334
328 - # TODO: See cross-compile issues listed above for x86.
329 - [[ ${ABI} == x86 ]] &&
330 - 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
331 - local t=${CTARGET_OPT:-${CTARGET}}
332 - t=${t%%-*}
333 - # Normally the target is x86_64-xxx, so turn that into the -march that
334 - # gcc actually accepts. #528708
335 - [[ ${t} == "x86_64" ]] && t="x86-64"
336 - filter-flags '-march=*'
337 - # ugly, ugly, ugly. ugly.
338 - CFLAGS_x86=$(CFLAGS=${CFLAGS_x86} filter-flags '-march=*'; echo "${CFLAGS}")
339 - export CFLAGS_x86="${CFLAGS_x86} -march=${t}"
340 - einfo "Auto adding -march=${t} to CFLAGS_x86 #185404 (ABI=${ABI})"
341 - fi
342 - ;;
343 - ia64)
344 - # Workaround GPREL22 overflow by slightly pessimizing global
345 - # references to go via 64-bit relocations instead of 22-bit ones.
346 - # This allows building glibc on ia64 without an overflow: #723268
347 - append-flags -fcommon
348 - ;;
349 - mips)
350 - # The mips abi cannot support the GNU style hashes. #233233
351 - filter-ldflags -Wl,--hash-style=gnu -Wl,--hash-style=both
352 - ;;
353 - sparc)
354 - # Both sparc and sparc64 can use -fcall-used-g6. -g7 is bad, though.
355 - filter-flags "-fcall-used-g7"
356 - append-flags "-fcall-used-g6"
357 -
358 - local cpu
359 - case ${CTARGET} in
360 - sparc64-*)
361 - cpu="sparc64"
362 - case $(get-flag mcpu) in
363 - v9)
364 - # We need to force at least v9a because the base build doesn't
365 - # work with just v9.
366 - # https://sourceware.org/bugzilla/show_bug.cgi?id=19477
367 - append-flags "-Wa,-xarch=v9a"
368 - ;;
369 - esac
370 - ;;
371 - sparc-*)
372 - case $(get-flag mcpu) in
373 - v8|supersparc|hypersparc|leon|leon3)
374 - cpu="sparcv8"
375 - ;;
376 - *)
377 - cpu="sparcv9"
378 - ;;
379 - esac
380 - ;;
381 - esac
382 - [[ -n ${cpu} ]] && CTARGET_OPT="${cpu}-${CTARGET#*-}"
383 - ;;
384 - esac
385 -}
386 -
387 -setup_flags() {
388 - # Make sure host make.conf doesn't pollute us
389 - if is_crosscompile || tc-is-cross-compiler ; then
390 - CHOST=${CTARGET} strip-unsupported-flags
391 - fi
392 -
393 - # Store our CFLAGS because it's changed depending on which CTARGET
394 - # we are building when pulling glibc on a multilib profile
395 - CFLAGS_BASE=${CFLAGS_BASE-${CFLAGS}}
396 - CFLAGS=${CFLAGS_BASE}
397 - CXXFLAGS_BASE=${CXXFLAGS_BASE-${CXXFLAGS}}
398 - CXXFLAGS=${CXXFLAGS_BASE}
399 - ASFLAGS_BASE=${ASFLAGS_BASE-${ASFLAGS}}
400 - ASFLAGS=${ASFLAGS_BASE}
401 -
402 - # Allow users to explicitly avoid flag sanitization via
403 - # USE=custom-cflags.
404 - if ! use custom-cflags; then
405 - # Over-zealous CFLAGS can often cause problems. What may work for one
406 - # person may not work for another. To avoid a large influx of bugs
407 - # relating to failed builds, we strip most CFLAGS out to ensure as few
408 - # problems as possible.
409 - strip-flags
410 - # Lock glibc at -O2; we want to be conservative here.
411 - filter-flags '-O?'
412 - append-flags -O2
413 - fi
414 - strip-unsupported-flags
415 - filter-flags -m32 -m64 '-mabi=*'
416 -
417 - # glibc aborts if rpath is set by LDFLAGS
418 - filter-ldflags '-Wl,-rpath=*'
419 -
420 - # #492892
421 - filter-flags -frecord-gcc-switches
422 -
423 - unset CBUILD_OPT CTARGET_OPT
424 - if use multilib ; then
425 - CTARGET_OPT=$(get_abi_CTARGET)
426 - [[ -z ${CTARGET_OPT} ]] && CTARGET_OPT=$(get_abi_CHOST)
427 - fi
428 -
429 - setup_target_flags
430 -
431 - if [[ -n ${CTARGET_OPT} && ${CBUILD} == ${CHOST} ]] && ! is_crosscompile; then
432 - CBUILD_OPT=${CTARGET_OPT}
433 - fi
434 -
435 - # glibc's headers disallow -O0 and fail at build time:
436 - # include/libc-symbols.h:75:3: #error "glibc cannot be compiled without optimization"
437 - replace-flags -O0 -O1
438 -
439 - filter-flags '-fstack-protector*'
440 -}
441 -
442 -want_tls() {
443 - # Archs that can use TLS (Thread Local Storage)
444 - case $(tc-arch) in
445 - x86)
446 - # requires i486 or better #106556
447 - [[ ${CTARGET} == i[4567]86* ]] && return 0
448 - return 1
449 - ;;
450 - esac
451 - return 0
452 -}
453 -
454 -want__thread() {
455 - want_tls || return 1
456 -
457 - # For some reason --with-tls --with__thread is causing segfaults on sparc32.
458 - [[ ${PROFILE_ARCH} == "sparc" ]] && return 1
459 -
460 - [[ -n ${WANT__THREAD} ]] && return ${WANT__THREAD}
461 -
462 - # only test gcc -- can't test linking yet
463 - tc-has-tls -c ${CTARGET}
464 - WANT__THREAD=$?
465 -
466 - return ${WANT__THREAD}
467 -}
468 -
469 -use_multiarch() {
470 - # Allow user to disable runtime arch detection in multilib.
471 - use multiarch || return 1
472 - # Make sure binutils is new enough to support indirect functions,
473 - # #336792. This funky sed supports gold and bfd linkers.
474 - local bver nver
475 - bver=$($(tc-getLD ${CTARGET}) -v | sed -n -r '1{s:[^0-9]*::;s:^([0-9.]*).*:\1:;p}')
476 - case $(tc-arch ${CTARGET}) in
477 - amd64|x86) nver="2.20" ;;
478 - arm) nver="2.22" ;;
479 - hppa) nver="2.23" ;;
480 - ppc|ppc64) nver="2.20" ;;
481 - # ifunc support was added in 2.23, but glibc also needs
482 - # machinemode which is in 2.24.
483 - s390) nver="2.24" ;;
484 - sparc) nver="2.21" ;;
485 - *) return 1 ;;
486 - esac
487 - ver_test ${bver} -ge ${nver}
488 -}
489 -
490 -# Setup toolchain variables that had historically been defined in the
491 -# profiles for these archs.
492 -setup_env() {
493 - # silly users
494 - unset LD_RUN_PATH
495 - unset LD_ASSUME_KERNEL
496 -
497 - if is_crosscompile || tc-is-cross-compiler ; then
498 - multilib_env ${CTARGET_OPT:-${CTARGET}}
499 -
500 - if ! use multilib ; then
501 - MULTILIB_ABIS=${DEFAULT_ABI}
502 - else
503 - MULTILIB_ABIS=${MULTILIB_ABIS:-${DEFAULT_ABI}}
504 - fi
505 -
506 - # If the user has CFLAGS_<CTARGET> in their make.conf, use that,
507 - # and fall back on CFLAGS.
508 - local VAR=CFLAGS_${CTARGET//[-.]/_}
509 - CFLAGS=${!VAR-${CFLAGS}}
510 - einfo " $(printf '%15s' 'Manual CFLAGS:') ${CFLAGS}"
511 - fi
512 -
513 - setup_flags
514 -
515 - export ABI=${ABI:-${DEFAULT_ABI:-default}}
516 -
517 - if just_headers ; then
518 - # Avoid mixing host's CC and target's CFLAGS_${ABI}:
519 - # At this bootstrap stage we have only binutils for
520 - # target but not compiler yet.
521 - einfo "Skip CC ABI injection. We can't use (cross-)compiler yet."
522 - return 0
523 - fi
524 - local VAR=CFLAGS_${ABI}
525 - # We need to export CFLAGS with abi information in them because glibc's
526 - # configure script checks CFLAGS for some targets (like mips). Keep
527 - # around the original clean value to avoid appending multiple ABIs on
528 - # top of each other.
529 - : ${__GLIBC_CC:=$(tc-getCC ${CTARGET})}
530 - export __GLIBC_CC CC="${__GLIBC_CC} ${!VAR}"
531 - einfo " $(printf '%15s' 'Manual CC:') ${CC}"
532 -}
533 -
534 -foreach_abi() {
535 - setup_env
536 -
537 - local ret=0
538 - local abilist=""
539 - if use multilib ; then
540 - abilist=$(get_install_abis)
541 - else
542 - abilist=${DEFAULT_ABI}
543 - fi
544 - local -x ABI
545 - for ABI in ${abilist:-default} ; do
546 - setup_env
547 - einfo "Running $1 for ABI ${ABI}"
548 - $1
549 - : $(( ret |= $? ))
550 - done
551 - return ${ret}
552 -}
553 -
554 -glibc_banner() {
555 - local b="Gentoo ${PVR}"
556 - [[ -n ${PATCH_VER} ]] && ! use vanilla && b+=" p${PATCH_VER}"
557 - echo "${b}"
558 -}
559 -
560 -# The following Kernel version handling functions are mostly copied from portage
561 -# source. It's better not to use linux-info.eclass here since a) it adds too
562 -# much magic, see bug 326693 for some of the arguments, and b) some of the
563 -# functions are just not provided.
564 -
565 -g_get_running_KV() {
566 - uname -r
567 - return $?
568 -}
569 -
570 -g_KV_major() {
571 - [[ -z $1 ]] && return 1
572 - local KV=$@
573 - echo "${KV%%.*}"
574 -}
575 -
576 -g_KV_minor() {
577 - [[ -z $1 ]] && return 1
578 - local KV=$@
579 - KV=${KV#*.}
580 - echo "${KV%%.*}"
581 -}
582 -
583 -g_KV_micro() {
584 - [[ -z $1 ]] && return 1
585 - local KV=$@
586 - KV=${KV#*.*.}
587 - echo "${KV%%[^[:digit:]]*}"
588 -}
589 -
590 -g_KV_to_int() {
591 - [[ -z $1 ]] && return 1
592 - local KV_MAJOR=$(g_KV_major "$1")
593 - local KV_MINOR=$(g_KV_minor "$1")
594 - local KV_MICRO=$(g_KV_micro "$1")
595 - local KV_int=$(( KV_MAJOR * 65536 + KV_MINOR * 256 + KV_MICRO ))
596 -
597 - # We make version 2.2.0 the minimum version we will handle as
598 - # a sanity check ... if its less, we fail ...
599 - if [[ ${KV_int} -ge 131584 ]] ; then
600 - echo "${KV_int}"
601 - return 0
602 - fi
603 - return 1
604 -}
605 -
606 -g_int_to_KV() {
607 - local version=$1 major minor micro
608 - major=$((version / 65536))
609 - minor=$(((version % 65536) / 256))
610 - micro=$((version % 256))
611 - echo ${major}.${minor}.${micro}
612 -}
613 -
614 -eend_KV() {
615 - [[ $(g_KV_to_int $1) -ge $(g_KV_to_int $2) ]]
616 - eend $?
617 -}
618 -
619 -get_kheader_version() {
620 - printf '#include <linux/version.h>\nLINUX_VERSION_CODE\n' | \
621 - $(tc-getCPP ${CTARGET}) -I "$(build_eprefix)$(alt_build_headers)" - | \
622 - tail -n 1
623 -}
624 -
625 -# We collect all sanity checks here. Consistency is not guranteed between
626 -# pkg_ and src_ phases, so we call this function both in pkg_pretend and in
627 -# src_unpack.
628 -sanity_prechecks() {
629 - # Prevent native builds from downgrading
630 - if [[ ${MERGE_TYPE} != "buildonly" ]] && \
631 - [[ -z ${ROOT} ]] && \
632 - [[ ${CBUILD} == ${CHOST} ]] && \
633 - [[ ${CHOST} == ${CTARGET} ]] ; then
634 -
635 - # The high rev # is to allow people to downgrade between -r#
636 - # versions. We want to block 2.20->2.19, but 2.20-r3->2.20-r2
637 - # should be fine. Hopefully we never actually use a r# this
638 - # high.
639 - if has_version ">${CATEGORY}/${P}-r10000" ; then
640 - eerror "Sanity check to keep you from breaking your system:"
641 - eerror " Downgrading glibc is not supported and a sure way to destruction."
642 - [[ ${I_ALLOW_TO_BREAK_MY_SYSTEM} = yes ]] || die "Aborting to save your system."
643 - fi
644 -
645 - if ! do_run_test '#include <unistd.h>\n#include <sys/syscall.h>\nint main(){return syscall(1000)!=-1;}\n' ; then
646 - eerror "Your old kernel is broken. You need to update it to a newer"
647 - eerror "version as syscall(<bignum>) will break. See bug 279260."
648 - die "Old and broken kernel."
649 - fi
650 - fi
651 -
652 - # Users have had a chance to phase themselves, time to give em the boot
653 - if [[ -e ${EROOT}/etc/locale.gen ]] && [[ -e ${EROOT}/etc/locales.build ]] ; then
654 - eerror "You still haven't deleted ${EROOT}/etc/locales.build."
655 - eerror "Do so now after making sure ${EROOT}/etc/locale.gen is kosher."
656 - die "Lazy upgrader detected"
657 - fi
658 -
659 - if [[ ${CTARGET} == i386-* ]] ; then
660 - eerror "i386 CHOSTs are no longer supported."
661 - eerror "Chances are you don't actually want/need i386."
662 - eerror "Please read https://www.gentoo.org/doc/en/change-chost.xml"
663 - die "Please fix your CHOST"
664 - fi
665 -
666 - if [[ -e /proc/xen ]] && [[ $(tc-arch) == "x86" ]] && ! is-flag -mno-tls-direct-seg-refs ; then
667 - ewarn "You are using Xen but don't have -mno-tls-direct-seg-refs in your CFLAGS."
668 - ewarn "This will result in a 50% performance penalty when running with a 32bit"
669 - ewarn "hypervisor, which is probably not what you want."
670 - fi
671 -
672 - # Check for sanity of /etc/nsswitch.conf
673 - if [[ -e ${EROOT}/etc/nsswitch.conf ]] ; then
674 - local entry
675 - for entry in passwd group shadow; do
676 - if ! egrep -q "^[ \t]*${entry}:.*files" "${EROOT}"/etc/nsswitch.conf; then
677 - eerror "Your ${EROOT}/etc/nsswitch.conf is out of date."
678 - eerror "Please make sure you have 'files' entries for"
679 - eerror "'passwd:', 'group:' and 'shadow:' databases."
680 - eerror "For more details see:"
681 - eerror " https://wiki.gentoo.org/wiki/Project:Toolchain/nsswitch.conf_in_glibc-2.26"
682 - die "nsswitch.conf has no 'files' provider in '${entry}'."
683 - fi
684 - done
685 - fi
686 -
687 - # ABI-specific checks follow here. Hey, we have a lot more specific conditions that
688 - # we test for...
689 - if ! is_crosscompile ; then
690 - if use amd64 && use multilib && [[ ${MERGE_TYPE} != "binary" ]] ; then
691 - ebegin "Checking that IA32 emulation is enabled in the running kernel"
692 - echo 'int main(){return 0;}' > "${T}/check-ia32-emulation.c"
693 - local STAT
694 - if "${CC-${CHOST}-gcc}" ${CFLAGS_x86} "${T}/check-ia32-emulation.c" -o "${T}/check-ia32-emulation.elf32"; then
695 - "${T}/check-ia32-emulation.elf32"
696 - STAT=$?
697 - else
698 - # Don't fail here to allow single->multi ABI switch
699 - # or recover from breakage like bug #646424
700 - ewarn "Failed to compile the ABI test. Broken host glibc?"
701 - STAT=0
702 - fi
703 - rm -f "${T}/check-ia32-emulation.elf32"
704 - eend $STAT
705 - [[ $STAT -eq 0 ]] || die "CONFIG_IA32_EMULATION must be enabled in the kernel to compile a multilib glibc."
706 - fi
707 -
708 - fi
709 -
710 - # When we actually have to compile something...
711 - if ! just_headers ; then
712 - ebegin "Checking gcc for __thread support"
713 - if ! eend $(want__thread ; echo $?) ; then
714 - echo
715 - eerror "Could not find a gcc that supports the __thread directive!"
716 - eerror "Please update your binutils/gcc and try again."
717 - die "No __thread support in gcc!"
718 - fi
719 -
720 - if [[ ${CTARGET} == *-linux* ]] ; then
721 - local run_kv build_kv want_kv
722 -
723 - run_kv=$(g_get_running_KV)
724 - build_kv=$(g_int_to_KV $(get_kheader_version))
725 - want_kv=${MIN_KERN_VER}
726 -
727 - if ! is_crosscompile && ! tc-is-cross-compiler ; then
728 - # Building fails on an non-supporting kernel
729 - ebegin "Checking running kernel version (${run_kv} >= ${want_kv})"
730 - if ! eend_KV ${run_kv} ${want_kv} ; then
731 - echo
732 - eerror "You need a kernel of at least ${want_kv}!"
733 - die "Kernel version too low!"
734 - fi
735 - fi
736 -
737 - ebegin "Checking linux-headers version (${build_kv} >= ${want_kv})"
738 - if ! eend_KV ${build_kv} ${want_kv} ; then
739 - echo
740 - eerror "You need linux-headers of at least ${want_kv}!"
741 - die "linux-headers version too low!"
742 - fi
743 - fi
744 - fi
745 -}
746 -
747 -#
748 -# the phases
749 -#
750 -
751 -# pkg_pretend
752 -
753 -pkg_pretend() {
754 - # All the checks...
755 - einfo "Checking general environment sanity."
756 - sanity_prechecks
757 -}
758 -
759 -pkg_setup() {
760 - # see bug 682570
761 - [[ -z ${BOOTSTRAP_RAP} ]] && python-any-r1_pkg_setup
762 -}
763 -
764 -# src_unpack
765 -
766 -src_unpack() {
767 - # Consistency is not guaranteed between pkg_ and src_ ...
768 - sanity_prechecks
769 -
770 - use multilib && unpack gcc-multilib-bootstrap-${GCC_BOOTSTRAP_VER}.tar.xz
771 -
772 - setup_env
773 -
774 - if [[ -n ${EGIT_REPO_URI} ]] ; then
775 - git-r3_src_unpack
776 - else
777 - unpack ${P}.tar.xz
778 - fi
779 -
780 - cd "${WORKDIR}" || die
781 - unpack glibc-${RELEASE_VER}-patches-${PATCH_VER}.tar.xz
782 -}
783 -
784 -src_prepare() {
785 - if ! use vanilla ; then
786 - elog "Applying Gentoo Glibc Patchset ${RELEASE_VER}-${PATCH_VER}"
787 - eapply "${WORKDIR}"/patches
788 - einfo "Done."
789 - fi
790 -
791 - default
792 -
793 - gnuconfig_update
794 -
795 - cd "${WORKDIR}"
796 - find . -name configure -exec touch {} +
797 -
798 - eprefixify extra/locale/locale-gen
799 -
800 - # Fix permissions on some of the scripts.
801 - chmod u+x "${S}"/scripts/*.sh
802 -
803 - cd "${S}"
804 -}
805 -
806 -glibc_do_configure() {
807 - # Glibc does not work with gold (for various reasons) #269274.
808 - tc-ld-disable-gold
809 -
810 - # CXX isnt handled by the multilib system, so if we dont unset here
811 - # we accumulate crap across abis
812 - unset CXX
813 -
814 - einfo "Configuring glibc for nptl"
815 -
816 - if use doc ; then
817 - export MAKEINFO=makeinfo
818 - else
819 - export MAKEINFO=/dev/null
820 - fi
821 -
822 - local v
823 - for v in ABI CBUILD CHOST CTARGET CBUILD_OPT CTARGET_OPT CC CXX LD {AS,C,CPP,CXX,LD}FLAGS MAKEINFO ; do
824 - einfo " $(printf '%15s' ${v}:) ${!v}"
825 - done
826 -
827 - # CFLAGS can contain ABI-specific flags like -mfpu=neon, see bug #657760
828 - # To build .S (assembly) files with the same ABI-specific flags
829 - # upstream currently recommends adding CFLAGS to CC/CXX:
830 - # https://sourceware.org/PR23273
831 - # Note: Passing CFLAGS via CPPFLAGS overrides glibc's arch-specific CFLAGS
832 - # and breaks multiarch support. See 659030#c3 for an example.
833 - # The glibc configure script doesn't properly use LDFLAGS all the time.
834 - export CC="$(tc-getCC ${CTARGET}) ${CFLAGS} ${LDFLAGS}"
835 - einfo " $(printf '%15s' 'Manual CC:') ${CC}"
836 -
837 - # Some of the tests are written in C++, so we need to force our multlib abis in, bug 623548
838 - export CXX="$(tc-getCXX ${CTARGET}) $(get_abi_CFLAGS) ${CFLAGS}"
839 -
840 - if is_crosscompile; then
841 - # Assume worst-case bootstrap: glibc is buil first time
842 - # when ${CTARGET}-g++ is not available yet. We avoid
843 - # building auxiliary programs that require C++: bug #683074
844 - # It should not affect final result.
845 - export libc_cv_cxx_link_ok=no
846 - # The line above has the same effect. We set CXX explicitly
847 - # to make build logs less confusing.
848 - export CXX=
849 - fi
850 - einfo " $(printf '%15s' 'Manual CXX:') ${CXX}"
851 -
852 - echo
853 -
854 - local myconf=()
855 -
856 - case ${CTARGET} in
857 - m68k*)
858 - # setjmp() is not compatible with stack protection:
859 - # https://sourceware.org/PR24202
860 - myconf+=( --enable-stack-protector=no )
861 - ;;
862 - powerpc-*)
863 - # Currently gcc on powerpc32 generates invalid code for
864 - # __builtin_return_address(0) calls. Normally programs
865 - # don't do that but malloc hooks in glibc do:
866 - # https://gcc.gnu.org/PR81996
867 - # https://bugs.gentoo.org/629054
868 - myconf+=( --enable-stack-protector=no )
869 - ;;
870 - *)
871 - # Use '=strong' instead of '=all' to protect only functions
872 - # worth protecting from stack smashes.
873 - # '=all' is also known to have a problem in IFUNC resolution
874 - # tests: https://sourceware.org/PR25680, bug #712356.
875 - myconf+=( --enable-stack-protector=$(usex ssp strong no) )
876 - ;;
877 - esac
878 - myconf+=( --enable-stackguard-randomization )
879 -
880 - # Keep a whitelist of targets supporing IFUNC. glibc's ./configure
881 - # is not robust enough to detect proper support:
882 - # https://bugs.gentoo.org/641216
883 - # https://sourceware.org/PR22634#c0
884 - case $(tc-arch ${CTARGET}) in
885 - # Keep whitelist of targets where autodetection mostly works.
886 - amd64|x86|sparc|ppc|ppc64|arm|arm64|s390) ;;
887 - # Blacklist everywhere else
888 - *) myconf+=( libc_cv_ld_gnu_indirect_function=no ) ;;
889 - esac
890 -
891 - # Enable Intel Control-flow Enforcement Technology on amd64 if requested
892 - case ${CTARGET} in
893 - x86_64-*) myconf+=( $(use_enable cet) ) ;;
894 - *) ;;
895 - esac
896 -
897 - [[ $(tc-is-softfloat) == "yes" ]] && myconf+=( --without-fp )
898 -
899 - myconf+=( --enable-kernel=${MIN_KERN_VER} )
900 -
901 - # Since SELinux support is only required for nscd, only enable it if:
902 - # 1. USE selinux
903 - # 2. only for the primary ABI on multilib systems
904 - # 3. Not a crosscompile
905 - if ! is_crosscompile && use selinux ; then
906 - if use multilib ; then
907 - if is_final_abi ; then
908 - myconf+=( --with-selinux )
909 - else
910 - myconf+=( --without-selinux )
911 - fi
912 - else
913 - myconf+=( --with-selinux )
914 - fi
915 - else
916 - myconf+=( --without-selinux )
917 - fi
918 -
919 - # Force a few tests where we always know the answer but
920 - # configure is incapable of finding it.
921 - if is_crosscompile ; then
922 - export \
923 - libc_cv_c_cleanup=yes \
924 - libc_cv_forced_unwind=yes
925 - fi
926 -
927 - myconf+=(
928 - --without-cvs
929 - --disable-werror
930 - --enable-bind-now
931 - --build=${CBUILD_OPT:-${CBUILD}}
932 - --host=${CTARGET_OPT:-${CTARGET}}
933 - $(use_enable profile)
934 - $(use_with gd)
935 - --with-headers=$(build_eprefix)$(alt_build_headers)
936 - --prefix="$(host_eprefix)/usr"
937 - --sysconfdir="$(host_eprefix)/etc"
938 - --localstatedir="$(host_eprefix)/var"
939 - --libdir='$(prefix)'/$(get_libdir)
940 - --mandir='$(prefix)'/share/man
941 - --infodir='$(prefix)'/share/info
942 - --libexecdir='$(libdir)'/misc/glibc
943 - --with-bugurl=https://bugs.gentoo.org/
944 - --with-pkgversion="$(glibc_banner)"
945 - $(use_enable crypt)
946 - $(use_multiarch || echo --disable-multi-arch)
947 - $(use_enable systemtap)
948 - $(use_enable nscd)
949 - ${EXTRA_ECONF}
950 - )
951 -
952 - # We rely on sys-libs/timezone-data for timezone tools normally.
953 - myconf+=( $(use_enable vanilla timezone-tools) )
954 -
955 - # These libs don't have configure flags.
956 - ac_cv_lib_audit_audit_log_user_avc_message=$(usex audit || echo no)
957 - ac_cv_lib_cap_cap_init=$(usex caps || echo no)
958 -
959 - # There is no configure option for this and we need to export it
960 - # since the glibc build will re-run configure on itself
961 - export libc_cv_rootsbindir="$(host_eprefix)/sbin"
962 - export libc_cv_slibdir="$(host_eprefix)/$(get_libdir)"
963 -
964 - # We take care of patching our binutils to use both hash styles,
965 - # and many people like to force gnu hash style only, so disable
966 - # this overriding check. #347761
967 - export libc_cv_hashstyle=no
968 -
969 - local builddir=$(builddir nptl)
970 - mkdir -p "${builddir}"
971 - cd "${builddir}"
972 - set -- "${S}"/configure "${myconf[@]}"
973 - echo "$@"
974 - "$@" || die "failed to configure glibc"
975 -
976 - # ia64 static cross-compilers are a pita in so much that they
977 - # can't produce static ELFs (as the libgcc.a is broken). so
978 - # disable building of the programs for those targets if it
979 - # doesn't work.
980 - # XXX: We could turn this into a compiler test, but ia64 is
981 - # the only one that matters, so this should be fine for now.
982 - if is_crosscompile && [[ ${CTARGET} == ia64* ]] ; then
983 - sed -i '1i+link-static = touch $@' config.make
984 - fi
985 -
986 - # If we're trying to migrate between ABI sets, we need
987 - # to lie and use a local copy of gcc. Like if the system
988 - # is built with MULTILIB_ABIS="amd64 x86" but we want to
989 - # add x32 to it, gcc/glibc don't yet support x32.
990 - #
991 - if [[ -n ${GCC_BOOTSTRAP_VER} ]] && use multilib ; then
992 - echo 'main(){}' > "${T}"/test.c
993 - if ! $(tc-getCC ${CTARGET}) ${CFLAGS} ${LDFLAGS} "${T}"/test.c -Wl,-emain -lgcc 2>/dev/null ; then
994 - sed -i -e '/^CC = /s:$: -B$(objdir)/../'"gcc-multilib-bootstrap-${GCC_BOOTSTRAP_VER}/${ABI}:" config.make || die
995 - fi
996 - fi
997 -}
998 -
999 -glibc_headers_configure() {
1000 - export ABI=default
1001 -
1002 - local builddir=$(builddir "headers")
1003 - mkdir -p "${builddir}"
1004 - cd "${builddir}"
1005 -
1006 - # if we don't have a compiler yet, we can't really test it now ...
1007 - # hopefully they don't affect header generation, so let's hope for
1008 - # the best here ...
1009 - local v vars=(
1010 - ac_cv_header_cpuid_h=yes
1011 - libc_cv_{386,390,alpha,arm,hppa,ia64,mips,{powerpc,sparc}{,32,64},sh,x86_64}_tls=yes
1012 - libc_cv_asm_cfi_directives=yes
1013 - libc_cv_broken_visibility_attribute=no
1014 - libc_cv_c_cleanup=yes
1015 - libc_cv_compiler_powerpc64le_binary128_ok=yes
1016 - libc_cv_forced_unwind=yes
1017 - libc_cv_gcc___thread=yes
1018 - libc_cv_mlong_double_128=yes
1019 - libc_cv_mlong_double_128ibm=yes
1020 - libc_cv_ppc_machine=yes
1021 - libc_cv_ppc_rel16=yes
1022 - libc_cv_predef_fortify_source=no
1023 - libc_cv_target_power8_ok=yes
1024 - libc_cv_visibility_attribute=yes
1025 - libc_cv_z_combreloc=yes
1026 - libc_cv_z_execstack=yes
1027 - libc_cv_z_initfirst=yes
1028 - libc_cv_z_nodelete=yes
1029 - libc_cv_z_nodlopen=yes
1030 - libc_cv_z_relro=yes
1031 - libc_mips_abi=${ABI}
1032 - libc_mips_float=$([[ $(tc-is-softfloat) == "yes" ]] && echo soft || echo hard)
1033 - # These libs don't have configure flags.
1034 - ac_cv_lib_audit_audit_log_user_avc_message=no
1035 - ac_cv_lib_cap_cap_init=no
1036 - )
1037 -
1038 - einfo "Forcing cached settings:"
1039 - for v in "${vars[@]}" ; do
1040 - einfo " ${v}"
1041 - export ${v}
1042 - done
1043 -
1044 - local headers_only_arch_CPPFLAGS=()
1045 -
1046 - # Blow away some random CC settings that screw things up. #550192
1047 - if [[ -d ${S}/sysdeps/mips ]]; then
1048 - pushd "${S}"/sysdeps/mips >/dev/null
1049 - sed -i -e '/^CC +=/s:=.*:= -D_MIPS_SZPTR=32:' mips32/Makefile mips64/n32/Makefile || die
1050 - sed -i -e '/^CC +=/s:=.*:= -D_MIPS_SZPTR=64:' mips64/n64/Makefile || die
1051 -
1052 - # Force the mips ABI to the default. This is OK because the set of
1053 - # installed headers in this phase is the same between the 3 ABIs.
1054 - # If this ever changes, this hack will break, but that's unlikely
1055 - # as glibc discourages that behavior.
1056 - # https://crbug.com/647033
1057 - sed -i -e 's:abiflag=.*:abiflag=_ABIO32:' preconfigure || die
1058 -
1059 - popd >/dev/null
1060 - fi
1061 -
1062 - case ${CTARGET} in
1063 - riscv*)
1064 - # RISC-V interrogates the compiler to determine which target to
1065 - # build. If building the headers then we don't strictly need a
1066 - # RISC-V compiler, so the built-in definitions that are provided
1067 - # along with all RISC-V compiler might not exist. This causes
1068 - # glibc's RISC-V preconfigure script to blow up. Since we're just
1069 - # building the headers any value will actually work here, so just
1070 - # pick the standard one (rv64g/lp64d) to make the build scripts
1071 - # happy for now -- the headers are all the same anyway so it
1072 - # doesn't matter.
1073 - headers_only_arch_CPPFLAGS+=(
1074 - -D__riscv_xlen=64
1075 - -D__riscv_flen=64
1076 - -D__riscv_float_abi_double=1
1077 - -D__riscv_atomic=1
1078 - ) ;;
1079 - esac
1080 -
1081 - local myconf=()
1082 - myconf+=(
1083 - --disable-sanity-checks
1084 - --enable-hacker-mode
1085 - --without-cvs
1086 - --disable-werror
1087 - --enable-bind-now
1088 - --build=${CBUILD_OPT:-${CBUILD}}
1089 - --host=${CTARGET_OPT:-${CTARGET}}
1090 - --with-headers=$(build_eprefix)$(alt_build_headers)
1091 - --prefix="$(host_eprefix)/usr"
1092 - ${EXTRA_ECONF}
1093 - )
1094 -
1095 - # Nothing is compiled here which would affect the headers for the target.
1096 - # So forcing CC/CFLAGS is sane.
1097 - local headers_only_CC=$(tc-getBUILD_CC)
1098 - local headers_only_CFLAGS="-O1 -pipe"
1099 - local headers_only_CPPFLAGS="-U_FORTIFY_SOURCE ${headers_only_arch_CPPFLAGS[*]}"
1100 - local headers_only_LDFLAGS=""
1101 - set -- "${S}"/configure "${myconf[@]}"
1102 - echo \
1103 - "CC=${headers_only_CC}" \
1104 - "CFLAGS=${headers_only_CFLAGS}" \
1105 - "CPPFLAGS=${headers_only_CPPFLAGS}" \
1106 - "LDFLAGS=${headers_only_LDFLAGS}" \
1107 - "$@"
1108 - CC=${headers_only_CC} \
1109 - CFLAGS=${headers_only_CFLAGS} \
1110 - CPPFLAGS=${headers_only_CPPFLAGS} \
1111 - LDFLAGS="" \
1112 - "$@" || die "failed to configure glibc"
1113 -}
1114 -
1115 -do_src_configure() {
1116 - if just_headers ; then
1117 - glibc_headers_configure
1118 - else
1119 - glibc_do_configure nptl
1120 - fi
1121 -}
1122 -
1123 -src_configure() {
1124 - foreach_abi do_src_configure
1125 -}
1126 -
1127 -do_src_compile() {
1128 - emake -C "$(builddir nptl)"
1129 -}
1130 -
1131 -src_compile() {
1132 - if just_headers ; then
1133 - return
1134 - fi
1135 -
1136 - foreach_abi do_src_compile
1137 -}
1138 -
1139 -glibc_src_test() {
1140 - cd "$(builddir nptl)"
1141 -
1142 - local myxfailparams=""
1143 - if [[ "${GENTOO_GLIBC_XFAIL_TESTS}" == "yes" ]] ; then
1144 - for myt in ${XFAIL_TEST_LIST[@]} ; do
1145 - myxfailparams+="test-xfail-${myt}=yes "
1146 - done
1147 - fi
1148 -
1149 - emake ${myxfailparams} check
1150 -}
1151 -
1152 -do_src_test() {
1153 - local ret=0
1154 -
1155 - glibc_src_test
1156 - : $(( ret |= $? ))
1157 -
1158 - return ${ret}
1159 -}
1160 -
1161 -src_test() {
1162 - if just_headers ; then
1163 - return
1164 - fi
1165 -
1166 - # Give tests more time to complete.
1167 - export TIMEOUTFACTOR=5
1168 -
1169 - foreach_abi do_src_test || die "tests failed"
1170 -}
1171 -
1172 -run_locale_gen() {
1173 - # if the host locales.gen contains no entries, we'll install everything
1174 - local root="$1"
1175 - local inplace=""
1176 -
1177 - if [[ "${root}" == "--inplace-glibc" ]] ; then
1178 - inplace="--inplace-glibc"
1179 - root="$2"
1180 - fi
1181 -
1182 - local locale_list="${root}/etc/locale.gen"
1183 -
1184 - pushd "${ED}"/$(get_libdir) >/dev/null
1185 -
1186 - if [[ -z $(locale-gen --list --config "${locale_list}") ]] ; then
1187 - [[ -z ${inplace} ]] && ewarn "Generating all locales; edit /etc/locale.gen to save time/space"
1188 - locale_list="${root}/usr/share/i18n/SUPPORTED"
1189 - fi
1190 -
1191 - locale-gen ${inplace} --jobs $(makeopts_jobs) --config "${locale_list}" \
1192 - --destdir "${root}"
1193 -
1194 - popd >/dev/null
1195 -}
1196 -
1197 -glibc_do_src_install() {
1198 - local builddir=$(builddir nptl)
1199 - cd "${builddir}"
1200 -
1201 - emake install_root="${D}/$(build_eprefix)$(alt_prefix)" install
1202 -
1203 - # This version (2.26) provides some compatibility libraries for the NIS/NIS+ support
1204 - # which come without headers etc. Only needed for binary packages since the
1205 - # external net-libs/libnsl has increased soversion. Keep only versioned libraries.
1206 - find "${D}" -name "libnsl.a" -delete
1207 - find "${D}" -name "libnsl.so" -delete
1208 -
1209 - # Normally upstream_pv is ${PV}. Live ebuilds are exception, there we need
1210 - # to infer upstream version:
1211 - # '#define VERSION "2.26.90"' -> '2.26.90'
1212 - local upstream_pv=$(sed -n -r 's/#define VERSION "(.*)"/\1/p' "${S}"/version.h)
1213 -
1214 - # Avoid stripping binaries not targeted by ${CHOST}. Or else
1215 - # ${CHOST}-strip would break binaries build for ${CTARGET}.
1216 - is_crosscompile && dostrip -x /
1217 - # gdb thread introspection relies on local libpthreas symbols. stripping breaks it
1218 - # See Note [Disable automatic stripping]
1219 - dostrip -x $(alt_libdir)/libpthread-${upstream_pv}.so
1220 -
1221 - if [[ -e ${ED}/$(alt_usrlibdir)/libm-${upstream_pv}.a ]] ; then
1222 - # Move versioned .a file out of libdir to evade portage QA checks
1223 - # instead of using gen_usr_ldscript(). We fix ldscript as:
1224 - # "GROUP ( /usr/lib64/libm-<pv>.a ..." -> "GROUP ( /usr/lib64/glibc-<pv>/libm-<pv>.a ..."
1225 - sed -i "s@\(libm-${upstream_pv}.a\)@${P}/\1@" "${ED}"/$(alt_usrlibdir)/libm.a || die
1226 - dodir $(alt_usrlibdir)/${P}
1227 - mv "${ED}"/$(alt_usrlibdir)/libm-${upstream_pv}.a "${ED}"/$(alt_usrlibdir)/${P}/libm-${upstream_pv}.a || die
1228 - fi
1229 -
1230 - # We'll take care of the cache ourselves
1231 - rm -f "${ED}"/etc/ld.so.cache
1232 -
1233 - # Everything past this point just needs to be done once ...
1234 - is_final_abi || return 0
1235 -
1236 - # Make sure the non-native interp can be found on multilib systems even
1237 - # if the main library set isn't installed into the right place. Maybe
1238 - # we should query the active gcc for info instead of hardcoding it ?
1239 - local i ldso_abi ldso_name
1240 - local ldso_abi_list=(
1241 - # x86
1242 - amd64 /lib64/ld-linux-x86-64.so.2
1243 - x32 /libx32/ld-linux-x32.so.2
1244 - x86 /lib/ld-linux.so.2
1245 - # mips
1246 - o32 /lib/ld.so.1
1247 - n32 /lib32/ld.so.1
1248 - n64 /lib64/ld.so.1
1249 - # powerpc
1250 - ppc /lib/ld.so.1
1251 - ppc64 /lib64/ld64.so.1
1252 - # riscv
1253 - lp64d /lib/ld-linux-riscv64-lp64d.so.1
1254 - lp64 /lib/ld-linux-riscv64-lp64.so.1
1255 - # s390
1256 - s390 /lib/ld.so.1
1257 - s390x /lib/ld64.so.1
1258 - # sparc
1259 - sparc32 /lib/ld-linux.so.2
1260 - sparc64 /lib64/ld-linux.so.2
1261 - )
1262 - case $(tc-endian) in
1263 - little)
1264 - ldso_abi_list+=(
1265 - # arm
1266 - arm64 /lib/ld-linux-aarch64.so.1
1267 - )
1268 - ;;
1269 - big)
1270 - ldso_abi_list+=(
1271 - # arm
1272 - arm64 /lib/ld-linux-aarch64_be.so.1
1273 - )
1274 - ;;
1275 - esac
1276 - if [[ ${SYMLINK_LIB} == "yes" ]] && [[ ! -e ${ED}/$(alt_prefix)/lib ]] ; then
1277 - dosym $(get_abi_LIBDIR ${DEFAULT_ABI}) $(alt_prefix)/lib
1278 - fi
1279 - for (( i = 0; i < ${#ldso_abi_list[@]}; i += 2 )) ; do
1280 - ldso_abi=${ldso_abi_list[i]}
1281 - has ${ldso_abi} $(get_install_abis) || continue
1282 -
1283 - ldso_name="$(alt_prefix)${ldso_abi_list[i+1]}"
1284 - if [[ ! -L ${ED}/${ldso_name} && ! -e ${ED}/${ldso_name} ]] ; then
1285 - dosym ../$(get_abi_LIBDIR ${ldso_abi})/${ldso_name##*/} ${ldso_name}
1286 - fi
1287 - done
1288 -
1289 - # With devpts under Linux mounted properly, we do not need the pt_chown
1290 - # binary to be setuid. This is because the default owners/perms will be
1291 - # exactly what we want.
1292 - if ! use suid ; then
1293 - find "${ED}" -name pt_chown -exec chmod -s {} +
1294 - fi
1295 -
1296 - #################################################################
1297 - # EVERYTHING AFTER THIS POINT IS FOR NATIVE GLIBC INSTALLS ONLY #
1298 - # Make sure we install some symlink hacks so that when we build
1299 - # a 2nd stage cross-compiler, gcc finds the target system
1300 - # headers correctly. See gcc/doc/gccinstall.info
1301 - if is_crosscompile ; then
1302 - # We need to make sure that /lib and /usr/lib always exists.
1303 - # gcc likes to use relative paths to get to its multilibs like
1304 - # /usr/lib/../lib64/. So while we don't install any files into
1305 - # /usr/lib/, we do need it to exist.
1306 - keepdir $(alt_prefix)/lib
1307 - keepdir $(alt_prefix)/usr/lib
1308 -
1309 - dosym usr/include $(alt_prefix)/sys-include
1310 - return 0
1311 - fi
1312 -
1313 - # Files for Debian-style locale updating
1314 - dodir /usr/share/i18n
1315 - sed \
1316 - -e "/^#/d" \
1317 - -e "/SUPPORTED-LOCALES=/d" \
1318 - -e "s: \\\\::g" -e "s:/: :g" \
1319 - "${S}"/localedata/SUPPORTED > "${ED}"/usr/share/i18n/SUPPORTED \
1320 - || die "generating /usr/share/i18n/SUPPORTED failed"
1321 - cd "${WORKDIR}"/extra/locale
1322 - dosbin locale-gen
1323 - doman *.[0-8]
1324 - insinto /etc
1325 - doins locale.gen
1326 -
1327 - # Make sure all the ABI's can find the locales and so we only
1328 - # have to generate one set
1329 - local a
1330 - keepdir /usr/$(get_libdir)/locale
1331 - for a in $(get_install_abis) ; do
1332 - if [[ ! -e ${ED}/usr/$(get_abi_LIBDIR ${a})/locale ]] ; then
1333 - dosym ../$(get_libdir)/locale /usr/$(get_abi_LIBDIR ${a})/locale
1334 - fi
1335 - done
1336 -
1337 - # HACK: If we're building for riscv, we need to additionally make sure that
1338 - # we can find the locale archive afterwards
1339 - case ${CTARGET} in
1340 - riscv*)
1341 - if [[ ! -e ${ED}/usr/lib/locale ]] ; then
1342 - dosym ../$(get_libdir)/locale /usr/lib/locale
1343 - fi
1344 - ;;
1345 - *) ;;
1346 - esac
1347 -
1348 - cd "${S}"
1349 -
1350 - # Install misc network config files
1351 - insinto /etc
1352 - doins nscd/nscd.conf posix/gai.conf nss/nsswitch.conf
1353 - doins "${WORKDIR}"/extra/etc/*.conf
1354 -
1355 - if use nscd ; then
1356 - doinitd "$(prefixify_ro "${WORKDIR}"/extra/etc/nscd)"
1357 -
1358 - local nscd_args=(
1359 - -e "s:@PIDFILE@:$(strings "${ED}"/usr/sbin/nscd | grep nscd.pid):"
1360 - )
1361 -
1362 - sed -i "${nscd_args[@]}" "${ED}"/etc/init.d/nscd
1363 -
1364 - systemd_dounit nscd/nscd.service
1365 - systemd_newtmpfilesd nscd/nscd.tmpfiles nscd.conf
1366 - else
1367 - # Do this since extra/etc/*.conf above might have nscd.conf.
1368 - rm -f "${ED}"/etc/nscd.conf
1369 - fi
1370 -
1371 - echo 'LDPATH="include ld.so.conf.d/*.conf"' > "${T}"/00glibc
1372 - doenvd "${T}"/00glibc
1373 -
1374 - for d in BUGS ChangeLog CONFORMANCE FAQ NEWS NOTES PROJECTS README* ; do
1375 - [[ -s ${d} ]] && dodoc ${d}
1376 - done
1377 - dodoc -r ChangeLog.old
1378 -
1379 - # Prevent overwriting of the /etc/localtime symlink. We'll handle the
1380 - # creation of the "factory" symlink in pkg_postinst().
1381 - rm -f "${ED}"/etc/localtime
1382 -
1383 - # Generate all locales if this is a native build as locale generation
1384 - if use compile-locales && ! is_crosscompile ; then
1385 - run_locale_gen --inplace-glibc "${ED}/"
1386 - sed -e 's:COMPILED_LOCALES="":COMPILED_LOCALES="1":' -i "${ED}"/usr/sbin/locale-gen || die
1387 - fi
1388 -}
1389 -
1390 -glibc_headers_install() {
1391 - local builddir=$(builddir "headers")
1392 - cd "${builddir}"
1393 - emake install_root="${D}/$(build_eprefix)$(alt_prefix)" install-headers
1394 -
1395 - insinto $(alt_headers)/gnu
1396 - doins "${S}"/include/gnu/stubs.h
1397 -
1398 - # Make sure we install the sys-include symlink so that when
1399 - # we build a 2nd stage cross-compiler, gcc finds the target
1400 - # system headers correctly. See gcc/doc/gccinstall.info
1401 - dosym usr/include $(alt_prefix)/sys-include
1402 -}
1403 -
1404 -src_install() {
1405 - if just_headers ; then
1406 - export ABI=default
1407 - glibc_headers_install
1408 - return
1409 - fi
1410 -
1411 - foreach_abi glibc_do_src_install
1412 -
1413 - if ! use static-libs ; then
1414 - elog "Not installing static glibc libraries"
1415 - find "${ED}" -name "*.a" -and -not -name "*_nonshared.a" -delete
1416 - fi
1417 -}
1418 -
1419 -# Simple test to make sure our new glibc isn't completely broken.
1420 -# Make sure we don't test with statically built binaries since
1421 -# they will fail. Also, skip if this glibc is a cross compiler.
1422 -#
1423 -# If coreutils is built with USE=multicall, some of these files
1424 -# will just be wrapper scripts, not actual ELFs we can test.
1425 -glibc_sanity_check() {
1426 - cd / #228809
1427 -
1428 - # We enter ${ED} so to avoid trouble if the path contains
1429 - # special characters; for instance if the path contains the
1430 - # colon character (:), then the linker will try to split it
1431 - # and look for the libraries in an unexpected place. This can
1432 - # lead to unsafe code execution if the generated prefix is
1433 - # within a world-writable directory.
1434 - # (e.g. /var/tmp/portage:${HOSTNAME})
1435 - pushd "${ED}"/$(get_libdir) >/dev/null
1436 -
1437 - local x striptest
1438 - for x in cal date env free ls true uname uptime ; do
1439 - x=$(type -p ${x})
1440 - [[ -z ${x} || ${x} != ${EPREFIX}/* ]] && continue
1441 - striptest=$(LC_ALL="C" file -L ${x} 2>/dev/null) || continue
1442 - case ${striptest} in
1443 - *"statically linked"*) continue;;
1444 - *"ASCII text"*) continue;;
1445 - esac
1446 - # We need to clear the locale settings as the upgrade might want
1447 - # incompatible locale data. This test is not for verifying that.
1448 - LC_ALL=C \
1449 - ./ld-*.so --library-path . ${x} > /dev/null \
1450 - || die "simple run test (${x}) failed"
1451 - done
1452 -
1453 - popd >/dev/null
1454 -}
1455 -
1456 -pkg_preinst() {
1457 - # nothing to do if just installing headers
1458 - just_headers && return
1459 -
1460 - # prepare /etc/ld.so.conf.d/ for files
1461 - mkdir -p "${EROOT}"/etc/ld.so.conf.d
1462 -
1463 - # Default /etc/hosts.conf:multi to on for systems with small dbs.
1464 - if [[ $(wc -l < "${EROOT}"/etc/hosts) -lt 1000 ]] ; then
1465 - sed -i '/^multi off/s:off:on:' "${ED}"/etc/host.conf
1466 - einfo "Defaulting /etc/host.conf:multi to on"
1467 - fi
1468 -
1469 - [[ -n ${ROOT} ]] && return 0
1470 - [[ -d ${ED}/$(get_libdir) ]] || return 0
1471 - [[ -z ${BOOTSTRAP_RAP} ]] && glibc_sanity_check
1472 -}
1473 -
1474 -pkg_postinst() {
1475 - # nothing to do if just installing headers
1476 - just_headers && return
1477 -
1478 - if ! tc-is-cross-compiler && [[ -x ${EROOT}/usr/sbin/iconvconfig ]] ; then
1479 - # Generate fastloading iconv module configuration file.
1480 - "${EROOT}"/usr/sbin/iconvconfig --prefix="${ROOT}/"
1481 - fi
1482 -
1483 - if ! is_crosscompile && [[ -z ${ROOT} ]] ; then
1484 - use compile-locales || run_locale_gen "${EROOT}/"
1485 - fi
1486 -
1487 - # Check for sanity of /etc/nsswitch.conf, take 2
1488 - if [[ -e ${EROOT}/etc/nsswitch.conf ]] && ! has_version sys-auth/libnss-nis ; then
1489 - local entry
1490 - for entry in passwd group shadow; do
1491 - if egrep -q "^[ \t]*${entry}:.*nis" "${EROOT}"/etc/nsswitch.conf; then
1492 - ewarn ""
1493 - ewarn "Your ${EROOT}/etc/nsswitch.conf uses NIS. Support for that has been"
1494 - ewarn "removed from glibc and is now provided by the package"
1495 - ewarn " sys-auth/libnss-nis"
1496 - ewarn "Install it now to keep your NIS setup working."
1497 - ewarn ""
1498 - fi
1499 - done
1500 - fi
1501 -}
1502
1503 diff --git a/sys-libs/glibc/glibc-2.31-r6.ebuild b/sys-libs/glibc/glibc-2.31-r6.ebuild
1504 deleted file mode 100644
1505 index 156e25f568a..00000000000
1506 --- a/sys-libs/glibc/glibc-2.31-r6.ebuild
1507 +++ /dev/null
1508 @@ -1,1495 +0,0 @@
1509 -# Copyright 1999-2020 Gentoo Authors
1510 -# Distributed under the terms of the GNU General Public License v2
1511 -
1512 -EAPI=7
1513 -
1514 -PYTHON_COMPAT=( python3_{7,8} )
1515 -
1516 -inherit python-any-r1 prefix eutils toolchain-funcs flag-o-matic gnuconfig \
1517 - multilib systemd multiprocessing
1518 -
1519 -DESCRIPTION="GNU libc C library"
1520 -HOMEPAGE="https://www.gnu.org/software/libc/"
1521 -LICENSE="LGPL-2.1+ BSD HPND ISC inner-net rc PCRE"
1522 -SLOT="2.2"
1523 -
1524 -EMULTILIB_PKG="true"
1525 -
1526 -# Gentoo patchset (ignored for live ebuilds)
1527 -PATCH_VER=8
1528 -PATCH_DEV=dilfridge
1529 -
1530 -if [[ ${PV} == 9999* ]]; then
1531 - inherit git-r3
1532 -else
1533 - KEYWORDS="~alpha amd64 arm arm64 hppa ~ia64 ~m68k ~mips ppc ppc64 ~riscv ~s390 sparc x86"
1534 - SRC_URI="mirror://gnu/glibc/${P}.tar.xz"
1535 - SRC_URI+=" https://dev.gentoo.org/~${PATCH_DEV}/distfiles/${P}-patches-${PATCH_VER}.tar.xz"
1536 -fi
1537 -
1538 -RELEASE_VER=${PV}
1539 -
1540 -GCC_BOOTSTRAP_VER=20180511
1541 -
1542 -LOCALE_GEN_VER=2.00
1543 -
1544 -SRC_URI+=" https://gitweb.gentoo.org/proj/locale-gen.git/snapshot/locale-gen-${LOCALE_GEN_VER}.tar.gz"
1545 -SRC_URI+=" multilib? ( https://dev.gentoo.org/~dilfridge/distfiles/gcc-multilib-bootstrap-${GCC_BOOTSTRAP_VER}.tar.xz )"
1546 -
1547 -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"
1548 -
1549 -# Minimum kernel version that glibc requires
1550 -MIN_KERN_VER="3.2.0"
1551 -
1552 -# Here's how the cross-compile logic breaks down ...
1553 -# CTARGET - machine that will target the binaries
1554 -# CHOST - machine that will host the binaries
1555 -# CBUILD - machine that will build the binaries
1556 -# If CTARGET != CHOST, it means you want a libc for cross-compiling.
1557 -# If CHOST != CBUILD, it means you want to cross-compile the libc.
1558 -# CBUILD = CHOST = CTARGET - native build/install
1559 -# CBUILD != (CHOST = CTARGET) - cross-compile a native build
1560 -# (CBUILD = CHOST) != CTARGET - libc for cross-compiler
1561 -# CBUILD != CHOST != CTARGET - cross-compile a libc for a cross-compiler
1562 -# For install paths:
1563 -# CHOST = CTARGET - install into /
1564 -# CHOST != CTARGET - install into /usr/CTARGET/
1565 -#
1566 -export CBUILD=${CBUILD:-${CHOST}}
1567 -export CTARGET=${CTARGET:-${CHOST}}
1568 -if [[ ${CTARGET} == ${CHOST} ]] ; then
1569 - if [[ ${CATEGORY} == cross-* ]] ; then
1570 - export CTARGET=${CATEGORY#cross-}
1571 - fi
1572 -fi
1573 -
1574 -# Note [Disable automatic stripping]
1575 -# Disabling automatic stripping for a few reasons:
1576 -# - portage's attempt to strip breaks non-native binaries at least on
1577 -# arm: bug #697428
1578 -# - portage's attempt to strip libpthread.so.0 breaks gdb thread
1579 -# enumeration: bug #697910. This is quite subtle:
1580 -# * gdb uses glibc's libthread_db-1.0.so to enumerate threads.
1581 -# * libthread_db-1.0.so needs access to libpthread.so.0 local symbols
1582 -# via 'ps_pglobal_lookup' symbol defined in gdb.
1583 -# * 'ps_pglobal_lookup' uses '.symtab' section table to resolve all
1584 -# known symbols in 'libpthread.so.0'. Specifically 'nptl_version'
1585 -# (unexported) is used to sanity check compatibility before enabling
1586 -# debugging.
1587 -# 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
1588 -# * normal 'strip' command trims '.symtab'
1589 -# Thus our main goal here is to prevent 'libpthread.so.0' from
1590 -# losing it's '.symtab' entries.
1591 -# As Gentoo's strip does not allow us to pass less aggressive stripping
1592 -# options and does not check the machine target we strip selectively.
1593 -
1594 -# We need a new-enough binutils/gcc to match upstream baseline.
1595 -# Also we need to make sure our binutils/gcc supports TLS,
1596 -# and that gcc already contains the hardened patches.
1597 -# Lastly, let's avoid some openssh nastiness, bug 708224, as
1598 -# convenience to our users.
1599 -BDEPEND="
1600 - ${PYTHON_DEPS}
1601 - >=app-misc/pax-utils-0.1.10
1602 - sys-devel/bison
1603 - doc? ( sys-apps/texinfo )
1604 -"
1605 -COMMON_DEPEND="
1606 - gd? ( media-libs/gd:2= )
1607 - nscd? ( selinux? (
1608 - audit? ( sys-process/audit )
1609 - caps? ( sys-libs/libcap )
1610 - ) )
1611 - suid? ( caps? ( sys-libs/libcap ) )
1612 - selinux? ( sys-libs/libselinux )
1613 - systemtap? ( dev-util/systemtap )
1614 - !<net-misc/openssh-8.1_p1-r2
1615 -"
1616 -DEPEND="${COMMON_DEPEND}
1617 - test? ( >=net-dns/libidn2-2.3.0 )
1618 -"
1619 -RDEPEND="${COMMON_DEPEND}
1620 - sys-apps/gentoo-functions
1621 -"
1622 -
1623 -RESTRICT="!test? ( test )"
1624 -
1625 -if [[ ${CATEGORY} == cross-* ]] ; then
1626 - BDEPEND+=" !headers-only? (
1627 - >=${CATEGORY}/binutils-2.24
1628 - >=${CATEGORY}/gcc-6
1629 - )"
1630 - [[ ${CATEGORY} == *-linux* ]] && DEPEND+=" ${CATEGORY}/linux-headers"
1631 -else
1632 - BDEPEND+="
1633 - >=sys-devel/binutils-2.24
1634 - >=sys-devel/gcc-6
1635 - "
1636 - DEPEND+=" virtual/os-headers "
1637 - RDEPEND+="
1638 - >=net-dns/libidn2-2.3.0
1639 - vanilla? ( !sys-libs/timezone-data )
1640 - "
1641 - PDEPEND+=" !vanilla? ( sys-libs/timezone-data )"
1642 -fi
1643 -
1644 -# Ignore tests whitelisted below
1645 -GENTOO_GLIBC_XFAIL_TESTS="${GENTOO_GLIBC_XFAIL_TESTS:-yes}"
1646 -
1647 -# The following tests fail due to the Gentoo build system and are thus
1648 -# executed but ignored:
1649 -XFAIL_TEST_LIST=(
1650 - # 9) Failures of unknown origin
1651 - tst-latepthread
1652 -
1653 - # buggy test, assumes /dev/ and /dev/null on a single filesystem
1654 - # 'mount --bind /dev/null /chroot/dev/null' breaks it.
1655 - # https://sourceware.org/PR25909
1656 - tst-support_descriptors
1657 -
1658 - # Flaky test, known to fail occasionally:
1659 - # https://sourceware.org/PR19329
1660 - # https://bugs.gentoo.org/719674#c12
1661 - tst-stack4
1662 -)
1663 -
1664 -#
1665 -# Small helper functions
1666 -#
1667 -
1668 -is_crosscompile() {
1669 - [[ ${CHOST} != ${CTARGET} ]]
1670 -}
1671 -
1672 -just_headers() {
1673 - is_crosscompile && use headers-only
1674 -}
1675 -
1676 -alt_prefix() {
1677 - is_crosscompile && echo /usr/${CTARGET}
1678 -}
1679 -
1680 -# This prefix is applicable to CHOST when building against this
1681 -# glibc. It is baked into the library at configure time.
1682 -host_eprefix() {
1683 - is_crosscompile || echo "${EPREFIX}"
1684 -}
1685 -
1686 -# This prefix is applicable to CBUILD when building against this
1687 -# glibc. It determines the destination path at install time.
1688 -build_eprefix() {
1689 - is_crosscompile && echo "${EPREFIX}"
1690 -}
1691 -
1692 -# We need to be able to set alternative headers for compiling for non-native
1693 -# platform. Will also become useful for testing kernel-headers without screwing
1694 -# up the whole system.
1695 -alt_headers() {
1696 - echo ${ALT_HEADERS:=$(alt_prefix)/usr/include}
1697 -}
1698 -
1699 -alt_build_headers() {
1700 - if [[ -z ${ALT_BUILD_HEADERS} ]] ; then
1701 - ALT_BUILD_HEADERS="$(host_eprefix)$(alt_headers)"
1702 - if tc-is-cross-compiler ; then
1703 - ALT_BUILD_HEADERS=${SYSROOT}$(alt_headers)
1704 - if [[ ! -e ${ALT_BUILD_HEADERS}/linux/version.h ]] ; then
1705 - local header_path=$(echo '#include <linux/version.h>' | $(tc-getCPP ${CTARGET}) ${CFLAGS} 2>&1 | grep -o '[^"]*linux/version.h')
1706 - ALT_BUILD_HEADERS=${header_path%/linux/version.h}
1707 - fi
1708 - fi
1709 - fi
1710 - echo "${ALT_BUILD_HEADERS}"
1711 -}
1712 -
1713 -alt_libdir() {
1714 - echo $(alt_prefix)/$(get_libdir)
1715 -}
1716 -alt_usrlibdir() {
1717 - echo $(alt_prefix)/usr/$(get_libdir)
1718 -}
1719 -
1720 -builddir() {
1721 - echo "${WORKDIR}/build-${ABI}-${CTARGET}-$1"
1722 -}
1723 -
1724 -do_compile_test() {
1725 - local ret save_cflags=${CFLAGS}
1726 - CFLAGS+=" $1"
1727 - shift
1728 -
1729 - pushd "${T}" >/dev/null
1730 -
1731 - rm -f glibc-test*
1732 - printf '%b' "$*" > glibc-test.c
1733 -
1734 - # Most of the time CC is already set, but not in early sanity checks.
1735 - nonfatal emake glibc-test CC="${CC-$(tc-getCC ${CTARGET})}"
1736 - ret=$?
1737 -
1738 - popd >/dev/null
1739 -
1740 - CFLAGS=${save_cflags}
1741 - return ${ret}
1742 -}
1743 -
1744 -do_run_test() {
1745 - local ret
1746 -
1747 - if [[ ${MERGE_TYPE} == "binary" ]] ; then
1748 - # ignore build failures when installing a binary package #324685
1749 - do_compile_test "" "$@" 2>/dev/null || return 0
1750 - else
1751 - if ! do_compile_test "" "$@" ; then
1752 - ewarn "Simple build failed ... assuming this is desired #324685"
1753 - return 0
1754 - fi
1755 - fi
1756 -
1757 - pushd "${T}" >/dev/null
1758 -
1759 - ./glibc-test
1760 - ret=$?
1761 - rm -f glibc-test*
1762 -
1763 - popd >/dev/null
1764 -
1765 - return ${ret}
1766 -}
1767 -
1768 -setup_target_flags() {
1769 - # This largely mucks with compiler flags. None of which should matter
1770 - # when building up just the headers.
1771 - just_headers && return 0
1772 -
1773 - case $(tc-arch) in
1774 - x86)
1775 - # -march needed for #185404 #199334
1776 - # TODO: When creating the first glibc cross-compile, this test will
1777 - # always fail as it does a full link which in turn requires glibc.
1778 - # Probably also applies when changing multilib profile settings (e.g.
1779 - # enabling x86 when the profile was amd64-only previously).
1780 - # We could change main to _start and pass -nostdlib here so that we
1781 - # only test the gcc code compilation. Or we could do a compile and
1782 - # then look for the symbol via scanelf.
1783 - 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
1784 - local t=${CTARGET_OPT:-${CTARGET}}
1785 - t=${t%%-*}
1786 - filter-flags '-march=*'
1787 - export CFLAGS="-march=${t} ${CFLAGS}"
1788 - einfo "Auto adding -march=${t} to CFLAGS #185404"
1789 - fi
1790 - ;;
1791 - amd64)
1792 - # -march needed for #185404 #199334
1793 - # TODO: See cross-compile issues listed above for x86.
1794 - [[ ${ABI} == x86 ]] &&
1795 - 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
1796 - local t=${CTARGET_OPT:-${CTARGET}}
1797 - t=${t%%-*}
1798 - # Normally the target is x86_64-xxx, so turn that into the -march that
1799 - # gcc actually accepts. #528708
1800 - [[ ${t} == "x86_64" ]] && t="x86-64"
1801 - filter-flags '-march=*'
1802 - # ugly, ugly, ugly. ugly.
1803 - CFLAGS_x86=$(CFLAGS=${CFLAGS_x86} filter-flags '-march=*'; echo "${CFLAGS}")
1804 - export CFLAGS_x86="${CFLAGS_x86} -march=${t}"
1805 - einfo "Auto adding -march=${t} to CFLAGS_x86 #185404 (ABI=${ABI})"
1806 - fi
1807 - ;;
1808 - mips)
1809 - # The mips abi cannot support the GNU style hashes. #233233
1810 - filter-ldflags -Wl,--hash-style=gnu -Wl,--hash-style=both
1811 - ;;
1812 - ppc|ppc64)
1813 - # Many arch-specific implementations do not work on ppc with
1814 - # cache-block not equal to 128 bytes. This breaks memset:
1815 - # https://sourceware.org/PR26522
1816 - # https://bugs.gentoo.org/737996
1817 - # Use default -mcpu=. For ppc it means non-multiarch setup.
1818 - filter-flags '-mcpu=*'
1819 - ;;
1820 - sparc)
1821 - # Both sparc and sparc64 can use -fcall-used-g6. -g7 is bad, though.
1822 - filter-flags "-fcall-used-g7"
1823 - append-flags "-fcall-used-g6"
1824 -
1825 - local cpu
1826 - case ${CTARGET} in
1827 - sparc64-*)
1828 - cpu="sparc64"
1829 - case $(get-flag mcpu) in
1830 - v9)
1831 - # We need to force at least v9a because the base build doesn't
1832 - # work with just v9.
1833 - # https://sourceware.org/bugzilla/show_bug.cgi?id=19477
1834 - append-flags "-Wa,-xarch=v9a"
1835 - ;;
1836 - esac
1837 - ;;
1838 - sparc-*)
1839 - case $(get-flag mcpu) in
1840 - v8|supersparc|hypersparc|leon|leon3)
1841 - cpu="sparcv8"
1842 - ;;
1843 - *)
1844 - cpu="sparcv9"
1845 - ;;
1846 - esac
1847 - ;;
1848 - esac
1849 - [[ -n ${cpu} ]] && CTARGET_OPT="${cpu}-${CTARGET#*-}"
1850 - ;;
1851 - esac
1852 -}
1853 -
1854 -setup_flags() {
1855 - # Make sure host make.conf doesn't pollute us
1856 - if is_crosscompile || tc-is-cross-compiler ; then
1857 - CHOST=${CTARGET} strip-unsupported-flags
1858 - fi
1859 -
1860 - # Store our CFLAGS because it's changed depending on which CTARGET
1861 - # we are building when pulling glibc on a multilib profile
1862 - CFLAGS_BASE=${CFLAGS_BASE-${CFLAGS}}
1863 - CFLAGS=${CFLAGS_BASE}
1864 - CXXFLAGS_BASE=${CXXFLAGS_BASE-${CXXFLAGS}}
1865 - CXXFLAGS=${CXXFLAGS_BASE}
1866 - ASFLAGS_BASE=${ASFLAGS_BASE-${ASFLAGS}}
1867 - ASFLAGS=${ASFLAGS_BASE}
1868 -
1869 - # Allow users to explicitly avoid flag sanitization via
1870 - # USE=custom-cflags.
1871 - if ! use custom-cflags; then
1872 - # Over-zealous CFLAGS can often cause problems. What may work for one
1873 - # person may not work for another. To avoid a large influx of bugs
1874 - # relating to failed builds, we strip most CFLAGS out to ensure as few
1875 - # problems as possible.
1876 - strip-flags
1877 - # Lock glibc at -O2; we want to be conservative here.
1878 - filter-flags '-O?'
1879 - append-flags -O2
1880 - fi
1881 - strip-unsupported-flags
1882 - filter-flags -m32 -m64 '-mabi=*'
1883 -
1884 - # glibc aborts if rpath is set by LDFLAGS
1885 - filter-ldflags '-Wl,-rpath=*'
1886 -
1887 - # #492892
1888 - filter-flags -frecord-gcc-switches
1889 -
1890 - unset CBUILD_OPT CTARGET_OPT
1891 - if use multilib ; then
1892 - CTARGET_OPT=$(get_abi_CTARGET)
1893 - [[ -z ${CTARGET_OPT} ]] && CTARGET_OPT=$(get_abi_CHOST)
1894 - fi
1895 -
1896 - setup_target_flags
1897 -
1898 - if [[ -n ${CTARGET_OPT} && ${CBUILD} == ${CHOST} ]] && ! is_crosscompile; then
1899 - CBUILD_OPT=${CTARGET_OPT}
1900 - fi
1901 -
1902 - # glibc's headers disallow -O0 and fail at build time:
1903 - # include/libc-symbols.h:75:3: #error "glibc cannot be compiled without optimization"
1904 - replace-flags -O0 -O1
1905 -
1906 - filter-flags '-fstack-protector*'
1907 -}
1908 -
1909 -want_tls() {
1910 - # Archs that can use TLS (Thread Local Storage)
1911 - case $(tc-arch) in
1912 - x86)
1913 - # requires i486 or better #106556
1914 - [[ ${CTARGET} == i[4567]86* ]] && return 0
1915 - return 1
1916 - ;;
1917 - esac
1918 - return 0
1919 -}
1920 -
1921 -want__thread() {
1922 - want_tls || return 1
1923 -
1924 - # For some reason --with-tls --with__thread is causing segfaults on sparc32.
1925 - [[ ${PROFILE_ARCH} == "sparc" ]] && return 1
1926 -
1927 - [[ -n ${WANT__THREAD} ]] && return ${WANT__THREAD}
1928 -
1929 - # only test gcc -- can't test linking yet
1930 - tc-has-tls -c ${CTARGET}
1931 - WANT__THREAD=$?
1932 -
1933 - return ${WANT__THREAD}
1934 -}
1935 -
1936 -use_multiarch() {
1937 - # Allow user to disable runtime arch detection in multilib.
1938 - use multiarch || return 1
1939 - # Make sure binutils is new enough to support indirect functions,
1940 - # #336792. This funky sed supports gold and bfd linkers.
1941 - local bver nver
1942 - bver=$($(tc-getLD ${CTARGET}) -v | sed -n -r '1{s:[^0-9]*::;s:^([0-9.]*).*:\1:;p}')
1943 - case $(tc-arch ${CTARGET}) in
1944 - amd64|x86) nver="2.20" ;;
1945 - arm) nver="2.22" ;;
1946 - hppa) nver="2.23" ;;
1947 - ppc|ppc64) nver="2.20" ;;
1948 - # ifunc support was added in 2.23, but glibc also needs
1949 - # machinemode which is in 2.24.
1950 - s390) nver="2.24" ;;
1951 - sparc) nver="2.21" ;;
1952 - *) return 1 ;;
1953 - esac
1954 - ver_test ${bver} -ge ${nver}
1955 -}
1956 -
1957 -# Setup toolchain variables that had historically been defined in the
1958 -# profiles for these archs.
1959 -setup_env() {
1960 - # silly users
1961 - unset LD_RUN_PATH
1962 - unset LD_ASSUME_KERNEL
1963 -
1964 - if is_crosscompile || tc-is-cross-compiler ; then
1965 - multilib_env ${CTARGET_OPT:-${CTARGET}}
1966 -
1967 - if ! use multilib ; then
1968 - MULTILIB_ABIS=${DEFAULT_ABI}
1969 - else
1970 - MULTILIB_ABIS=${MULTILIB_ABIS:-${DEFAULT_ABI}}
1971 - fi
1972 -
1973 - # If the user has CFLAGS_<CTARGET> in their make.conf, use that,
1974 - # and fall back on CFLAGS.
1975 - local VAR=CFLAGS_${CTARGET//[-.]/_}
1976 - CFLAGS=${!VAR-${CFLAGS}}
1977 - einfo " $(printf '%15s' 'Manual CFLAGS:') ${CFLAGS}"
1978 - fi
1979 -
1980 - setup_flags
1981 -
1982 - export ABI=${ABI:-${DEFAULT_ABI:-default}}
1983 -
1984 - if just_headers ; then
1985 - # Avoid mixing host's CC and target's CFLAGS_${ABI}:
1986 - # At this bootstrap stage we have only binutils for
1987 - # target but not compiler yet.
1988 - einfo "Skip CC ABI injection. We can't use (cross-)compiler yet."
1989 - return 0
1990 - fi
1991 - local VAR=CFLAGS_${ABI}
1992 - # We need to export CFLAGS with abi information in them because glibc's
1993 - # configure script checks CFLAGS for some targets (like mips). Keep
1994 - # around the original clean value to avoid appending multiple ABIs on
1995 - # top of each other.
1996 - : ${__GLIBC_CC:=$(tc-getCC ${CTARGET})}
1997 - export __GLIBC_CC CC="${__GLIBC_CC} ${!VAR}"
1998 - einfo " $(printf '%15s' 'Manual CC:') ${CC}"
1999 -}
2000 -
2001 -foreach_abi() {
2002 - setup_env
2003 -
2004 - local ret=0
2005 - local abilist=""
2006 - if use multilib ; then
2007 - abilist=$(get_install_abis)
2008 - else
2009 - abilist=${DEFAULT_ABI}
2010 - fi
2011 - local -x ABI
2012 - for ABI in ${abilist:-default} ; do
2013 - setup_env
2014 - einfo "Running $1 for ABI ${ABI}"
2015 - $1
2016 - : $(( ret |= $? ))
2017 - done
2018 - return ${ret}
2019 -}
2020 -
2021 -glibc_banner() {
2022 - local b="Gentoo ${PVR}"
2023 - [[ -n ${PATCH_VER} ]] && ! use vanilla && b+=" p${PATCH_VER}"
2024 - echo "${b}"
2025 -}
2026 -
2027 -# The following Kernel version handling functions are mostly copied from portage
2028 -# source. It's better not to use linux-info.eclass here since a) it adds too
2029 -# much magic, see bug 326693 for some of the arguments, and b) some of the
2030 -# functions are just not provided.
2031 -
2032 -g_get_running_KV() {
2033 - uname -r
2034 - return $?
2035 -}
2036 -
2037 -g_KV_major() {
2038 - [[ -z $1 ]] && return 1
2039 - local KV=$@
2040 - echo "${KV%%.*}"
2041 -}
2042 -
2043 -g_KV_minor() {
2044 - [[ -z $1 ]] && return 1
2045 - local KV=$@
2046 - KV=${KV#*.}
2047 - echo "${KV%%.*}"
2048 -}
2049 -
2050 -g_KV_micro() {
2051 - [[ -z $1 ]] && return 1
2052 - local KV=$@
2053 - KV=${KV#*.*.}
2054 - echo "${KV%%[^[:digit:]]*}"
2055 -}
2056 -
2057 -g_KV_to_int() {
2058 - [[ -z $1 ]] && return 1
2059 - local KV_MAJOR=$(g_KV_major "$1")
2060 - local KV_MINOR=$(g_KV_minor "$1")
2061 - local KV_MICRO=$(g_KV_micro "$1")
2062 - local KV_int=$(( KV_MAJOR * 65536 + KV_MINOR * 256 + KV_MICRO ))
2063 -
2064 - # We make version 2.2.0 the minimum version we will handle as
2065 - # a sanity check ... if its less, we fail ...
2066 - if [[ ${KV_int} -ge 131584 ]] ; then
2067 - echo "${KV_int}"
2068 - return 0
2069 - fi
2070 - return 1
2071 -}
2072 -
2073 -g_int_to_KV() {
2074 - local version=$1 major minor micro
2075 - major=$((version / 65536))
2076 - minor=$(((version % 65536) / 256))
2077 - micro=$((version % 256))
2078 - echo ${major}.${minor}.${micro}
2079 -}
2080 -
2081 -eend_KV() {
2082 - [[ $(g_KV_to_int $1) -ge $(g_KV_to_int $2) ]]
2083 - eend $?
2084 -}
2085 -
2086 -get_kheader_version() {
2087 - printf '#include <linux/version.h>\nLINUX_VERSION_CODE\n' | \
2088 - $(tc-getCPP ${CTARGET}) -I "$(build_eprefix)$(alt_build_headers)" - | \
2089 - tail -n 1
2090 -}
2091 -
2092 -# We collect all sanity checks here. Consistency is not guranteed between
2093 -# pkg_ and src_ phases, so we call this function both in pkg_pretend and in
2094 -# src_unpack.
2095 -sanity_prechecks() {
2096 - # Prevent native builds from downgrading
2097 - if [[ ${MERGE_TYPE} != "buildonly" ]] && \
2098 - [[ -z ${ROOT} ]] && \
2099 - [[ ${CBUILD} == ${CHOST} ]] && \
2100 - [[ ${CHOST} == ${CTARGET} ]] ; then
2101 -
2102 - # The high rev # is to allow people to downgrade between -r#
2103 - # versions. We want to block 2.20->2.19, but 2.20-r3->2.20-r2
2104 - # should be fine. Hopefully we never actually use a r# this
2105 - # high.
2106 - if has_version ">${CATEGORY}/${P}-r10000" ; then
2107 - eerror "Sanity check to keep you from breaking your system:"
2108 - eerror " Downgrading glibc is not supported and a sure way to destruction."
2109 - [[ ${I_ALLOW_TO_BREAK_MY_SYSTEM} = yes ]] || die "Aborting to save your system."
2110 - fi
2111 -
2112 - if ! do_run_test '#include <unistd.h>\n#include <sys/syscall.h>\nint main(){return syscall(1000)!=-1;}\n' ; then
2113 - eerror "Your old kernel is broken. You need to update it to a newer"
2114 - eerror "version as syscall(<bignum>) will break. See bug 279260."
2115 - die "Old and broken kernel."
2116 - fi
2117 - fi
2118 -
2119 - # Users have had a chance to phase themselves, time to give em the boot
2120 - if [[ -e ${EROOT}/etc/locale.gen ]] && [[ -e ${EROOT}/etc/locales.build ]] ; then
2121 - eerror "You still haven't deleted ${EROOT}/etc/locales.build."
2122 - eerror "Do so now after making sure ${EROOT}/etc/locale.gen is kosher."
2123 - die "Lazy upgrader detected"
2124 - fi
2125 -
2126 - if [[ ${CTARGET} == i386-* ]] ; then
2127 - eerror "i386 CHOSTs are no longer supported."
2128 - eerror "Chances are you don't actually want/need i386."
2129 - eerror "Please read https://www.gentoo.org/doc/en/change-chost.xml"
2130 - die "Please fix your CHOST"
2131 - fi
2132 -
2133 - if [[ -e /proc/xen ]] && [[ $(tc-arch) == "x86" ]] && ! is-flag -mno-tls-direct-seg-refs ; then
2134 - ewarn "You are using Xen but don't have -mno-tls-direct-seg-refs in your CFLAGS."
2135 - ewarn "This will result in a 50% performance penalty when running with a 32bit"
2136 - ewarn "hypervisor, which is probably not what you want."
2137 - fi
2138 -
2139 - # Check for sanity of /etc/nsswitch.conf
2140 - if [[ -e ${EROOT}/etc/nsswitch.conf ]] ; then
2141 - local entry
2142 - for entry in passwd group shadow; do
2143 - if ! egrep -q "^[ \t]*${entry}:.*files" "${EROOT}"/etc/nsswitch.conf; then
2144 - eerror "Your ${EROOT}/etc/nsswitch.conf is out of date."
2145 - eerror "Please make sure you have 'files' entries for"
2146 - eerror "'passwd:', 'group:' and 'shadow:' databases."
2147 - eerror "For more details see:"
2148 - eerror " https://wiki.gentoo.org/wiki/Project:Toolchain/nsswitch.conf_in_glibc-2.26"
2149 - die "nsswitch.conf has no 'files' provider in '${entry}'."
2150 - fi
2151 - done
2152 - fi
2153 -
2154 - # ABI-specific checks follow here. Hey, we have a lot more specific conditions that
2155 - # we test for...
2156 - if ! is_crosscompile ; then
2157 - if use amd64 && use multilib && [[ ${MERGE_TYPE} != "binary" ]] ; then
2158 - ebegin "Checking that IA32 emulation is enabled in the running kernel"
2159 - echo 'int main(){return 0;}' > "${T}/check-ia32-emulation.c"
2160 - local STAT
2161 - if "${CC-${CHOST}-gcc}" ${CFLAGS_x86} "${T}/check-ia32-emulation.c" -o "${T}/check-ia32-emulation.elf32"; then
2162 - "${T}/check-ia32-emulation.elf32"
2163 - STAT=$?
2164 - else
2165 - # Don't fail here to allow single->multi ABI switch
2166 - # or recover from breakage like bug #646424
2167 - ewarn "Failed to compile the ABI test. Broken host glibc?"
2168 - STAT=0
2169 - fi
2170 - rm -f "${T}/check-ia32-emulation.elf32"
2171 - eend $STAT
2172 - [[ $STAT -eq 0 ]] || die "CONFIG_IA32_EMULATION must be enabled in the kernel to compile a multilib glibc."
2173 - fi
2174 -
2175 - fi
2176 -
2177 - # When we actually have to compile something...
2178 - if ! just_headers ; then
2179 - ebegin "Checking gcc for __thread support"
2180 - if ! eend $(want__thread ; echo $?) ; then
2181 - echo
2182 - eerror "Could not find a gcc that supports the __thread directive!"
2183 - eerror "Please update your binutils/gcc and try again."
2184 - die "No __thread support in gcc!"
2185 - fi
2186 -
2187 - if [[ ${CTARGET} == *-linux* ]] ; then
2188 - local run_kv build_kv want_kv
2189 -
2190 - run_kv=$(g_get_running_KV)
2191 - build_kv=$(g_int_to_KV $(get_kheader_version))
2192 - want_kv=${MIN_KERN_VER}
2193 -
2194 - if ! is_crosscompile && ! tc-is-cross-compiler ; then
2195 - # Building fails on an non-supporting kernel
2196 - ebegin "Checking running kernel version (${run_kv} >= ${want_kv})"
2197 - if ! eend_KV ${run_kv} ${want_kv} ; then
2198 - echo
2199 - eerror "You need a kernel of at least ${want_kv}!"
2200 - die "Kernel version too low!"
2201 - fi
2202 - fi
2203 -
2204 - ebegin "Checking linux-headers version (${build_kv} >= ${want_kv})"
2205 - if ! eend_KV ${build_kv} ${want_kv} ; then
2206 - echo
2207 - eerror "You need linux-headers of at least ${want_kv}!"
2208 - die "linux-headers version too low!"
2209 - fi
2210 - fi
2211 - fi
2212 -}
2213 -
2214 -#
2215 -# the phases
2216 -#
2217 -
2218 -# pkg_pretend
2219 -
2220 -pkg_pretend() {
2221 - # All the checks...
2222 - einfo "Checking general environment sanity."
2223 - sanity_prechecks
2224 -}
2225 -
2226 -pkg_setup() {
2227 - # see bug 682570
2228 - [[ -z ${BOOTSTRAP_RAP} ]] && python-any-r1_pkg_setup
2229 -}
2230 -
2231 -# src_unpack
2232 -
2233 -src_unpack() {
2234 - # Consistency is not guaranteed between pkg_ and src_ ...
2235 - sanity_prechecks
2236 -
2237 - use multilib && unpack gcc-multilib-bootstrap-${GCC_BOOTSTRAP_VER}.tar.xz
2238 -
2239 - setup_env
2240 -
2241 - if [[ ${PV} == 9999* ]] ; then
2242 - EGIT_REPO_URI="https://anongit.gentoo.org/git/proj/toolchain/glibc-patches.git"
2243 - EGIT_CHECKOUT_DIR=${WORKDIR}/patches-git
2244 - git-r3_src_unpack
2245 - mv patches-git/9999 patches || die
2246 -
2247 - EGIT_REPO_URI="https://sourceware.org/git/glibc.git"
2248 - EGIT_CHECKOUT_DIR=${S}
2249 - git-r3_src_unpack
2250 - else
2251 - unpack ${P}.tar.xz
2252 -
2253 - cd "${WORKDIR}" || die
2254 - unpack glibc-${RELEASE_VER}-patches-${PATCH_VER}.tar.xz
2255 - fi
2256 -
2257 - cd "${WORKDIR}" || die
2258 - unpack locale-gen-${LOCALE_GEN_VER}.tar.gz
2259 -}
2260 -
2261 -src_prepare() {
2262 - local patchsetname
2263 - if ! use vanilla ; then
2264 - if [[ ${PV} == 9999* ]] ; then
2265 - patchsetname="from git master"
2266 - else
2267 - patchsetname="${RELEASE_VER}-${PATCH_VER}"
2268 - fi
2269 - elog "Applying Gentoo Glibc Patchset ${patchsetname}"
2270 - eapply "${WORKDIR}"/patches
2271 - einfo "Done."
2272 - fi
2273 -
2274 - default
2275 -
2276 - gnuconfig_update
2277 -
2278 - cd "${WORKDIR}"
2279 - find . -name configure -exec touch {} +
2280 -
2281 - # move the external locale-gen to its old place
2282 - mkdir extra || die
2283 - mv locale-gen-${LOCALE_GEN_VER} extra/locale || die
2284 -
2285 - eprefixify extra/locale/locale-gen
2286 -
2287 - # Fix permissions on some of the scripts.
2288 - chmod u+x "${S}"/scripts/*.sh
2289 -
2290 - cd "${S}"
2291 -}
2292 -
2293 -glibc_do_configure() {
2294 - # Glibc does not work with gold (for various reasons) #269274.
2295 - tc-ld-disable-gold
2296 -
2297 - # CXX isnt handled by the multilib system, so if we dont unset here
2298 - # we accumulate crap across abis
2299 - unset CXX
2300 -
2301 - einfo "Configuring glibc for nptl"
2302 -
2303 - if use doc ; then
2304 - export MAKEINFO=makeinfo
2305 - else
2306 - export MAKEINFO=/dev/null
2307 - fi
2308 -
2309 - local v
2310 - for v in ABI CBUILD CHOST CTARGET CBUILD_OPT CTARGET_OPT CC CXX LD {AS,C,CPP,CXX,LD}FLAGS MAKEINFO NM READELF; do
2311 - einfo " $(printf '%15s' ${v}:) ${!v}"
2312 - done
2313 -
2314 - # CFLAGS can contain ABI-specific flags like -mfpu=neon, see bug #657760
2315 - # To build .S (assembly) files with the same ABI-specific flags
2316 - # upstream currently recommends adding CFLAGS to CC/CXX:
2317 - # https://sourceware.org/PR23273
2318 - # Note: Passing CFLAGS via CPPFLAGS overrides glibc's arch-specific CFLAGS
2319 - # and breaks multiarch support. See 659030#c3 for an example.
2320 - # The glibc configure script doesn't properly use LDFLAGS all the time.
2321 - export CC="$(tc-getCC ${CTARGET}) ${CFLAGS} ${LDFLAGS}"
2322 - einfo " $(printf '%15s' 'Manual CC:') ${CC}"
2323 -
2324 - # Some of the tests are written in C++, so we need to force our multlib abis in, bug 623548
2325 - export CXX="$(tc-getCXX ${CTARGET}) $(get_abi_CFLAGS) ${CFLAGS}"
2326 -
2327 - if is_crosscompile; then
2328 - # Assume worst-case bootstrap: glibc is buil first time
2329 - # when ${CTARGET}-g++ is not available yet. We avoid
2330 - # building auxiliary programs that require C++: bug #683074
2331 - # It should not affect final result.
2332 - export libc_cv_cxx_link_ok=no
2333 - # The line above has the same effect. We set CXX explicitly
2334 - # to make build logs less confusing.
2335 - export CXX=
2336 - fi
2337 - einfo " $(printf '%15s' 'Manual CXX:') ${CXX}"
2338 -
2339 - # Always use tuple-prefixed toolchain. For non-native ABI glibc's configure
2340 - # can't detect them automatically due to ${CHOST} mismatch and fallbacks
2341 - # to unprefixed tools. Similar to multilib.eclass:multilib_toolchain_setup().
2342 - export NM="$(tc-getNM ${CTARGET})"
2343 - export READELF="$(tc-getREADELF ${CTARGET})"
2344 - einfo " $(printf '%15s' 'Manual NM:') ${NM}"
2345 - einfo " $(printf '%15s' 'Manual READELF:') ${READELF}"
2346 -
2347 - echo
2348 -
2349 - local myconf=()
2350 -
2351 - case ${CTARGET} in
2352 - m68k*)
2353 - # setjmp() is not compatible with stack protection:
2354 - # https://sourceware.org/PR24202
2355 - myconf+=( --enable-stack-protector=no )
2356 - ;;
2357 - powerpc-*)
2358 - # Currently gcc on powerpc32 generates invalid code for
2359 - # __builtin_return_address(0) calls. Normally programs
2360 - # don't do that but malloc hooks in glibc do:
2361 - # https://gcc.gnu.org/PR81996
2362 - # https://bugs.gentoo.org/629054
2363 - myconf+=( --enable-stack-protector=no )
2364 - ;;
2365 - *)
2366 - # Use '=strong' instead of '=all' to protect only functions
2367 - # worth protecting from stack smashes.
2368 - # '=all' is also known to have a problem in IFUNC resolution
2369 - # tests: https://sourceware.org/PR25680, bug #712356.
2370 - myconf+=( --enable-stack-protector=$(usex ssp strong no) )
2371 - ;;
2372 - esac
2373 - myconf+=( --enable-stackguard-randomization )
2374 -
2375 - # Keep a whitelist of targets supporing IFUNC. glibc's ./configure
2376 - # is not robust enough to detect proper support:
2377 - # https://bugs.gentoo.org/641216
2378 - # https://sourceware.org/PR22634#c0
2379 - case $(tc-arch ${CTARGET}) in
2380 - # Keep whitelist of targets where autodetection mostly works.
2381 - amd64|x86|sparc|ppc|ppc64|arm|arm64|s390) ;;
2382 - # Blacklist everywhere else
2383 - *) myconf+=( libc_cv_ld_gnu_indirect_function=no ) ;;
2384 - esac
2385 -
2386 - # Enable Intel Control-flow Enforcement Technology on amd64 if requested
2387 - case ${CTARGET} in
2388 - x86_64-*) myconf+=( $(use_enable cet) ) ;;
2389 - *) ;;
2390 - esac
2391 -
2392 - [[ $(tc-is-softfloat) == "yes" ]] && myconf+=( --without-fp )
2393 -
2394 - myconf+=( --enable-kernel=${MIN_KERN_VER} )
2395 -
2396 - # Since SELinux support is only required for nscd, only enable it if:
2397 - # 1. USE selinux
2398 - # 2. only for the primary ABI on multilib systems
2399 - # 3. Not a crosscompile
2400 - if ! is_crosscompile && use selinux ; then
2401 - if use multilib ; then
2402 - if is_final_abi ; then
2403 - myconf+=( --with-selinux )
2404 - else
2405 - myconf+=( --without-selinux )
2406 - fi
2407 - else
2408 - myconf+=( --with-selinux )
2409 - fi
2410 - else
2411 - myconf+=( --without-selinux )
2412 - fi
2413 -
2414 - # Force a few tests where we always know the answer but
2415 - # configure is incapable of finding it.
2416 - if is_crosscompile ; then
2417 - export \
2418 - libc_cv_c_cleanup=yes \
2419 - libc_cv_forced_unwind=yes
2420 - fi
2421 -
2422 - myconf+=(
2423 - --without-cvs
2424 - --disable-werror
2425 - --enable-bind-now
2426 - --build=${CBUILD_OPT:-${CBUILD}}
2427 - --host=${CTARGET_OPT:-${CTARGET}}
2428 - $(use_enable profile)
2429 - $(use_with gd)
2430 - --with-headers=$(build_eprefix)$(alt_build_headers)
2431 - --prefix="$(host_eprefix)/usr"
2432 - --sysconfdir="$(host_eprefix)/etc"
2433 - --localstatedir="$(host_eprefix)/var"
2434 - --libdir='$(prefix)'/$(get_libdir)
2435 - --mandir='$(prefix)'/share/man
2436 - --infodir='$(prefix)'/share/info
2437 - --libexecdir='$(libdir)'/misc/glibc
2438 - --with-bugurl=https://bugs.gentoo.org/
2439 - --with-pkgversion="$(glibc_banner)"
2440 - $(use_enable crypt)
2441 - $(use_multiarch || echo --disable-multi-arch)
2442 - $(use_enable static-pie)
2443 - $(use_enable systemtap)
2444 - $(use_enable nscd)
2445 - ${EXTRA_ECONF}
2446 - )
2447 -
2448 - # We rely on sys-libs/timezone-data for timezone tools normally.
2449 - myconf+=( $(use_enable vanilla timezone-tools) )
2450 -
2451 - # These libs don't have configure flags.
2452 - ac_cv_lib_audit_audit_log_user_avc_message=$(usex audit || echo no)
2453 - ac_cv_lib_cap_cap_init=$(usex caps || echo no)
2454 -
2455 - # There is no configure option for this and we need to export it
2456 - # since the glibc build will re-run configure on itself
2457 - export libc_cv_rootsbindir="$(host_eprefix)/sbin"
2458 - export libc_cv_slibdir="$(host_eprefix)/$(get_libdir)"
2459 -
2460 - # We take care of patching our binutils to use both hash styles,
2461 - # and many people like to force gnu hash style only, so disable
2462 - # this overriding check. #347761
2463 - export libc_cv_hashstyle=no
2464 -
2465 - local builddir=$(builddir nptl)
2466 - mkdir -p "${builddir}"
2467 - cd "${builddir}"
2468 - set -- "${S}"/configure "${myconf[@]}"
2469 - echo "$@"
2470 - "$@" || die "failed to configure glibc"
2471 -
2472 - # ia64 static cross-compilers are a pita in so much that they
2473 - # can't produce static ELFs (as the libgcc.a is broken). so
2474 - # disable building of the programs for those targets if it
2475 - # doesn't work.
2476 - # XXX: We could turn this into a compiler test, but ia64 is
2477 - # the only one that matters, so this should be fine for now.
2478 - if is_crosscompile && [[ ${CTARGET} == ia64* ]] ; then
2479 - sed -i '1i+link-static = touch $@' config.make
2480 - fi
2481 -
2482 - # If we're trying to migrate between ABI sets, we need
2483 - # to lie and use a local copy of gcc. Like if the system
2484 - # is built with MULTILIB_ABIS="amd64 x86" but we want to
2485 - # add x32 to it, gcc/glibc don't yet support x32.
2486 - #
2487 - if [[ -n ${GCC_BOOTSTRAP_VER} ]] && use multilib ; then
2488 - echo 'main(){}' > "${T}"/test.c
2489 - if ! $(tc-getCC ${CTARGET}) ${CFLAGS} ${LDFLAGS} "${T}"/test.c -Wl,-emain -lgcc 2>/dev/null ; then
2490 - sed -i -e '/^CC = /s:$: -B$(objdir)/../'"gcc-multilib-bootstrap-${GCC_BOOTSTRAP_VER}/${ABI}:" config.make || die
2491 - fi
2492 - fi
2493 -}
2494 -
2495 -glibc_headers_configure() {
2496 - export ABI=default
2497 -
2498 - local builddir=$(builddir "headers")
2499 - mkdir -p "${builddir}"
2500 - cd "${builddir}"
2501 -
2502 - # if we don't have a compiler yet, we can't really test it now ...
2503 - # hopefully they don't affect header generation, so let's hope for
2504 - # the best here ...
2505 - local v vars=(
2506 - ac_cv_header_cpuid_h=yes
2507 - libc_cv_{386,390,alpha,arm,hppa,ia64,mips,{powerpc,sparc}{,32,64},sh,x86_64}_tls=yes
2508 - libc_cv_asm_cfi_directives=yes
2509 - libc_cv_broken_visibility_attribute=no
2510 - libc_cv_c_cleanup=yes
2511 - libc_cv_compiler_powerpc64le_binary128_ok=yes
2512 - libc_cv_forced_unwind=yes
2513 - libc_cv_gcc___thread=yes
2514 - libc_cv_mlong_double_128=yes
2515 - libc_cv_mlong_double_128ibm=yes
2516 - libc_cv_ppc_machine=yes
2517 - libc_cv_ppc_rel16=yes
2518 - libc_cv_predef_fortify_source=no
2519 - libc_cv_target_power8_ok=yes
2520 - libc_cv_visibility_attribute=yes
2521 - libc_cv_z_combreloc=yes
2522 - libc_cv_z_execstack=yes
2523 - libc_cv_z_initfirst=yes
2524 - libc_cv_z_nodelete=yes
2525 - libc_cv_z_nodlopen=yes
2526 - libc_cv_z_relro=yes
2527 - libc_mips_abi=${ABI}
2528 - libc_mips_float=$([[ $(tc-is-softfloat) == "yes" ]] && echo soft || echo hard)
2529 - # These libs don't have configure flags.
2530 - ac_cv_lib_audit_audit_log_user_avc_message=no
2531 - ac_cv_lib_cap_cap_init=no
2532 - )
2533 -
2534 - einfo "Forcing cached settings:"
2535 - for v in "${vars[@]}" ; do
2536 - einfo " ${v}"
2537 - export ${v}
2538 - done
2539 -
2540 - local headers_only_arch_CPPFLAGS=()
2541 -
2542 - # Blow away some random CC settings that screw things up. #550192
2543 - if [[ -d ${S}/sysdeps/mips ]]; then
2544 - pushd "${S}"/sysdeps/mips >/dev/null
2545 - sed -i -e '/^CC +=/s:=.*:= -D_MIPS_SZPTR=32:' mips32/Makefile mips64/n32/Makefile || die
2546 - sed -i -e '/^CC +=/s:=.*:= -D_MIPS_SZPTR=64:' mips64/n64/Makefile || die
2547 -
2548 - # Force the mips ABI to the default. This is OK because the set of
2549 - # installed headers in this phase is the same between the 3 ABIs.
2550 - # If this ever changes, this hack will break, but that's unlikely
2551 - # as glibc discourages that behavior.
2552 - # https://crbug.com/647033
2553 - sed -i -e 's:abiflag=.*:abiflag=_ABIO32:' preconfigure || die
2554 -
2555 - popd >/dev/null
2556 - fi
2557 -
2558 - case ${CTARGET} in
2559 - riscv*)
2560 - # RISC-V interrogates the compiler to determine which target to
2561 - # build. If building the headers then we don't strictly need a
2562 - # RISC-V compiler, so the built-in definitions that are provided
2563 - # along with all RISC-V compiler might not exist. This causes
2564 - # glibc's RISC-V preconfigure script to blow up. Since we're just
2565 - # building the headers any value will actually work here, so just
2566 - # pick the standard one (rv64g/lp64d) to make the build scripts
2567 - # happy for now -- the headers are all the same anyway so it
2568 - # doesn't matter.
2569 - headers_only_arch_CPPFLAGS+=(
2570 - -D__riscv_xlen=64
2571 - -D__riscv_flen=64
2572 - -D__riscv_float_abi_double=1
2573 - -D__riscv_atomic=1
2574 - ) ;;
2575 - esac
2576 -
2577 - local myconf=()
2578 - myconf+=(
2579 - --disable-sanity-checks
2580 - --enable-hacker-mode
2581 - --without-cvs
2582 - --disable-werror
2583 - --enable-bind-now
2584 - --build=${CBUILD_OPT:-${CBUILD}}
2585 - --host=${CTARGET_OPT:-${CTARGET}}
2586 - --with-headers=$(build_eprefix)$(alt_build_headers)
2587 - --prefix="$(host_eprefix)/usr"
2588 - ${EXTRA_ECONF}
2589 - )
2590 -
2591 - # Nothing is compiled here which would affect the headers for the target.
2592 - # So forcing CC/CFLAGS is sane.
2593 - local headers_only_CC=$(tc-getBUILD_CC)
2594 - local headers_only_CFLAGS="-O1 -pipe"
2595 - local headers_only_CPPFLAGS="-U_FORTIFY_SOURCE ${headers_only_arch_CPPFLAGS[*]}"
2596 - local headers_only_LDFLAGS=""
2597 - set -- "${S}"/configure "${myconf[@]}"
2598 - echo \
2599 - "CC=${headers_only_CC}" \
2600 - "CFLAGS=${headers_only_CFLAGS}" \
2601 - "CPPFLAGS=${headers_only_CPPFLAGS}" \
2602 - "LDFLAGS=${headers_only_LDFLAGS}" \
2603 - "$@"
2604 - CC=${headers_only_CC} \
2605 - CFLAGS=${headers_only_CFLAGS} \
2606 - CPPFLAGS=${headers_only_CPPFLAGS} \
2607 - LDFLAGS="" \
2608 - "$@" || die "failed to configure glibc"
2609 -}
2610 -
2611 -do_src_configure() {
2612 - if just_headers ; then
2613 - glibc_headers_configure
2614 - else
2615 - glibc_do_configure nptl
2616 - fi
2617 -}
2618 -
2619 -src_configure() {
2620 - foreach_abi do_src_configure
2621 -}
2622 -
2623 -do_src_compile() {
2624 - emake -C "$(builddir nptl)"
2625 -}
2626 -
2627 -src_compile() {
2628 - if just_headers ; then
2629 - return
2630 - fi
2631 -
2632 - foreach_abi do_src_compile
2633 -}
2634 -
2635 -glibc_src_test() {
2636 - cd "$(builddir nptl)"
2637 -
2638 - local myxfailparams=""
2639 - if [[ "${GENTOO_GLIBC_XFAIL_TESTS}" == "yes" ]] ; then
2640 - for myt in ${XFAIL_TEST_LIST[@]} ; do
2641 - myxfailparams+="test-xfail-${myt}=yes "
2642 - done
2643 - fi
2644 -
2645 - # sandbox does not understand unshare() and prevents
2646 - # writes to /proc/, which makes many tests fail
2647 -
2648 - SANDBOX_ON=0 LD_PRELOAD= emake ${myxfailparams} check
2649 -}
2650 -
2651 -do_src_test() {
2652 - local ret=0
2653 -
2654 - glibc_src_test
2655 - : $(( ret |= $? ))
2656 -
2657 - return ${ret}
2658 -}
2659 -
2660 -src_test() {
2661 - if just_headers ; then
2662 - return
2663 - fi
2664 -
2665 - # Give tests more time to complete.
2666 - export TIMEOUTFACTOR=5
2667 -
2668 - foreach_abi do_src_test || die "tests failed"
2669 -}
2670 -
2671 -run_locale_gen() {
2672 - # if the host locales.gen contains no entries, we'll install everything
2673 - local root="$1"
2674 - local inplace=""
2675 -
2676 - if [[ "${root}" == "--inplace-glibc" ]] ; then
2677 - inplace="--inplace-glibc"
2678 - root="$2"
2679 - fi
2680 -
2681 - local locale_list="${root}/etc/locale.gen"
2682 -
2683 - pushd "${ED}"/$(get_libdir) >/dev/null
2684 -
2685 - if [[ -z $(locale-gen --list --config "${locale_list}") ]] ; then
2686 - [[ -z ${inplace} ]] && ewarn "Generating all locales; edit /etc/locale.gen to save time/space"
2687 - locale_list="${root}/usr/share/i18n/SUPPORTED"
2688 - fi
2689 -
2690 - set -- locale-gen ${inplace} --jobs $(makeopts_jobs) --config "${locale_list}" \
2691 - --destdir "${root}"
2692 - echo "$@"
2693 - "$@"
2694 -
2695 - popd >/dev/null
2696 -}
2697 -
2698 -glibc_do_src_install() {
2699 - local builddir=$(builddir nptl)
2700 - cd "${builddir}"
2701 -
2702 - emake install_root="${D}/$(build_eprefix)$(alt_prefix)" install
2703 -
2704 - # This version (2.26) provides some compatibility libraries for the NIS/NIS+ support
2705 - # which come without headers etc. Only needed for binary packages since the
2706 - # external net-libs/libnsl has increased soversion. Keep only versioned libraries.
2707 - find "${D}" -name "libnsl.a" -delete
2708 - find "${D}" -name "libnsl.so" -delete
2709 -
2710 - # Normally upstream_pv is ${PV}. Live ebuilds are exception, there we need
2711 - # to infer upstream version:
2712 - # '#define VERSION "2.26.90"' -> '2.26.90'
2713 - local upstream_pv=$(sed -n -r 's/#define VERSION "(.*)"/\1/p' "${S}"/version.h)
2714 -
2715 - # Avoid stripping binaries not targeted by ${CHOST}. Or else
2716 - # ${CHOST}-strip would break binaries build for ${CTARGET}.
2717 - is_crosscompile && dostrip -x /
2718 - # gdb thread introspection relies on local libpthreas symbols. stripping breaks it
2719 - # See Note [Disable automatic stripping]
2720 - dostrip -x $(alt_libdir)/libpthread-${upstream_pv}.so
2721 -
2722 - if [[ -e ${ED}/$(alt_usrlibdir)/libm-${upstream_pv}.a ]] ; then
2723 - # Move versioned .a file out of libdir to evade portage QA checks
2724 - # instead of using gen_usr_ldscript(). We fix ldscript as:
2725 - # "GROUP ( /usr/lib64/libm-<pv>.a ..." -> "GROUP ( /usr/lib64/glibc-<pv>/libm-<pv>.a ..."
2726 - sed -i "s@\(libm-${upstream_pv}.a\)@${P}/\1@" "${ED}"/$(alt_usrlibdir)/libm.a || die
2727 - dodir $(alt_usrlibdir)/${P}
2728 - mv "${ED}"/$(alt_usrlibdir)/libm-${upstream_pv}.a "${ED}"/$(alt_usrlibdir)/${P}/libm-${upstream_pv}.a || die
2729 - fi
2730 -
2731 - # We'll take care of the cache ourselves
2732 - rm -f "${ED}"/etc/ld.so.cache
2733 -
2734 - # Everything past this point just needs to be done once ...
2735 - is_final_abi || return 0
2736 -
2737 - # Make sure the non-native interp can be found on multilib systems even
2738 - # if the main library set isn't installed into the right place. Maybe
2739 - # we should query the active gcc for info instead of hardcoding it ?
2740 - local i ldso_abi ldso_name
2741 - local ldso_abi_list=(
2742 - # x86
2743 - amd64 /lib64/ld-linux-x86-64.so.2
2744 - x32 /libx32/ld-linux-x32.so.2
2745 - x86 /lib/ld-linux.so.2
2746 - # mips
2747 - o32 /lib/ld.so.1
2748 - n32 /lib32/ld.so.1
2749 - n64 /lib64/ld.so.1
2750 - # powerpc
2751 - ppc /lib/ld.so.1
2752 - ppc64 /lib64/ld64.so.1
2753 - # riscv
2754 - lp64d /lib/ld-linux-riscv64-lp64d.so.1
2755 - lp64 /lib/ld-linux-riscv64-lp64.so.1
2756 - # s390
2757 - s390 /lib/ld.so.1
2758 - s390x /lib/ld64.so.1
2759 - # sparc
2760 - sparc32 /lib/ld-linux.so.2
2761 - sparc64 /lib64/ld-linux.so.2
2762 - )
2763 - case $(tc-endian) in
2764 - little)
2765 - ldso_abi_list+=(
2766 - # arm
2767 - arm64 /lib/ld-linux-aarch64.so.1
2768 - )
2769 - ;;
2770 - big)
2771 - ldso_abi_list+=(
2772 - # arm
2773 - arm64 /lib/ld-linux-aarch64_be.so.1
2774 - )
2775 - ;;
2776 - esac
2777 - if [[ ${SYMLINK_LIB} == "yes" ]] && [[ ! -e ${ED}/$(alt_prefix)/lib ]] ; then
2778 - dosym $(get_abi_LIBDIR ${DEFAULT_ABI}) $(alt_prefix)/lib
2779 - fi
2780 - for (( i = 0; i < ${#ldso_abi_list[@]}; i += 2 )) ; do
2781 - ldso_abi=${ldso_abi_list[i]}
2782 - has ${ldso_abi} $(get_install_abis) || continue
2783 -
2784 - ldso_name="$(alt_prefix)${ldso_abi_list[i+1]}"
2785 - if [[ ! -L ${ED}/${ldso_name} && ! -e ${ED}/${ldso_name} ]] ; then
2786 - dosym ../$(get_abi_LIBDIR ${ldso_abi})/${ldso_name##*/} ${ldso_name}
2787 - fi
2788 - done
2789 -
2790 - # With devpts under Linux mounted properly, we do not need the pt_chown
2791 - # binary to be setuid. This is because the default owners/perms will be
2792 - # exactly what we want.
2793 - if ! use suid ; then
2794 - find "${ED}" -name pt_chown -exec chmod -s {} +
2795 - fi
2796 -
2797 - #################################################################
2798 - # EVERYTHING AFTER THIS POINT IS FOR NATIVE GLIBC INSTALLS ONLY #
2799 - # Make sure we install some symlink hacks so that when we build
2800 - # a 2nd stage cross-compiler, gcc finds the target system
2801 - # headers correctly. See gcc/doc/gccinstall.info
2802 - if is_crosscompile ; then
2803 - # We need to make sure that /lib and /usr/lib always exists.
2804 - # gcc likes to use relative paths to get to its multilibs like
2805 - # /usr/lib/../lib64/. So while we don't install any files into
2806 - # /usr/lib/, we do need it to exist.
2807 - keepdir $(alt_prefix)/lib
2808 - keepdir $(alt_prefix)/usr/lib
2809 -
2810 - dosym usr/include $(alt_prefix)/sys-include
2811 - return 0
2812 - fi
2813 -
2814 - # Files for Debian-style locale updating
2815 - dodir /usr/share/i18n
2816 - sed \
2817 - -e "/^#/d" \
2818 - -e "/SUPPORTED-LOCALES=/d" \
2819 - -e "s: \\\\::g" -e "s:/: :g" \
2820 - "${S}"/localedata/SUPPORTED > "${ED}"/usr/share/i18n/SUPPORTED \
2821 - || die "generating /usr/share/i18n/SUPPORTED failed"
2822 - cd "${WORKDIR}"/extra/locale
2823 - dosbin locale-gen
2824 - doman *.[0-8]
2825 - insinto /etc
2826 - doins locale.gen
2827 -
2828 - # Make sure all the ABI's can find the locales and so we only
2829 - # have to generate one set
2830 - local a
2831 - keepdir /usr/$(get_libdir)/locale
2832 - for a in $(get_install_abis) ; do
2833 - if [[ ! -e ${ED}/usr/$(get_abi_LIBDIR ${a})/locale ]] ; then
2834 - dosym ../$(get_libdir)/locale /usr/$(get_abi_LIBDIR ${a})/locale
2835 - fi
2836 - done
2837 -
2838 - # HACK: If we're building for riscv, we need to additionally make sure that
2839 - # we can find the locale archive afterwards
2840 - case ${CTARGET} in
2841 - riscv*)
2842 - if [[ ! -e ${ED}/usr/lib/locale ]] ; then
2843 - dosym ../$(get_libdir)/locale /usr/lib/locale
2844 - fi
2845 - ;;
2846 - *) ;;
2847 - esac
2848 -
2849 - cd "${S}"
2850 -
2851 - # Install misc network config files
2852 - insinto /etc
2853 - doins posix/gai.conf nss/nsswitch.conf
2854 -
2855 - # Gentoo-specific
2856 - newins "${FILESDIR}"/host.conf-1 host.conf
2857 -
2858 - if use nscd ; then
2859 - doins nscd/nscd.conf
2860 -
2861 - newinitd "$(prefixify_ro "${FILESDIR}"/nscd-1)" nscd
2862 -
2863 - local nscd_args=(
2864 - -e "s:@PIDFILE@:$(strings "${ED}"/usr/sbin/nscd | grep nscd.pid):"
2865 - )
2866 -
2867 - sed -i "${nscd_args[@]}" "${ED}"/etc/init.d/nscd
2868 -
2869 - systemd_dounit nscd/nscd.service
2870 - systemd_newtmpfilesd nscd/nscd.tmpfiles nscd.conf
2871 - fi
2872 -
2873 - echo 'LDPATH="include ld.so.conf.d/*.conf"' > "${T}"/00glibc
2874 - doenvd "${T}"/00glibc
2875 -
2876 - for d in BUGS ChangeLog CONFORMANCE FAQ NEWS NOTES PROJECTS README* ; do
2877 - [[ -s ${d} ]] && dodoc ${d}
2878 - done
2879 - dodoc -r ChangeLog.old
2880 -
2881 - # Prevent overwriting of the /etc/localtime symlink. We'll handle the
2882 - # creation of the "factory" symlink in pkg_postinst().
2883 - rm -f "${ED}"/etc/localtime
2884 -
2885 - # Generate all locales if this is a native build as locale generation
2886 - if use compile-locales && ! is_crosscompile ; then
2887 - run_locale_gen --inplace-glibc "${ED}/"
2888 - sed -e 's:COMPILED_LOCALES="":COMPILED_LOCALES="1":' -i "${ED}"/usr/sbin/locale-gen || die
2889 - fi
2890 -}
2891 -
2892 -glibc_headers_install() {
2893 - local builddir=$(builddir "headers")
2894 - cd "${builddir}"
2895 - emake install_root="${D}/$(build_eprefix)$(alt_prefix)" install-headers
2896 -
2897 - insinto $(alt_headers)/gnu
2898 - doins "${S}"/include/gnu/stubs.h
2899 -
2900 - # Make sure we install the sys-include symlink so that when
2901 - # we build a 2nd stage cross-compiler, gcc finds the target
2902 - # system headers correctly. See gcc/doc/gccinstall.info
2903 - dosym usr/include $(alt_prefix)/sys-include
2904 -}
2905 -
2906 -src_install() {
2907 - if just_headers ; then
2908 - export ABI=default
2909 - glibc_headers_install
2910 - return
2911 - fi
2912 -
2913 - foreach_abi glibc_do_src_install
2914 -
2915 - if ! use static-libs ; then
2916 - elog "Not installing static glibc libraries"
2917 - find "${ED}" -name "*.a" -and -not -name "*_nonshared.a" -delete
2918 - fi
2919 -}
2920 -
2921 -# Simple test to make sure our new glibc isn't completely broken.
2922 -# Make sure we don't test with statically built binaries since
2923 -# they will fail. Also, skip if this glibc is a cross compiler.
2924 -#
2925 -# If coreutils is built with USE=multicall, some of these files
2926 -# will just be wrapper scripts, not actual ELFs we can test.
2927 -glibc_sanity_check() {
2928 - cd / #228809
2929 -
2930 - # We enter ${ED} so to avoid trouble if the path contains
2931 - # special characters; for instance if the path contains the
2932 - # colon character (:), then the linker will try to split it
2933 - # and look for the libraries in an unexpected place. This can
2934 - # lead to unsafe code execution if the generated prefix is
2935 - # within a world-writable directory.
2936 - # (e.g. /var/tmp/portage:${HOSTNAME})
2937 - pushd "${ED}"/$(get_libdir) >/dev/null
2938 -
2939 - local x striptest
2940 - for x in cal date env free ls true uname uptime ; do
2941 - x=$(type -p ${x})
2942 - [[ -z ${x} || ${x} != ${EPREFIX}/* ]] && continue
2943 - striptest=$(LC_ALL="C" file -L ${x} 2>/dev/null) || continue
2944 - case ${striptest} in
2945 - *"statically linked"*) continue;;
2946 - *"ASCII text"*) continue;;
2947 - esac
2948 - # We need to clear the locale settings as the upgrade might want
2949 - # incompatible locale data. This test is not for verifying that.
2950 - LC_ALL=C \
2951 - ./ld-*.so --library-path . ${x} > /dev/null \
2952 - || die "simple run test (${x}) failed"
2953 - done
2954 -
2955 - popd >/dev/null
2956 -}
2957 -
2958 -pkg_preinst() {
2959 - # nothing to do if just installing headers
2960 - just_headers && return
2961 -
2962 - # prepare /etc/ld.so.conf.d/ for files
2963 - mkdir -p "${EROOT}"/etc/ld.so.conf.d
2964 -
2965 - # Default /etc/hosts.conf:multi to on for systems with small dbs.
2966 - if [[ $(wc -l < "${EROOT}"/etc/hosts) -lt 1000 ]] ; then
2967 - sed -i '/^multi off/s:off:on:' "${ED}"/etc/host.conf
2968 - einfo "Defaulting /etc/host.conf:multi to on"
2969 - fi
2970 -
2971 - [[ -n ${ROOT} ]] && return 0
2972 - [[ -d ${ED}/$(get_libdir) ]] || return 0
2973 - [[ -z ${BOOTSTRAP_RAP} ]] && glibc_sanity_check
2974 -}
2975 -
2976 -pkg_postinst() {
2977 - # nothing to do if just installing headers
2978 - just_headers && return
2979 -
2980 - if ! tc-is-cross-compiler && [[ -x ${EROOT}/usr/sbin/iconvconfig ]] ; then
2981 - # Generate fastloading iconv module configuration file.
2982 - "${EROOT}"/usr/sbin/iconvconfig --prefix="${ROOT}/"
2983 - fi
2984 -
2985 - if ! is_crosscompile && [[ -z ${ROOT} ]] ; then
2986 - use compile-locales || run_locale_gen "${EROOT}/"
2987 - fi
2988 -
2989 - # Check for sanity of /etc/nsswitch.conf, take 2
2990 - if [[ -e ${EROOT}/etc/nsswitch.conf ]] && ! has_version sys-auth/libnss-nis ; then
2991 - local entry
2992 - for entry in passwd group shadow; do
2993 - if egrep -q "^[ \t]*${entry}:.*nis" "${EROOT}"/etc/nsswitch.conf; then
2994 - ewarn ""
2995 - ewarn "Your ${EROOT}/etc/nsswitch.conf uses NIS. Support for that has been"
2996 - ewarn "removed from glibc and is now provided by the package"
2997 - ewarn " sys-auth/libnss-nis"
2998 - ewarn "Install it now to keep your NIS setup working."
2999 - ewarn ""
3000 - fi
3001 - done
3002 - fi
3003 -}