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