Gentoo Archives: gentoo-commits

From: "Andreas Hüttel" <dilfridge@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-libs/glibc/
Date: Sat, 09 Sep 2017 21:23:24
Message-Id: 1504992086.94888b758915aa8b936fd0461ebb684e024c25f1.dilfridge@gentoo
1 commit: 94888b758915aa8b936fd0461ebb684e024c25f1
2 Author: Andreas K. Hüttel <dilfridge <AT> gentoo <DOT> org>
3 AuthorDate: Sun Sep 3 20:06:27 2017 +0000
4 Commit: Andreas Hüttel <dilfridge <AT> gentoo <DOT> org>
5 CommitDate: Sat Sep 9 21:21:26 2017 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=94888b75
7
8 sys-libs/glibc: Integrate eclass code of phase functions
9
10 sys-libs/glibc/glibc-2.26-r1.ebuild | 904 ++++++++++++++++++++++++++++++++++++
11 1 file changed, 904 insertions(+)
12
13 diff --git a/sys-libs/glibc/glibc-2.26-r1.ebuild b/sys-libs/glibc/glibc-2.26-r1.ebuild
14 new file mode 100644
15 index 00000000000..98b89a06c6f
16 --- /dev/null
17 +++ b/sys-libs/glibc/glibc-2.26-r1.ebuild
18 @@ -0,0 +1,904 @@
19 +# Copyright 1999-2017 Gentoo Foundation
20 +# Distributed under the terms of the GNU General Public License v2
21 +
22 +EAPI=6
23 +
24 +inherit toolchain-glibc
25 +
26 +DESCRIPTION="GNU libc6 (also called glibc2) C library"
27 +HOMEPAGE="https://www.gnu.org/software/libc/libc.html"
28 +
29 +LICENSE="LGPL-2.1+ BSD HPND ISC inner-net rc PCRE"
30 +RESTRICT="strip" # strip ourself #46186
31 +EMULTILIB_PKG="true"
32 +
33 +# Configuration variables
34 +
35 +if [[ ${PV} == 9999* ]]; then
36 + EGIT_REPO_URIS="git://sourceware.org/git/glibc.git"
37 + EGIT_SOURCEDIRS="${S}"
38 + inherit git-2
39 +else
40 + # KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86"
41 + KEYWORDS=""
42 +fi
43 +
44 +RELEASE_VER=${PV}
45 +
46 +GCC_BOOTSTRAP_VER="4.7.3-r1"
47 +# patches live at https://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo/src/patchsets/glibc/
48 +PATCH_VER="0" # Gentoo patchset
49 +: ${NPTL_KERN_VER:="2.6.32"} # min kernel version nptl requires
50 +
51 +IUSE="audit caps debug gd hardened multilib nscd +rpc selinux systemtap profile suid vanilla crosscompile_opts_headers-only"
52 +
53 +# Here's how the cross-compile logic breaks down ...
54 +# CTARGET - machine that will target the binaries
55 +# CHOST - machine that will host the binaries
56 +# CBUILD - machine that will build the binaries
57 +# If CTARGET != CHOST, it means you want a libc for cross-compiling.
58 +# If CHOST != CBUILD, it means you want to cross-compile the libc.
59 +# CBUILD = CHOST = CTARGET - native build/install
60 +# CBUILD != (CHOST = CTARGET) - cross-compile a native build
61 +# (CBUILD = CHOST) != CTARGET - libc for cross-compiler
62 +# CBUILD != CHOST != CTARGET - cross-compile a libc for a cross-compiler
63 +# For install paths:
64 +# CHOST = CTARGET - install into /
65 +# CHOST != CTARGET - install into /usr/CTARGET/
66 +
67 +export CBUILD=${CBUILD:-${CHOST}}
68 +export CTARGET=${CTARGET:-${CHOST}}
69 +if [[ ${CTARGET} == ${CHOST} ]] ; then
70 + if [[ ${CATEGORY} == cross-* ]] ; then
71 + export CTARGET=${CATEGORY#cross-}
72 + fi
73 +fi
74 +
75 +is_crosscompile() {
76 + [[ ${CHOST} != ${CTARGET} ]]
77 +}
78 +
79 +# Why SLOT 2.2 you ask yourself while sippin your tea ?
80 +# Everyone knows 2.2 > 0, duh.
81 +SLOT="2.2"
82 +
83 +# General: We need a new-enough binutils/gcc to match upstream baseline.
84 +# arch: we need to make sure our binutils/gcc supports TLS.
85 +COMMON_DEPEND="
86 + nscd? ( selinux? (
87 + audit? ( sys-process/audit )
88 + caps? ( sys-libs/libcap )
89 + ) )
90 + suid? ( caps? ( sys-libs/libcap ) )
91 + selinux? ( sys-libs/libselinux )
92 +"
93 +DEPEND="${COMMON_DEPEND}
94 + >=app-misc/pax-utils-0.1.10
95 + !<sys-apps/sandbox-1.6
96 + !<sys-apps/portage-2.1.2"
97 +RDEPEND="${COMMON_DEPEND}
98 + !sys-kernel/ps3-sources
99 + sys-apps/gentoo-functions
100 + !sys-libs/nss-db"
101 +
102 +if [[ ${CATEGORY} == cross-* ]] ; then
103 + DEPEND+=" !crosscompile_opts_headers-only? (
104 + >=${CATEGORY}/binutils-2.24
105 + >=${CATEGORY}/gcc-4.7
106 + )"
107 + [[ ${CATEGORY} == *-linux* ]] && DEPEND+=" ${CATEGORY}/linux-headers"
108 +else
109 + DEPEND+="
110 + >=sys-devel/binutils-2.24
111 + >=sys-devel/gcc-4.7
112 + virtual/os-headers"
113 + RDEPEND+=" vanilla? ( !sys-libs/timezone-data )"
114 + PDEPEND+=" !vanilla? ( sys-libs/timezone-data )"
115 +fi
116 +
117 +upstream_uris() {
118 + echo mirror://gnu/glibc/$1 ftp://sourceware.org/pub/glibc/{releases,snapshots}/$1 mirror://gentoo/$1
119 +}
120 +gentoo_uris() {
121 + local devspace="HTTP~vapier/dist/URI HTTP~tamiko/distfiles/URI HTTP~dilfridge/distfiles/URI HTTP~slyfox/distfiles/URI"
122 + devspace=${devspace//HTTP/https://dev.gentoo.org/}
123 + echo mirror://gentoo/$1 ${devspace//URI/$1}
124 +}
125 +SRC_URI=$(
126 + [[ -z ${EGIT_REPO_URIS} ]] && upstream_uris ${P}.tar.xz
127 + [[ -n ${PATCH_VER} ]] && gentoo_uris ${P}-patches-${PATCH_VER}.tar.bz2
128 +)
129 +SRC_URI+=" ${GCC_BOOTSTRAP_VER:+multilib? ( $(gentoo_uris gcc-${GCC_BOOTSTRAP_VER}-multilib-bootstrap.tar.bz2) )}"
130 +
131 +#
132 +# the phases
133 +#
134 +
135 +pkg_pretend() {
136 + check_devpts
137 +
138 + # Prevent native builds from downgrading.
139 + if [[ ${MERGE_TYPE} != "buildonly" ]] && \
140 + [[ ${ROOT} == "/" ]] && \
141 + [[ ${CBUILD} == ${CHOST} ]] && \
142 + [[ ${CHOST} == ${CTARGET} ]] ; then
143 + # The high rev # is to allow people to downgrade between -r# versions.
144 + # We want to block 2.20->2.19, but 2.20-r3->2.20-r2 should be fine.
145 + # Hopefully we never actually use a r# this high.
146 + if has_version ">${CATEGORY}/${P}-r10000" ; then
147 + eerror "Sanity check to keep you from breaking your system:"
148 + eerror " Downgrading glibc is not supported and a sure way to destruction"
149 + die "aborting to save your system"
150 + fi
151 +
152 + if ! glibc_run_test '#include <pwd.h>\nint main(){return getpwuid(0)==0;}\n'
153 + then
154 + eerror "Your patched vendor kernel is broken. You need to get an"
155 + eerror "update from whoever is providing the kernel to you."
156 + eerror "https://sourceware.org/bugzilla/show_bug.cgi?id=5227"
157 + eerror "http://bugs.gentoo.org/262698"
158 + die "keeping your system alive, say thank you"
159 + fi
160 +
161 + if ! glibc_run_test '#include <unistd.h>\n#include <sys/syscall.h>\nint main(){return syscall(1000)!=-1;}\n'
162 + then
163 + eerror "Your old kernel is broken. You need to update it to"
164 + eerror "a newer version as syscall(<bignum>) will break."
165 + eerror "http://bugs.gentoo.org/279260"
166 + die "keeping your system alive, say thank you"
167 + fi
168 + fi
169 +
170 + # users have had a chance to phase themselves, time to give em the boot
171 + if [[ -e ${EROOT}/etc/locale.gen ]] && [[ -e ${EROOT}/etc/locales.build ]] ; then
172 + eerror "You still haven't deleted ${EROOT}/etc/locales.build."
173 + eerror "Do so now after making sure ${EROOT}/etc/locale.gen is kosher."
174 + die "lazy upgrader detected"
175 + fi
176 +
177 + if [[ ${CTARGET} == i386-* ]] ; then
178 + eerror "i386 CHOSTs are no longer supported."
179 + eerror "Chances are you don't actually want/need i386."
180 + eerror "Please read http://www.gentoo.org/doc/en/change-chost.xml"
181 + die "please fix your CHOST"
182 + fi
183 +
184 + if [[ -e /proc/xen ]] && [[ $(tc-arch) == "x86" ]] && ! is-flag -mno-tls-direct-seg-refs ; then
185 + ewarn "You are using Xen but don't have -mno-tls-direct-seg-refs in your CFLAGS."
186 + ewarn "This will result in a 50% performance penalty when running with a 32bit"
187 + ewarn "hypervisor, which is probably not what you want."
188 + fi
189 +
190 + use hardened && ! tc-enables-pie && \
191 + ewarn "PIE hardening not applied, as your compiler doesn't default to PIE"
192 +
193 + # Make sure host system is up to date #394453
194 + if has_version '<sys-libs/glibc-2.13' && \
195 + [[ -n $(scanelf -qys__guard -F'#s%F' "${EROOT}"/lib*/l*-*.so) ]]
196 + then
197 + ebegin "Scanning system for __guard to see if you need to rebuild first ..."
198 + local files=$(
199 + scanelf -qys__guard -F'#s%F' \
200 + "${EROOT}"/*bin/ \
201 + "${EROOT}"/lib* \
202 + "${EROOT}"/usr/*bin/ \
203 + "${EROOT}"/usr/lib* | \
204 + egrep -v \
205 + -e "^${EROOT}/lib.*/(libc|ld)-2.*.so$" \
206 + -e "^${EROOT}/sbin/(ldconfig|sln)$"
207 + )
208 + [[ -z ${files} ]]
209 + if ! eend $? ; then
210 + eerror "Your system still has old SSP __guard symbols. You need to"
211 + eerror "rebuild all the packages that provide these files first:"
212 + eerror "${files}"
213 + die "old __guard detected"
214 + fi
215 + fi
216 +}
217 +
218 +src_unpack() {
219 + [[ -n ${GCC_BOOTSTRAP_VER} ]] && use multilib && unpack gcc-${GCC_BOOTSTRAP_VER}-multilib-bootstrap.tar.bz2
220 +
221 + setup_env
222 +
223 + # Check NPTL support _before_ we unpack things to save some time
224 + want_nptl && check_nptl_support
225 +
226 + if [[ -n ${EGIT_REPO_URIS} ]] ; then
227 + local i d
228 + for ((i=0; i<${#EGIT_REPO_URIS[@]}; ++i)) ; do
229 + EGIT_REPO_URI=${EGIT_REPO_URIS[$i]}
230 + EGIT_SOURCEDIR=${EGIT_SOURCEDIRS[$i]}
231 + git-2_src_unpack
232 + done
233 + else
234 + unpack_pkg
235 + fi
236 +
237 + cd "${S}"
238 + touch locale/C-translit.h #185476 #218003
239 + [[ -n ${LT_VER} ]] && unpack_pkg linuxthreads ${LT_VER}
240 + [[ -n ${PORTS_VER} ]] && unpack_pkg ports ${PORTS_VER}
241 + [[ -n ${LIBIDN_VER} ]] && unpack_pkg libidn
242 +
243 + if [[ -n ${PATCH_VER} ]] ; then
244 + cd "${WORKDIR}"
245 + unpack glibc-${RELEASE_VER}-patches-${PATCH_VER}.tar.bz2
246 + # pull out all the addons
247 + local d
248 + for d in extra/*/configure ; do
249 + d=${d%/configure}
250 + [[ -d ${S}/${d} ]] && die "${d} already exists in \${S}"
251 + mv "${d}" "${S}" || die "moving ${d} failed"
252 + done
253 + fi
254 +}
255 +
256 +src_prepare() {
257 + # XXX: We should do the branchupdate, before extracting the manpages and
258 + # infopages else it does not help much (mtimes change if there is a change
259 + # to them with branchupdate)
260 + if [[ -n ${BRANCH_UPDATE} ]] ; then
261 + epatch "${DISTDIR}"/glibc-${RELEASE_VER}-branch-update-${BRANCH_UPDATE}.patch.bz2
262 +
263 + # Snapshot date patch
264 + einfo "Patching version to display snapshot date ..."
265 + sed -i -e "s:\(#define RELEASE\).*:\1 \"${BRANCH_UPDATE}\":" version.h
266 + fi
267 +
268 + if [[ -n ${PATCH_VER} ]] && ! use vanilla ; then
269 + EPATCH_MULTI_MSG="Applying Gentoo Glibc Patchset ${RELEASE_VER}-${PATCH_VER} ..." \
270 + EPATCH_EXCLUDE=${GLIBC_PATCH_EXCLUDE} \
271 + EPATCH_SUFFIX="patch" \
272 + ARCH=$(tc-arch) \
273 + epatch "${WORKDIR}"/patches
274 + fi
275 +
276 + if just_headers ; then
277 + if [[ -e ports/sysdeps/mips/preconfigure ]] ; then
278 + # mips peeps like to screw with us. if building headers,
279 + # we don't have a real compiler, so we can't let them
280 + # insert -mabi on us.
281 + sed -i '/CPPFLAGS=.*-mabi/s|.*|:|' ports/sysdeps/mips/preconfigure || die
282 + find ports/sysdeps/mips/ -name Makefile -exec sed -i '/^CC.*-mabi=/s:-mabi=.*:-D_MIPS_SZPTR=32:' {} +
283 + fi
284 + fi
285 +
286 + eapply_user
287 +
288 + gnuconfig_update
289 +
290 + cd "${WORKDIR}"
291 + find . -type f '(' -size 0 -o -name "*.orig" ')' -delete
292 + find . -name configure -exec touch {} +
293 +
294 + eprefixify extra/locale/locale-gen
295 +
296 + # Fix permissions on some of the scripts.
297 + chmod u+x "${S}"/scripts/*.sh
298 +
299 + cd "${S}"
300 +
301 + if use hardened ; then
302 + # We don't enable these for non-hardened as the output is very terse --
303 + # it only states that a crash happened. The default upstream behavior
304 + # includes backtraces and symbols.
305 + einfo "Installing Hardened Gentoo SSP and FORTIFY_SOURCE handler"
306 + cp "${FILESDIR}"/2.20/glibc-2.20-gentoo-stack_chk_fail.c debug/stack_chk_fail.c || die
307 + cp "${FILESDIR}"/2.25/glibc-2.25-gentoo-chk_fail.c debug/chk_fail.c || die
308 +
309 + if use debug ; then
310 + # Allow SIGABRT to dump core on non-hardened systems, or when debug is requested.
311 + sed -i \
312 + -e '/^CFLAGS-backtrace.c/ iCPPFLAGS-stack_chk_fail.c = -DSSP_SMASH_DUMPS_CORE' \
313 + -e '/^CFLAGS-backtrace.c/ iCPPFLAGS-chk_fail.c = -DSSP_SMASH_DUMPS_CORE' \
314 + debug/Makefile || die
315 + fi
316 + fi
317 +
318 + case $(gcc-fullversion) in
319 + 4.8.[0-3]|4.9.0)
320 + eerror "You need to switch to a newer compiler; gcc-4.8.[0-3] and gcc-4.9.0 miscompile"
321 + eerror "glibc. See https://bugs.gentoo.org/547420 for details."
322 + die "need to switch compilers #547420"
323 + ;;
324 + esac
325 +}
326 +
327 +glibc_do_configure() {
328 + # Glibc does not work with gold (for various reasons) #269274.
329 + tc-ld-disable-gold
330 +
331 + dump_toolchain_settings "Configuring glibc for $1"
332 +
333 + local myconf=()
334 +
335 + # set addons
336 + pushd "${S}" > /dev/null
337 + local addons=$(echo */configure | sed \
338 + -e 's:/configure::g' \
339 + -e 's:\(linuxthreads\|nptl\|rtkaio\|glibc-compat\)\( \|$\)::g' \
340 + -e 's: \+$::' \
341 + -e 's! !,!g' \
342 + -e 's!^!,!' \
343 + -e '/^,\*$/d')
344 + [[ -d ports ]] && addons+=",ports"
345 + popd > /dev/null
346 +
347 + if has_version '<sys-libs/glibc-2.13' ; then
348 + myconf+=( --enable-old-ssp-compat )
349 + fi
350 +
351 + if version_is_at_least 2.25 ; then
352 + myconf+=( --enable-stack-protector=all )
353 + fi
354 +
355 + if version_is_at_least 2.25 ; then
356 + myconf+=( --enable-stackguard-randomization )
357 + else
358 + myconf+=( $(use_enable hardened stackguard-randomization) )
359 + fi
360 +
361 + [[ $(tc-is-softfloat) == "yes" ]] && myconf+=( --without-fp )
362 +
363 + if [[ $1 == "linuxthreads" ]] ; then
364 + if want_tls ; then
365 + myconf+=( --with-tls )
366 +
367 + if ! want__thread || use glibc-compat20 || [[ ${LT_KER_VER} == 2.[02].* ]] ; then
368 + myconf+=( --without-__thread )
369 + else
370 + myconf+=( --with-__thread )
371 + fi
372 + else
373 + myconf+=( --without-tls --without-__thread )
374 + fi
375 +
376 + myconf+=( --disable-sanity-checks )
377 + addons="linuxthreads${addons}"
378 + myconf+=( --enable-kernel=${LT_KER_VER} )
379 + elif [[ $1 == "nptl" ]] ; then
380 + # Newer versions require nptl, so there is no addon for it.
381 + version_is_at_least 2.20 || addons="nptl${addons}"
382 + myconf+=( --enable-kernel=${NPTL_KERN_VER} )
383 + else
384 + die "invalid pthread option"
385 + fi
386 + myconf+=( --enable-add-ons="${addons#,}" )
387 +
388 + # Since SELinux support is only required for nscd, only enable it if:
389 + # 1. USE selinux
390 + # 2. only for the primary ABI on multilib systems
391 + # 3. Not a crosscompile
392 + if ! is_crosscompile && use selinux ; then
393 + if use multilib ; then
394 + if is_final_abi ; then
395 + myconf+=( --with-selinux )
396 + else
397 + myconf+=( --without-selinux )
398 + fi
399 + else
400 + myconf+=( --with-selinux )
401 + fi
402 + else
403 + myconf+=( --without-selinux )
404 + fi
405 +
406 + # Force a few tests where we always know the answer but
407 + # configure is incapable of finding it.
408 + if is_crosscompile ; then
409 + export \
410 + libc_cv_c_cleanup=yes \
411 + libc_cv_forced_unwind=yes
412 + fi
413 +
414 + myconf+=(
415 + --without-cvs
416 + --disable-werror
417 + --enable-bind-now
418 + --build=${CBUILD_OPT:-${CBUILD}}
419 + --host=${CTARGET_OPT:-${CTARGET}}
420 + $(use_enable profile)
421 + $(use_with gd)
422 + --with-headers=$(alt_build_headers)
423 + --prefix="${EPREFIX}/usr"
424 + --sysconfdir="${EPREFIX}/etc"
425 + --localstatedir="${EPREFIX}/var"
426 + --libdir='$(prefix)'/$(get_libdir)
427 + --mandir='$(prefix)'/share/man
428 + --infodir='$(prefix)'/share/info
429 + --libexecdir='$(libdir)'/misc/glibc
430 + --with-bugurl=http://bugs.gentoo.org/
431 + --with-pkgversion="$(glibc_banner)"
432 + $(use_multiarch || echo --disable-multi-arch)
433 + $(in_iuse rpc && use_enable rpc obsolete-rpc || echo --enable-obsolete-rpc)
434 + $(in_iuse systemtap && use_enable systemtap)
435 + $(in_iuse nscd && use_enable nscd)
436 + ${EXTRA_ECONF}
437 + )
438 +
439 + # We rely on sys-libs/timezone-data for timezone tools normally.
440 + if version_is_at_least 2.23 ; then
441 + myconf+=( $(use_enable vanilla timezone-tools) )
442 + fi
443 +
444 + # These libs don't have configure flags.
445 + ac_cv_lib_audit_audit_log_user_avc_message=$(in_iuse audit && usex audit || echo no)
446 + ac_cv_lib_cap_cap_init=$(in_iuse caps && usex caps || echo no)
447 +
448 + # There is no configure option for this and we need to export it
449 + # since the glibc build will re-run configure on itself
450 + export libc_cv_rootsbindir="${EPREFIX}/sbin"
451 + export libc_cv_slibdir="${EPREFIX}/$(get_libdir)"
452 +
453 + # We take care of patching our binutils to use both hash styles,
454 + # and many people like to force gnu hash style only, so disable
455 + # this overriding check. #347761
456 + export libc_cv_hashstyle=no
457 +
458 + # Overtime, generating info pages can be painful. So disable this for
459 + # versions older than the latest stable to avoid the issue (this ver
460 + # should be updated from time to time). #464394 #465816
461 + if ! version_is_at_least 2.17 ; then
462 + export ac_cv_prog_MAKEINFO=:
463 + fi
464 +
465 + local builddir=$(builddir "$1")
466 + mkdir -p "${builddir}"
467 + cd "${builddir}"
468 + set -- "${S}"/configure "${myconf[@]}"
469 + echo "$@"
470 + "$@" || die "failed to configure glibc"
471 +
472 + # ia64 static cross-compilers are a pita in so much that they
473 + # can't produce static ELFs (as the libgcc.a is broken). so
474 + # disable building of the programs for those targets if it
475 + # doesn't work.
476 + # XXX: We could turn this into a compiler test, but ia64 is
477 + # the only one that matters, so this should be fine for now.
478 + if is_crosscompile && [[ ${CTARGET} == ia64* ]] ; then
479 + sed -i '1i+link-static = touch $@' config.make
480 + fi
481 +
482 + # If we're trying to migrate between ABI sets, we need
483 + # to lie and use a local copy of gcc. Like if the system
484 + # is built with MULTILIB_ABIS="amd64 x86" but we want to
485 + # add x32 to it, gcc/glibc don't yet support x32.
486 + if [[ -n ${GCC_BOOTSTRAP_VER} ]] && use multilib ; then
487 + echo 'main(){}' > "${T}"/test.c
488 + if ! $(tc-getCC ${CTARGET}) ${CFLAGS} ${LDFLAGS} "${T}"/test.c -Wl,-emain -lgcc 2>/dev/null ; then
489 + sed -i -e '/^CC = /s:$: -B$(objdir)/../'"gcc-${GCC_BOOTSTRAP_VER}/${ABI}:" config.make || die
490 + mkdir -p sunrpc
491 + cp $(which rpcgen) sunrpc/cross-rpcgen || die
492 + touch -t 202001010101 sunrpc/cross-rpcgen || die
493 + fi
494 + fi
495 +}
496 +
497 +glibc_headers_configure() {
498 + export ABI=default
499 +
500 + local builddir=$(builddir "headers")
501 + mkdir -p "${builddir}"
502 + cd "${builddir}"
503 +
504 + # if we don't have a compiler yet, we can't really test it now ...
505 + # hopefully they don't affect header generation, so let's hope for
506 + # the best here ...
507 + local v vars=(
508 + ac_cv_header_cpuid_h=yes
509 + libc_cv_{386,390,alpha,arm,hppa,ia64,mips,{powerpc,sparc}{,32,64},sh,x86_64}_tls=yes
510 + libc_cv_asm_cfi_directives=yes
511 + libc_cv_broken_visibility_attribute=no
512 + libc_cv_c_cleanup=yes
513 + libc_cv_forced_unwind=yes
514 + libc_cv_gcc___thread=yes
515 + libc_cv_mlong_double_128=yes
516 + libc_cv_mlong_double_128ibm=yes
517 + libc_cv_ppc_machine=yes
518 + libc_cv_ppc_rel16=yes
519 + libc_cv_predef_fortify_source=no
520 + libc_cv_visibility_attribute=yes
521 + libc_cv_z_combreloc=yes
522 + libc_cv_z_execstack=yes
523 + libc_cv_z_initfirst=yes
524 + libc_cv_z_nodelete=yes
525 + libc_cv_z_nodlopen=yes
526 + libc_cv_z_relro=yes
527 + libc_mips_abi=${ABI}
528 + libc_mips_float=$([[ $(tc-is-softfloat) == "yes" ]] && echo soft || echo hard)
529 + # These libs don't have configure flags.
530 + ac_cv_lib_audit_audit_log_user_avc_message=no
531 + ac_cv_lib_cap_cap_init=no
532 + )
533 + if ! version_is_at_least 2.25 ; then
534 + vars+=(
535 + libc_cv_predef_stack_protector=no
536 + )
537 + fi
538 + einfo "Forcing cached settings:"
539 + for v in "${vars[@]}" ; do
540 + einfo " ${v}"
541 + export ${v}
542 + done
543 +
544 + # Blow away some random CC settings that screw things up. #550192
545 + if [[ -d ${S}/sysdeps/mips ]]; then
546 + pushd "${S}"/sysdeps/mips >/dev/null
547 + sed -i -e '/^CC +=/s:=.*:= -D_MIPS_SZPTR=32:' mips32/Makefile mips64/n32/Makefile || die
548 + sed -i -e '/^CC +=/s:=.*:= -D_MIPS_SZPTR=64:' mips64/n64/Makefile || die
549 + if version_is_at_least 2.21 ; then
550 + # Force the mips ABI to the default. This is OK because the set of
551 + # installed headers in this phase is the same between the 3 ABIs.
552 + # If this ever changes, this hack will break, but that's unlikely
553 + # as glibc discourages that behavior.
554 + # https://crbug.com/647033
555 + sed -i -e 's:abiflag=.*:abiflag=_ABIO32:' preconfigure || die
556 + fi
557 + popd >/dev/null
558 + fi
559 +
560 + local myconf=()
561 + myconf+=(
562 + --disable-sanity-checks
563 + --enable-hacker-mode
564 + --without-cvs
565 + --disable-werror
566 + --enable-bind-now
567 + --build=${CBUILD_OPT:-${CBUILD}}
568 + --host=${CTARGET_OPT:-${CTARGET}}
569 + --with-headers=$(alt_build_headers)
570 + --prefix="${EPREFIX}/usr"
571 + ${EXTRA_ECONF}
572 + )
573 +
574 + local addons
575 + [[ -d ${S}/ports ]] && addons+=",ports"
576 + # Newer versions require nptl, so there is no addon for it.
577 + version_is_at_least 2.20 || addons+=",nptl"
578 + myconf+=( --enable-add-ons="${addons#,}" )
579 +
580 + # Nothing is compiled here which would affect the headers for the target.
581 + # So forcing CC/CFLAGS is sane.
582 + set -- "${S}"/configure "${myconf[@]}"
583 + echo "$@"
584 + CC="$(tc-getBUILD_CC)" \
585 + CFLAGS="-O1 -pipe" \
586 + CPPFLAGS="-U_FORTIFY_SOURCE" \
587 + LDFLAGS="" \
588 + "$@" || die "failed to configure glibc"
589 +}
590 +
591 +do_src_configure() {
592 + if just_headers ; then
593 + glibc_headers_configure
594 + else
595 + want_linuxthreads && glibc_do_configure linuxthreads
596 + want_nptl && glibc_do_configure nptl
597 + fi
598 +}
599 +
600 +src_configure() {
601 + foreach_abi do_src_configure
602 +}
603 +
604 +do_src_compile() {
605 + local t
606 + for t in linuxthreads nptl ; do
607 + if want_${t} ; then
608 + emake -C "$(builddir ${t})" || die "make ${t} for ${ABI} failed"
609 + fi
610 + done
611 +}
612 +
613 +src_compile() {
614 + if just_headers ; then
615 + return
616 + fi
617 +
618 + foreach_abi do_src_compile
619 +}
620 +
621 +glibc_src_test() {
622 + cd "$(builddir $1)"
623 + nonfatal emake -j1 check && return 0
624 + einfo "make check failed - re-running with --keep-going to get the rest of the results"
625 + nonfatal emake -j1 -k check
626 + ewarn "make check failed for ${ABI}-${CTARGET}-$1"
627 + return 1
628 +}
629 +
630 +glibc_do_src_test() {
631 + local ret=0 t
632 + for t in linuxthreads nptl ; do
633 + if want_${t} ; then
634 + glibc_src_test ${t}
635 + : $(( ret |= $? ))
636 + fi
637 + done
638 + return ${ret}
639 +}
640 +
641 +src_test() {
642 + # Give tests more time to complete.
643 + export TIMEOUTFACTOR=5
644 +
645 + foreach_abi toolchain-glibc_do_src_test || die "tests failed"
646 +}
647 +
648 +glibc_do_src_install() {
649 + local builddir=$(builddir $(want_linuxthreads && echo linuxthreads || echo nptl))
650 + cd "${builddir}"
651 +
652 + emake install_root="${D}$(alt_prefix)" install || die
653 +
654 + if want_linuxthreads && want_nptl ; then
655 + einfo "Installing NPTL to $(alt_libdir)/tls/..."
656 + cd "$(builddir nptl)"
657 + dodir $(alt_libdir)/tls $(alt_usrlibdir)/nptl
658 +
659 + local l src_lib
660 + for l in libc libm librt libpthread libthread_db ; do
661 + # take care of shared lib first ...
662 + l=${l}.so
663 + if [[ -e ${l} ]] ; then
664 + src_lib=${l}
665 + else
666 + src_lib=$(eval echo */${l})
667 + fi
668 + cp -a ${src_lib} "${ED}"$(alt_libdir)/tls/${l} || die "copying nptl ${l}"
669 + fperms a+rx $(alt_libdir)/tls/${l}
670 + dosym ${l} $(alt_libdir)/tls/$(scanelf -qSF'%S#F' ${src_lib})
671 +
672 + # then grab the linker script or the symlink ...
673 + if [[ -L ${ED}$(alt_usrlibdir)/${l} ]] ; then
674 + dosym $(alt_libdir)/tls/${l} $(alt_usrlibdir)/nptl/${l}
675 + else
676 + sed \
677 + -e "s:/${l}:/tls/${l}:g" \
678 + -e "s:/${l/%.so/_nonshared.a}:/nptl/${l/%.so/_nonshared.a}:g" \
679 + "${ED}"$(alt_usrlibdir)/${l} > "${ED}"$(alt_usrlibdir)/nptl/${l}
680 + fi
681 +
682 + # then grab the static lib ...
683 + src_lib=${src_lib/%.so/.a}
684 + [[ ! -e ${src_lib} ]] && src_lib=${src_lib/%.a/_pic.a}
685 + cp -a ${src_lib} "${ED}"$(alt_usrlibdir)/nptl/ || die "copying nptl ${src_lib}"
686 + src_lib=${src_lib/%.a/_nonshared.a}
687 + if [[ -e ${src_lib} ]] ; then
688 + cp -a ${src_lib} "${ED}"$(alt_usrlibdir)/nptl/ || die "copying nptl ${src_lib}"
689 + fi
690 + done
691 +
692 + # use the nptl linker instead of the linuxthreads one as the linuxthreads
693 + # one may lack TLS support and that can be really bad for business
694 + cp -a elf/ld.so "${ED}"$(alt_libdir)/$(scanelf -qSF'%S#F' elf/ld.so) || die "copying nptl interp"
695 + fi
696 +
697 + # Normally real_pv is ${PV}. Live ebuilds are exception, there we need
698 + # to infer upstream version:
699 + # '#define VERSION "2.26.90"' -> '2.26.90'
700 + local upstream_pv=$(sed -n -r 's/#define VERSION "(.*)"/\1/p' "${S}"/version.h)
701 + # Newer versions get fancy with libm linkage to include vectorized support.
702 + # While we don't really need a ldscript here, portage QA checks get upset.
703 + if [[ -e ${ED}$(alt_usrlibdir)/libm-${upstream_pv}.a ]] ; then
704 + dosym ../../$(get_libdir)/libm-${upstream_pv}.so $(alt_usrlibdir)/libm-${upstream_pv}.so
705 + fi
706 +
707 + # We'll take care of the cache ourselves
708 + rm -f "${ED}"/etc/ld.so.cache
709 +
710 + # Everything past this point just needs to be done once ...
711 + is_final_abi || return 0
712 +
713 + # Make sure the non-native interp can be found on multilib systems even
714 + # if the main library set isn't installed into the right place. Maybe
715 + # we should query the active gcc for info instead of hardcoding it ?
716 + local i ldso_abi ldso_name
717 + local ldso_abi_list=(
718 + # x86
719 + amd64 /lib64/ld-linux-x86-64.so.2
720 + x32 /libx32/ld-linux-x32.so.2
721 + x86 /lib/ld-linux.so.2
722 + # mips
723 + o32 /lib/ld.so.1
724 + n32 /lib32/ld.so.1
725 + n64 /lib64/ld.so.1
726 + # powerpc
727 + ppc /lib/ld.so.1
728 + ppc64 /lib64/ld64.so.1
729 + # s390
730 + s390 /lib/ld.so.1
731 + s390x /lib/ld64.so.1
732 + # sparc
733 + sparc32 /lib/ld-linux.so.2
734 + sparc64 /lib64/ld-linux.so.2
735 + )
736 + case $(tc-endian) in
737 + little)
738 + ldso_abi_list+=(
739 + # arm
740 + arm64 /lib/ld-linux-aarch64.so.1
741 + )
742 + ;;
743 + big)
744 + ldso_abi_list+=(
745 + # arm
746 + arm64 /lib/ld-linux-aarch64_be.so.1
747 + )
748 + ;;
749 + esac
750 + if [[ ${SYMLINK_LIB} == "yes" ]] && [[ ! -e ${ED}/$(alt_prefix)/lib ]] ; then
751 + dosym $(get_abi_LIBDIR ${DEFAULT_ABI}) $(alt_prefix)/lib
752 + fi
753 + for (( i = 0; i < ${#ldso_abi_list[@]}; i += 2 )) ; do
754 + ldso_abi=${ldso_abi_list[i]}
755 + has ${ldso_abi} $(get_install_abis) || continue
756 +
757 + ldso_name="$(alt_prefix)${ldso_abi_list[i+1]}"
758 + if [[ ! -L ${ED}/${ldso_name} && ! -e ${ED}/${ldso_name} ]] ; then
759 + dosym ../$(get_abi_LIBDIR ${ldso_abi})/${ldso_name##*/} ${ldso_name}
760 + fi
761 + done
762 +
763 + # With devpts under Linux mounted properly, we do not need the pt_chown
764 + # binary to be setuid. This is because the default owners/perms will be
765 + # exactly what we want.
766 + if in_iuse suid && ! use suid ; then
767 + find "${ED}" -name pt_chown -exec chmod -s {} +
768 + fi
769 +
770 + #################################################################
771 + # EVERYTHING AFTER THIS POINT IS FOR NATIVE GLIBC INSTALLS ONLY #
772 + # Make sure we install some symlink hacks so that when we build
773 + # a 2nd stage cross-compiler, gcc finds the target system
774 + # headers correctly. See gcc/doc/gccinstall.info
775 + if is_crosscompile ; then
776 + # We need to make sure that /lib and /usr/lib always exists.
777 + # gcc likes to use relative paths to get to its multilibs like
778 + # /usr/lib/../lib64/. So while we don't install any files into
779 + # /usr/lib/, we do need it to exist.
780 + cd "${ED}"$(alt_libdir)/..
781 + [[ -e lib ]] || mkdir lib
782 + cd "${ED}"$(alt_usrlibdir)/..
783 + [[ -e lib ]] || mkdir lib
784 +
785 + dosym usr/include $(alt_prefix)/sys-include
786 + return 0
787 + fi
788 +
789 + # Files for Debian-style locale updating
790 + dodir /usr/share/i18n
791 + sed \
792 + -e "/^#/d" \
793 + -e "/SUPPORTED-LOCALES=/d" \
794 + -e "s: \\\\::g" -e "s:/: :g" \
795 + "${S}"/localedata/SUPPORTED > "${ED}"/usr/share/i18n/SUPPORTED \
796 + || die "generating /usr/share/i18n/SUPPORTED failed"
797 + cd "${WORKDIR}"/extra/locale
798 + dosbin locale-gen || die
799 + doman *.[0-8]
800 + insinto /etc
801 + doins locale.gen || die
802 +
803 + # Make sure all the ABI's can find the locales and so we only
804 + # have to generate one set
805 + local a
806 + keepdir /usr/$(get_libdir)/locale
807 + for a in $(get_install_abis) ; do
808 + if [[ ! -e ${ED}/usr/$(get_abi_LIBDIR ${a})/locale ]] ; then
809 + dosym /usr/$(get_libdir)/locale /usr/$(get_abi_LIBDIR ${a})/locale
810 + fi
811 + done
812 +
813 + cd "${S}"
814 +
815 + # Install misc network config files
816 + insinto /etc
817 + doins nscd/nscd.conf posix/gai.conf nss/nsswitch.conf || die
818 + doins "${WORKDIR}"/extra/etc/*.conf || die
819 +
820 + if ! in_iuse nscd || use nscd ; then
821 + doinitd "${WORKDIR}"/extra/etc/nscd || die
822 +
823 + local nscd_args=(
824 + -e "s:@PIDFILE@:$(strings "${ED}"/usr/sbin/nscd | grep nscd.pid):"
825 + )
826 + version_is_at_least 2.16 || nscd_args+=( -e 's: --foreground : :' )
827 + sed -i "${nscd_args[@]}" "${ED}"/etc/init.d/nscd
828 +
829 + # Newer versions of glibc include the nscd.service themselves.
830 + # TODO: Drop the $FILESDIR copy once 2.19 goes stable.
831 + if version_is_at_least 2.19 ; then
832 + systemd_dounit nscd/nscd.service || die
833 + systemd_newtmpfilesd nscd/nscd.tmpfiles nscd.conf || die
834 + else
835 + systemd_dounit "${FILESDIR}"/nscd.service || die
836 + systemd_newtmpfilesd "${FILESDIR}"/nscd.tmpfilesd nscd.conf || die
837 + fi
838 + else
839 + # Do this since extra/etc/*.conf above might have nscd.conf.
840 + rm -f "${ED}"/etc/nscd.conf
841 + fi
842 +
843 + echo 'LDPATH="include ld.so.conf.d/*.conf"' > "${T}"/00glibc
844 + doenvd "${T}"/00glibc || die
845 +
846 + for d in BUGS ChangeLog* CONFORMANCE FAQ NEWS NOTES PROJECTS README* ; do
847 + [[ -s ${d} ]] && dodoc ${d}
848 + done
849 +
850 + # Prevent overwriting of the /etc/localtime symlink. We'll handle the
851 + # creation of the "factory" symlink in pkg_postinst().
852 + rm -f "${ED}"/etc/localtime
853 +}
854 +
855 +glibc_headers_install() {
856 + local builddir=$(builddir "headers")
857 + cd "${builddir}"
858 + emake install_root="${D}$(alt_prefix)" install-headers || die
859 + if ! version_is_at_least 2.16 ; then
860 + insinto $(alt_headers)/bits
861 + doins bits/stdio_lim.h || die
862 + fi
863 + insinto $(alt_headers)/gnu
864 + doins "${S}"/include/gnu/stubs.h || die "doins include gnu"
865 + # Make sure we install the sys-include symlink so that when
866 + # we build a 2nd stage cross-compiler, gcc finds the target
867 + # system headers correctly. See gcc/doc/gccinstall.info
868 + dosym usr/include $(alt_prefix)/sys-include
869 +}
870 +
871 +src_install() {
872 + if just_headers ; then
873 + export ABI=default
874 + glibc_headers_install
875 + return
876 + fi
877 +
878 + foreach_abi glibc_do_src_install
879 + src_strip
880 +}
881 +
882 +pkg_preinst() {
883 + # nothing to do if just installing headers
884 + just_headers && return
885 +
886 + # prepare /etc/ld.so.conf.d/ for files
887 + mkdir -p "${EROOT}"/etc/ld.so.conf.d
888 +
889 + # Default /etc/hosts.conf:multi to on for systems with small dbs.
890 + if [[ $(wc -l < "${EROOT}"/etc/hosts) -lt 1000 ]] ; then
891 + sed -i '/^multi off/s:off:on:' "${ED}"/etc/host.conf
892 + elog "Defaulting /etc/host.conf:multi to on"
893 + fi
894 +
895 + [[ ${ROOT} != "/" ]] && return 0
896 + [[ -d ${ED}/$(get_libdir) ]] || return 0
897 + [[ -z ${BOOTSTRAP_RAP} ]] && glibc_sanity_check
898 +}
899 +
900 +pkg_postinst() {
901 + # nothing to do if just installing headers
902 + just_headers && return
903 +
904 + if ! tc-is-cross-compiler && [[ -x ${EROOT}/usr/sbin/iconvconfig ]] ; then
905 + # Generate fastloading iconv module configuration file.
906 + "${EROOT}"/usr/sbin/iconvconfig --prefix="${ROOT}"
907 + fi
908 +
909 + if ! is_crosscompile && [[ ${ROOT} == "/" ]] ; then
910 + # Reload init ... if in a chroot or a diff init package, ignore
911 + # errors from this step #253697
912 + /sbin/telinit U 2>/dev/null
913 +
914 + # if the host locales.gen contains no entries, we'll install everything
915 + local locale_list="${EROOT}etc/locale.gen"
916 + if [[ -z $(locale-gen --list --config "${locale_list}") ]] ; then
917 + ewarn "Generating all locales; edit /etc/locale.gen to save time/space"
918 + locale_list="${EROOT}usr/share/i18n/SUPPORTED"
919 + fi
920 + locale-gen -j $(makeopts_jobs) --config "${locale_list}"
921 + fi
922 +}