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