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