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