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