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