Gentoo Archives: gentoo-commits

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