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