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