1 |
commit: bfd4644d464949179a652fa6c2cbfd1fd2fd4b3e |
2 |
Author: Andreas K. Hüttel <dilfridge <AT> gentoo <DOT> org> |
3 |
AuthorDate: Wed Mar 30 23:18:57 2022 +0000 |
4 |
Commit: Andreas K. Hüttel <dilfridge <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed Mar 30 23:19:22 2022 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=bfd4644d |
7 |
|
8 |
sys-libs/glibc: Revbumps to reintroduce clone3 useflag |
9 |
|
10 |
Unkeyworded until minimal testing is done |
11 |
|
12 |
Bug: https://bugs.gentoo.org/835930 |
13 |
Package-Manager: Portage-3.0.30, Repoman-3.0.3 |
14 |
Signed-off-by: Andreas K. Hüttel <dilfridge <AT> gentoo.org> |
15 |
|
16 |
sys-libs/glibc/Manifest | 2 + |
17 |
sys-libs/glibc/glibc-2.34-r11.ebuild | 1619 ++++++++++++++++++++++++++++++++++ |
18 |
sys-libs/glibc/glibc-2.35-r2.ebuild | 1590 +++++++++++++++++++++++++++++++++ |
19 |
sys-libs/glibc/metadata.xml | 1 + |
20 |
4 files changed, 3212 insertions(+) |
21 |
|
22 |
diff --git a/sys-libs/glibc/Manifest b/sys-libs/glibc/Manifest |
23 |
index 6302f98807af..78eb7f5cc1e1 100644 |
24 |
--- a/sys-libs/glibc/Manifest |
25 |
+++ b/sys-libs/glibc/Manifest |
26 |
@@ -14,8 +14,10 @@ DIST glibc-2.32.tar.xz 16744512 BLAKE2B a56b4afbb35315c5cd6dca0f62e44455dceae3e6 |
27 |
DIST glibc-2.33-patches-11.tar.xz 143916 BLAKE2B ac13b3ccf9681bb6d3c35ecc33e268ea3f67c1809f916019e692dc83e3ce809402a45548da5ca6c7c30d2a45a2638f9fa4254c0355bd4c53bdb216f17aa4e28b SHA512 0ee1dfcf9574543d49ab4fbfe53571258422b6e82b9d12a33e411cee7e517821a4c45c24962b5120783a4efc898afdfa170d33486cc74d94c526bdd14cc84300 |
28 |
DIST glibc-2.33.tar.xz 17031280 BLAKE2B 703d12121c1e2c5d9e0c6ba5341f5fb5c4d9111611a83f2360029b5de9c6e5a5611249d1833684a58ed4afdf49cae614365d87ec8721ba0e5d218f593b1f229d SHA512 4cb5777b68b22b746cc51669e0e9282b43c83f6944e42656e6db7195ebb68f2f9260f130fdeb4e3cfc64efae4f58d96c43d388f52be1eb024ca448084684abdb |
29 |
DIST glibc-2.34-patches-15.tar.xz 146124 BLAKE2B f679f0fc27780173875178537cf996cbfb59bb844566388df0c351dec125eb02070571d4e2852742b43933d09c7a148a39bbc7b2b71fffebd7b8d9d3c16850ac SHA512 5224613e2288fcf027be224001306a84019ebe741114ee1b09d3de9b269dad0280a6dc4d88f4bc38dace501b2944a0098972589a1560756cb3da7e1b7341d672 |
30 |
+DIST glibc-2.34-patches-16.tar.xz 164648 BLAKE2B 78786a67109812942ac11bee9a880b9383aa61d0c2b006e3e7e635218842f49c6ce5b7c75597f7d317aa18fede0ca0c79a4bd436b8659ba6a2f1953848484d2a SHA512 acfc91e821cd8b4e57907c7aeaf1eac0bae1f8e244e4011f27819a8ba16a4e9c10fc675c6aaff992be81bba9373ec981fb598838f26aa247e7bd016e2cd786d2 |
31 |
DIST glibc-2.34.tar.xz 17301232 BLAKE2B 874031192f2f5a3b35c3f5b044a467d4be4e67e8593e070e5b49b901ce8ea6bde2f8d2f6c92fa33b3f61eb723572a9e5f2b45e56064168df80a96d3fdb6fa30c SHA512 15252affd9ef4523a8001db16d497f4fdcb3ddf4cde7fe80e075df0bd3cc6524dc29fbe20229dbf5f97af580556e6b1fac0de321a5fe25322bc3e72f93beb624 |
32 |
DIST glibc-2.35-patches-4.tar.xz 45456 BLAKE2B 47e1c5e4db4969da27f14816ac9b856f3a57e152139e071f0fd0ecf53b7ac2a0372a8dec7e9e51808d463d2e5b12a6acc9145bb0127a7f36cf1d19b96a0efa41 SHA512 39ca84ed5f3e74bccb8875a77188bb16f6b45b1b22843b4ccf8a7f792d35e05e8305929fbeede290ebb128722caf8277da03dbf4aee9261940765f8dfcd01561 |
33 |
+DIST glibc-2.35-patches-5.tar.xz 45632 BLAKE2B b49161139e8a9e6f4351b5954f38eaa3b0b16a444c370b906e2fcac8eb25c306e6f95474063e511a4f8bf48c0eade9509a6158a1019e32ec4b95c49f992405eb SHA512 5bf20061f24ad087aa0f22808cb0dfd810e5413e71dc9b9c7ec0e9cecd172c40e3517e0a151294175351cf0e037e9c35d8b50ba391a312976e7c4103845089e4 |
34 |
DIST glibc-2.35.tar.xz 18165952 BLAKE2B 623c728884f070cd87ffeb9203f74206197c52405ac9bc44f3dd519a3468b8e8ae2536c883e5d17d94417dbd1e91775de2e674314e4ff7424f9720026d6b7063 SHA512 e7336ce27561be5d7c217832a1136fb327e057bd8d3f92925b35c97e3e9f9e486948b5a1e03e5e4090772ef06437a074d10b82e68f17f1ad8f22077ee39e1b66 |
35 |
DIST glibc-systemd-20210729.tar.gz 1480 BLAKE2B 37722c7579df782d890e44dbab99c3de52ab466eb9de80d82405e9bb5620bf39ffc8c5f466a435bdb86ef6d36dd7019c0736573916bda6c67d02a2581e0ec979 SHA512 efd75af58b50522c28cdac7abd1fc56555bc1bb042512c90d8340c1ec09c5791b3872a305bf83723252bbde5855b75d958c041083457765c4cfd170732d09238 |
36 |
DIST glibc-systemd-20210814.tar.gz 1469 BLAKE2B 10fa7bcb46d4fdce9c0ab353cbd30871e9b09a347a13a9c9a3b5777f931aa3c826c158d2e49532c604d4a834f2fab4089b67495fb88d0398945dc50d45ad9ef1 SHA512 5346a9ea459a1e6ccf665389f2a294de1e16f1e3e05cdf07e3dd99ed0e4f6f8b52cc333d4bff3c75ac90ab6ce70cd4ab2b3e126f920ce7979abd6dda56315efc |
37 |
|
38 |
diff --git a/sys-libs/glibc/glibc-2.34-r11.ebuild b/sys-libs/glibc/glibc-2.34-r11.ebuild |
39 |
new file mode 100644 |
40 |
index 000000000000..20fbb221625f |
41 |
--- /dev/null |
42 |
+++ b/sys-libs/glibc/glibc-2.34-r11.ebuild |
43 |
@@ -0,0 +1,1619 @@ |
44 |
+# Copyright 1999-2022 Gentoo Authors |
45 |
+# Distributed under the terms of the GNU General Public License v2 |
46 |
+ |
47 |
+EAPI=7 |
48 |
+ |
49 |
+# Bumping notes: https://wiki.gentoo.org/wiki/Project:Toolchain/sys-libs/glibc |
50 |
+# Please read & adapt the page as necessary if obsolete. |
51 |
+ |
52 |
+# We avoid Python 3.10 here _for now_ (it does work!) to avoid circular dependencies |
53 |
+# on upgrades as people migrate to libxcrypt. |
54 |
+# https://wiki.gentoo.org/wiki/User:Sam/Portage_help/Circular_dependencies#Python_and_libcrypt |
55 |
+PYTHON_COMPAT=( python3_{8,9} ) |
56 |
+TMPFILES_OPTIONAL=1 |
57 |
+ |
58 |
+inherit python-any-r1 prefix preserve-libs toolchain-funcs flag-o-matic gnuconfig \ |
59 |
+ multilib systemd multiprocessing tmpfiles |
60 |
+ |
61 |
+DESCRIPTION="GNU libc C library" |
62 |
+HOMEPAGE="https://www.gnu.org/software/libc/" |
63 |
+LICENSE="LGPL-2.1+ BSD HPND ISC inner-net rc PCRE" |
64 |
+SLOT="2.2" |
65 |
+ |
66 |
+EMULTILIB_PKG="true" |
67 |
+ |
68 |
+# Gentoo patchset (ignored for live ebuilds) |
69 |
+PATCH_VER=16 |
70 |
+PATCH_DEV=dilfridge |
71 |
+ |
72 |
+if [[ ${PV} == 9999* ]]; then |
73 |
+ inherit git-r3 |
74 |
+else |
75 |
+ #KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86" |
76 |
+ SRC_URI="mirror://gnu/glibc/${P}.tar.xz" |
77 |
+ SRC_URI+=" https://dev.gentoo.org/~${PATCH_DEV}/distfiles/${P}-patches-${PATCH_VER}.tar.xz" |
78 |
+fi |
79 |
+ |
80 |
+RELEASE_VER=${PV} |
81 |
+ |
82 |
+GCC_BOOTSTRAP_VER=20201208 |
83 |
+ |
84 |
+LOCALE_GEN_VER=2.22 |
85 |
+ |
86 |
+GLIBC_SYSTEMD_VER=20210729 |
87 |
+ |
88 |
+SRC_URI+=" https://gitweb.gentoo.org/proj/locale-gen.git/snapshot/locale-gen-${LOCALE_GEN_VER}.tar.gz" |
89 |
+SRC_URI+=" multilib-bootstrap? ( https://dev.gentoo.org/~dilfridge/distfiles/gcc-multilib-bootstrap-${GCC_BOOTSTRAP_VER}.tar.xz )" |
90 |
+SRC_URI+=" systemd? ( https://gitweb.gentoo.org/proj/toolchain/glibc-systemd.git/snapshot/glibc-systemd-${GLIBC_SYSTEMD_VER}.tar.gz )" |
91 |
+ |
92 |
+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" |
93 |
+ |
94 |
+# Minimum kernel version that glibc requires |
95 |
+MIN_KERN_VER="3.2.0" |
96 |
+# Minimum pax-utils version needed (which contains any new syscall changes for |
97 |
+# its seccomp filter!). Please double check this! |
98 |
+MIN_PAX_UTILS_VER="1.3.3" |
99 |
+ |
100 |
+# Here's how the cross-compile logic breaks down ... |
101 |
+# CTARGET - machine that will target the binaries |
102 |
+# CHOST - machine that will host the binaries |
103 |
+# CBUILD - machine that will build the binaries |
104 |
+# If CTARGET != CHOST, it means you want a libc for cross-compiling. |
105 |
+# If CHOST != CBUILD, it means you want to cross-compile the libc. |
106 |
+# CBUILD = CHOST = CTARGET - native build/install |
107 |
+# CBUILD != (CHOST = CTARGET) - cross-compile a native build |
108 |
+# (CBUILD = CHOST) != CTARGET - libc for cross-compiler |
109 |
+# CBUILD != CHOST != CTARGET - cross-compile a libc for a cross-compiler |
110 |
+# For install paths: |
111 |
+# CHOST = CTARGET - install into / |
112 |
+# CHOST != CTARGET - install into /usr/CTARGET/ |
113 |
+# |
114 |
+export CBUILD=${CBUILD:-${CHOST}} |
115 |
+export CTARGET=${CTARGET:-${CHOST}} |
116 |
+if [[ ${CTARGET} == ${CHOST} ]] ; then |
117 |
+ if [[ ${CATEGORY} == cross-* ]] ; then |
118 |
+ export CTARGET=${CATEGORY#cross-} |
119 |
+ fi |
120 |
+fi |
121 |
+ |
122 |
+# Note [Disable automatic stripping] |
123 |
+# Disabling automatic stripping for a few reasons: |
124 |
+# - portage's attempt to strip breaks non-native binaries at least on |
125 |
+# arm: bug #697428 |
126 |
+# - portage's attempt to strip libpthread.so.0 breaks gdb thread |
127 |
+# enumeration: bug #697910. This is quite subtle: |
128 |
+# * gdb uses glibc's libthread_db-1.0.so to enumerate threads. |
129 |
+# * libthread_db-1.0.so needs access to libpthread.so.0 local symbols |
130 |
+# via 'ps_pglobal_lookup' symbol defined in gdb. |
131 |
+# * 'ps_pglobal_lookup' uses '.symtab' section table to resolve all |
132 |
+# known symbols in 'libpthread.so.0'. Specifically 'nptl_version' |
133 |
+# (unexported) is used to sanity check compatibility before enabling |
134 |
+# debugging. |
135 |
+# 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 |
136 |
+# * normal 'strip' command trims '.symtab' |
137 |
+# Thus our main goal here is to prevent 'libpthread.so.0' from |
138 |
+# losing it's '.symtab' entries. |
139 |
+# As Gentoo's strip does not allow us to pass less aggressive stripping |
140 |
+# options and does not check the machine target we strip selectively. |
141 |
+ |
142 |
+# We need a new-enough binutils/gcc to match upstream baseline. |
143 |
+# Also we need to make sure our binutils/gcc supports TLS, |
144 |
+# and that gcc already contains the hardened patches. |
145 |
+# Lastly, let's avoid some openssh nastiness, bug 708224, as |
146 |
+# convenience to our users. |
147 |
+ |
148 |
+# gzip, grep, awk are needed by locale-gen, bug 740750 |
149 |
+ |
150 |
+BDEPEND=" |
151 |
+ ${PYTHON_DEPS} |
152 |
+ >=app-misc/pax-utils-${MIN_PAX_UTILS_VER} |
153 |
+ sys-devel/bison |
154 |
+ doc? ( sys-apps/texinfo ) |
155 |
+ !compile-locales? ( |
156 |
+ app-arch/gzip |
157 |
+ sys-apps/grep |
158 |
+ virtual/awk |
159 |
+ ) |
160 |
+" |
161 |
+COMMON_DEPEND=" |
162 |
+ gd? ( media-libs/gd:2= ) |
163 |
+ nscd? ( selinux? ( |
164 |
+ audit? ( sys-process/audit ) |
165 |
+ caps? ( sys-libs/libcap ) |
166 |
+ ) ) |
167 |
+ suid? ( caps? ( sys-libs/libcap ) ) |
168 |
+ selinux? ( sys-libs/libselinux ) |
169 |
+ systemtap? ( dev-util/systemtap ) |
170 |
+" |
171 |
+DEPEND="${COMMON_DEPEND} |
172 |
+ compile-locales? ( |
173 |
+ app-arch/gzip |
174 |
+ sys-apps/grep |
175 |
+ virtual/awk |
176 |
+ ) |
177 |
+ test? ( >=net-dns/libidn2-2.3.0 ) |
178 |
+" |
179 |
+RDEPEND="${COMMON_DEPEND} |
180 |
+ app-arch/gzip |
181 |
+ sys-apps/grep |
182 |
+ virtual/awk |
183 |
+ sys-apps/gentoo-functions |
184 |
+ !<app-misc/pax-utils-${MIN_PAX_UTILS_VER} |
185 |
+ !<net-misc/openssh-8.1_p1-r2 |
186 |
+" |
187 |
+ |
188 |
+RESTRICT="!test? ( test )" |
189 |
+ |
190 |
+if [[ ${CATEGORY} == cross-* ]] ; then |
191 |
+ BDEPEND+=" !headers-only? ( |
192 |
+ >=${CATEGORY}/binutils-2.27 |
193 |
+ >=${CATEGORY}/gcc-6 |
194 |
+ )" |
195 |
+ [[ ${CATEGORY} == *-linux* ]] && DEPEND+=" ${CATEGORY}/linux-headers" |
196 |
+else |
197 |
+ BDEPEND+=" |
198 |
+ >=sys-devel/binutils-2.27 |
199 |
+ >=sys-devel/gcc-6 |
200 |
+ " |
201 |
+ DEPEND+=" virtual/os-headers " |
202 |
+ RDEPEND+=" |
203 |
+ >=net-dns/libidn2-2.3.0 |
204 |
+ vanilla? ( !sys-libs/timezone-data ) |
205 |
+ " |
206 |
+ PDEPEND+=" !vanilla? ( sys-libs/timezone-data )" |
207 |
+fi |
208 |
+ |
209 |
+# Ignore tests whitelisted below |
210 |
+GENTOO_GLIBC_XFAIL_TESTS="${GENTOO_GLIBC_XFAIL_TESTS:-yes}" |
211 |
+ |
212 |
+# The following tests fail due to the Gentoo build system and are thus |
213 |
+# executed but ignored: |
214 |
+XFAIL_TEST_LIST=( |
215 |
+ # buggy test, assumes /dev/ and /dev/null on a single filesystem |
216 |
+ # 'mount --bind /dev/null /chroot/dev/null' breaks it. |
217 |
+ # https://sourceware.org/PR25909 |
218 |
+ tst-support_descriptors |
219 |
+ |
220 |
+ # The following tests fail only inside portage |
221 |
+ # https://bugs.gentoo.org/831267 |
222 |
+ tst-system |
223 |
+ tst-strerror |
224 |
+ tst-strsignal |
225 |
+) |
226 |
+ |
227 |
+# |
228 |
+# Small helper functions |
229 |
+# |
230 |
+ |
231 |
+is_crosscompile() { |
232 |
+ [[ ${CHOST} != ${CTARGET} ]] |
233 |
+} |
234 |
+ |
235 |
+just_headers() { |
236 |
+ is_crosscompile && use headers-only |
237 |
+} |
238 |
+ |
239 |
+alt_prefix() { |
240 |
+ is_crosscompile && echo /usr/${CTARGET} |
241 |
+} |
242 |
+ |
243 |
+# This prefix is applicable to CHOST when building against this |
244 |
+# glibc. It is baked into the library at configure time. |
245 |
+host_eprefix() { |
246 |
+ is_crosscompile || echo "${EPREFIX}" |
247 |
+} |
248 |
+ |
249 |
+# This prefix is applicable to CBUILD when building against this |
250 |
+# glibc. It determines the destination path at install time. |
251 |
+build_eprefix() { |
252 |
+ is_crosscompile && echo "${EPREFIX}" |
253 |
+} |
254 |
+ |
255 |
+# We need to be able to set alternative headers for compiling for non-native |
256 |
+# platform. Will also become useful for testing kernel-headers without screwing |
257 |
+# up the whole system. |
258 |
+alt_headers() { |
259 |
+ echo ${ALT_HEADERS:=$(alt_prefix)/usr/include} |
260 |
+} |
261 |
+ |
262 |
+alt_build_headers() { |
263 |
+ if [[ -z ${ALT_BUILD_HEADERS} ]] ; then |
264 |
+ ALT_BUILD_HEADERS="$(host_eprefix)$(alt_headers)" |
265 |
+ if tc-is-cross-compiler ; then |
266 |
+ ALT_BUILD_HEADERS=${SYSROOT}$(alt_headers) |
267 |
+ if [[ ! -e ${ALT_BUILD_HEADERS}/linux/version.h ]] ; then |
268 |
+ local header_path=$(echo '#include <linux/version.h>' | $(tc-getCPP ${CTARGET}) ${CFLAGS} 2>&1 | grep -o '[^"]*linux/version.h') |
269 |
+ ALT_BUILD_HEADERS=${header_path%/linux/version.h} |
270 |
+ fi |
271 |
+ fi |
272 |
+ fi |
273 |
+ echo "${ALT_BUILD_HEADERS}" |
274 |
+} |
275 |
+ |
276 |
+alt_libdir() { |
277 |
+ echo $(alt_prefix)/$(get_libdir) |
278 |
+} |
279 |
+alt_usrlibdir() { |
280 |
+ echo $(alt_prefix)/usr/$(get_libdir) |
281 |
+} |
282 |
+ |
283 |
+builddir() { |
284 |
+ echo "${WORKDIR}/build-${ABI}-${CTARGET}-$1" |
285 |
+} |
286 |
+ |
287 |
+do_compile_test() { |
288 |
+ local ret save_cflags=${CFLAGS} |
289 |
+ CFLAGS+=" $1" |
290 |
+ shift |
291 |
+ |
292 |
+ pushd "${T}" >/dev/null |
293 |
+ |
294 |
+ rm -f glibc-test* |
295 |
+ printf '%b' "$*" > glibc-test.c |
296 |
+ |
297 |
+ # Most of the time CC is already set, but not in early sanity checks. |
298 |
+ nonfatal emake glibc-test CC="${CC-$(tc-getCC ${CTARGET})}" |
299 |
+ ret=$? |
300 |
+ |
301 |
+ popd >/dev/null |
302 |
+ |
303 |
+ CFLAGS=${save_cflags} |
304 |
+ return ${ret} |
305 |
+} |
306 |
+ |
307 |
+do_run_test() { |
308 |
+ local ret |
309 |
+ |
310 |
+ if [[ ${MERGE_TYPE} == "binary" ]] ; then |
311 |
+ # ignore build failures when installing a binary package #324685 |
312 |
+ do_compile_test "" "$@" 2>/dev/null || return 0 |
313 |
+ else |
314 |
+ if ! do_compile_test "" "$@" ; then |
315 |
+ ewarn "Simple build failed ... assuming this is desired #324685" |
316 |
+ return 0 |
317 |
+ fi |
318 |
+ fi |
319 |
+ |
320 |
+ pushd "${T}" >/dev/null |
321 |
+ |
322 |
+ ./glibc-test |
323 |
+ ret=$? |
324 |
+ rm -f glibc-test* |
325 |
+ |
326 |
+ popd >/dev/null |
327 |
+ |
328 |
+ return ${ret} |
329 |
+} |
330 |
+ |
331 |
+setup_target_flags() { |
332 |
+ # This largely mucks with compiler flags. None of which should matter |
333 |
+ # when building up just the headers. |
334 |
+ just_headers && return 0 |
335 |
+ |
336 |
+ case $(tc-arch) in |
337 |
+ x86) |
338 |
+ # -march needed for #185404 #199334 |
339 |
+ # TODO: When creating the first glibc cross-compile, this test will |
340 |
+ # always fail as it does a full link which in turn requires glibc. |
341 |
+ # Probably also applies when changing multilib profile settings (e.g. |
342 |
+ # enabling x86 when the profile was amd64-only previously). |
343 |
+ # We could change main to _start and pass -nostdlib here so that we |
344 |
+ # only test the gcc code compilation. Or we could do a compile and |
345 |
+ # then look for the symbol via scanelf. |
346 |
+ 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 |
347 |
+ local t=${CTARGET_OPT:-${CTARGET}} |
348 |
+ t=${t%%-*} |
349 |
+ filter-flags '-march=*' |
350 |
+ export CFLAGS="-march=${t} ${CFLAGS}" |
351 |
+ einfo "Auto adding -march=${t} to CFLAGS #185404" |
352 |
+ fi |
353 |
+ ;; |
354 |
+ amd64) |
355 |
+ # -march needed for #185404 #199334 |
356 |
+ # TODO: See cross-compile issues listed above for x86. |
357 |
+ [[ ${ABI} == x86 ]] && |
358 |
+ 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 |
359 |
+ local t=${CTARGET_OPT:-${CTARGET}} |
360 |
+ t=${t%%-*} |
361 |
+ # Normally the target is x86_64-xxx, so turn that into the -march that |
362 |
+ # gcc actually accepts. #528708 |
363 |
+ [[ ${t} == "x86_64" ]] && t="x86-64" |
364 |
+ filter-flags '-march=*' |
365 |
+ # ugly, ugly, ugly. ugly. |
366 |
+ CFLAGS_x86=$(CFLAGS=${CFLAGS_x86} filter-flags '-march=*'; echo "${CFLAGS}") |
367 |
+ export CFLAGS_x86="${CFLAGS_x86} -march=${t}" |
368 |
+ einfo "Auto adding -march=${t} to CFLAGS_x86 #185404 (ABI=${ABI})" |
369 |
+ fi |
370 |
+ |
371 |
+ # Workaround for https://bugs.gentoo.org/823780. This really should |
372 |
+ # be removed when the upstream bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103275 |
373 |
+ # is fixed in our tree, either via 11.3 or an 11.2p2 patch set. |
374 |
+ if [[ ${ABI} == x86 ]] && tc-is-gcc && (($(gcc-major-version) == 11)) && (($(gcc-minor-version) <= 2)) && (($(gcc-micro-version) == 0)); then |
375 |
+ export CFLAGS_x86="${CFLAGS_x86} -mno-avx512f" |
376 |
+ einfo "Auto adding -mno-avx512f to CFLAGS_x86 (bug #823780) (ABI=${ABI})" |
377 |
+ fi |
378 |
+ ;; |
379 |
+ mips) |
380 |
+ # The mips abi cannot support the GNU style hashes. #233233 |
381 |
+ filter-ldflags -Wl,--hash-style=gnu -Wl,--hash-style=both |
382 |
+ ;; |
383 |
+ ppc|ppc64) |
384 |
+ # Many arch-specific implementations do not work on ppc with |
385 |
+ # cache-block not equal to 128 bytes. This breaks memset: |
386 |
+ # https://sourceware.org/PR26522 |
387 |
+ # https://bugs.gentoo.org/737996 |
388 |
+ # Use default -mcpu=. For ppc it means non-multiarch setup. |
389 |
+ filter-flags '-mcpu=*' |
390 |
+ ;; |
391 |
+ sparc) |
392 |
+ # Both sparc and sparc64 can use -fcall-used-g6. -g7 is bad, though. |
393 |
+ filter-flags "-fcall-used-g7" |
394 |
+ append-flags "-fcall-used-g6" |
395 |
+ |
396 |
+ local cpu |
397 |
+ case ${CTARGET} in |
398 |
+ sparc64-*) |
399 |
+ cpu="sparc64" |
400 |
+ case $(get-flag mcpu) in |
401 |
+ v9) |
402 |
+ # We need to force at least v9a because the base build doesn't |
403 |
+ # work with just v9. |
404 |
+ # https://sourceware.org/bugzilla/show_bug.cgi?id=19477 |
405 |
+ append-flags "-Wa,-xarch=v9a" |
406 |
+ ;; |
407 |
+ esac |
408 |
+ ;; |
409 |
+ sparc-*) |
410 |
+ case $(get-flag mcpu) in |
411 |
+ v8|supersparc|hypersparc|leon|leon3) |
412 |
+ cpu="sparcv8" |
413 |
+ ;; |
414 |
+ *) |
415 |
+ cpu="sparcv9" |
416 |
+ ;; |
417 |
+ esac |
418 |
+ ;; |
419 |
+ esac |
420 |
+ [[ -n ${cpu} ]] && CTARGET_OPT="${cpu}-${CTARGET#*-}" |
421 |
+ ;; |
422 |
+ esac |
423 |
+} |
424 |
+ |
425 |
+setup_flags() { |
426 |
+ # Make sure host make.conf doesn't pollute us |
427 |
+ if is_crosscompile || tc-is-cross-compiler ; then |
428 |
+ CHOST=${CTARGET} strip-unsupported-flags |
429 |
+ fi |
430 |
+ |
431 |
+ # Store our CFLAGS because it's changed depending on which CTARGET |
432 |
+ # we are building when pulling glibc on a multilib profile |
433 |
+ CFLAGS_BASE=${CFLAGS_BASE-${CFLAGS}} |
434 |
+ CFLAGS=${CFLAGS_BASE} |
435 |
+ CXXFLAGS_BASE=${CXXFLAGS_BASE-${CXXFLAGS}} |
436 |
+ CXXFLAGS=${CXXFLAGS_BASE} |
437 |
+ ASFLAGS_BASE=${ASFLAGS_BASE-${ASFLAGS}} |
438 |
+ ASFLAGS=${ASFLAGS_BASE} |
439 |
+ |
440 |
+ # Allow users to explicitly avoid flag sanitization via |
441 |
+ # USE=custom-cflags. |
442 |
+ if ! use custom-cflags; then |
443 |
+ # Over-zealous CFLAGS can often cause problems. What may work for one |
444 |
+ # person may not work for another. To avoid a large influx of bugs |
445 |
+ # relating to failed builds, we strip most CFLAGS out to ensure as few |
446 |
+ # problems as possible. |
447 |
+ strip-flags |
448 |
+ # Lock glibc at -O2; we want to be conservative here. |
449 |
+ filter-flags '-O?' |
450 |
+ append-flags -O2 |
451 |
+ fi |
452 |
+ |
453 |
+ strip-unsupported-flags |
454 |
+ filter-flags -m32 -m64 '-mabi=*' |
455 |
+ |
456 |
+ # glibc aborts if rpath is set by LDFLAGS |
457 |
+ filter-ldflags '-Wl,-rpath=*' |
458 |
+ |
459 |
+ # ld can't use -r & --relax at the same time, bug #788901 |
460 |
+ # https://sourceware.org/PR27837 |
461 |
+ filter-ldflags '-Wl,--relax' |
462 |
+ |
463 |
+ # #492892 |
464 |
+ filter-flags -frecord-gcc-switches |
465 |
+ |
466 |
+ # #829583 |
467 |
+ filter-lfs-flags |
468 |
+ |
469 |
+ unset CBUILD_OPT CTARGET_OPT |
470 |
+ if use multilib ; then |
471 |
+ CTARGET_OPT=$(get_abi_CTARGET) |
472 |
+ [[ -z ${CTARGET_OPT} ]] && CTARGET_OPT=$(get_abi_CHOST) |
473 |
+ fi |
474 |
+ |
475 |
+ setup_target_flags |
476 |
+ |
477 |
+ if [[ -n ${CTARGET_OPT} && ${CBUILD} == ${CHOST} ]] && ! is_crosscompile; then |
478 |
+ CBUILD_OPT=${CTARGET_OPT} |
479 |
+ fi |
480 |
+ |
481 |
+ # glibc's headers disallow -O0 and fail at build time: |
482 |
+ # include/libc-symbols.h:75:3: #error "glibc cannot be compiled without optimization" |
483 |
+ replace-flags -O0 -O1 |
484 |
+ |
485 |
+ filter-flags '-fstack-protector*' |
486 |
+} |
487 |
+ |
488 |
+use_multiarch() { |
489 |
+ # Allow user to disable runtime arch detection in multilib. |
490 |
+ use multiarch || return 1 |
491 |
+ # Make sure binutils is new enough to support indirect functions, |
492 |
+ # #336792. This funky sed supports gold and bfd linkers. |
493 |
+ local bver nver |
494 |
+ bver=$($(tc-getLD ${CTARGET}) -v | sed -n -r '1{s:[^0-9]*::;s:^([0-9.]*).*:\1:;p}') |
495 |
+ case $(tc-arch ${CTARGET}) in |
496 |
+ amd64|x86) nver="2.20" ;; |
497 |
+ arm) nver="2.22" ;; |
498 |
+ hppa) nver="2.23" ;; |
499 |
+ ppc|ppc64) nver="2.20" ;; |
500 |
+ # ifunc support was added in 2.23, but glibc also needs |
501 |
+ # machinemode which is in 2.24. |
502 |
+ s390) nver="2.24" ;; |
503 |
+ sparc) nver="2.21" ;; |
504 |
+ *) return 1 ;; |
505 |
+ esac |
506 |
+ ver_test ${bver} -ge ${nver} |
507 |
+} |
508 |
+ |
509 |
+# Setup toolchain variables that had historically been defined in the |
510 |
+# profiles for these archs. |
511 |
+setup_env() { |
512 |
+ # silly users |
513 |
+ unset LD_RUN_PATH |
514 |
+ unset LD_ASSUME_KERNEL |
515 |
+ |
516 |
+ if is_crosscompile || tc-is-cross-compiler ; then |
517 |
+ multilib_env ${CTARGET_OPT:-${CTARGET}} |
518 |
+ |
519 |
+ if ! use multilib ; then |
520 |
+ MULTILIB_ABIS=${DEFAULT_ABI} |
521 |
+ else |
522 |
+ MULTILIB_ABIS=${MULTILIB_ABIS:-${DEFAULT_ABI}} |
523 |
+ fi |
524 |
+ |
525 |
+ # If the user has CFLAGS_<CTARGET> in their make.conf, use that, |
526 |
+ # and fall back on CFLAGS. |
527 |
+ local VAR=CFLAGS_${CTARGET//[-.]/_} |
528 |
+ CFLAGS=${!VAR-${CFLAGS}} |
529 |
+ einfo " $(printf '%15s' 'Manual CFLAGS:') ${CFLAGS}" |
530 |
+ fi |
531 |
+ |
532 |
+ setup_flags |
533 |
+ |
534 |
+ export ABI=${ABI:-${DEFAULT_ABI:-default}} |
535 |
+ |
536 |
+ if just_headers ; then |
537 |
+ # Avoid mixing host's CC and target's CFLAGS_${ABI}: |
538 |
+ # At this bootstrap stage we have only binutils for |
539 |
+ # target but not compiler yet. |
540 |
+ einfo "Skip CC ABI injection. We can't use (cross-)compiler yet." |
541 |
+ return 0 |
542 |
+ fi |
543 |
+ |
544 |
+ # Glibc does not work with gold (for various reasons) #269274. |
545 |
+ tc-ld-disable-gold |
546 |
+ |
547 |
+ if use doc ; then |
548 |
+ export MAKEINFO=makeinfo |
549 |
+ else |
550 |
+ export MAKEINFO=/dev/null |
551 |
+ fi |
552 |
+ |
553 |
+ # Reset CC and CXX to the value at start of emerge |
554 |
+ export CC=${__ORIG_CC:-${CC:-$(tc-getCC ${CTARGET})}} |
555 |
+ export CXX=${__ORIG_CXX:-${CXX:-$(tc-getCXX ${CTARGET})}} |
556 |
+ |
557 |
+ # and make sure __ORIC_CC and __ORIG_CXX is defined now. |
558 |
+ export __ORIG_CC=${CC} |
559 |
+ export __ORIG_CXX=${CXX} |
560 |
+ |
561 |
+ if tc-is-clang && ! use custom-cflags && ! is_crosscompile ; then |
562 |
+ |
563 |
+ # If we are running in an otherwise clang/llvm environment, we need to |
564 |
+ # recover the proper gcc and binutils settings here, at least until glibc |
565 |
+ # is finally building with clang. So let's override everything that is |
566 |
+ # set in the clang profiles. |
567 |
+ # Want to shoot yourself into the foot? Set USE=custom-cflags, that's always |
568 |
+ # a good start into that direction. |
569 |
+ # Also, if you're crosscompiling, let's assume you know what you are doing. |
570 |
+ # Hopefully. |
571 |
+ # Last, we need the settings of the *build* environment, not of the |
572 |
+ # target environment... |
573 |
+ |
574 |
+ local current_binutils_path=$(env ROOT="${BROOT}" binutils-config -B) |
575 |
+ local current_gcc_path=$(env ROOT="${BROOT}" gcc-config -B) |
576 |
+ einfo "Overriding clang configuration, since it won't work here" |
577 |
+ |
578 |
+ export CC="${current_gcc_path}/gcc" |
579 |
+ export CXX="${current_gcc_path}/g++" |
580 |
+ export LD="${current_binutils_path}/ld.bfd" |
581 |
+ export AR="${current_binutils_path}/ar" |
582 |
+ export AS="${current_binutils_path}/as" |
583 |
+ export NM="${current_binutils_path}/nm" |
584 |
+ export STRIP="${current_binutils_path}/strip" |
585 |
+ export RANLIB="${current_binutils_path}/ranlib" |
586 |
+ export OBJCOPY="${current_binutils_path}/objcopy" |
587 |
+ export STRINGS="${current_binutils_path}/strings" |
588 |
+ export OBJDUMP="${current_binutils_path}/objdump" |
589 |
+ export READELF="${current_binutils_path}/readelf" |
590 |
+ export ADDR2LINE="${current_binutils_path}/addr2line" |
591 |
+ |
592 |
+ # do we need to also do flags munging here? yes! at least... |
593 |
+ filter-flags '-fuse-ld=*' |
594 |
+ filter-flags '-D_FORTIFY_SOURCE=*' |
595 |
+ |
596 |
+ else |
597 |
+ |
598 |
+ # this is the "normal" case |
599 |
+ |
600 |
+ export CC="$(tc-getCC ${CTARGET})" |
601 |
+ export CXX="$(tc-getCXX ${CTARGET})" |
602 |
+ |
603 |
+ # Always use tuple-prefixed toolchain. For non-native ABI glibc's configure |
604 |
+ # can't detect them automatically due to ${CHOST} mismatch and fallbacks |
605 |
+ # to unprefixed tools. Similar to multilib.eclass:multilib_toolchain_setup(). |
606 |
+ export NM="$(tc-getNM ${CTARGET})" |
607 |
+ export READELF="$(tc-getREADELF ${CTARGET})" |
608 |
+ |
609 |
+ fi |
610 |
+ |
611 |
+ # We need to export CFLAGS with abi information in them because glibc's |
612 |
+ # configure script checks CFLAGS for some targets (like mips). Keep |
613 |
+ # around the original clean value to avoid appending multiple ABIs on |
614 |
+ # top of each other. (Why does the comment talk about CFLAGS if the code |
615 |
+ # acts on CC?) |
616 |
+ export __GLIBC_CC=${CC} |
617 |
+ export __GLIBC_CXX=${CXX} |
618 |
+ |
619 |
+ export __abi_CFLAGS="$(get_abi_CFLAGS)" |
620 |
+ |
621 |
+ # CFLAGS can contain ABI-specific flags like -mfpu=neon, see bug #657760 |
622 |
+ # To build .S (assembly) files with the same ABI-specific flags |
623 |
+ # upstream currently recommends adding CFLAGS to CC/CXX: |
624 |
+ # https://sourceware.org/PR23273 |
625 |
+ # Note: Passing CFLAGS via CPPFLAGS overrides glibc's arch-specific CFLAGS |
626 |
+ # and breaks multiarch support. See 659030#c3 for an example. |
627 |
+ # The glibc configure script doesn't properly use LDFLAGS all the time. |
628 |
+ export CC="${__GLIBC_CC} ${__abi_CFLAGS} ${CFLAGS} ${LDFLAGS}" |
629 |
+ |
630 |
+ # Some of the tests are written in C++, so we need to force our multlib abis in, bug 623548 |
631 |
+ export CXX="${__GLIBC_CXX} ${__abi_CFLAGS} ${CFLAGS}" |
632 |
+ |
633 |
+ if is_crosscompile; then |
634 |
+ # Assume worst-case bootstrap: glibc is buil first time |
635 |
+ # when ${CTARGET}-g++ is not available yet. We avoid |
636 |
+ # building auxiliary programs that require C++: bug #683074 |
637 |
+ # It should not affect final result. |
638 |
+ export libc_cv_cxx_link_ok=no |
639 |
+ # The line above has the same effect. We set CXX explicitly |
640 |
+ # to make build logs less confusing. |
641 |
+ export CXX= |
642 |
+ fi |
643 |
+} |
644 |
+ |
645 |
+foreach_abi() { |
646 |
+ setup_env |
647 |
+ |
648 |
+ local ret=0 |
649 |
+ local abilist="" |
650 |
+ if use multilib ; then |
651 |
+ abilist=$(get_install_abis) |
652 |
+ else |
653 |
+ abilist=${DEFAULT_ABI} |
654 |
+ fi |
655 |
+ local -x ABI |
656 |
+ for ABI in ${abilist:-default} ; do |
657 |
+ setup_env |
658 |
+ einfo "Running $1 for ABI ${ABI}" |
659 |
+ $1 |
660 |
+ : $(( ret |= $? )) |
661 |
+ done |
662 |
+ return ${ret} |
663 |
+} |
664 |
+ |
665 |
+glibc_banner() { |
666 |
+ local b="Gentoo ${PVR}" |
667 |
+ [[ -n ${PATCH_VER} ]] && ! use vanilla && b+=" p${PATCH_VER}" |
668 |
+ echo "${b}" |
669 |
+} |
670 |
+ |
671 |
+# The following Kernel version handling functions are mostly copied from portage |
672 |
+# source. It's better not to use linux-info.eclass here since a) it adds too |
673 |
+# much magic, see bug 326693 for some of the arguments, and b) some of the |
674 |
+# functions are just not provided. |
675 |
+ |
676 |
+g_get_running_KV() { |
677 |
+ uname -r |
678 |
+ return $? |
679 |
+} |
680 |
+ |
681 |
+g_KV_major() { |
682 |
+ [[ -z $1 ]] && return 1 |
683 |
+ local KV=$@ |
684 |
+ echo "${KV%%.*}" |
685 |
+} |
686 |
+ |
687 |
+g_KV_minor() { |
688 |
+ [[ -z $1 ]] && return 1 |
689 |
+ local KV=$@ |
690 |
+ KV=${KV#*.} |
691 |
+ echo "${KV%%.*}" |
692 |
+} |
693 |
+ |
694 |
+g_KV_micro() { |
695 |
+ [[ -z $1 ]] && return 1 |
696 |
+ local KV=$@ |
697 |
+ KV=${KV#*.*.} |
698 |
+ echo "${KV%%[^[:digit:]]*}" |
699 |
+} |
700 |
+ |
701 |
+g_KV_to_int() { |
702 |
+ [[ -z $1 ]] && return 1 |
703 |
+ local KV_MAJOR=$(g_KV_major "$1") |
704 |
+ local KV_MINOR=$(g_KV_minor "$1") |
705 |
+ local KV_MICRO=$(g_KV_micro "$1") |
706 |
+ local KV_int=$(( KV_MAJOR * 65536 + KV_MINOR * 256 + KV_MICRO )) |
707 |
+ |
708 |
+ # We make version 2.2.0 the minimum version we will handle as |
709 |
+ # a sanity check ... if its less, we fail ... |
710 |
+ if [[ ${KV_int} -ge 131584 ]] ; then |
711 |
+ echo "${KV_int}" |
712 |
+ return 0 |
713 |
+ fi |
714 |
+ return 1 |
715 |
+} |
716 |
+ |
717 |
+g_int_to_KV() { |
718 |
+ local version=$1 major minor micro |
719 |
+ major=$((version / 65536)) |
720 |
+ minor=$(((version % 65536) / 256)) |
721 |
+ micro=$((version % 256)) |
722 |
+ echo ${major}.${minor}.${micro} |
723 |
+} |
724 |
+ |
725 |
+eend_KV() { |
726 |
+ [[ $(g_KV_to_int $1) -ge $(g_KV_to_int $2) ]] |
727 |
+ eend $? |
728 |
+} |
729 |
+ |
730 |
+get_kheader_version() { |
731 |
+ printf '#include <linux/version.h>\nLINUX_VERSION_CODE\n' | \ |
732 |
+ $(tc-getCPP ${CTARGET}) -I "$(build_eprefix)$(alt_build_headers)" - | \ |
733 |
+ tail -n 1 |
734 |
+} |
735 |
+ |
736 |
+# We collect all sanity checks here. Consistency is not guranteed between |
737 |
+# pkg_ and src_ phases, so we call this function both in pkg_pretend and in |
738 |
+# src_unpack. |
739 |
+sanity_prechecks() { |
740 |
+ # Prevent native builds from downgrading |
741 |
+ if [[ ${MERGE_TYPE} != "buildonly" ]] && \ |
742 |
+ [[ -z ${ROOT} ]] && \ |
743 |
+ [[ ${CBUILD} == ${CHOST} ]] && \ |
744 |
+ [[ ${CHOST} == ${CTARGET} ]] ; then |
745 |
+ |
746 |
+ # The high rev # is to allow people to downgrade between -r# |
747 |
+ # versions. We want to block 2.20->2.19, but 2.20-r3->2.20-r2 |
748 |
+ # should be fine. Hopefully we never actually use a r# this |
749 |
+ # high. |
750 |
+ if has_version ">${CATEGORY}/${P}-r10000" ; then |
751 |
+ eerror "Sanity check to keep you from breaking your system:" |
752 |
+ eerror " Downgrading glibc is not supported and a sure way to destruction." |
753 |
+ [[ ${I_ALLOW_TO_BREAK_MY_SYSTEM} = yes ]] || die "Aborting to save your system." |
754 |
+ fi |
755 |
+ |
756 |
+ if ! do_run_test '#include <unistd.h>\n#include <sys/syscall.h>\nint main(){return syscall(1000)!=-1;}\n' ; then |
757 |
+ eerror "Your old kernel is broken. You need to update it to a newer" |
758 |
+ eerror "version as syscall(<bignum>) will break. See bug 279260." |
759 |
+ die "Old and broken kernel." |
760 |
+ fi |
761 |
+ fi |
762 |
+ |
763 |
+ # Users have had a chance to phase themselves, time to give em the boot |
764 |
+ if [[ -e ${EROOT}/etc/locale.gen ]] && [[ -e ${EROOT}/etc/locales.build ]] ; then |
765 |
+ eerror "You still haven't deleted ${EROOT}/etc/locales.build." |
766 |
+ eerror "Do so now after making sure ${EROOT}/etc/locale.gen is kosher." |
767 |
+ die "Lazy upgrader detected" |
768 |
+ fi |
769 |
+ |
770 |
+ if [[ ${CTARGET} == i386-* ]] ; then |
771 |
+ eerror "i386 CHOSTs are no longer supported." |
772 |
+ eerror "Chances are you don't actually want/need i386." |
773 |
+ eerror "Please read https://www.gentoo.org/doc/en/change-chost.xml" |
774 |
+ die "Please fix your CHOST" |
775 |
+ fi |
776 |
+ |
777 |
+ if [[ -e /proc/xen ]] && [[ $(tc-arch) == "x86" ]] && ! is-flag -mno-tls-direct-seg-refs ; then |
778 |
+ ewarn "You are using Xen but don't have -mno-tls-direct-seg-refs in your CFLAGS." |
779 |
+ ewarn "This will result in a 50% performance penalty when running with a 32bit" |
780 |
+ ewarn "hypervisor, which is probably not what you want." |
781 |
+ fi |
782 |
+ |
783 |
+ # ABI-specific checks follow here. Hey, we have a lot more specific conditions that |
784 |
+ # we test for... |
785 |
+ if ! is_crosscompile ; then |
786 |
+ if use amd64 && use multilib && [[ ${MERGE_TYPE} != "binary" ]] ; then |
787 |
+ ebegin "Checking that IA32 emulation is enabled in the running kernel" |
788 |
+ echo 'int main(){return 0;}' > "${T}/check-ia32-emulation.c" |
789 |
+ local STAT |
790 |
+ if "${CC-${CHOST}-gcc}" ${CFLAGS_x86} "${T}/check-ia32-emulation.c" -o "${T}/check-ia32-emulation.elf32"; then |
791 |
+ "${T}/check-ia32-emulation.elf32" |
792 |
+ STAT=$? |
793 |
+ else |
794 |
+ # Don't fail here to allow single->multi ABI switch |
795 |
+ # or recover from breakage like bug #646424 |
796 |
+ ewarn "Failed to compile the ABI test. Broken host glibc?" |
797 |
+ STAT=0 |
798 |
+ fi |
799 |
+ rm -f "${T}/check-ia32-emulation.elf32" |
800 |
+ eend $STAT |
801 |
+ [[ $STAT -eq 0 ]] || die "CONFIG_IA32_EMULATION must be enabled in the kernel to compile a multilib glibc." |
802 |
+ fi |
803 |
+ |
804 |
+ fi |
805 |
+ |
806 |
+ # When we actually have to compile something... |
807 |
+ if ! just_headers && [[ ${MERGE_TYPE} != "binary" ]] ; then |
808 |
+ if [[ -d "${ESYSROOT}"/usr/lib/include ]] ; then |
809 |
+ # bug #833620, bug #643302 |
810 |
+ eerror "Found ${ESYSROOT}/usr/lib/include directory!" |
811 |
+ eerror "This is known to break glibc's build." |
812 |
+ eerror "Please backup its contents then remove the directory." |
813 |
+ die "Found directory (${ESYSROOT}/usr/lib/include) which will break build (bug #833620)!" |
814 |
+ fi |
815 |
+ |
816 |
+ if [[ ${CTARGET} == *-linux* ]] ; then |
817 |
+ local run_kv build_kv want_kv |
818 |
+ |
819 |
+ run_kv=$(g_get_running_KV) |
820 |
+ build_kv=$(g_int_to_KV $(get_kheader_version)) |
821 |
+ want_kv=${MIN_KERN_VER} |
822 |
+ |
823 |
+ if ! is_crosscompile && ! tc-is-cross-compiler ; then |
824 |
+ # Building fails on an non-supporting kernel |
825 |
+ ebegin "Checking running kernel version (${run_kv} >= ${want_kv})" |
826 |
+ if ! eend_KV ${run_kv} ${want_kv} ; then |
827 |
+ echo |
828 |
+ eerror "You need a kernel of at least ${want_kv}!" |
829 |
+ die "Kernel version too low!" |
830 |
+ fi |
831 |
+ fi |
832 |
+ |
833 |
+ ebegin "Checking linux-headers version (${build_kv} >= ${want_kv})" |
834 |
+ if ! eend_KV ${build_kv} ${want_kv} ; then |
835 |
+ echo |
836 |
+ eerror "You need linux-headers of at least ${want_kv}!" |
837 |
+ die "linux-headers version too low!" |
838 |
+ fi |
839 |
+ fi |
840 |
+ fi |
841 |
+} |
842 |
+ |
843 |
+upgrade_warning() { |
844 |
+ if [[ ${MERGE_TYPE} != buildonly && -n ${REPLACING_VERSIONS} && -z ${ROOT} ]]; then |
845 |
+ local oldv newv=$(ver_cut 1-2 ${PV}) |
846 |
+ for oldv in ${REPLACING_VERSIONS}; do |
847 |
+ if ver_test ${oldv} -lt ${newv}; then |
848 |
+ ewarn "After upgrading glibc, please restart all running processes." |
849 |
+ ewarn "Be sure to include init (telinit u) or systemd (systemctl daemon-reexec)." |
850 |
+ ewarn "Alternatively, reboot your system." |
851 |
+ ewarn "(See bug #660556, bug #741116, bug #823756, etc)" |
852 |
+ break |
853 |
+ fi |
854 |
+ done |
855 |
+ fi |
856 |
+} |
857 |
+ |
858 |
+# |
859 |
+# the phases |
860 |
+# |
861 |
+ |
862 |
+# pkg_pretend |
863 |
+ |
864 |
+pkg_pretend() { |
865 |
+ # All the checks... |
866 |
+ einfo "Checking general environment sanity." |
867 |
+ sanity_prechecks |
868 |
+ upgrade_warning |
869 |
+} |
870 |
+ |
871 |
+pkg_setup() { |
872 |
+ # see bug 682570 |
873 |
+ [[ -z ${BOOTSTRAP_RAP} ]] && python-any-r1_pkg_setup |
874 |
+} |
875 |
+ |
876 |
+# src_unpack |
877 |
+ |
878 |
+src_unpack() { |
879 |
+ # Consistency is not guaranteed between pkg_ and src_ ... |
880 |
+ sanity_prechecks |
881 |
+ |
882 |
+ use multilib-bootstrap && unpack gcc-multilib-bootstrap-${GCC_BOOTSTRAP_VER}.tar.xz |
883 |
+ |
884 |
+ setup_env |
885 |
+ |
886 |
+ if [[ ${PV} == 9999* ]] ; then |
887 |
+ EGIT_REPO_URI="https://anongit.gentoo.org/git/proj/toolchain/glibc-patches.git" |
888 |
+ EGIT_CHECKOUT_DIR=${WORKDIR}/patches-git |
889 |
+ git-r3_src_unpack |
890 |
+ mv patches-git/9999 patches || die |
891 |
+ |
892 |
+ EGIT_REPO_URI="https://sourceware.org/git/glibc.git" |
893 |
+ EGIT_CHECKOUT_DIR=${S} |
894 |
+ git-r3_src_unpack |
895 |
+ else |
896 |
+ unpack ${P}.tar.xz |
897 |
+ |
898 |
+ cd "${WORKDIR}" || die |
899 |
+ unpack glibc-${RELEASE_VER}-patches-${PATCH_VER}.tar.xz |
900 |
+ fi |
901 |
+ |
902 |
+ cd "${WORKDIR}" || die |
903 |
+ unpack locale-gen-${LOCALE_GEN_VER}.tar.gz |
904 |
+ use systemd && unpack glibc-systemd-${GLIBC_SYSTEMD_VER}.tar.gz |
905 |
+} |
906 |
+ |
907 |
+src_prepare() { |
908 |
+ local patchsetname |
909 |
+ if ! use vanilla ; then |
910 |
+ if [[ ${PV} == 9999* ]] ; then |
911 |
+ patchsetname="from git master" |
912 |
+ else |
913 |
+ patchsetname="${RELEASE_VER}-${PATCH_VER}" |
914 |
+ fi |
915 |
+ einfo "Applying Gentoo Glibc Patchset ${patchsetname}" |
916 |
+ eapply "${WORKDIR}"/patches |
917 |
+ einfo "Done." |
918 |
+ fi |
919 |
+ |
920 |
+ if use clone3 ; then |
921 |
+ append-cppflags -DGENTOO_USE_CLONE3 |
922 |
+ else |
923 |
+ # See e.g. bug #827386, bug #819045. |
924 |
+ elog "Disabling the clone3 syscall for compatibility with older Electron apps." |
925 |
+ elog "Please re-enable this flag before filing bugs!" |
926 |
+ fi |
927 |
+ |
928 |
+ default |
929 |
+ |
930 |
+ gnuconfig_update |
931 |
+ |
932 |
+ cd "${WORKDIR}" |
933 |
+ find . -name configure -exec touch {} + |
934 |
+ |
935 |
+ # move the external locale-gen to its old place |
936 |
+ mkdir extra || die |
937 |
+ mv locale-gen-${LOCALE_GEN_VER} extra/locale || die |
938 |
+ |
939 |
+ eprefixify extra/locale/locale-gen |
940 |
+ |
941 |
+ # Fix permissions on some of the scripts. |
942 |
+ chmod u+x "${S}"/scripts/*.sh |
943 |
+ |
944 |
+ cd "${S}" |
945 |
+} |
946 |
+ |
947 |
+glibc_do_configure() { |
948 |
+ |
949 |
+ local v |
950 |
+ 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 |
951 |
+ einfo " $(printf '%15s' ${v}:) ${!v}" |
952 |
+ done |
953 |
+ |
954 |
+ echo |
955 |
+ local myconf=() |
956 |
+ |
957 |
+ case ${CTARGET} in |
958 |
+ m68k*) |
959 |
+ # setjmp() is not compatible with stack protection: |
960 |
+ # https://sourceware.org/PR24202 |
961 |
+ myconf+=( --enable-stack-protector=no ) |
962 |
+ ;; |
963 |
+ *) |
964 |
+ # Use '=strong' instead of '=all' to protect only functions |
965 |
+ # worth protecting from stack smashes. |
966 |
+ # '=all' is also known to have a problem in IFUNC resolution |
967 |
+ # tests: https://sourceware.org/PR25680, bug #712356. |
968 |
+ myconf+=( --enable-stack-protector=$(usex ssp strong no) ) |
969 |
+ ;; |
970 |
+ esac |
971 |
+ myconf+=( --enable-stackguard-randomization ) |
972 |
+ |
973 |
+ # Keep a whitelist of targets supporing IFUNC. glibc's ./configure |
974 |
+ # is not robust enough to detect proper support: |
975 |
+ # https://bugs.gentoo.org/641216 |
976 |
+ # https://sourceware.org/PR22634#c0 |
977 |
+ case $(tc-arch ${CTARGET}) in |
978 |
+ # Keep whitelist of targets where autodetection mostly works. |
979 |
+ amd64|x86|sparc|ppc|ppc64|arm|arm64|s390) ;; |
980 |
+ # Blacklist everywhere else |
981 |
+ *) myconf+=( libc_cv_ld_gnu_indirect_function=no ) ;; |
982 |
+ esac |
983 |
+ |
984 |
+ # Enable Intel Control-flow Enforcement Technology on amd64 if requested |
985 |
+ case ${CTARGET} in |
986 |
+ x86_64-*) myconf+=( $(use_enable cet) ) ;; |
987 |
+ *) ;; |
988 |
+ esac |
989 |
+ |
990 |
+ [[ $(tc-is-softfloat) == "yes" ]] && myconf+=( --without-fp ) |
991 |
+ |
992 |
+ myconf+=( --enable-kernel=${MIN_KERN_VER} ) |
993 |
+ |
994 |
+ # Since SELinux support is only required for nscd, only enable it if: |
995 |
+ # 1. USE selinux |
996 |
+ # 2. only for the primary ABI on multilib systems |
997 |
+ # 3. Not a crosscompile |
998 |
+ if ! is_crosscompile && use selinux ; then |
999 |
+ if use multilib ; then |
1000 |
+ if is_final_abi ; then |
1001 |
+ myconf+=( --with-selinux ) |
1002 |
+ else |
1003 |
+ myconf+=( --without-selinux ) |
1004 |
+ fi |
1005 |
+ else |
1006 |
+ myconf+=( --with-selinux ) |
1007 |
+ fi |
1008 |
+ else |
1009 |
+ myconf+=( --without-selinux ) |
1010 |
+ fi |
1011 |
+ |
1012 |
+ # Force a few tests where we always know the answer but |
1013 |
+ # configure is incapable of finding it. |
1014 |
+ if is_crosscompile ; then |
1015 |
+ export \ |
1016 |
+ libc_cv_c_cleanup=yes \ |
1017 |
+ libc_cv_forced_unwind=yes |
1018 |
+ fi |
1019 |
+ |
1020 |
+ myconf+=( |
1021 |
+ --without-cvs |
1022 |
+ --disable-werror |
1023 |
+ --enable-bind-now |
1024 |
+ --build=${CBUILD_OPT:-${CBUILD}} |
1025 |
+ --host=${CTARGET_OPT:-${CTARGET}} |
1026 |
+ $(use_enable profile) |
1027 |
+ $(use_with gd) |
1028 |
+ --with-headers=$(build_eprefix)$(alt_build_headers) |
1029 |
+ --prefix="$(host_eprefix)/usr" |
1030 |
+ --sysconfdir="$(host_eprefix)/etc" |
1031 |
+ --localstatedir="$(host_eprefix)/var" |
1032 |
+ --libdir='$(prefix)'/$(get_libdir) |
1033 |
+ --mandir='$(prefix)'/share/man |
1034 |
+ --infodir='$(prefix)'/share/info |
1035 |
+ --libexecdir='$(libdir)'/misc/glibc |
1036 |
+ --with-bugurl=https://bugs.gentoo.org/ |
1037 |
+ --with-pkgversion="$(glibc_banner)" |
1038 |
+ $(use_enable crypt) |
1039 |
+ $(use_multiarch || echo --disable-multi-arch) |
1040 |
+ $(use_enable static-pie) |
1041 |
+ $(use_enable systemtap) |
1042 |
+ $(use_enable nscd) |
1043 |
+ |
1044 |
+ # locale data is arch-independent |
1045 |
+ # https://bugs.gentoo.org/753740 |
1046 |
+ libc_cv_complocaledir='${exec_prefix}/lib/locale' |
1047 |
+ |
1048 |
+ # -march= option tricks build system to infer too |
1049 |
+ # high ISA level: https://sourceware.org/PR27318 |
1050 |
+ libc_cv_include_x86_isa_level=no |
1051 |
+ # Explicit override of https://sourceware.org/PR27991 |
1052 |
+ # exposes a bug in glibc's configure: |
1053 |
+ # https://sourceware.org/PR27991 |
1054 |
+ libc_cv_have_x86_lahf_sahf=no |
1055 |
+ libc_cv_have_x86_movbe=no |
1056 |
+ |
1057 |
+ ${EXTRA_ECONF} |
1058 |
+ ) |
1059 |
+ |
1060 |
+ # We rely on sys-libs/timezone-data for timezone tools normally. |
1061 |
+ myconf+=( $(use_enable vanilla timezone-tools) ) |
1062 |
+ |
1063 |
+ # These libs don't have configure flags. |
1064 |
+ ac_cv_lib_audit_audit_log_user_avc_message=$(usex audit || echo no) |
1065 |
+ ac_cv_lib_cap_cap_init=$(usex caps || echo no) |
1066 |
+ |
1067 |
+ # There is no configure option for this and we need to export it |
1068 |
+ # since the glibc build will re-run configure on itself |
1069 |
+ export libc_cv_rootsbindir="$(host_eprefix)/sbin" |
1070 |
+ export libc_cv_slibdir="$(host_eprefix)/$(get_libdir)" |
1071 |
+ |
1072 |
+ # We take care of patching our binutils to use both hash styles, |
1073 |
+ # and many people like to force gnu hash style only, so disable |
1074 |
+ # this overriding check. #347761 |
1075 |
+ export libc_cv_hashstyle=no |
1076 |
+ |
1077 |
+ local builddir=$(builddir nptl) |
1078 |
+ mkdir -p "${builddir}" |
1079 |
+ cd "${builddir}" |
1080 |
+ set -- "${S}"/configure "${myconf[@]}" |
1081 |
+ echo "$@" |
1082 |
+ "$@" || die "failed to configure glibc" |
1083 |
+ |
1084 |
+ # ia64 static cross-compilers are a pita in so much that they |
1085 |
+ # can't produce static ELFs (as the libgcc.a is broken). so |
1086 |
+ # disable building of the programs for those targets if it |
1087 |
+ # doesn't work. |
1088 |
+ # XXX: We could turn this into a compiler test, but ia64 is |
1089 |
+ # the only one that matters, so this should be fine for now. |
1090 |
+ if is_crosscompile && [[ ${CTARGET} == ia64* ]] ; then |
1091 |
+ sed -i '1i+link-static = touch $@' config.make |
1092 |
+ fi |
1093 |
+ |
1094 |
+ # If we're trying to migrate between ABI sets, we need |
1095 |
+ # to lie and use a local copy of gcc. Like if the system |
1096 |
+ # is built with MULTILIB_ABIS="amd64 x86" but we want to |
1097 |
+ # add x32 to it, gcc/glibc don't yet support x32. |
1098 |
+ # |
1099 |
+ if [[ -n ${GCC_BOOTSTRAP_VER} ]] && use multilib-bootstrap ; then |
1100 |
+ echo 'main(){}' > "${T}"/test.c |
1101 |
+ if ! $(tc-getCC ${CTARGET}) ${CFLAGS} ${LDFLAGS} "${T}"/test.c -Wl,-emain -lgcc 2>/dev/null ; then |
1102 |
+ sed -i -e '/^CC = /s:$: -B$(objdir)/../'"gcc-multilib-bootstrap-${GCC_BOOTSTRAP_VER}/${ABI}:" config.make || die |
1103 |
+ fi |
1104 |
+ fi |
1105 |
+} |
1106 |
+ |
1107 |
+glibc_headers_configure() { |
1108 |
+ export ABI=default |
1109 |
+ |
1110 |
+ local builddir=$(builddir "headers") |
1111 |
+ mkdir -p "${builddir}" |
1112 |
+ cd "${builddir}" |
1113 |
+ |
1114 |
+ # if we don't have a compiler yet, we can't really test it now ... |
1115 |
+ # hopefully they don't affect header generation, so let's hope for |
1116 |
+ # the best here ... |
1117 |
+ local v vars=( |
1118 |
+ ac_cv_header_cpuid_h=yes |
1119 |
+ libc_cv_{386,390,alpha,arm,hppa,ia64,mips,{powerpc,sparc}{,32,64},sh,x86_64}_tls=yes |
1120 |
+ libc_cv_asm_cfi_directives=yes |
1121 |
+ libc_cv_broken_visibility_attribute=no |
1122 |
+ libc_cv_c_cleanup=yes |
1123 |
+ libc_cv_compiler_powerpc64le_binary128_ok=yes |
1124 |
+ libc_cv_forced_unwind=yes |
1125 |
+ libc_cv_gcc___thread=yes |
1126 |
+ libc_cv_mlong_double_128=yes |
1127 |
+ libc_cv_mlong_double_128ibm=yes |
1128 |
+ libc_cv_ppc_machine=yes |
1129 |
+ libc_cv_ppc_rel16=yes |
1130 |
+ libc_cv_predef_fortify_source=no |
1131 |
+ libc_cv_target_power8_ok=yes |
1132 |
+ libc_cv_visibility_attribute=yes |
1133 |
+ libc_cv_z_combreloc=yes |
1134 |
+ libc_cv_z_execstack=yes |
1135 |
+ libc_cv_z_initfirst=yes |
1136 |
+ libc_cv_z_nodelete=yes |
1137 |
+ libc_cv_z_nodlopen=yes |
1138 |
+ libc_cv_z_relro=yes |
1139 |
+ libc_mips_abi=${ABI} |
1140 |
+ libc_mips_float=$([[ $(tc-is-softfloat) == "yes" ]] && echo soft || echo hard) |
1141 |
+ # These libs don't have configure flags. |
1142 |
+ ac_cv_lib_audit_audit_log_user_avc_message=no |
1143 |
+ ac_cv_lib_cap_cap_init=no |
1144 |
+ ) |
1145 |
+ |
1146 |
+ einfo "Forcing cached settings:" |
1147 |
+ for v in "${vars[@]}" ; do |
1148 |
+ einfo " ${v}" |
1149 |
+ export ${v} |
1150 |
+ done |
1151 |
+ |
1152 |
+ local headers_only_arch_CPPFLAGS=() |
1153 |
+ |
1154 |
+ # Blow away some random CC settings that screw things up. #550192 |
1155 |
+ if [[ -d ${S}/sysdeps/mips ]]; then |
1156 |
+ pushd "${S}"/sysdeps/mips >/dev/null |
1157 |
+ sed -i -e '/^CC +=/s:=.*:= -D_MIPS_SZPTR=32:' mips32/Makefile mips64/n32/Makefile || die |
1158 |
+ sed -i -e '/^CC +=/s:=.*:= -D_MIPS_SZPTR=64:' mips64/n64/Makefile || die |
1159 |
+ |
1160 |
+ # Force the mips ABI to the default. This is OK because the set of |
1161 |
+ # installed headers in this phase is the same between the 3 ABIs. |
1162 |
+ # If this ever changes, this hack will break, but that's unlikely |
1163 |
+ # as glibc discourages that behavior. |
1164 |
+ # https://crbug.com/647033 |
1165 |
+ sed -i -e 's:abiflag=.*:abiflag=_ABIO32:' preconfigure || die |
1166 |
+ |
1167 |
+ popd >/dev/null |
1168 |
+ fi |
1169 |
+ |
1170 |
+ case ${CTARGET} in |
1171 |
+ riscv*) |
1172 |
+ # RISC-V interrogates the compiler to determine which target to |
1173 |
+ # build. If building the headers then we don't strictly need a |
1174 |
+ # RISC-V compiler, so the built-in definitions that are provided |
1175 |
+ # along with all RISC-V compiler might not exist. This causes |
1176 |
+ # glibc's RISC-V preconfigure script to blow up. Since we're just |
1177 |
+ # building the headers any value will actually work here, so just |
1178 |
+ # pick the standard one (rv64g/lp64d) to make the build scripts |
1179 |
+ # happy for now -- the headers are all the same anyway so it |
1180 |
+ # doesn't matter. |
1181 |
+ headers_only_arch_CPPFLAGS+=( |
1182 |
+ -D__riscv_xlen=64 |
1183 |
+ -D__riscv_flen=64 |
1184 |
+ -D__riscv_float_abi_double=1 |
1185 |
+ -D__riscv_atomic=1 |
1186 |
+ ) ;; |
1187 |
+ esac |
1188 |
+ |
1189 |
+ local myconf=() |
1190 |
+ myconf+=( |
1191 |
+ --disable-sanity-checks |
1192 |
+ --enable-hacker-mode |
1193 |
+ --without-cvs |
1194 |
+ --disable-werror |
1195 |
+ --enable-bind-now |
1196 |
+ --build=${CBUILD_OPT:-${CBUILD}} |
1197 |
+ --host=${CTARGET_OPT:-${CTARGET}} |
1198 |
+ --with-headers=$(build_eprefix)$(alt_build_headers) |
1199 |
+ --prefix="$(host_eprefix)/usr" |
1200 |
+ ${EXTRA_ECONF} |
1201 |
+ ) |
1202 |
+ |
1203 |
+ # Nothing is compiled here which would affect the headers for the target. |
1204 |
+ # So forcing CC/CFLAGS is sane. |
1205 |
+ local headers_only_CC=$(tc-getBUILD_CC) |
1206 |
+ local headers_only_CFLAGS="-O1 -pipe" |
1207 |
+ local headers_only_CPPFLAGS="-U_FORTIFY_SOURCE ${headers_only_arch_CPPFLAGS[*]}" |
1208 |
+ local headers_only_LDFLAGS="" |
1209 |
+ set -- "${S}"/configure "${myconf[@]}" |
1210 |
+ echo \ |
1211 |
+ "CC=${headers_only_CC}" \ |
1212 |
+ "CFLAGS=${headers_only_CFLAGS}" \ |
1213 |
+ "CPPFLAGS=${headers_only_CPPFLAGS}" \ |
1214 |
+ "LDFLAGS=${headers_only_LDFLAGS}" \ |
1215 |
+ "$@" |
1216 |
+ CC=${headers_only_CC} \ |
1217 |
+ CFLAGS=${headers_only_CFLAGS} \ |
1218 |
+ CPPFLAGS=${headers_only_CPPFLAGS} \ |
1219 |
+ LDFLAGS="" \ |
1220 |
+ "$@" || die "failed to configure glibc" |
1221 |
+} |
1222 |
+ |
1223 |
+do_src_configure() { |
1224 |
+ if just_headers ; then |
1225 |
+ glibc_headers_configure |
1226 |
+ else |
1227 |
+ glibc_do_configure nptl |
1228 |
+ fi |
1229 |
+} |
1230 |
+ |
1231 |
+src_configure() { |
1232 |
+ foreach_abi do_src_configure |
1233 |
+} |
1234 |
+ |
1235 |
+do_src_compile() { |
1236 |
+ emake -C "$(builddir nptl)" |
1237 |
+} |
1238 |
+ |
1239 |
+src_compile() { |
1240 |
+ if just_headers ; then |
1241 |
+ return |
1242 |
+ fi |
1243 |
+ |
1244 |
+ foreach_abi do_src_compile |
1245 |
+} |
1246 |
+ |
1247 |
+glibc_src_test() { |
1248 |
+ cd "$(builddir nptl)" |
1249 |
+ |
1250 |
+ local myxfailparams="" |
1251 |
+ if [[ "${GENTOO_GLIBC_XFAIL_TESTS}" == "yes" ]] ; then |
1252 |
+ for myt in ${XFAIL_TEST_LIST[@]} ; do |
1253 |
+ myxfailparams+="test-xfail-${myt}=yes " |
1254 |
+ done |
1255 |
+ fi |
1256 |
+ |
1257 |
+ # sandbox does not understand unshare() and prevents |
1258 |
+ # writes to /proc/, which makes many tests fail |
1259 |
+ |
1260 |
+ SANDBOX_ON=0 LD_PRELOAD= emake ${myxfailparams} check |
1261 |
+} |
1262 |
+ |
1263 |
+do_src_test() { |
1264 |
+ local ret=0 |
1265 |
+ |
1266 |
+ glibc_src_test |
1267 |
+ : $(( ret |= $? )) |
1268 |
+ |
1269 |
+ return ${ret} |
1270 |
+} |
1271 |
+ |
1272 |
+src_test() { |
1273 |
+ if just_headers ; then |
1274 |
+ return |
1275 |
+ fi |
1276 |
+ |
1277 |
+ # Give tests more time to complete. |
1278 |
+ export TIMEOUTFACTOR=5 |
1279 |
+ |
1280 |
+ foreach_abi do_src_test || die "tests failed" |
1281 |
+} |
1282 |
+ |
1283 |
+run_locale_gen() { |
1284 |
+ # if the host locales.gen contains no entries, we'll install everything |
1285 |
+ local root="$1" |
1286 |
+ local inplace="" |
1287 |
+ |
1288 |
+ if [[ "${root}" == "--inplace-glibc" ]] ; then |
1289 |
+ inplace="--inplace-glibc" |
1290 |
+ root="$2" |
1291 |
+ fi |
1292 |
+ |
1293 |
+ local locale_list="${root%/}/etc/locale.gen" |
1294 |
+ |
1295 |
+ pushd "${ED}"/$(get_libdir) >/dev/null |
1296 |
+ |
1297 |
+ if [[ -z $(locale-gen --list --config "${locale_list}") ]] ; then |
1298 |
+ [[ -z ${inplace} ]] && ewarn "Generating all locales; edit /etc/locale.gen to save time/space" |
1299 |
+ locale_list="${root%/}/usr/share/i18n/SUPPORTED" |
1300 |
+ fi |
1301 |
+ |
1302 |
+ set -- locale-gen ${inplace} --jobs $(makeopts_jobs) --config "${locale_list}" \ |
1303 |
+ --destdir "${root}" |
1304 |
+ echo "$@" |
1305 |
+ "$@" |
1306 |
+ |
1307 |
+ popd >/dev/null |
1308 |
+} |
1309 |
+ |
1310 |
+glibc_do_src_install() { |
1311 |
+ local builddir=$(builddir nptl) |
1312 |
+ cd "${builddir}" |
1313 |
+ |
1314 |
+ emake install_root="${D}/$(build_eprefix)$(alt_prefix)" install |
1315 |
+ |
1316 |
+ # This version (2.26) provides some compatibility libraries for the NIS/NIS+ support |
1317 |
+ # which come without headers etc. Only needed for binary packages since the |
1318 |
+ # external net-libs/libnsl has increased soversion. Keep only versioned libraries. |
1319 |
+ find "${D}" -name "libnsl.a" -delete |
1320 |
+ find "${D}" -name "libnsl.so" -delete |
1321 |
+ |
1322 |
+ # Normally upstream_pv is ${PV}. Live ebuilds are exception, there we need |
1323 |
+ # to infer upstream version: |
1324 |
+ # '#define VERSION "2.26.90"' -> '2.26.90' |
1325 |
+ local upstream_pv=$(sed -n -r 's/#define VERSION "(.*)"/\1/p' "${S}"/version.h) |
1326 |
+ |
1327 |
+ # Avoid stripping binaries not targeted by ${CHOST}. Or else |
1328 |
+ # ${CHOST}-strip would break binaries build for ${CTARGET}. |
1329 |
+ is_crosscompile && dostrip -x / |
1330 |
+ # gdb thread introspection relies on local libpthreas symbols. stripping breaks it |
1331 |
+ # See Note [Disable automatic stripping] |
1332 |
+ dostrip -x $(alt_libdir)/libpthread-${upstream_pv}.so |
1333 |
+ |
1334 |
+ if [[ -e ${ED}/$(alt_usrlibdir)/libm-${upstream_pv}.a ]] ; then |
1335 |
+ # Move versioned .a file out of libdir to evade portage QA checks |
1336 |
+ # instead of using gen_usr_ldscript(). We fix ldscript as: |
1337 |
+ # "GROUP ( /usr/lib64/libm-<pv>.a ..." -> "GROUP ( /usr/lib64/glibc-<pv>/libm-<pv>.a ..." |
1338 |
+ sed -i "s@\(libm-${upstream_pv}.a\)@${P}/\1@" "${ED}"/$(alt_usrlibdir)/libm.a || die |
1339 |
+ dodir $(alt_usrlibdir)/${P} |
1340 |
+ mv "${ED}"/$(alt_usrlibdir)/libm-${upstream_pv}.a "${ED}"/$(alt_usrlibdir)/${P}/libm-${upstream_pv}.a || die |
1341 |
+ fi |
1342 |
+ |
1343 |
+ # We'll take care of the cache ourselves |
1344 |
+ rm -f "${ED}"/etc/ld.so.cache |
1345 |
+ |
1346 |
+ # Everything past this point just needs to be done once ... |
1347 |
+ is_final_abi || return 0 |
1348 |
+ |
1349 |
+ # Make sure the non-native interp can be found on multilib systems even |
1350 |
+ # if the main library set isn't installed into the right place. Maybe |
1351 |
+ # we should query the active gcc for info instead of hardcoding it ? |
1352 |
+ local i ldso_abi ldso_name |
1353 |
+ local ldso_abi_list=( |
1354 |
+ # x86 |
1355 |
+ amd64 /lib64/ld-linux-x86-64.so.2 |
1356 |
+ x32 /libx32/ld-linux-x32.so.2 |
1357 |
+ x86 /lib/ld-linux.so.2 |
1358 |
+ # mips |
1359 |
+ o32 /lib/ld.so.1 |
1360 |
+ n32 /lib32/ld.so.1 |
1361 |
+ n64 /lib64/ld.so.1 |
1362 |
+ # powerpc |
1363 |
+ ppc /lib/ld.so.1 |
1364 |
+ # riscv |
1365 |
+ ilp32d /lib/ld-linux-riscv32-ilp32d.so.1 |
1366 |
+ ilp32 /lib/ld-linux-riscv32-ilp32.so.1 |
1367 |
+ lp64d /lib/ld-linux-riscv64-lp64d.so.1 |
1368 |
+ lp64 /lib/ld-linux-riscv64-lp64.so.1 |
1369 |
+ # s390 |
1370 |
+ s390 /lib/ld.so.1 |
1371 |
+ s390x /lib/ld64.so.1 |
1372 |
+ # sparc |
1373 |
+ sparc32 /lib/ld-linux.so.2 |
1374 |
+ sparc64 /lib64/ld-linux.so.2 |
1375 |
+ ) |
1376 |
+ case $(tc-endian) in |
1377 |
+ little) |
1378 |
+ ldso_abi_list+=( |
1379 |
+ # arm |
1380 |
+ arm64 /lib/ld-linux-aarch64.so.1 |
1381 |
+ # ELFv2 (glibc does not support ELFv1 on LE) |
1382 |
+ ppc64 /lib64/ld64.so.2 |
1383 |
+ ) |
1384 |
+ ;; |
1385 |
+ big) |
1386 |
+ ldso_abi_list+=( |
1387 |
+ # arm |
1388 |
+ arm64 /lib/ld-linux-aarch64_be.so.1 |
1389 |
+ # ELFv1 (glibc does not support ELFv2 on BE) |
1390 |
+ ppc64 /lib64/ld64.so.1 |
1391 |
+ ) |
1392 |
+ ;; |
1393 |
+ esac |
1394 |
+ if [[ ${SYMLINK_LIB} == "yes" ]] && [[ ! -e ${ED}/$(alt_prefix)/lib ]] ; then |
1395 |
+ dosym $(get_abi_LIBDIR ${DEFAULT_ABI}) $(alt_prefix)/lib |
1396 |
+ fi |
1397 |
+ for (( i = 0; i < ${#ldso_abi_list[@]}; i += 2 )) ; do |
1398 |
+ ldso_abi=${ldso_abi_list[i]} |
1399 |
+ has ${ldso_abi} $(get_install_abis) || continue |
1400 |
+ |
1401 |
+ ldso_name="$(alt_prefix)${ldso_abi_list[i+1]}" |
1402 |
+ if [[ ! -L ${ED}/${ldso_name} && ! -e ${ED}/${ldso_name} ]] ; then |
1403 |
+ dosym ../$(get_abi_LIBDIR ${ldso_abi})/${ldso_name##*/} ${ldso_name} |
1404 |
+ fi |
1405 |
+ done |
1406 |
+ |
1407 |
+ # In the LSB 5.0 definition, someone had the excellent idea to "standardize" |
1408 |
+ # the runtime loader name, see also https://xkcd.com/927/ |
1409 |
+ # Normally, in Gentoo one should never come across executables that require this. |
1410 |
+ # However, binary commercial packages are known to adhere to weird practices. |
1411 |
+ # https://refspecs.linuxfoundation.org/LSB_5.0.0/LSB-Core-AMD64/LSB-Core-AMD64.html#BASELIB |
1412 |
+ local lsb_ldso_name native_ldso_name lsb_ldso_abi |
1413 |
+ local lsb_ldso_abi_list=( |
1414 |
+ # x86 |
1415 |
+ amd64 ld-linux-x86-64.so.2 ld-lsb-x86-64.so.3 |
1416 |
+ ) |
1417 |
+ for (( i = 0; i < ${#lsb_ldso_abi_list[@]}; i += 3 )) ; do |
1418 |
+ lsb_ldso_abi=${lsb_ldso_abi_list[i]} |
1419 |
+ native_ldso_name=${lsb_ldso_abi_list[i+1]} |
1420 |
+ lsb_ldso_name=${lsb_ldso_abi_list[i+2]} |
1421 |
+ has ${lsb_ldso_abi} $(get_install_abis) || continue |
1422 |
+ |
1423 |
+ if [[ ! -L ${ED}/$(get_abi_LIBDIR ${lsb_ldso_abi})/${lsb_ldso_name} && ! -e ${ED}/$(get_abi_LIBDIR ${lsb_ldso_abi})/${lsb_ldso_name} ]] ; then |
1424 |
+ dosym ${native_ldso_name} "$(alt_prefix)/$(get_abi_LIBDIR ${lsb_ldso_abi})/${lsb_ldso_name}" |
1425 |
+ fi |
1426 |
+ done |
1427 |
+ |
1428 |
+ # With devpts under Linux mounted properly, we do not need the pt_chown |
1429 |
+ # binary to be setuid. This is because the default owners/perms will be |
1430 |
+ # exactly what we want. |
1431 |
+ if ! use suid ; then |
1432 |
+ find "${ED}" -name pt_chown -exec chmod -s {} + |
1433 |
+ fi |
1434 |
+ |
1435 |
+ ################################################################# |
1436 |
+ # EVERYTHING AFTER THIS POINT IS FOR NATIVE GLIBC INSTALLS ONLY # |
1437 |
+ # Make sure we install some symlink hacks so that when we build |
1438 |
+ # a 2nd stage cross-compiler, gcc finds the target system |
1439 |
+ # headers correctly. See gcc/doc/gccinstall.info |
1440 |
+ if is_crosscompile ; then |
1441 |
+ # We need to make sure that /lib and /usr/lib always exists. |
1442 |
+ # gcc likes to use relative paths to get to its multilibs like |
1443 |
+ # /usr/lib/../lib64/. So while we don't install any files into |
1444 |
+ # /usr/lib/, we do need it to exist. |
1445 |
+ keepdir $(alt_prefix)/lib |
1446 |
+ keepdir $(alt_prefix)/usr/lib |
1447 |
+ |
1448 |
+ dosym usr/include $(alt_prefix)/sys-include |
1449 |
+ return 0 |
1450 |
+ fi |
1451 |
+ |
1452 |
+ # Files for Debian-style locale updating |
1453 |
+ dodir /usr/share/i18n |
1454 |
+ sed \ |
1455 |
+ -e "/^#/d" \ |
1456 |
+ -e "/SUPPORTED-LOCALES=/d" \ |
1457 |
+ -e "s: \\\\::g" -e "s:/: :g" \ |
1458 |
+ "${S}"/localedata/SUPPORTED > "${ED}"/usr/share/i18n/SUPPORTED \ |
1459 |
+ || die "generating /usr/share/i18n/SUPPORTED failed" |
1460 |
+ cd "${WORKDIR}"/extra/locale |
1461 |
+ dosbin locale-gen |
1462 |
+ doman *.[0-8] |
1463 |
+ insinto /etc |
1464 |
+ doins locale.gen |
1465 |
+ |
1466 |
+ keepdir /usr/lib/locale |
1467 |
+ |
1468 |
+ cd "${S}" |
1469 |
+ |
1470 |
+ # Install misc network config files |
1471 |
+ insinto /etc |
1472 |
+ doins posix/gai.conf |
1473 |
+ |
1474 |
+ if use systemd ; then |
1475 |
+ doins "${WORKDIR}/glibc-systemd-${GLIBC_SYSTEMD_VER}/gentoo-config/nsswitch.conf" |
1476 |
+ else |
1477 |
+ doins nss/nsswitch.conf |
1478 |
+ fi |
1479 |
+ |
1480 |
+ # Gentoo-specific |
1481 |
+ newins "${FILESDIR}"/host.conf-1 host.conf |
1482 |
+ |
1483 |
+ if use nscd ; then |
1484 |
+ doins nscd/nscd.conf |
1485 |
+ |
1486 |
+ newinitd "$(prefixify_ro "${FILESDIR}"/nscd-1)" nscd |
1487 |
+ |
1488 |
+ local nscd_args=( |
1489 |
+ -e "s:@PIDFILE@:$(strings "${ED}"/usr/sbin/nscd | grep nscd.pid):" |
1490 |
+ ) |
1491 |
+ |
1492 |
+ sed -i "${nscd_args[@]}" "${ED}"/etc/init.d/nscd |
1493 |
+ |
1494 |
+ use systemd && systemd_dounit nscd/nscd.service |
1495 |
+ newtmpfiles nscd/nscd.tmpfiles nscd.conf |
1496 |
+ fi |
1497 |
+ |
1498 |
+ echo 'LDPATH="include ld.so.conf.d/*.conf"' > "${T}"/00glibc |
1499 |
+ doenvd "${T}"/00glibc |
1500 |
+ |
1501 |
+ for d in BUGS ChangeLog CONFORMANCE FAQ NEWS NOTES PROJECTS README* ; do |
1502 |
+ [[ -s ${d} ]] && dodoc ${d} |
1503 |
+ done |
1504 |
+ dodoc -r ChangeLog.old |
1505 |
+ |
1506 |
+ # Prevent overwriting of the /etc/localtime symlink. We'll handle the |
1507 |
+ # creation of the "factory" symlink in pkg_postinst(). |
1508 |
+ rm -f "${ED}"/etc/localtime |
1509 |
+ |
1510 |
+ # Generate all locales if this is a native build as locale generation |
1511 |
+ if use compile-locales && ! is_crosscompile ; then |
1512 |
+ run_locale_gen --inplace-glibc "${ED}/" |
1513 |
+ sed -e 's:COMPILED_LOCALES="":COMPILED_LOCALES="1":' -i "${ED}"/usr/sbin/locale-gen || die |
1514 |
+ fi |
1515 |
+} |
1516 |
+ |
1517 |
+glibc_headers_install() { |
1518 |
+ local builddir=$(builddir "headers") |
1519 |
+ cd "${builddir}" |
1520 |
+ emake install_root="${D}/$(build_eprefix)$(alt_prefix)" install-headers |
1521 |
+ |
1522 |
+ insinto $(alt_headers)/gnu |
1523 |
+ doins "${S}"/include/gnu/stubs.h |
1524 |
+ |
1525 |
+ # Make sure we install the sys-include symlink so that when |
1526 |
+ # we build a 2nd stage cross-compiler, gcc finds the target |
1527 |
+ # system headers correctly. See gcc/doc/gccinstall.info |
1528 |
+ dosym usr/include $(alt_prefix)/sys-include |
1529 |
+} |
1530 |
+ |
1531 |
+src_install() { |
1532 |
+ if just_headers ; then |
1533 |
+ export ABI=default |
1534 |
+ glibc_headers_install |
1535 |
+ return |
1536 |
+ fi |
1537 |
+ |
1538 |
+ foreach_abi glibc_do_src_install |
1539 |
+ |
1540 |
+ if ! use static-libs ; then |
1541 |
+ einfo "Not installing static glibc libraries" |
1542 |
+ find "${ED}" -name "*.a" -and -not -name "*_nonshared.a" -delete |
1543 |
+ fi |
1544 |
+} |
1545 |
+ |
1546 |
+# Simple test to make sure our new glibc isn't completely broken. |
1547 |
+# Make sure we don't test with statically built binaries since |
1548 |
+# they will fail. Also, skip if this glibc is a cross compiler. |
1549 |
+# |
1550 |
+# If coreutils is built with USE=multicall, some of these files |
1551 |
+# will just be wrapper scripts, not actual ELFs we can test. |
1552 |
+glibc_sanity_check() { |
1553 |
+ cd / #228809 |
1554 |
+ |
1555 |
+ # We enter ${ED} so to avoid trouble if the path contains |
1556 |
+ # special characters; for instance if the path contains the |
1557 |
+ # colon character (:), then the linker will try to split it |
1558 |
+ # and look for the libraries in an unexpected place. This can |
1559 |
+ # lead to unsafe code execution if the generated prefix is |
1560 |
+ # within a world-writable directory. |
1561 |
+ # (e.g. /var/tmp/portage:${HOSTNAME}) |
1562 |
+ pushd "${ED}"/$(get_libdir) >/dev/null |
1563 |
+ |
1564 |
+ # first let's find the actual dynamic linker here |
1565 |
+ # symlinks may point to the wrong abi |
1566 |
+ local newldso=$(find . -maxdepth 1 -name 'ld*so.?' -type f -print -quit) |
1567 |
+ |
1568 |
+ einfo Last-minute run tests with ${newldso} in /$(get_libdir) ... |
1569 |
+ |
1570 |
+ local x striptest |
1571 |
+ for x in cal date env free ls true uname uptime ; do |
1572 |
+ x=$(type -p ${x}) |
1573 |
+ [[ -z ${x} || ${x} != ${EPREFIX}/* ]] && continue |
1574 |
+ striptest=$(LC_ALL="C" file -L ${x} 2>/dev/null) || continue |
1575 |
+ case ${striptest} in |
1576 |
+ *"statically linked"*) continue;; |
1577 |
+ *"ASCII text"*) continue;; |
1578 |
+ esac |
1579 |
+ # We need to clear the locale settings as the upgrade might want |
1580 |
+ # incompatible locale data. This test is not for verifying that. |
1581 |
+ LC_ALL=C \ |
1582 |
+ ${newldso} --library-path . ${x} > /dev/null \ |
1583 |
+ || die "simple run test (${x}) failed" |
1584 |
+ done |
1585 |
+ |
1586 |
+ popd >/dev/null |
1587 |
+} |
1588 |
+ |
1589 |
+pkg_preinst() { |
1590 |
+ # nothing to do if just installing headers |
1591 |
+ just_headers && return |
1592 |
+ |
1593 |
+ # prepare /etc/ld.so.conf.d/ for files |
1594 |
+ mkdir -p "${EROOT}"/etc/ld.so.conf.d |
1595 |
+ |
1596 |
+ # Default /etc/hosts.conf:multi to on for systems with small dbs. |
1597 |
+ if [[ $(wc -l < "${EROOT}"/etc/hosts) -lt 1000 ]] ; then |
1598 |
+ sed -i '/^multi off/s:off:on:' "${ED}"/etc/host.conf |
1599 |
+ einfo "Defaulting /etc/host.conf:multi to on" |
1600 |
+ fi |
1601 |
+ |
1602 |
+ [[ -n ${ROOT} ]] && return 0 |
1603 |
+ [[ -d ${ED}/$(get_libdir) ]] || return 0 |
1604 |
+ [[ -z ${BOOTSTRAP_RAP} ]] && glibc_sanity_check |
1605 |
+ |
1606 |
+ if [[ -L ${EROOT}/usr/lib/locale ]]; then |
1607 |
+ # Help portage migrate this to a directory |
1608 |
+ # https://bugs.gentoo.org/753740 |
1609 |
+ rm "${EROOT}"/usr/lib/locale || die |
1610 |
+ fi |
1611 |
+ |
1612 |
+ # Keep around libcrypt so that Perl doesn't break when merging libxcrypt |
1613 |
+ # (libxcrypt is the new provider for now of libcrypt.so.{1,2}). |
1614 |
+ # bug #802207 |
1615 |
+ if ! use crypt && has_version "${CATEGORY}/${PN}[crypt]" && ! has preserve-libs ${FEATURES}; then |
1616 |
+ PRESERVED_OLD_LIBCRYPT=1 |
1617 |
+ cp -p "${EROOT}/$(get_libdir)/libcrypt$(get_libname 1)" "${T}/libcrypt$(get_libname 1)" || die |
1618 |
+ else |
1619 |
+ PRESERVED_OLD_LIBCRYPT=0 |
1620 |
+ fi |
1621 |
+} |
1622 |
+ |
1623 |
+pkg_postinst() { |
1624 |
+ # nothing to do if just installing headers |
1625 |
+ just_headers && return |
1626 |
+ |
1627 |
+ if ! tc-is-cross-compiler && [[ -x ${EROOT}/usr/sbin/iconvconfig ]] ; then |
1628 |
+ # Generate fastloading iconv module configuration file. |
1629 |
+ "${EROOT}"/usr/sbin/iconvconfig --prefix="${ROOT}/" |
1630 |
+ fi |
1631 |
+ |
1632 |
+ if ! is_crosscompile && [[ -z ${ROOT} ]] ; then |
1633 |
+ use compile-locales || run_locale_gen "${EROOT}/" |
1634 |
+ fi |
1635 |
+ |
1636 |
+ upgrade_warning |
1637 |
+ |
1638 |
+ # Check for sanity of /etc/nsswitch.conf, take 2 |
1639 |
+ if [[ -e ${EROOT}/etc/nsswitch.conf ]] && ! has_version sys-auth/libnss-nis ; then |
1640 |
+ local entry |
1641 |
+ for entry in passwd group shadow; do |
1642 |
+ if egrep -q "^[ \t]*${entry}:.*nis" "${EROOT}"/etc/nsswitch.conf; then |
1643 |
+ ewarn "" |
1644 |
+ ewarn "Your ${EROOT}/etc/nsswitch.conf uses NIS. Support for that has been" |
1645 |
+ ewarn "removed from glibc and is now provided by the package" |
1646 |
+ ewarn " sys-auth/libnss-nis" |
1647 |
+ ewarn "Install it now to keep your NIS setup working." |
1648 |
+ ewarn "" |
1649 |
+ fi |
1650 |
+ done |
1651 |
+ fi |
1652 |
+ |
1653 |
+ if [[ ${PRESERVED_OLD_LIBCRYPT} -eq 1 ]] ; then |
1654 |
+ cp -p "${T}/libcrypt$(get_libname 1)" "${EROOT}/$(get_libdir)/libcrypt$(get_libname 1)" || die |
1655 |
+ preserve_old_lib_notify /$(get_libdir)/libcrypt$(get_libname 1) |
1656 |
+ |
1657 |
+ elog "Please ignore a possible later error message about a file collision involving" |
1658 |
+ elog "${EROOT}/$(get_libdir)/libcrypt$(get_libname 1). We need to preserve this file for the moment to keep" |
1659 |
+ elog "the upgrade working, but it also needs to be overwritten when" |
1660 |
+ elog "sys-libs/libxcrypt is installed. See bug 802210 for more details." |
1661 |
+ fi |
1662 |
+} |
1663 |
|
1664 |
diff --git a/sys-libs/glibc/glibc-2.35-r2.ebuild b/sys-libs/glibc/glibc-2.35-r2.ebuild |
1665 |
new file mode 100644 |
1666 |
index 000000000000..78bb7d0b6e0f |
1667 |
--- /dev/null |
1668 |
+++ b/sys-libs/glibc/glibc-2.35-r2.ebuild |
1669 |
@@ -0,0 +1,1590 @@ |
1670 |
+# Copyright 1999-2022 Gentoo Authors |
1671 |
+# Distributed under the terms of the GNU General Public License v2 |
1672 |
+ |
1673 |
+EAPI=7 |
1674 |
+ |
1675 |
+# Bumping notes: https://wiki.gentoo.org/wiki/Project:Toolchain/sys-libs/glibc |
1676 |
+# Please read & adapt the page as necessary if obsolete. |
1677 |
+ |
1678 |
+PYTHON_COMPAT=( python3_{8,9,10} ) |
1679 |
+TMPFILES_OPTIONAL=1 |
1680 |
+ |
1681 |
+inherit python-any-r1 prefix preserve-libs toolchain-funcs flag-o-matic gnuconfig \ |
1682 |
+ multilib systemd multiprocessing tmpfiles |
1683 |
+ |
1684 |
+DESCRIPTION="GNU libc C library" |
1685 |
+HOMEPAGE="https://www.gnu.org/software/libc/" |
1686 |
+LICENSE="LGPL-2.1+ BSD HPND ISC inner-net rc PCRE" |
1687 |
+SLOT="2.2" |
1688 |
+ |
1689 |
+EMULTILIB_PKG="true" |
1690 |
+ |
1691 |
+# Gentoo patchset (ignored for live ebuilds) |
1692 |
+PATCH_VER=5 |
1693 |
+PATCH_DEV=dilfridge |
1694 |
+ |
1695 |
+if [[ ${PV} == 9999* ]]; then |
1696 |
+ inherit git-r3 |
1697 |
+else |
1698 |
+ #KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86" |
1699 |
+ SRC_URI="mirror://gnu/glibc/${P}.tar.xz" |
1700 |
+ SRC_URI+=" https://dev.gentoo.org/~${PATCH_DEV}/distfiles/${P}-patches-${PATCH_VER}.tar.xz" |
1701 |
+fi |
1702 |
+ |
1703 |
+RELEASE_VER=${PV} |
1704 |
+ |
1705 |
+GCC_BOOTSTRAP_VER=20201208 |
1706 |
+ |
1707 |
+LOCALE_GEN_VER=2.22 |
1708 |
+ |
1709 |
+GLIBC_SYSTEMD_VER=20210729 |
1710 |
+ |
1711 |
+SRC_URI+=" https://gitweb.gentoo.org/proj/locale-gen.git/snapshot/locale-gen-${LOCALE_GEN_VER}.tar.gz" |
1712 |
+SRC_URI+=" multilib-bootstrap? ( https://dev.gentoo.org/~dilfridge/distfiles/gcc-multilib-bootstrap-${GCC_BOOTSTRAP_VER}.tar.xz )" |
1713 |
+SRC_URI+=" systemd? ( https://gitweb.gentoo.org/proj/toolchain/glibc-systemd.git/snapshot/glibc-systemd-${GLIBC_SYSTEMD_VER}.tar.gz )" |
1714 |
+ |
1715 |
+IUSE="audit caps cet +clone3 compile-locales +crypt custom-cflags doc gd headers-only +multiarch multilib multilib-bootstrap nscd profile selinux +ssp +static-libs suid systemd systemtap test vanilla" |
1716 |
+ |
1717 |
+# Minimum kernel version that glibc requires |
1718 |
+MIN_KERN_VER="3.2.0" |
1719 |
+# Minimum pax-utils version needed (which contains any new syscall changes for |
1720 |
+# its seccomp filter!). Please double check this! |
1721 |
+MIN_PAX_UTILS_VER="1.3.3" |
1722 |
+ |
1723 |
+# Here's how the cross-compile logic breaks down ... |
1724 |
+# CTARGET - machine that will target the binaries |
1725 |
+# CHOST - machine that will host the binaries |
1726 |
+# CBUILD - machine that will build the binaries |
1727 |
+# If CTARGET != CHOST, it means you want a libc for cross-compiling. |
1728 |
+# If CHOST != CBUILD, it means you want to cross-compile the libc. |
1729 |
+# CBUILD = CHOST = CTARGET - native build/install |
1730 |
+# CBUILD != (CHOST = CTARGET) - cross-compile a native build |
1731 |
+# (CBUILD = CHOST) != CTARGET - libc for cross-compiler |
1732 |
+# CBUILD != CHOST != CTARGET - cross-compile a libc for a cross-compiler |
1733 |
+# For install paths: |
1734 |
+# CHOST = CTARGET - install into / |
1735 |
+# CHOST != CTARGET - install into /usr/CTARGET/ |
1736 |
+# |
1737 |
+export CBUILD=${CBUILD:-${CHOST}} |
1738 |
+export CTARGET=${CTARGET:-${CHOST}} |
1739 |
+if [[ ${CTARGET} == ${CHOST} ]] ; then |
1740 |
+ if [[ ${CATEGORY} == cross-* ]] ; then |
1741 |
+ export CTARGET=${CATEGORY#cross-} |
1742 |
+ fi |
1743 |
+fi |
1744 |
+ |
1745 |
+# Note [Disable automatic stripping] |
1746 |
+# Disabling automatic stripping for a few reasons: |
1747 |
+# - portage's attempt to strip breaks non-native binaries at least on |
1748 |
+# arm: bug #697428 |
1749 |
+# - portage's attempt to strip libpthread.so.0 breaks gdb thread |
1750 |
+# enumeration: bug #697910. This is quite subtle: |
1751 |
+# * gdb uses glibc's libthread_db-1.0.so to enumerate threads. |
1752 |
+# * libthread_db-1.0.so needs access to libpthread.so.0 local symbols |
1753 |
+# via 'ps_pglobal_lookup' symbol defined in gdb. |
1754 |
+# * 'ps_pglobal_lookup' uses '.symtab' section table to resolve all |
1755 |
+# known symbols in 'libpthread.so.0'. Specifically 'nptl_version' |
1756 |
+# (unexported) is used to sanity check compatibility before enabling |
1757 |
+# debugging. |
1758 |
+# 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 |
1759 |
+# * normal 'strip' command trims '.symtab' |
1760 |
+# Thus our main goal here is to prevent 'libpthread.so.0' from |
1761 |
+# losing it's '.symtab' entries. |
1762 |
+# As Gentoo's strip does not allow us to pass less aggressive stripping |
1763 |
+# options and does not check the machine target we strip selectively. |
1764 |
+ |
1765 |
+# We need a new-enough binutils/gcc to match upstream baseline. |
1766 |
+# Also we need to make sure our binutils/gcc supports TLS, |
1767 |
+# and that gcc already contains the hardened patches. |
1768 |
+# Lastly, let's avoid some openssh nastiness, bug 708224, as |
1769 |
+# convenience to our users. |
1770 |
+ |
1771 |
+# gzip, grep, awk are needed by locale-gen, bug 740750 |
1772 |
+ |
1773 |
+BDEPEND=" |
1774 |
+ ${PYTHON_DEPS} |
1775 |
+ >=app-misc/pax-utils-${MIN_PAX_UTILS_VER} |
1776 |
+ sys-devel/bison |
1777 |
+ doc? ( sys-apps/texinfo ) |
1778 |
+ !compile-locales? ( |
1779 |
+ app-arch/gzip |
1780 |
+ sys-apps/grep |
1781 |
+ virtual/awk |
1782 |
+ ) |
1783 |
+" |
1784 |
+COMMON_DEPEND=" |
1785 |
+ gd? ( media-libs/gd:2= ) |
1786 |
+ nscd? ( selinux? ( |
1787 |
+ audit? ( sys-process/audit ) |
1788 |
+ caps? ( sys-libs/libcap ) |
1789 |
+ ) ) |
1790 |
+ suid? ( caps? ( sys-libs/libcap ) ) |
1791 |
+ selinux? ( sys-libs/libselinux ) |
1792 |
+ systemtap? ( dev-util/systemtap ) |
1793 |
+" |
1794 |
+DEPEND="${COMMON_DEPEND} |
1795 |
+ compile-locales? ( |
1796 |
+ app-arch/gzip |
1797 |
+ sys-apps/grep |
1798 |
+ virtual/awk |
1799 |
+ ) |
1800 |
+ test? ( >=net-dns/libidn2-2.3.0 ) |
1801 |
+" |
1802 |
+RDEPEND="${COMMON_DEPEND} |
1803 |
+ app-arch/gzip |
1804 |
+ sys-apps/grep |
1805 |
+ virtual/awk |
1806 |
+ sys-apps/gentoo-functions |
1807 |
+ !<app-misc/pax-utils-${MIN_PAX_UTILS_VER} |
1808 |
+ !<net-misc/openssh-8.1_p1-r2 |
1809 |
+" |
1810 |
+ |
1811 |
+RESTRICT="!test? ( test )" |
1812 |
+ |
1813 |
+if [[ ${CATEGORY} == cross-* ]] ; then |
1814 |
+ BDEPEND+=" !headers-only? ( |
1815 |
+ >=${CATEGORY}/binutils-2.27 |
1816 |
+ >=${CATEGORY}/gcc-6.2 |
1817 |
+ )" |
1818 |
+ [[ ${CATEGORY} == *-linux* ]] && DEPEND+=" ${CATEGORY}/linux-headers" |
1819 |
+else |
1820 |
+ BDEPEND+=" |
1821 |
+ >=sys-devel/binutils-2.27 |
1822 |
+ >=sys-devel/gcc-6.2 |
1823 |
+ " |
1824 |
+ DEPEND+=" virtual/os-headers " |
1825 |
+ RDEPEND+=" |
1826 |
+ >=net-dns/libidn2-2.3.0 |
1827 |
+ vanilla? ( !sys-libs/timezone-data ) |
1828 |
+ " |
1829 |
+ PDEPEND+=" !vanilla? ( sys-libs/timezone-data )" |
1830 |
+fi |
1831 |
+ |
1832 |
+# Ignore tests whitelisted below |
1833 |
+GENTOO_GLIBC_XFAIL_TESTS="${GENTOO_GLIBC_XFAIL_TESTS:-yes}" |
1834 |
+ |
1835 |
+# The following tests fail due to the Gentoo build system and are thus |
1836 |
+# executed but ignored: |
1837 |
+XFAIL_TEST_LIST=( |
1838 |
+ # buggy test, assumes /dev/ and /dev/null on a single filesystem |
1839 |
+ # 'mount --bind /dev/null /chroot/dev/null' breaks it. |
1840 |
+ # https://sourceware.org/PR25909 |
1841 |
+ tst-support_descriptors |
1842 |
+ |
1843 |
+ # The following tests fail only inside portage |
1844 |
+ # https://bugs.gentoo.org/831267 |
1845 |
+ tst-system |
1846 |
+ tst-strerror |
1847 |
+ tst-strsignal |
1848 |
+) |
1849 |
+ |
1850 |
+# |
1851 |
+# Small helper functions |
1852 |
+# |
1853 |
+ |
1854 |
+is_crosscompile() { |
1855 |
+ [[ ${CHOST} != ${CTARGET} ]] |
1856 |
+} |
1857 |
+ |
1858 |
+just_headers() { |
1859 |
+ is_crosscompile && use headers-only |
1860 |
+} |
1861 |
+ |
1862 |
+alt_prefix() { |
1863 |
+ is_crosscompile && echo /usr/${CTARGET} |
1864 |
+} |
1865 |
+ |
1866 |
+# This prefix is applicable to CHOST when building against this |
1867 |
+# glibc. It is baked into the library at configure time. |
1868 |
+host_eprefix() { |
1869 |
+ is_crosscompile || echo "${EPREFIX}" |
1870 |
+} |
1871 |
+ |
1872 |
+# This prefix is applicable to CBUILD when building against this |
1873 |
+# glibc. It determines the destination path at install time. |
1874 |
+build_eprefix() { |
1875 |
+ is_crosscompile && echo "${EPREFIX}" |
1876 |
+} |
1877 |
+ |
1878 |
+# We need to be able to set alternative headers for compiling for non-native |
1879 |
+# platform. Will also become useful for testing kernel-headers without screwing |
1880 |
+# up the whole system. |
1881 |
+alt_headers() { |
1882 |
+ echo ${ALT_HEADERS:=$(alt_prefix)/usr/include} |
1883 |
+} |
1884 |
+ |
1885 |
+alt_build_headers() { |
1886 |
+ if [[ -z ${ALT_BUILD_HEADERS} ]] ; then |
1887 |
+ ALT_BUILD_HEADERS="$(host_eprefix)$(alt_headers)" |
1888 |
+ if tc-is-cross-compiler ; then |
1889 |
+ ALT_BUILD_HEADERS=${SYSROOT}$(alt_headers) |
1890 |
+ if [[ ! -e ${ALT_BUILD_HEADERS}/linux/version.h ]] ; then |
1891 |
+ local header_path=$(echo '#include <linux/version.h>' | $(tc-getCPP ${CTARGET}) ${CFLAGS} 2>&1 | grep -o '[^"]*linux/version.h') |
1892 |
+ ALT_BUILD_HEADERS=${header_path%/linux/version.h} |
1893 |
+ fi |
1894 |
+ fi |
1895 |
+ fi |
1896 |
+ echo "${ALT_BUILD_HEADERS}" |
1897 |
+} |
1898 |
+ |
1899 |
+alt_libdir() { |
1900 |
+ echo $(alt_prefix)/$(get_libdir) |
1901 |
+} |
1902 |
+alt_usrlibdir() { |
1903 |
+ echo $(alt_prefix)/usr/$(get_libdir) |
1904 |
+} |
1905 |
+ |
1906 |
+builddir() { |
1907 |
+ echo "${WORKDIR}/build-${ABI}-${CTARGET}-$1" |
1908 |
+} |
1909 |
+ |
1910 |
+do_compile_test() { |
1911 |
+ local ret save_cflags=${CFLAGS} |
1912 |
+ CFLAGS+=" $1" |
1913 |
+ shift |
1914 |
+ |
1915 |
+ pushd "${T}" >/dev/null |
1916 |
+ |
1917 |
+ rm -f glibc-test* |
1918 |
+ printf '%b' "$*" > glibc-test.c |
1919 |
+ |
1920 |
+ # We assume CC is already set up. |
1921 |
+ nonfatal emake glibc-test |
1922 |
+ ret=$? |
1923 |
+ |
1924 |
+ popd >/dev/null |
1925 |
+ |
1926 |
+ CFLAGS=${save_cflags} |
1927 |
+ return ${ret} |
1928 |
+} |
1929 |
+ |
1930 |
+do_run_test() { |
1931 |
+ local ret |
1932 |
+ |
1933 |
+ if [[ ${MERGE_TYPE} == "binary" ]] ; then |
1934 |
+ # ignore build failures when installing a binary package #324685 |
1935 |
+ do_compile_test "" "$@" 2>/dev/null || return 0 |
1936 |
+ else |
1937 |
+ if ! do_compile_test "" "$@" ; then |
1938 |
+ ewarn "Simple build failed ... assuming this is desired #324685" |
1939 |
+ return 0 |
1940 |
+ fi |
1941 |
+ fi |
1942 |
+ |
1943 |
+ pushd "${T}" >/dev/null |
1944 |
+ |
1945 |
+ ./glibc-test |
1946 |
+ ret=$? |
1947 |
+ rm -f glibc-test* |
1948 |
+ |
1949 |
+ popd >/dev/null |
1950 |
+ |
1951 |
+ return ${ret} |
1952 |
+} |
1953 |
+ |
1954 |
+setup_target_flags() { |
1955 |
+ # This largely mucks with compiler flags. None of which should matter |
1956 |
+ # when building up just the headers. |
1957 |
+ just_headers && return 0 |
1958 |
+ |
1959 |
+ case $(tc-arch) in |
1960 |
+ x86) |
1961 |
+ # -march needed for #185404 #199334 |
1962 |
+ # TODO: When creating the first glibc cross-compile, this test will |
1963 |
+ # always fail as it does a full link which in turn requires glibc. |
1964 |
+ # Probably also applies when changing multilib profile settings (e.g. |
1965 |
+ # enabling x86 when the profile was amd64-only previously). |
1966 |
+ # We could change main to _start and pass -nostdlib here so that we |
1967 |
+ # only test the gcc code compilation. Or we could do a compile and |
1968 |
+ # then look for the symbol via scanelf. |
1969 |
+ 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 |
1970 |
+ local t=${CTARGET_OPT:-${CTARGET}} |
1971 |
+ t=${t%%-*} |
1972 |
+ filter-flags '-march=*' |
1973 |
+ export CFLAGS="-march=${t} ${CFLAGS}" |
1974 |
+ einfo "Auto adding -march=${t} to CFLAGS #185404" |
1975 |
+ fi |
1976 |
+ ;; |
1977 |
+ amd64) |
1978 |
+ # -march needed for #185404 #199334 |
1979 |
+ # TODO: See cross-compile issues listed above for x86. |
1980 |
+ [[ ${ABI} == x86 ]] && |
1981 |
+ 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 |
1982 |
+ local t=${CTARGET_OPT:-${CTARGET}} |
1983 |
+ t=${t%%-*} |
1984 |
+ # Normally the target is x86_64-xxx, so turn that into the -march that |
1985 |
+ # gcc actually accepts. #528708 |
1986 |
+ [[ ${t} == "x86_64" ]] && t="x86-64" |
1987 |
+ filter-flags '-march=*' |
1988 |
+ # ugly, ugly, ugly. ugly. |
1989 |
+ CFLAGS_x86=$(CFLAGS=${CFLAGS_x86} filter-flags '-march=*'; echo "${CFLAGS}") |
1990 |
+ export CFLAGS_x86="${CFLAGS_x86} -march=${t}" |
1991 |
+ einfo "Auto adding -march=${t} to CFLAGS_x86 #185404 (ABI=${ABI})" |
1992 |
+ fi |
1993 |
+ ;; |
1994 |
+ mips) |
1995 |
+ # The mips abi cannot support the GNU style hashes. #233233 |
1996 |
+ filter-ldflags -Wl,--hash-style=gnu -Wl,--hash-style=both |
1997 |
+ ;; |
1998 |
+ ppc|ppc64) |
1999 |
+ # Many arch-specific implementations do not work on ppc with |
2000 |
+ # cache-block not equal to 128 bytes. This breaks memset: |
2001 |
+ # https://sourceware.org/PR26522 |
2002 |
+ # https://bugs.gentoo.org/737996 |
2003 |
+ # Use default -mcpu=. For ppc it means non-multiarch setup. |
2004 |
+ filter-flags '-mcpu=*' |
2005 |
+ ;; |
2006 |
+ sparc) |
2007 |
+ # Both sparc and sparc64 can use -fcall-used-g6. -g7 is bad, though. |
2008 |
+ filter-flags "-fcall-used-g7" |
2009 |
+ append-flags "-fcall-used-g6" |
2010 |
+ |
2011 |
+ local cpu |
2012 |
+ case ${CTARGET} in |
2013 |
+ sparc64-*) |
2014 |
+ cpu="sparc64" |
2015 |
+ case $(get-flag mcpu) in |
2016 |
+ v9) |
2017 |
+ # We need to force at least v9a because the base build doesn't |
2018 |
+ # work with just v9. |
2019 |
+ # https://sourceware.org/bugzilla/show_bug.cgi?id=19477 |
2020 |
+ append-flags "-Wa,-xarch=v9a" |
2021 |
+ ;; |
2022 |
+ esac |
2023 |
+ ;; |
2024 |
+ sparc-*) |
2025 |
+ case $(get-flag mcpu) in |
2026 |
+ v8|supersparc|hypersparc|leon|leon3) |
2027 |
+ cpu="sparcv8" |
2028 |
+ ;; |
2029 |
+ *) |
2030 |
+ cpu="sparcv9" |
2031 |
+ ;; |
2032 |
+ esac |
2033 |
+ ;; |
2034 |
+ esac |
2035 |
+ [[ -n ${cpu} ]] && CTARGET_OPT="${cpu}-${CTARGET#*-}" |
2036 |
+ ;; |
2037 |
+ esac |
2038 |
+} |
2039 |
+ |
2040 |
+setup_flags() { |
2041 |
+ # Make sure host make.conf doesn't pollute us |
2042 |
+ if is_crosscompile || tc-is-cross-compiler ; then |
2043 |
+ CHOST=${CTARGET} strip-unsupported-flags |
2044 |
+ fi |
2045 |
+ |
2046 |
+ # Store our CFLAGS because it's changed depending on which CTARGET |
2047 |
+ # we are building when pulling glibc on a multilib profile |
2048 |
+ CFLAGS_BASE=${CFLAGS_BASE-${CFLAGS}} |
2049 |
+ CFLAGS=${CFLAGS_BASE} |
2050 |
+ CXXFLAGS_BASE=${CXXFLAGS_BASE-${CXXFLAGS}} |
2051 |
+ CXXFLAGS=${CXXFLAGS_BASE} |
2052 |
+ ASFLAGS_BASE=${ASFLAGS_BASE-${ASFLAGS}} |
2053 |
+ ASFLAGS=${ASFLAGS_BASE} |
2054 |
+ |
2055 |
+ # Allow users to explicitly avoid flag sanitization via |
2056 |
+ # USE=custom-cflags. |
2057 |
+ if ! use custom-cflags; then |
2058 |
+ # Over-zealous CFLAGS can often cause problems. What may work for one |
2059 |
+ # person may not work for another. To avoid a large influx of bugs |
2060 |
+ # relating to failed builds, we strip most CFLAGS out to ensure as few |
2061 |
+ # problems as possible. |
2062 |
+ strip-flags |
2063 |
+ # Lock glibc at -O2; we want to be conservative here. |
2064 |
+ filter-flags '-O?' |
2065 |
+ append-flags -O2 |
2066 |
+ fi |
2067 |
+ |
2068 |
+ strip-unsupported-flags |
2069 |
+ filter-flags -m32 -m64 '-mabi=*' |
2070 |
+ |
2071 |
+ # glibc aborts if rpath is set by LDFLAGS |
2072 |
+ filter-ldflags '-Wl,-rpath=*' |
2073 |
+ |
2074 |
+ # ld can't use -r & --relax at the same time, bug #788901 |
2075 |
+ # https://sourceware.org/PR27837 |
2076 |
+ filter-ldflags '-Wl,--relax' |
2077 |
+ |
2078 |
+ # #492892 |
2079 |
+ filter-flags -frecord-gcc-switches |
2080 |
+ |
2081 |
+ # #829583 |
2082 |
+ filter-lfs-flags |
2083 |
+ |
2084 |
+ unset CBUILD_OPT CTARGET_OPT |
2085 |
+ if use multilib ; then |
2086 |
+ CTARGET_OPT=$(get_abi_CTARGET) |
2087 |
+ [[ -z ${CTARGET_OPT} ]] && CTARGET_OPT=$(get_abi_CHOST) |
2088 |
+ fi |
2089 |
+ |
2090 |
+ setup_target_flags |
2091 |
+ |
2092 |
+ if [[ -n ${CTARGET_OPT} && ${CBUILD} == ${CHOST} ]] && ! is_crosscompile; then |
2093 |
+ CBUILD_OPT=${CTARGET_OPT} |
2094 |
+ fi |
2095 |
+ |
2096 |
+ # glibc's headers disallow -O0 and fail at build time: |
2097 |
+ # include/libc-symbols.h:75:3: #error "glibc cannot be compiled without optimization" |
2098 |
+ replace-flags -O0 -O1 |
2099 |
+ |
2100 |
+ filter-flags '-fstack-protector*' |
2101 |
+} |
2102 |
+ |
2103 |
+use_multiarch() { |
2104 |
+ # Allow user to disable runtime arch detection in multilib. |
2105 |
+ use multiarch || return 1 |
2106 |
+ # Make sure binutils is new enough to support indirect functions, |
2107 |
+ # #336792. This funky sed supports gold and bfd linkers. |
2108 |
+ local bver nver |
2109 |
+ bver=$($(tc-getLD ${CTARGET}) -v | sed -n -r '1{s:[^0-9]*::;s:^([0-9.]*).*:\1:;p}') |
2110 |
+ case $(tc-arch ${CTARGET}) in |
2111 |
+ amd64|x86) nver="2.20" ;; |
2112 |
+ arm) nver="2.22" ;; |
2113 |
+ hppa) nver="2.23" ;; |
2114 |
+ ppc|ppc64) nver="2.20" ;; |
2115 |
+ # ifunc support was added in 2.23, but glibc also needs |
2116 |
+ # machinemode which is in 2.24. |
2117 |
+ s390) nver="2.24" ;; |
2118 |
+ sparc) nver="2.21" ;; |
2119 |
+ *) return 1 ;; |
2120 |
+ esac |
2121 |
+ ver_test ${bver} -ge ${nver} |
2122 |
+} |
2123 |
+ |
2124 |
+# Setup toolchain variables that had historically been defined in the |
2125 |
+# profiles for these archs. |
2126 |
+setup_env() { |
2127 |
+ # silly users |
2128 |
+ unset LD_RUN_PATH |
2129 |
+ unset LD_ASSUME_KERNEL |
2130 |
+ |
2131 |
+ if is_crosscompile || tc-is-cross-compiler ; then |
2132 |
+ multilib_env ${CTARGET_OPT:-${CTARGET}} |
2133 |
+ |
2134 |
+ if ! use multilib ; then |
2135 |
+ MULTILIB_ABIS=${DEFAULT_ABI} |
2136 |
+ else |
2137 |
+ MULTILIB_ABIS=${MULTILIB_ABIS:-${DEFAULT_ABI}} |
2138 |
+ fi |
2139 |
+ |
2140 |
+ # If the user has CFLAGS_<CTARGET> in their make.conf, use that, |
2141 |
+ # and fall back on CFLAGS. |
2142 |
+ local VAR=CFLAGS_${CTARGET//[-.]/_} |
2143 |
+ CFLAGS=${!VAR-${CFLAGS}} |
2144 |
+ einfo " $(printf '%15s' 'Manual CFLAGS:') ${CFLAGS}" |
2145 |
+ fi |
2146 |
+ |
2147 |
+ setup_flags |
2148 |
+ |
2149 |
+ export ABI=${ABI:-${DEFAULT_ABI:-default}} |
2150 |
+ |
2151 |
+ if just_headers ; then |
2152 |
+ # Avoid mixing host's CC and target's CFLAGS_${ABI}: |
2153 |
+ # At this bootstrap stage we have only binutils for |
2154 |
+ # target but not compiler yet. |
2155 |
+ einfo "Skip CC ABI injection. We can't use (cross-)compiler yet." |
2156 |
+ return 0 |
2157 |
+ fi |
2158 |
+ |
2159 |
+ # Glibc does not work with gold (for various reasons) #269274. |
2160 |
+ tc-ld-disable-gold |
2161 |
+ |
2162 |
+ if use doc ; then |
2163 |
+ export MAKEINFO=makeinfo |
2164 |
+ else |
2165 |
+ export MAKEINFO=/dev/null |
2166 |
+ fi |
2167 |
+ |
2168 |
+ # Reset CC and CXX to the value at start of emerge |
2169 |
+ export CC=${__ORIG_CC:-${CC:-$(tc-getCC ${CTARGET})}} |
2170 |
+ export CXX=${__ORIG_CXX:-${CXX:-$(tc-getCXX ${CTARGET})}} |
2171 |
+ |
2172 |
+ # and make sure __ORIC_CC and __ORIG_CXX is defined now. |
2173 |
+ export __ORIG_CC=${CC} |
2174 |
+ export __ORIG_CXX=${CXX} |
2175 |
+ |
2176 |
+ if tc-is-clang && ! use custom-cflags && ! is_crosscompile ; then |
2177 |
+ |
2178 |
+ # If we are running in an otherwise clang/llvm environment, we need to |
2179 |
+ # recover the proper gcc and binutils settings here, at least until glibc |
2180 |
+ # is finally building with clang. So let's override everything that is |
2181 |
+ # set in the clang profiles. |
2182 |
+ # Want to shoot yourself into the foot? Set USE=custom-cflags, that's always |
2183 |
+ # a good start into that direction. |
2184 |
+ # Also, if you're crosscompiling, let's assume you know what you are doing. |
2185 |
+ # Hopefully. |
2186 |
+ # Last, we need the settings of the *build* environment, not of the |
2187 |
+ # target environment... |
2188 |
+ |
2189 |
+ local current_binutils_path=$(env ROOT="${BROOT}" binutils-config -B) |
2190 |
+ local current_gcc_path=$(env ROOT="${BROOT}" gcc-config -B) |
2191 |
+ einfo "Overriding clang configuration, since it won't work here" |
2192 |
+ |
2193 |
+ export CC="${current_gcc_path}/gcc" |
2194 |
+ export CXX="${current_gcc_path}/g++" |
2195 |
+ export LD="${current_binutils_path}/ld.bfd" |
2196 |
+ export AR="${current_binutils_path}/ar" |
2197 |
+ export AS="${current_binutils_path}/as" |
2198 |
+ export NM="${current_binutils_path}/nm" |
2199 |
+ export STRIP="${current_binutils_path}/strip" |
2200 |
+ export RANLIB="${current_binutils_path}/ranlib" |
2201 |
+ export OBJCOPY="${current_binutils_path}/objcopy" |
2202 |
+ export STRINGS="${current_binutils_path}/strings" |
2203 |
+ export OBJDUMP="${current_binutils_path}/objdump" |
2204 |
+ export READELF="${current_binutils_path}/readelf" |
2205 |
+ export ADDR2LINE="${current_binutils_path}/addr2line" |
2206 |
+ |
2207 |
+ # do we need to also do flags munging here? yes! at least... |
2208 |
+ filter-flags '-fuse-ld=*' |
2209 |
+ filter-flags '-D_FORTIFY_SOURCE=*' |
2210 |
+ |
2211 |
+ else |
2212 |
+ |
2213 |
+ # this is the "normal" case |
2214 |
+ |
2215 |
+ export CC="$(tc-getCC ${CTARGET})" |
2216 |
+ export CXX="$(tc-getCXX ${CTARGET})" |
2217 |
+ |
2218 |
+ # Always use tuple-prefixed toolchain. For non-native ABI glibc's configure |
2219 |
+ # can't detect them automatically due to ${CHOST} mismatch and fallbacks |
2220 |
+ # to unprefixed tools. Similar to multilib.eclass:multilib_toolchain_setup(). |
2221 |
+ export NM="$(tc-getNM ${CTARGET})" |
2222 |
+ export READELF="$(tc-getREADELF ${CTARGET})" |
2223 |
+ |
2224 |
+ fi |
2225 |
+ |
2226 |
+ # We need to export CFLAGS with abi information in them because glibc's |
2227 |
+ # configure script checks CFLAGS for some targets (like mips). Keep |
2228 |
+ # around the original clean value to avoid appending multiple ABIs on |
2229 |
+ # top of each other. (Why does the comment talk about CFLAGS if the code |
2230 |
+ # acts on CC?) |
2231 |
+ export __GLIBC_CC=${CC} |
2232 |
+ export __GLIBC_CXX=${CXX} |
2233 |
+ |
2234 |
+ export __abi_CFLAGS="$(get_abi_CFLAGS)" |
2235 |
+ |
2236 |
+ # CFLAGS can contain ABI-specific flags like -mfpu=neon, see bug #657760 |
2237 |
+ # To build .S (assembly) files with the same ABI-specific flags |
2238 |
+ # upstream currently recommends adding CFLAGS to CC/CXX: |
2239 |
+ # https://sourceware.org/PR23273 |
2240 |
+ # Note: Passing CFLAGS via CPPFLAGS overrides glibc's arch-specific CFLAGS |
2241 |
+ # and breaks multiarch support. See 659030#c3 for an example. |
2242 |
+ # The glibc configure script doesn't properly use LDFLAGS all the time. |
2243 |
+ export CC="${__GLIBC_CC} ${__abi_CFLAGS} ${CFLAGS} ${LDFLAGS}" |
2244 |
+ |
2245 |
+ # Some of the tests are written in C++, so we need to force our multlib abis in, bug 623548 |
2246 |
+ export CXX="${__GLIBC_CXX} ${__abi_CFLAGS} ${CFLAGS}" |
2247 |
+ |
2248 |
+ if is_crosscompile; then |
2249 |
+ # Assume worst-case bootstrap: glibc is buil first time |
2250 |
+ # when ${CTARGET}-g++ is not available yet. We avoid |
2251 |
+ # building auxiliary programs that require C++: bug #683074 |
2252 |
+ # It should not affect final result. |
2253 |
+ export libc_cv_cxx_link_ok=no |
2254 |
+ # The line above has the same effect. We set CXX explicitly |
2255 |
+ # to make build logs less confusing. |
2256 |
+ export CXX= |
2257 |
+ fi |
2258 |
+} |
2259 |
+ |
2260 |
+foreach_abi() { |
2261 |
+ setup_env |
2262 |
+ |
2263 |
+ local ret=0 |
2264 |
+ local abilist="" |
2265 |
+ if use multilib ; then |
2266 |
+ abilist=$(get_install_abis) |
2267 |
+ else |
2268 |
+ abilist=${DEFAULT_ABI} |
2269 |
+ fi |
2270 |
+ local -x ABI |
2271 |
+ for ABI in ${abilist:-default} ; do |
2272 |
+ setup_env |
2273 |
+ einfo "Running $1 for ABI ${ABI}" |
2274 |
+ $1 |
2275 |
+ : $(( ret |= $? )) |
2276 |
+ done |
2277 |
+ return ${ret} |
2278 |
+} |
2279 |
+ |
2280 |
+glibc_banner() { |
2281 |
+ local b="Gentoo ${PVR}" |
2282 |
+ [[ -n ${PATCH_VER} ]] && ! use vanilla && b+=" p${PATCH_VER}" |
2283 |
+ echo "${b}" |
2284 |
+} |
2285 |
+ |
2286 |
+# The following Kernel version handling functions are mostly copied from portage |
2287 |
+# source. It's better not to use linux-info.eclass here since a) it adds too |
2288 |
+# much magic, see bug 326693 for some of the arguments, and b) some of the |
2289 |
+# functions are just not provided. |
2290 |
+ |
2291 |
+g_get_running_KV() { |
2292 |
+ uname -r |
2293 |
+ return $? |
2294 |
+} |
2295 |
+ |
2296 |
+g_KV_major() { |
2297 |
+ [[ -z $1 ]] && return 1 |
2298 |
+ local KV=$@ |
2299 |
+ echo "${KV%%.*}" |
2300 |
+} |
2301 |
+ |
2302 |
+g_KV_minor() { |
2303 |
+ [[ -z $1 ]] && return 1 |
2304 |
+ local KV=$@ |
2305 |
+ KV=${KV#*.} |
2306 |
+ echo "${KV%%.*}" |
2307 |
+} |
2308 |
+ |
2309 |
+g_KV_micro() { |
2310 |
+ [[ -z $1 ]] && return 1 |
2311 |
+ local KV=$@ |
2312 |
+ KV=${KV#*.*.} |
2313 |
+ echo "${KV%%[^[:digit:]]*}" |
2314 |
+} |
2315 |
+ |
2316 |
+g_KV_to_int() { |
2317 |
+ [[ -z $1 ]] && return 1 |
2318 |
+ local KV_MAJOR=$(g_KV_major "$1") |
2319 |
+ local KV_MINOR=$(g_KV_minor "$1") |
2320 |
+ local KV_MICRO=$(g_KV_micro "$1") |
2321 |
+ local KV_int=$(( KV_MAJOR * 65536 + KV_MINOR * 256 + KV_MICRO )) |
2322 |
+ |
2323 |
+ # We make version 2.2.0 the minimum version we will handle as |
2324 |
+ # a sanity check ... if its less, we fail ... |
2325 |
+ if [[ ${KV_int} -ge 131584 ]] ; then |
2326 |
+ echo "${KV_int}" |
2327 |
+ return 0 |
2328 |
+ fi |
2329 |
+ return 1 |
2330 |
+} |
2331 |
+ |
2332 |
+g_int_to_KV() { |
2333 |
+ local version=$1 major minor micro |
2334 |
+ major=$((version / 65536)) |
2335 |
+ minor=$(((version % 65536) / 256)) |
2336 |
+ micro=$((version % 256)) |
2337 |
+ echo ${major}.${minor}.${micro} |
2338 |
+} |
2339 |
+ |
2340 |
+eend_KV() { |
2341 |
+ [[ $(g_KV_to_int $1) -ge $(g_KV_to_int $2) ]] |
2342 |
+ eend $? |
2343 |
+} |
2344 |
+ |
2345 |
+get_kheader_version() { |
2346 |
+ printf '#include <linux/version.h>\nLINUX_VERSION_CODE\n' | \ |
2347 |
+ $(tc-getCPP ${CTARGET}) -I "$(build_eprefix)$(alt_build_headers)" - | \ |
2348 |
+ tail -n 1 |
2349 |
+} |
2350 |
+ |
2351 |
+# We collect all sanity checks here. Consistency is not guranteed between |
2352 |
+# pkg_ and src_ phases, so we call this function both in pkg_pretend and in |
2353 |
+# src_unpack. |
2354 |
+sanity_prechecks() { |
2355 |
+ # Prevent native builds from downgrading |
2356 |
+ if [[ ${MERGE_TYPE} != "buildonly" ]] && \ |
2357 |
+ [[ -z ${ROOT} ]] && \ |
2358 |
+ [[ ${CBUILD} == ${CHOST} ]] && \ |
2359 |
+ [[ ${CHOST} == ${CTARGET} ]] ; then |
2360 |
+ |
2361 |
+ # The high rev # is to allow people to downgrade between -r# |
2362 |
+ # versions. We want to block 2.20->2.19, but 2.20-r3->2.20-r2 |
2363 |
+ # should be fine. Hopefully we never actually use a r# this |
2364 |
+ # high. |
2365 |
+ if has_version ">${CATEGORY}/${P}-r10000" ; then |
2366 |
+ eerror "Sanity check to keep you from breaking your system:" |
2367 |
+ eerror " Downgrading glibc is not supported and a sure way to destruction." |
2368 |
+ [[ ${I_ALLOW_TO_BREAK_MY_SYSTEM} = yes ]] || die "Aborting to save your system." |
2369 |
+ fi |
2370 |
+ |
2371 |
+ if ! do_run_test '#include <unistd.h>\n#include <sys/syscall.h>\nint main(){return syscall(1000)!=-1;}\n' ; then |
2372 |
+ eerror "Your old kernel is broken. You need to update it to a newer" |
2373 |
+ eerror "version as syscall(<bignum>) will break. See bug 279260." |
2374 |
+ die "Old and broken kernel." |
2375 |
+ fi |
2376 |
+ fi |
2377 |
+ |
2378 |
+ # Users have had a chance to phase themselves, time to give em the boot |
2379 |
+ if [[ -e ${EROOT}/etc/locale.gen ]] && [[ -e ${EROOT}/etc/locales.build ]] ; then |
2380 |
+ eerror "You still haven't deleted ${EROOT}/etc/locales.build." |
2381 |
+ eerror "Do so now after making sure ${EROOT}/etc/locale.gen is kosher." |
2382 |
+ die "Lazy upgrader detected" |
2383 |
+ fi |
2384 |
+ |
2385 |
+ if [[ ${CTARGET} == i386-* ]] ; then |
2386 |
+ eerror "i386 CHOSTs are no longer supported." |
2387 |
+ eerror "Chances are you don't actually want/need i386." |
2388 |
+ eerror "Please read https://www.gentoo.org/doc/en/change-chost.xml" |
2389 |
+ die "Please fix your CHOST" |
2390 |
+ fi |
2391 |
+ |
2392 |
+ if [[ -e /proc/xen ]] && [[ $(tc-arch) == "x86" ]] && ! is-flag -mno-tls-direct-seg-refs ; then |
2393 |
+ ewarn "You are using Xen but don't have -mno-tls-direct-seg-refs in your CFLAGS." |
2394 |
+ ewarn "This will result in a 50% performance penalty when running with a 32bit" |
2395 |
+ ewarn "hypervisor, which is probably not what you want." |
2396 |
+ fi |
2397 |
+ |
2398 |
+ # ABI-specific checks follow here. Hey, we have a lot more specific conditions that |
2399 |
+ # we test for... |
2400 |
+ if ! is_crosscompile ; then |
2401 |
+ if use amd64 && use multilib && [[ ${MERGE_TYPE} != "binary" ]] ; then |
2402 |
+ ebegin "Checking that IA32 emulation is enabled in the running kernel" |
2403 |
+ echo 'int main(){return 0;}' > "${T}/check-ia32-emulation.c" |
2404 |
+ local STAT |
2405 |
+ if ${CC-${CHOST}-gcc} ${CFLAGS_x86} "${T}/check-ia32-emulation.c" -o "${T}/check-ia32-emulation.elf32"; then |
2406 |
+ "${T}/check-ia32-emulation.elf32" |
2407 |
+ STAT=$? |
2408 |
+ else |
2409 |
+ # Don't fail here to allow single->multi ABI switch |
2410 |
+ # or recover from breakage like bug #646424 |
2411 |
+ ewarn "Failed to compile the ABI test. Broken host glibc?" |
2412 |
+ STAT=0 |
2413 |
+ fi |
2414 |
+ rm -f "${T}/check-ia32-emulation.elf32" |
2415 |
+ eend $STAT |
2416 |
+ [[ $STAT -eq 0 ]] || die "CONFIG_IA32_EMULATION must be enabled in the kernel to compile a multilib glibc." |
2417 |
+ fi |
2418 |
+ |
2419 |
+ fi |
2420 |
+ |
2421 |
+ # When we actually have to compile something... |
2422 |
+ if ! just_headers && [[ ${MERGE_TYPE} != "binary" ]] ; then |
2423 |
+ if [[ -d "${ESYSROOT}"/usr/lib/include ]] ; then |
2424 |
+ # bug #833620, bug #643302 |
2425 |
+ eerror "Found ${ESYSROOT}/usr/lib/include directory!" |
2426 |
+ eerror "This is known to break glibc's build." |
2427 |
+ eerror "Please backup its contents then remove the directory." |
2428 |
+ die "Found directory (${ESYSROOT}/usr/lib/include) which will break build (bug #833620)!" |
2429 |
+ fi |
2430 |
+ |
2431 |
+ if [[ ${CTARGET} == *-linux* ]] ; then |
2432 |
+ local run_kv build_kv want_kv |
2433 |
+ |
2434 |
+ run_kv=$(g_get_running_KV) |
2435 |
+ build_kv=$(g_int_to_KV $(get_kheader_version)) |
2436 |
+ want_kv=${MIN_KERN_VER} |
2437 |
+ |
2438 |
+ if ! is_crosscompile && ! tc-is-cross-compiler ; then |
2439 |
+ # Building fails on an non-supporting kernel |
2440 |
+ ebegin "Checking running kernel version (${run_kv} >= ${want_kv})" |
2441 |
+ if ! eend_KV ${run_kv} ${want_kv} ; then |
2442 |
+ echo |
2443 |
+ eerror "You need a kernel of at least ${want_kv}!" |
2444 |
+ die "Kernel version too low!" |
2445 |
+ fi |
2446 |
+ fi |
2447 |
+ |
2448 |
+ ebegin "Checking linux-headers version (${build_kv} >= ${want_kv})" |
2449 |
+ if ! eend_KV ${build_kv} ${want_kv} ; then |
2450 |
+ echo |
2451 |
+ eerror "You need linux-headers of at least ${want_kv}!" |
2452 |
+ die "linux-headers version too low!" |
2453 |
+ fi |
2454 |
+ fi |
2455 |
+ fi |
2456 |
+} |
2457 |
+ |
2458 |
+upgrade_warning() { |
2459 |
+ if [[ ${MERGE_TYPE} != buildonly && -n ${REPLACING_VERSIONS} && -z ${ROOT} ]]; then |
2460 |
+ local oldv newv=$(ver_cut 1-2 ${PV}) |
2461 |
+ for oldv in ${REPLACING_VERSIONS}; do |
2462 |
+ if ver_test ${oldv} -lt ${newv}; then |
2463 |
+ ewarn "After upgrading glibc, please restart all running processes." |
2464 |
+ ewarn "Be sure to include init (telinit u) or systemd (systemctl daemon-reexec)." |
2465 |
+ ewarn "Alternatively, reboot your system." |
2466 |
+ ewarn "(See bug #660556, bug #741116, bug #823756, etc)" |
2467 |
+ break |
2468 |
+ fi |
2469 |
+ done |
2470 |
+ fi |
2471 |
+} |
2472 |
+ |
2473 |
+# |
2474 |
+# the phases |
2475 |
+# |
2476 |
+ |
2477 |
+# pkg_pretend |
2478 |
+ |
2479 |
+pkg_pretend() { |
2480 |
+ upgrade_warning |
2481 |
+} |
2482 |
+ |
2483 |
+pkg_setup() { |
2484 |
+ # see bug 682570 |
2485 |
+ [[ -z ${BOOTSTRAP_RAP} ]] && python-any-r1_pkg_setup |
2486 |
+} |
2487 |
+ |
2488 |
+# src_unpack |
2489 |
+ |
2490 |
+src_unpack() { |
2491 |
+ setup_env |
2492 |
+ |
2493 |
+ einfo "Checking general environment sanity." |
2494 |
+ sanity_prechecks |
2495 |
+ |
2496 |
+ use multilib-bootstrap && unpack gcc-multilib-bootstrap-${GCC_BOOTSTRAP_VER}.tar.xz |
2497 |
+ |
2498 |
+ if [[ ${PV} == 9999* ]] ; then |
2499 |
+ EGIT_REPO_URI="https://anongit.gentoo.org/git/proj/toolchain/glibc-patches.git" |
2500 |
+ EGIT_CHECKOUT_DIR=${WORKDIR}/patches-git |
2501 |
+ git-r3_src_unpack |
2502 |
+ mv patches-git/9999 patches || die |
2503 |
+ |
2504 |
+ EGIT_REPO_URI="https://sourceware.org/git/glibc.git" |
2505 |
+ EGIT_CHECKOUT_DIR=${S} |
2506 |
+ git-r3_src_unpack |
2507 |
+ else |
2508 |
+ unpack ${P}.tar.xz |
2509 |
+ |
2510 |
+ cd "${WORKDIR}" || die |
2511 |
+ unpack glibc-${RELEASE_VER}-patches-${PATCH_VER}.tar.xz |
2512 |
+ fi |
2513 |
+ |
2514 |
+ cd "${WORKDIR}" || die |
2515 |
+ unpack locale-gen-${LOCALE_GEN_VER}.tar.gz |
2516 |
+ use systemd && unpack glibc-systemd-${GLIBC_SYSTEMD_VER}.tar.gz |
2517 |
+} |
2518 |
+ |
2519 |
+src_prepare() { |
2520 |
+ local patchsetname |
2521 |
+ if ! use vanilla ; then |
2522 |
+ if [[ ${PV} == 9999* ]] ; then |
2523 |
+ patchsetname="from git master" |
2524 |
+ else |
2525 |
+ patchsetname="${RELEASE_VER}-${PATCH_VER}" |
2526 |
+ fi |
2527 |
+ einfo "Applying Gentoo Glibc Patchset ${patchsetname}" |
2528 |
+ eapply "${WORKDIR}"/patches |
2529 |
+ einfo "Done." |
2530 |
+ fi |
2531 |
+ |
2532 |
+ if use clone3 ; then |
2533 |
+ append-cppflags -DGENTOO_USE_CLONE3 |
2534 |
+ else |
2535 |
+ # See e.g. bug #827386, bug #819045. |
2536 |
+ elog "Disabling the clone3 syscall for compatibility with older Electron apps." |
2537 |
+ elog "Please re-enable this flag before filing bugs!" |
2538 |
+ fi |
2539 |
+ |
2540 |
+ default |
2541 |
+ |
2542 |
+ gnuconfig_update |
2543 |
+ |
2544 |
+ cd "${WORKDIR}" |
<