Gentoo Archives: gentoo-commits

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