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