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