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