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