1 |
commit: 860cbbb5dfad9cac7f44743c91d007faf4f450ed |
2 |
Author: Andreas K. Hüttel <dilfridge <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sun Jan 16 14:45:17 2022 +0000 |
4 |
Commit: Andreas K. Hüttel <dilfridge <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun Jan 16 14:45:52 2022 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=860cbbb5 |
7 |
|
8 |
toolchain-glibc.eclass: Begone foul spirit! |
9 |
|
10 |
Signed-off-by: Andreas K. Hüttel <dilfridge <AT> gentoo.org> |
11 |
|
12 |
eclass/toolchain-glibc.eclass | 1488 ----------------------------------------- |
13 |
1 file changed, 1488 deletions(-) |
14 |
|
15 |
diff --git a/eclass/toolchain-glibc.eclass b/eclass/toolchain-glibc.eclass |
16 |
deleted file mode 100644 |
17 |
index a0a407882d60..000000000000 |
18 |
--- a/eclass/toolchain-glibc.eclass |
19 |
+++ /dev/null |
20 |
@@ -1,1488 +0,0 @@ |
21 |
-# Copyright 1999-2019 Gentoo Authors |
22 |
-# Distributed under the terms of the GNU General Public License v2 |
23 |
- |
24 |
-# @DEAD |
25 |
- |
26 |
-# @ECLASS: toolchain-glibc.eclass |
27 |
-# @MAINTAINER: |
28 |
-# <toolchain@g.o> |
29 |
-# @SUPPORTED_EAPIS: 0 1 2 3 4 5 6 |
30 |
-# @BLURB: Common code for sys-libs/glibc ebuilds |
31 |
-# @DESCRIPTION: |
32 |
-# This eclass contains the common phase functions migrated from |
33 |
-# sys-libs/glibc eblits. |
34 |
- |
35 |
-if [[ -z ${_TOOLCHAIN_GLIBC_ECLASS} ]]; then |
36 |
- |
37 |
-TMPFILES_OPTIONAL=1 |
38 |
- |
39 |
-inherit eutils versionator toolchain-funcs flag-o-matic gnuconfig \ |
40 |
- multilib systemd tmpfiles unpacker multiprocessing prefix |
41 |
- |
42 |
-case ${EAPI:-0} in |
43 |
- 0|1|2|3) EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_test \ |
44 |
- src_install pkg_preinst pkg_postinst;; |
45 |
- 2|3) EXPORT_FUNCTIONS pkg_setup src_unpack src_prepare src_configure \ |
46 |
- src_compile src_test src_install pkg_preinst pkg_postinst;; |
47 |
- 4|5) EXPORT_FUNCTIONS pkg_pretend pkg_setup src_unpack src_prepare \ |
48 |
- src_configure src_compile src_test src_install \ |
49 |
- pkg_preinst pkg_postinst;; |
50 |
- 6) EXPORT_FUNCTIONS pkg_pretend;; |
51 |
- *) die "Unsupported EAPI=${EAPI}";; |
52 |
-esac |
53 |
- |
54 |
-# == common == |
55 |
- |
56 |
-alt_prefix() { |
57 |
- is_crosscompile && echo /usr/${CTARGET} |
58 |
-} |
59 |
- |
60 |
-if [[ ${EAPI:-0} == [012] ]] ; then |
61 |
- : ${ED:=${D}} |
62 |
- : ${EROOT:=${ROOT}} |
63 |
-fi |
64 |
-# This indirection is for binpkgs. #523332 |
65 |
-_nonfatal() { nonfatal "$@" ; } |
66 |
-if [[ ${EAPI:-0} == [0123] ]] ; then |
67 |
- nonfatal() { "$@" ; } |
68 |
- _nonfatal() { "$@" ; } |
69 |
-fi |
70 |
- |
71 |
-# We need to be able to set alternative headers for |
72 |
-# compiling for non-native platform |
73 |
-# Will also become useful for testing kernel-headers without screwing up |
74 |
-# the whole system. |
75 |
-# note: intentionally undocumented. |
76 |
-alt_headers() { |
77 |
- echo ${ALT_HEADERS:=$(alt_prefix)/usr/include} |
78 |
-} |
79 |
-alt_build_headers() { |
80 |
- if [[ -z ${ALT_BUILD_HEADERS} ]] ; then |
81 |
- ALT_BUILD_HEADERS="${EPREFIX}$(alt_headers)" |
82 |
- if tc-is-cross-compiler ; then |
83 |
- ALT_BUILD_HEADERS=${SYSROOT}$(alt_headers) |
84 |
- if [[ ! -e ${ALT_BUILD_HEADERS}/linux/version.h ]] ; then |
85 |
- local header_path=$(echo '#include <linux/version.h>' | $(tc-getCPP ${CTARGET}) ${CFLAGS} 2>&1 | grep -o '[^"]*linux/version.h') |
86 |
- ALT_BUILD_HEADERS=${header_path%/linux/version.h} |
87 |
- fi |
88 |
- fi |
89 |
- fi |
90 |
- echo "${ALT_BUILD_HEADERS}" |
91 |
-} |
92 |
- |
93 |
-alt_libdir() { |
94 |
- echo $(alt_prefix)/$(get_libdir) |
95 |
-} |
96 |
-alt_usrlibdir() { |
97 |
- echo $(alt_prefix)/usr/$(get_libdir) |
98 |
-} |
99 |
- |
100 |
-builddir() { |
101 |
- echo "${WORKDIR}/build-${ABI}-${CTARGET}-$1" |
102 |
-} |
103 |
- |
104 |
-setup_target_flags() { |
105 |
- # This largely mucks with compiler flags. None of which should matter |
106 |
- # when building up just the headers. |
107 |
- just_headers && return 0 |
108 |
- |
109 |
- case $(tc-arch) in |
110 |
- x86) |
111 |
- # -march needed for #185404 #199334 |
112 |
- # TODO: When creating the first glibc cross-compile, this test will |
113 |
- # always fail as it does a full link which in turn requires glibc. |
114 |
- # Probably also applies when changing multilib profile settings (e.g. |
115 |
- # enabling x86 when the profile was amd64-only previously). |
116 |
- # We could change main to _start and pass -nostdlib here so that we |
117 |
- # only test the gcc code compilation. Or we could do a compile and |
118 |
- # then look for the symbol via scanelf. |
119 |
- if ! glibc_compile_test "" 'void f(int i, void *p) {if (__sync_fetch_and_add(&i, 1)) f(i, p);}\nint main(){return 0;}\n' 2>/dev/null ; then |
120 |
- local t=${CTARGET_OPT:-${CTARGET}} |
121 |
- t=${t%%-*} |
122 |
- filter-flags '-march=*' |
123 |
- export CFLAGS="-march=${t} ${CFLAGS}" |
124 |
- einfo "Auto adding -march=${t} to CFLAGS #185404" |
125 |
- fi |
126 |
- ;; |
127 |
- amd64) |
128 |
- # -march needed for #185404 #199334 |
129 |
- # Note: This test only matters when the x86 ABI is enabled, so we could |
130 |
- # optimize a bit and elide it. |
131 |
- # TODO: See cross-compile issues listed above for x86. |
132 |
- if ! glibc_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' 2>/dev/null ; then |
133 |
- local t=${CTARGET_OPT:-${CTARGET}} |
134 |
- t=${t%%-*} |
135 |
- # Normally the target is x86_64-xxx, so turn that into the -march that |
136 |
- # gcc actually accepts. #528708 |
137 |
- [[ ${t} == "x86_64" ]] && t="x86-64" |
138 |
- filter-flags '-march=*' |
139 |
- # ugly, ugly, ugly. ugly. |
140 |
- CFLAGS_x86=$(CFLAGS=${CFLAGS_x86} filter-flags '-march=*'; echo "${CFLAGS}") |
141 |
- export CFLAGS_x86="${CFLAGS_x86} -march=${t}" |
142 |
- einfo "Auto adding -march=${t} to CFLAGS_x86 #185404" |
143 |
- fi |
144 |
- ;; |
145 |
- mips) |
146 |
- # The mips abi cannot support the GNU style hashes. #233233 |
147 |
- filter-ldflags -Wl,--hash-style=gnu -Wl,--hash-style=both |
148 |
- ;; |
149 |
- sparc) |
150 |
- # Both sparc and sparc64 can use -fcall-used-g6. -g7 is bad, though. |
151 |
- filter-flags "-fcall-used-g7" |
152 |
- append-flags "-fcall-used-g6" |
153 |
- |
154 |
- # If the CHOST is the basic one (e.g. not sparcv9-xxx already), |
155 |
- # try to pick a better one so glibc can use cpu-specific .S files. |
156 |
- # We key off the CFLAGS to get a good value. Also need to handle |
157 |
- # version skew. |
158 |
- # We can't force users to set their CHOST to their exact machine |
159 |
- # as many of these are not recognized by config.sub/gcc and such :(. |
160 |
- # Note: If the mcpu values don't scale, we might try probing CPP defines. |
161 |
- # Note: Should we factor in -Wa,-AvXXX flags too ? Or -mvis/etc... ? |
162 |
- |
163 |
- local cpu |
164 |
- case ${CTARGET} in |
165 |
- sparc64-*) |
166 |
- case $(get-flag mcpu) in |
167 |
- niagara[234]) |
168 |
- if version_is_at_least 2.8 ; then |
169 |
- cpu="sparc64v2" |
170 |
- elif version_is_at_least 2.4 ; then |
171 |
- cpu="sparc64v" |
172 |
- elif version_is_at_least 2.2.3 ; then |
173 |
- cpu="sparc64b" |
174 |
- fi |
175 |
- ;; |
176 |
- niagara) |
177 |
- if version_is_at_least 2.4 ; then |
178 |
- cpu="sparc64v" |
179 |
- elif version_is_at_least 2.2.3 ; then |
180 |
- cpu="sparc64b" |
181 |
- fi |
182 |
- ;; |
183 |
- ultrasparc3) |
184 |
- cpu="sparc64b" |
185 |
- ;; |
186 |
- *) |
187 |
- # We need to force at least v9a because the base build doesn't |
188 |
- # work with just v9. |
189 |
- # https://sourceware.org/bugzilla/show_bug.cgi?id=19477 |
190 |
- [[ -z ${cpu} ]] && append-flags "-Wa,-xarch=v9a" |
191 |
- ;; |
192 |
- esac |
193 |
- ;; |
194 |
- sparc-*) |
195 |
- case $(get-flag mcpu) in |
196 |
- niagara[234]) |
197 |
- if version_is_at_least 2.8 ; then |
198 |
- cpu="sparcv9v2" |
199 |
- elif version_is_at_least 2.4 ; then |
200 |
- cpu="sparcv9v" |
201 |
- elif version_is_at_least 2.2.3 ; then |
202 |
- cpu="sparcv9b" |
203 |
- else |
204 |
- cpu="sparcv9" |
205 |
- fi |
206 |
- ;; |
207 |
- niagara) |
208 |
- if version_is_at_least 2.4 ; then |
209 |
- cpu="sparcv9v" |
210 |
- elif version_is_at_least 2.2.3 ; then |
211 |
- cpu="sparcv9b" |
212 |
- else |
213 |
- cpu="sparcv9" |
214 |
- fi |
215 |
- ;; |
216 |
- ultrasparc3) |
217 |
- cpu="sparcv9b" |
218 |
- ;; |
219 |
- v9|ultrasparc) |
220 |
- cpu="sparcv9" |
221 |
- ;; |
222 |
- v8|supersparc|hypersparc|leon|leon3) |
223 |
- cpu="sparcv8" |
224 |
- ;; |
225 |
- esac |
226 |
- ;; |
227 |
- esac |
228 |
- [[ -n ${cpu} ]] && CTARGET_OPT="${cpu}-${CTARGET#*-}" |
229 |
- ;; |
230 |
- esac |
231 |
-} |
232 |
- |
233 |
-setup_flags() { |
234 |
- # Make sure host make.conf doesn't pollute us |
235 |
- if is_crosscompile || tc-is-cross-compiler ; then |
236 |
- CHOST=${CTARGET} strip-unsupported-flags |
237 |
- fi |
238 |
- |
239 |
- # Store our CFLAGS because it's changed depending on which CTARGET |
240 |
- # we are building when pulling glibc on a multilib profile |
241 |
- CFLAGS_BASE=${CFLAGS_BASE-${CFLAGS}} |
242 |
- CFLAGS=${CFLAGS_BASE} |
243 |
- CXXFLAGS_BASE=${CXXFLAGS_BASE-${CXXFLAGS}} |
244 |
- CXXFLAGS=${CXXFLAGS_BASE} |
245 |
- ASFLAGS_BASE=${ASFLAGS_BASE-${ASFLAGS}} |
246 |
- ASFLAGS=${ASFLAGS_BASE} |
247 |
- |
248 |
- # Over-zealous CFLAGS can often cause problems. What may work for one |
249 |
- # person may not work for another. To avoid a large influx of bugs |
250 |
- # relating to failed builds, we strip most CFLAGS out to ensure as few |
251 |
- # problems as possible. |
252 |
- strip-flags |
253 |
- strip-unsupported-flags |
254 |
- filter-flags -m32 -m64 -mabi=* |
255 |
- filter-ldflags -Wl,-rpath=* |
256 |
- |
257 |
- # Bug 492892. |
258 |
- filter-flags -frecord-gcc-switches |
259 |
- |
260 |
- unset CBUILD_OPT CTARGET_OPT |
261 |
- if use multilib ; then |
262 |
- CTARGET_OPT=$(get_abi_CTARGET) |
263 |
- [[ -z ${CTARGET_OPT} ]] && CTARGET_OPT=$(get_abi_CHOST) |
264 |
- fi |
265 |
- |
266 |
- setup_target_flags |
267 |
- |
268 |
- if [[ -n ${CTARGET_OPT} && ${CBUILD} == ${CHOST} ]] && ! is_crosscompile; then |
269 |
- CBUILD_OPT=${CTARGET_OPT} |
270 |
- fi |
271 |
- |
272 |
- # Lock glibc at -O2 -- linuxthreads needs it and we want to be |
273 |
- # conservative here. -fno-strict-aliasing is to work around #155906 |
274 |
- filter-flags -O? |
275 |
- append-flags -O2 -fno-strict-aliasing |
276 |
- |
277 |
- # Can't build glibc itself with fortify code. Newer versions add |
278 |
- # this flag for us, so no need to do it manually. |
279 |
- version_is_at_least 2.16 ${PV} || append-cppflags -U_FORTIFY_SOURCE |
280 |
- |
281 |
- # building glibc <2.25 with SSP is fraught with difficulty, especially |
282 |
- # due to __stack_chk_fail_local which would mean significant changes |
283 |
- # to the glibc build process. See bug #94325 #293721 |
284 |
- # Note we have to handle both user-given CFLAGS and gcc defaults via |
285 |
- # spec rules here. We can't simply add -fno-stack-protector as it gets |
286 |
- # added before user flags, and we can't just filter-flags because |
287 |
- # _filter_hardened doesn't support globs. |
288 |
- filter-flags -fstack-protector* |
289 |
- if ! version_is_at_least 2.25 ; then |
290 |
- tc-enables-ssp && append-flags $(test-flags -fno-stack-protector) |
291 |
- fi |
292 |
- |
293 |
- if [[ $(gcc-major-version) -lt 6 ]]; then |
294 |
- # Starting with gcc-6 (and fully upstreamed pie patches) we control |
295 |
- # default enabled/disabled pie via use flags. So nothing to do |
296 |
- # here. #618160 |
297 |
- |
298 |
- if use hardened && tc-enables-pie ; then |
299 |
- # Force PIC macro definition for all compilations since they're all |
300 |
- # either -fPIC or -fPIE with the default-PIE compiler. |
301 |
- append-cppflags -DPIC |
302 |
- else |
303 |
- # Don't build -fPIE without the default-PIE compiler and the |
304 |
- # hardened-pie patch |
305 |
- filter-flags -fPIE |
306 |
- fi |
307 |
- fi |
308 |
-} |
309 |
- |
310 |
-want_nptl() { |
311 |
- [[ -z ${LT_VER} ]] && return 0 |
312 |
- want_tls || return 1 |
313 |
- use nptl || return 1 |
314 |
- |
315 |
- # Older versions of glibc had incomplete arch support for nptl. |
316 |
- # But if you're building those now, you can handle USE=nptl yourself. |
317 |
- return 0 |
318 |
-} |
319 |
- |
320 |
-want_linuxthreads() { |
321 |
- [[ -z ${LT_VER} ]] && return 1 |
322 |
- use linuxthreads |
323 |
-} |
324 |
- |
325 |
-want_tls() { |
326 |
- # Archs that can use TLS (Thread Local Storage) |
327 |
- case $(tc-arch) in |
328 |
- x86) |
329 |
- # requires i486 or better #106556 |
330 |
- [[ ${CTARGET} == i[4567]86* ]] && return 0 |
331 |
- return 1 |
332 |
- ;; |
333 |
- esac |
334 |
- |
335 |
- return 0 |
336 |
-} |
337 |
- |
338 |
-want__thread() { |
339 |
- want_tls || return 1 |
340 |
- |
341 |
- # For some reason --with-tls --with__thread is causing segfaults on sparc32. |
342 |
- [[ ${PROFILE_ARCH} == "sparc" ]] && return 1 |
343 |
- |
344 |
- [[ -n ${WANT__THREAD} ]] && return ${WANT__THREAD} |
345 |
- |
346 |
- # only test gcc -- can't test linking yet |
347 |
- tc-has-tls -c ${CTARGET} |
348 |
- WANT__THREAD=$? |
349 |
- |
350 |
- return ${WANT__THREAD} |
351 |
-} |
352 |
- |
353 |
-use_multiarch() { |
354 |
- # Make sure binutils is new enough to support indirect functions #336792 |
355 |
- # This funky sed supports gold and bfd linkers. |
356 |
- local bver nver |
357 |
- bver=$($(tc-getLD ${CTARGET}) -v | sed -n -r '1{s:[^0-9]*::;s:^([0-9.]*).*:\1:;p}') |
358 |
- case $(tc-arch ${CTARGET}) in |
359 |
- amd64|x86) nver="2.20" ;; |
360 |
- arm) nver="2.22" ;; |
361 |
- hppa) nver="2.23" ;; |
362 |
- ppc|ppc64) nver="2.20" ;; |
363 |
- # ifunc was added in 2.23, but glibc also needs machinemode which is in 2.24. |
364 |
- s390) nver="2.24" ;; |
365 |
- sparc) nver="2.21" ;; |
366 |
- *) return 1 ;; |
367 |
- esac |
368 |
- version_is_at_least ${nver} ${bver} |
369 |
-} |
370 |
- |
371 |
-# Setup toolchain variables that had historically |
372 |
-# been defined in the profiles for these archs. |
373 |
-setup_env() { |
374 |
- # silly users |
375 |
- unset LD_RUN_PATH |
376 |
- unset LD_ASSUME_KERNEL |
377 |
- |
378 |
- if is_crosscompile || tc-is-cross-compiler ; then |
379 |
- multilib_env ${CTARGET_OPT:-${CTARGET}} |
380 |
- |
381 |
- if ! use multilib ; then |
382 |
- MULTILIB_ABIS=${DEFAULT_ABI} |
383 |
- else |
384 |
- MULTILIB_ABIS=${MULTILIB_ABIS:-${DEFAULT_ABI}} |
385 |
- fi |
386 |
- |
387 |
- # If the user has CFLAGS_<CTARGET> in their make.conf, use that, |
388 |
- # and fall back on CFLAGS. |
389 |
- local VAR=CFLAGS_${CTARGET//[-.]/_} |
390 |
- CFLAGS=${!VAR-${CFLAGS}} |
391 |
- einfo " $(printf '%15s' 'Manual CFLAGS:') ${CFLAGS}" |
392 |
- fi |
393 |
- |
394 |
- setup_flags |
395 |
- |
396 |
- export ABI=${ABI:-${DEFAULT_ABI:-default}} |
397 |
- |
398 |
- if just_headers ; then |
399 |
- # Avoid mixing host's CC and target's CFLAGS_${ABI}: |
400 |
- # At this bootstrap stage we have only binutils for |
401 |
- # target but not compiler yet. |
402 |
- einfo "Skip CC ABI injection. We can't use (cross-)compiler yet." |
403 |
- return 0 |
404 |
- fi |
405 |
- |
406 |
- local VAR=CFLAGS_${ABI} |
407 |
- # We need to export CFLAGS with abi information in them because glibc's |
408 |
- # configure script checks CFLAGS for some targets (like mips). Keep |
409 |
- # around the original clean value to avoid appending multiple ABIs on |
410 |
- # top of each other. |
411 |
- : ${__GLIBC_CC:=$(tc-getCC ${CTARGET_OPT:-${CTARGET}})} |
412 |
- export __GLIBC_CC CC="${__GLIBC_CC} ${!VAR}" |
413 |
- einfo " $(printf '%15s' 'Manual CC:') ${CC}" |
414 |
-} |
415 |
- |
416 |
-foreach_abi() { |
417 |
- setup_env |
418 |
- |
419 |
- local ret=0 |
420 |
- local abilist="" |
421 |
- if use multilib ; then |
422 |
- abilist=$(get_install_abis) |
423 |
- else |
424 |
- abilist=${DEFAULT_ABI} |
425 |
- fi |
426 |
- local -x ABI |
427 |
- for ABI in ${abilist:-default} ; do |
428 |
- setup_env |
429 |
- einfo "Running $1 for ABI ${ABI}" |
430 |
- $1 |
431 |
- : $(( ret |= $? )) |
432 |
- done |
433 |
- return ${ret} |
434 |
-} |
435 |
- |
436 |
-just_headers() { |
437 |
- is_crosscompile && use headers-only |
438 |
-} |
439 |
- |
440 |
-glibc_banner() { |
441 |
- local b="Gentoo ${PVR}" |
442 |
- [[ -n ${SNAP_VER} ]] && b+=" snapshot ${SNAP_VER}" |
443 |
- [[ -n ${PATCH_VER} ]] && ! use vanilla && b+=" p${PATCH_VER}" |
444 |
- echo "${b}" |
445 |
-} |
446 |
- |
447 |
-# == phases == |
448 |
- |
449 |
-glibc_compile_test() { |
450 |
- local ret save_cflags=${CFLAGS} |
451 |
- CFLAGS+=" $1" |
452 |
- shift |
453 |
- |
454 |
- pushd "${T}" >/dev/null |
455 |
- |
456 |
- rm -f glibc-test* |
457 |
- printf '%b' "$*" > glibc-test.c |
458 |
- |
459 |
- _nonfatal emake -s glibc-test |
460 |
- ret=$? |
461 |
- |
462 |
- popd >/dev/null |
463 |
- |
464 |
- CFLAGS=${save_cflags} |
465 |
- return ${ret} |
466 |
-} |
467 |
- |
468 |
-glibc_run_test() { |
469 |
- local ret |
470 |
- |
471 |
- if [[ ${EMERGE_FROM} == "binary" ]] ; then |
472 |
- # ignore build failures when installing a binary package #324685 |
473 |
- glibc_compile_test "" "$@" 2>/dev/null || return 0 |
474 |
- else |
475 |
- if ! glibc_compile_test "" "$@" ; then |
476 |
- ewarn "Simple build failed ... assuming this is desired #324685" |
477 |
- return 0 |
478 |
- fi |
479 |
- fi |
480 |
- |
481 |
- pushd "${T}" >/dev/null |
482 |
- |
483 |
- ./glibc-test |
484 |
- ret=$? |
485 |
- rm -f glibc-test* |
486 |
- |
487 |
- popd >/dev/null |
488 |
- |
489 |
- return ${ret} |
490 |
-} |
491 |
- |
492 |
-check_devpts() { |
493 |
- # Make sure devpts is mounted correctly for use w/out setuid pt_chown. |
494 |
- |
495 |
- # If merely building the binary package, then there's nothing to verify. |
496 |
- [[ ${MERGE_TYPE} == "buildonly" ]] && return |
497 |
- |
498 |
- # Only sanity check when installing the native glibc. |
499 |
- [[ ${ROOT} != "/" ]] && return |
500 |
- |
501 |
- # Older versions always installed setuid, so no need to check. |
502 |
- in_iuse suid || return |
503 |
- |
504 |
- # If they're opting in to the old suid code, then no need to check. |
505 |
- use suid && return |
506 |
- |
507 |
- if awk '$3 == "devpts" && $4 ~ /[, ]gid=5[, ]/ { exit 1 }' /proc/mounts ; then |
508 |
- eerror "In order to use glibc with USE=-suid, you must make sure that" |
509 |
- eerror "you have devpts mounted at /dev/pts with the gid=5 option." |
510 |
- eerror "Openrc should do this for you, so you should check /etc/fstab" |
511 |
- eerror "and make sure you do not have any invalid settings there." |
512 |
- # Do not die on older kernels as devpts did not export these settings #489520. |
513 |
- if version_is_at_least 2.6.25 $(uname -r) ; then |
514 |
- die "mount & fix your /dev/pts settings" |
515 |
- fi |
516 |
- fi |
517 |
-} |
518 |
- |
519 |
-toolchain-glibc_pkg_pretend() { |
520 |
- if [[ ${EAPI:-0} == 6 ]]; then |
521 |
- eerror "We're moving code back to the ebuilds to get away from the ancient EAPI cruft." |
522 |
- eerror "From EAPI=6 on you'll have to define the phases in the glibc ebuilds." |
523 |
- die "Silly overlay authors..." |
524 |
- fi |
525 |
- |
526 |
- # For older EAPIs, this is run in pkg_preinst. |
527 |
- if [[ ${EAPI:-0} != [0123] ]] ; then |
528 |
- check_devpts |
529 |
- fi |
530 |
- |
531 |
- # Prevent native builds from downgrading. |
532 |
- if [[ ${MERGE_TYPE} != "buildonly" ]] && \ |
533 |
- [[ ${ROOT} == "/" ]] && \ |
534 |
- [[ ${CBUILD} == ${CHOST} ]] && \ |
535 |
- [[ ${CHOST} == ${CTARGET} ]] ; then |
536 |
- # The high rev # is to allow people to downgrade between -r# versions. |
537 |
- # We want to block 2.20->2.19, but 2.20-r3->2.20-r2 should be fine. |
538 |
- # Hopefully we never actually use a r# this high. |
539 |
- if has_version ">${CATEGORY}/${P}-r10000" ; then |
540 |
- eerror "Sanity check to keep you from breaking your system:" |
541 |
- eerror " Downgrading glibc is not supported and a sure way to destruction" |
542 |
- [[ ${I_ALLOW_TO_BREAK_MY_SYSTEM} = yes ]] || die "Aborting to save your system." |
543 |
- fi |
544 |
- |
545 |
- if ! glibc_run_test '#include <pwd.h>\nint main(){return getpwuid(0)==0;}\n' |
546 |
- then |
547 |
- eerror "Your patched vendor kernel is broken. You need to get an" |
548 |
- eerror "update from whoever is providing the kernel to you." |
549 |
- eerror "https://sourceware.org/bugzilla/show_bug.cgi?id=5227" |
550 |
- eerror "http://bugs.gentoo.org/262698" |
551 |
- die "keeping your system alive, say thank you" |
552 |
- fi |
553 |
- |
554 |
- if ! glibc_run_test '#include <unistd.h>\n#include <sys/syscall.h>\nint main(){return syscall(1000)!=-1;}\n' |
555 |
- then |
556 |
- eerror "Your old kernel is broken. You need to update it to" |
557 |
- eerror "a newer version as syscall(<bignum>) will break." |
558 |
- eerror "http://bugs.gentoo.org/279260" |
559 |
- die "keeping your system alive, say thank you" |
560 |
- fi |
561 |
- fi |
562 |
- |
563 |
- # users have had a chance to phase themselves, time to give em the boot |
564 |
- if [[ -e ${EROOT}/etc/locale.gen ]] && [[ -e ${EROOT}/etc/locales.build ]] ; then |
565 |
- eerror "You still haven't deleted ${EROOT}/etc/locales.build." |
566 |
- eerror "Do so now after making sure ${EROOT}/etc/locale.gen is kosher." |
567 |
- die "lazy upgrader detected" |
568 |
- fi |
569 |
- |
570 |
- if [[ ${CTARGET} == i386-* ]] ; then |
571 |
- eerror "i386 CHOSTs are no longer supported." |
572 |
- eerror "Chances are you don't actually want/need i386." |
573 |
- eerror "Please read http://www.gentoo.org/doc/en/change-chost.xml" |
574 |
- die "please fix your CHOST" |
575 |
- fi |
576 |
- |
577 |
- if [[ -e /proc/xen ]] && [[ $(tc-arch) == "x86" ]] && ! is-flag -mno-tls-direct-seg-refs ; then |
578 |
- ewarn "You are using Xen but don't have -mno-tls-direct-seg-refs in your CFLAGS." |
579 |
- ewarn "This will result in a 50% performance penalty when running with a 32bit" |
580 |
- ewarn "hypervisor, which is probably not what you want." |
581 |
- fi |
582 |
- |
583 |
- # Make sure host system is up to date #394453 |
584 |
- if has_version '<sys-libs/glibc-2.13' && \ |
585 |
- [[ -n $(scanelf -qys__guard -F'#s%F' "${EROOT}"/lib*/l*-*.so) ]] |
586 |
- then |
587 |
- ebegin "Scanning system for __guard to see if you need to rebuild first ..." |
588 |
- local files=$( |
589 |
- scanelf -qys__guard -F'#s%F' \ |
590 |
- "${EROOT}"/*bin/ \ |
591 |
- "${EROOT}"/lib* \ |
592 |
- "${EROOT}"/usr/*bin/ \ |
593 |
- "${EROOT}"/usr/lib* | \ |
594 |
- egrep -v \ |
595 |
- -e "^${EROOT}/lib.*/(libc|ld)-2.*.so$" \ |
596 |
- -e "^${EROOT}/sbin/(ldconfig|sln)$" |
597 |
- ) |
598 |
- [[ -z ${files} ]] |
599 |
- if ! eend $? ; then |
600 |
- eerror "Your system still has old SSP __guard symbols. You need to" |
601 |
- eerror "rebuild all the packages that provide these files first:" |
602 |
- eerror "${files}" |
603 |
- die "old __guard detected" |
604 |
- fi |
605 |
- fi |
606 |
-} |
607 |
- |
608 |
-toolchain-glibc_pkg_setup() { |
609 |
- [[ ${EAPI:-0} == [0123] ]] && toolchain-glibc_pkg_pretend |
610 |
-} |
611 |
- |
612 |
-# The following Kernel version handling functions are mostly copied from portage |
613 |
-# source. It's better not to use linux-info.eclass here since a) it adds too |
614 |
-# much magic, see bug 326693 for some of the arguments, and b) some of the |
615 |
-# functions are just not provided. |
616 |
- |
617 |
-tc_glibc_get_KV() { |
618 |
- uname -r |
619 |
- return $? |
620 |
-} |
621 |
- |
622 |
-tc_glibc_KV_major() { |
623 |
- [[ -z $1 ]] && return 1 |
624 |
- local KV=$@ |
625 |
- echo "${KV%%.*}" |
626 |
-} |
627 |
- |
628 |
-tc_glibc_KV_minor() { |
629 |
- [[ -z $1 ]] && return 1 |
630 |
- local KV=$@ |
631 |
- KV=${KV#*.} |
632 |
- echo "${KV%%.*}" |
633 |
-} |
634 |
- |
635 |
-tc_glibc_KV_micro() { |
636 |
- [[ -z $1 ]] && return 1 |
637 |
- local KV=$@ |
638 |
- KV=${KV#*.*.} |
639 |
- echo "${KV%%[^[:digit:]]*}" |
640 |
-} |
641 |
- |
642 |
-tc_glibc_KV_to_int() { |
643 |
- [[ -z $1 ]] && return 1 |
644 |
- local KV_MAJOR=$(tc_glibc_KV_major "$1") |
645 |
- local KV_MINOR=$(tc_glibc_KV_minor "$1") |
646 |
- local KV_MICRO=$(tc_glibc_KV_micro "$1") |
647 |
- local KV_int=$(( KV_MAJOR * 65536 + KV_MINOR * 256 + KV_MICRO )) |
648 |
- |
649 |
- # We make version 2.2.0 the minimum version we will handle as |
650 |
- # a sanity check ... if its less, we fail ... |
651 |
- if [[ ${KV_int} -ge 131584 ]] ; then |
652 |
- echo "${KV_int}" |
653 |
- return 0 |
654 |
- fi |
655 |
- return 1 |
656 |
-} |
657 |
- |
658 |
-tc_glibc_int_to_KV() { |
659 |
- local version=$1 major minor micro |
660 |
- major=$((version / 65536)) |
661 |
- minor=$(((version % 65536) / 256)) |
662 |
- micro=$((version % 256)) |
663 |
- echo ${major}.${minor}.${micro} |
664 |
-} |
665 |
- |
666 |
-eend_KV() { |
667 |
- [[ $(tc_glibc_KV_to_int $1) -ge $(tc_glibc_KV_to_int $2) ]] |
668 |
- eend $? |
669 |
-} |
670 |
- |
671 |
-get_kheader_version() { |
672 |
- printf '#include <linux/version.h>\nLINUX_VERSION_CODE\n' | \ |
673 |
- $(tc-getCPP ${CTARGET}) -I "$(alt_build_headers)" - | \ |
674 |
- tail -n 1 |
675 |
-} |
676 |
- |
677 |
-check_nptl_support() { |
678 |
- # don't care about the compiler here as we aren't using it |
679 |
- just_headers && return |
680 |
- |
681 |
- local run_kv build_kv want_kv |
682 |
- run_kv=$(tc_glibc_get_KV) |
683 |
- build_kv=$(tc_glibc_int_to_KV $(get_kheader_version)) |
684 |
- want_kv=${NPTL_KERN_VER} |
685 |
- |
686 |
- ebegin "Checking gcc for __thread support" |
687 |
- if ! eend $(want__thread ; echo $?) ; then |
688 |
- echo |
689 |
- eerror "Could not find a gcc that supports the __thread directive!" |
690 |
- eerror "Please update your binutils/gcc and try again." |
691 |
- die "No __thread support in gcc!" |
692 |
- fi |
693 |
- |
694 |
- if ! is_crosscompile && ! tc-is-cross-compiler ; then |
695 |
- # Building fails on an non-supporting kernel |
696 |
- ebegin "Checking kernel version (${run_kv} >= ${want_kv})" |
697 |
- if ! eend_KV ${run_kv} ${want_kv} ; then |
698 |
- echo |
699 |
- eerror "You need a kernel of at least ${want_kv} for NPTL support!" |
700 |
- die "Kernel version too low!" |
701 |
- fi |
702 |
- fi |
703 |
- |
704 |
- ebegin "Checking linux-headers version (${build_kv} >= ${want_kv})" |
705 |
- if ! eend_KV ${build_kv} ${want_kv} ; then |
706 |
- echo |
707 |
- eerror "You need linux-headers of at least ${want_kv} for NPTL support!" |
708 |
- die "linux-headers version too low!" |
709 |
- fi |
710 |
-} |
711 |
- |
712 |
-unpack_pkg() { |
713 |
- local a=${PN} |
714 |
- [[ -n ${SNAP_VER} ]] && a="${a}-${RELEASE_VER}" |
715 |
- [[ -n $1 ]] && a="${a}-$1" |
716 |
- if [[ -n ${SNAP_VER} ]] ; then |
717 |
- a="${a}-${SNAP_VER}" |
718 |
- else |
719 |
- if [[ -n $2 ]] ; then |
720 |
- a="${a}-$2" |
721 |
- else |
722 |
- a="${a}-${RELEASE_VER}" |
723 |
- fi |
724 |
- fi |
725 |
- if has ${a}.tar.xz ${A} ; then |
726 |
- unpacker ${a}.tar.xz |
727 |
- else |
728 |
- unpack ${a}.tar.bz2 |
729 |
- fi |
730 |
- [[ -n $1 ]] && { mv ${a} $1 || die ; } |
731 |
-} |
732 |
- |
733 |
-toolchain-glibc_do_src_unpack() { |
734 |
- # Check NPTL support _before_ we unpack things to save some time |
735 |
- want_nptl && check_nptl_support |
736 |
- |
737 |
- unpack_pkg |
738 |
- |
739 |
- cd "${S}" |
740 |
- touch locale/C-translit.h #185476 #218003 |
741 |
- [[ -n ${LT_VER} ]] && unpack_pkg linuxthreads ${LT_VER} |
742 |
- [[ -n ${PORTS_VER} ]] && unpack_pkg ports ${PORTS_VER} |
743 |
- [[ -n ${LIBIDN_VER} ]] && unpack_pkg libidn |
744 |
- |
745 |
- if [[ -n ${PATCH_VER} ]] ; then |
746 |
- cd "${WORKDIR}" |
747 |
- unpack glibc-${RELEASE_VER}-patches-${PATCH_VER}.tar.bz2 |
748 |
- # pull out all the addons |
749 |
- local d |
750 |
- for d in extra/*/configure ; do |
751 |
- d=${d%/configure} |
752 |
- [[ -d ${S}/${d} ]] && die "${d} already exists in \${S}" |
753 |
- mv "${d}" "${S}" || die "moving ${d} failed" |
754 |
- done |
755 |
- fi |
756 |
-} |
757 |
- |
758 |
-toolchain-glibc_src_unpack() { |
759 |
- setup_env |
760 |
- |
761 |
- toolchain-glibc_do_src_unpack |
762 |
- [[ ${EAPI:-0} == [01] ]] && cd "${S}" && toolchain-glibc_src_prepare |
763 |
-} |
764 |
- |
765 |
-toolchain-glibc_src_prepare() { |
766 |
- # tag, glibc is it |
767 |
- if ! version_is_at_least 2.17 ; then |
768 |
- [[ -e csu/Banner ]] && die "need new banner location" |
769 |
- glibc_banner > csu/Banner |
770 |
- fi |
771 |
- if [[ -n ${PATCH_VER} ]] && ! use vanilla ; then |
772 |
- EPATCH_MULTI_MSG="Applying Gentoo Glibc Patchset ${RELEASE_VER}-${PATCH_VER} ..." \ |
773 |
- EPATCH_EXCLUDE=${GLIBC_PATCH_EXCLUDE} \ |
774 |
- EPATCH_SUFFIX="patch" \ |
775 |
- ARCH=$(tc-arch) \ |
776 |
- epatch "${WORKDIR}"/patches |
777 |
- fi |
778 |
- |
779 |
- if just_headers ; then |
780 |
- if [[ -e ports/sysdeps/mips/preconfigure ]] ; then |
781 |
- # mips peeps like to screw with us. if building headers, |
782 |
- # we don't have a real compiler, so we can't let them |
783 |
- # insert -mabi on us. |
784 |
- sed -i '/CPPFLAGS=.*-mabi/s|.*|:|' ports/sysdeps/mips/preconfigure || die |
785 |
- find ports/sysdeps/mips/ -name Makefile -exec sed -i '/^CC.*-mabi=/s:-mabi=.*:-D_MIPS_SZPTR=32:' {} + |
786 |
- fi |
787 |
- fi |
788 |
- |
789 |
- epatch_user |
790 |
- |
791 |
- gnuconfig_update |
792 |
- |
793 |
- # Glibc is stupid sometimes, and doesn't realize that with a |
794 |
- # static C-Only gcc, -lgcc_eh doesn't exist. |
795 |
- # https://sourceware.org/ml/libc-alpha/2003-09/msg00100.html |
796 |
- # https://sourceware.org/ml/libc-alpha/2005-02/msg00042.html |
797 |
- # But! Finally fixed in recent versions: |
798 |
- # https://sourceware.org/ml/libc-alpha/2012-05/msg01865.html |
799 |
- if ! version_is_at_least 2.16 ; then |
800 |
- echo 'int main(){}' > "${T}"/gcc_eh_test.c |
801 |
- if ! $(tc-getCC ${CTARGET}) ${CFLAGS} ${LDFLAGS} "${T}"/gcc_eh_test.c -lgcc_eh 2>/dev/null ; then |
802 |
- sed -i -e 's:-lgcc_eh::' Makeconfig || die "sed gcc_eh" |
803 |
- fi |
804 |
- fi |
805 |
- |
806 |
- cd "${WORKDIR}" |
807 |
- find . -type f '(' -size 0 -o -name "*.orig" ')' -delete |
808 |
- find . -name configure -exec touch {} + |
809 |
- |
810 |
- eprefixify extra/locale/locale-gen |
811 |
- |
812 |
- # Fix permissions on some of the scripts. |
813 |
- chmod u+x "${S}"/scripts/*.sh |
814 |
-} |
815 |
-dump_toolchain_settings() { |
816 |
- echo |
817 |
- |
818 |
- einfo "$*" |
819 |
- |
820 |
- local v |
821 |
- for v in ABI CBUILD CHOST CTARGET CBUILD_OPT CTARGET_OPT CC LD {AS,C,CPP,CXX,LD}FLAGS ; do |
822 |
- einfo " $(printf '%15s' ${v}:) ${!v}" |
823 |
- done |
824 |
- |
825 |
- # The glibc configure script doesn't properly use LDFLAGS all the time. |
826 |
- export CC="$(tc-getCC ${CTARGET}) ${LDFLAGS}" |
827 |
- einfo " $(printf '%15s' 'Manual CC:') ${CC}" |
828 |
- echo |
829 |
-} |
830 |
- |
831 |
-glibc_do_configure() { |
832 |
- # Glibc does not work with gold (for various reasons) #269274. |
833 |
- tc-ld-disable-gold |
834 |
- |
835 |
- dump_toolchain_settings "Configuring glibc for $1" |
836 |
- |
837 |
- local myconf=() |
838 |
- |
839 |
- # set addons |
840 |
- pushd "${S}" > /dev/null |
841 |
- local addons=$(echo */configure | sed \ |
842 |
- -e 's:/configure::g' \ |
843 |
- -e 's:\(linuxthreads\|nptl\|rtkaio\|glibc-compat\)\( \|$\)::g' \ |
844 |
- -e 's: \+$::' \ |
845 |
- -e 's! !,!g' \ |
846 |
- -e 's!^!,!' \ |
847 |
- -e '/^,\*$/d') |
848 |
- [[ -d ports ]] && addons+=",ports" |
849 |
- popd > /dev/null |
850 |
- |
851 |
- if has_version '<sys-libs/glibc-2.13' ; then |
852 |
- myconf+=( --enable-old-ssp-compat ) |
853 |
- fi |
854 |
- |
855 |
- if version_is_at_least 2.25 ; then |
856 |
- case ${CTARGET} in |
857 |
- m68k*) |
858 |
- # setjmp() is not compatible with stack protection: |
859 |
- # https://sourceware.org/PR24202 |
860 |
- myconf+=( --enable-stack-protector=no ) |
861 |
- ;; |
862 |
- mips*) |
863 |
- # dlopen() detects stack smash on mips n32 ABI. |
864 |
- # Cause is unknown: https://bugs.gentoo.org/640130 |
865 |
- myconf+=( --enable-stack-protector=no ) |
866 |
- ;; |
867 |
- powerpc-*) |
868 |
- # Currently gcc on powerpc32 generates invalid code for |
869 |
- # __builtin_return_address(0) calls. Normally programs |
870 |
- # don't do that but malloc hooks in glibc do: |
871 |
- # https://gcc.gnu.org/PR81996 |
872 |
- # https://bugs.gentoo.org/629054 |
873 |
- myconf+=( --enable-stack-protector=no ) |
874 |
- ;; |
875 |
- *) |
876 |
- myconf+=( --enable-stack-protector=all ) |
877 |
- ;; |
878 |
- esac |
879 |
- fi |
880 |
- |
881 |
- # Keep a whitelist of targets supporing IFUNC. glibc's ./configure |
882 |
- # is not robust enough to detect proper support: |
883 |
- # https://bugs.gentoo.org/641216 |
884 |
- # https://sourceware.org/PR22634#c0 |
885 |
- case $(tc-arch ${CTARGET}) in |
886 |
- # Keep whitelist of targets where autodetection mostly works. |
887 |
- amd64|x86|sparc|ppc|ppc64|arm|arm64|s390) ;; |
888 |
- # Blacklist everywhere else |
889 |
- *) myconf+=( libc_cv_ld_gnu_indirect_function=no ) ;; |
890 |
- esac |
891 |
- |
892 |
- if version_is_at_least 2.25 ; then |
893 |
- myconf+=( --enable-stackguard-randomization ) |
894 |
- else |
895 |
- myconf+=( $(use_enable hardened stackguard-randomization) ) |
896 |
- fi |
897 |
- |
898 |
- [[ $(tc-is-softfloat) == "yes" ]] && myconf+=( --without-fp ) |
899 |
- |
900 |
- if [[ $1 == "linuxthreads" ]] ; then |
901 |
- if want_tls ; then |
902 |
- myconf+=( --with-tls ) |
903 |
- |
904 |
- if ! want__thread || use glibc-compat20 || [[ ${LT_KER_VER} == 2.[02].* ]] ; then |
905 |
- myconf+=( --without-__thread ) |
906 |
- else |
907 |
- myconf+=( --with-__thread ) |
908 |
- fi |
909 |
- else |
910 |
- myconf+=( --without-tls --without-__thread ) |
911 |
- fi |
912 |
- |
913 |
- myconf+=( --disable-sanity-checks ) |
914 |
- addons="linuxthreads${addons}" |
915 |
- myconf+=( --enable-kernel=${LT_KER_VER} ) |
916 |
- elif [[ $1 == "nptl" ]] ; then |
917 |
- # Newer versions require nptl, so there is no addon for it. |
918 |
- version_is_at_least 2.20 || addons="nptl${addons}" |
919 |
- myconf+=( --enable-kernel=${NPTL_KERN_VER} ) |
920 |
- else |
921 |
- die "invalid pthread option" |
922 |
- fi |
923 |
- myconf+=( --enable-add-ons="${addons#,}" ) |
924 |
- |
925 |
- # Since SELinux support is only required for nscd, only enable it if: |
926 |
- # 1. USE selinux |
927 |
- # 2. only for the primary ABI on multilib systems |
928 |
- # 3. Not a crosscompile |
929 |
- if ! is_crosscompile && use selinux ; then |
930 |
- if use multilib ; then |
931 |
- if is_final_abi ; then |
932 |
- myconf+=( --with-selinux ) |
933 |
- else |
934 |
- myconf+=( --without-selinux ) |
935 |
- fi |
936 |
- else |
937 |
- myconf+=( --with-selinux ) |
938 |
- fi |
939 |
- else |
940 |
- myconf+=( --without-selinux ) |
941 |
- fi |
942 |
- |
943 |
- # Force a few tests where we always know the answer but |
944 |
- # configure is incapable of finding it. |
945 |
- if is_crosscompile ; then |
946 |
- export \ |
947 |
- libc_cv_c_cleanup=yes \ |
948 |
- libc_cv_forced_unwind=yes |
949 |
- fi |
950 |
- |
951 |
- myconf+=( |
952 |
- --without-cvs |
953 |
- --disable-werror |
954 |
- --enable-bind-now |
955 |
- --build=${CBUILD_OPT:-${CBUILD}} |
956 |
- --host=${CTARGET_OPT:-${CTARGET}} |
957 |
- $(use_enable profile) |
958 |
- $(use_with gd) |
959 |
- --with-headers=$(alt_build_headers) |
960 |
- --prefix="${EPREFIX}/usr" |
961 |
- --sysconfdir="${EPREFIX}/etc" |
962 |
- --localstatedir="${EPREFIX}/var" |
963 |
- --libdir='$(prefix)'/$(get_libdir) |
964 |
- --mandir='$(prefix)'/share/man |
965 |
- --infodir='$(prefix)'/share/info |
966 |
- --libexecdir='$(libdir)'/misc/glibc |
967 |
- --with-bugurl=http://bugs.gentoo.org/ |
968 |
- --with-pkgversion="$(glibc_banner)" |
969 |
- $(use_multiarch || echo --disable-multi-arch) |
970 |
- $(in_iuse rpc && use_enable rpc obsolete-rpc || echo --enable-obsolete-rpc) |
971 |
- $(in_iuse systemtap && use_enable systemtap) |
972 |
- $(in_iuse nscd && use_enable nscd) |
973 |
- ${EXTRA_ECONF} |
974 |
- ) |
975 |
- |
976 |
- # We rely on sys-libs/timezone-data for timezone tools normally. |
977 |
- if version_is_at_least 2.23 ; then |
978 |
- myconf+=( $(use_enable vanilla timezone-tools) ) |
979 |
- fi |
980 |
- |
981 |
- # These libs don't have configure flags. |
982 |
- ac_cv_lib_audit_audit_log_user_avc_message=$(in_iuse audit && usex audit || echo no) |
983 |
- ac_cv_lib_cap_cap_init=$(in_iuse caps && usex caps || echo no) |
984 |
- |
985 |
- # There is no configure option for this and we need to export it |
986 |
- # since the glibc build will re-run configure on itself |
987 |
- export libc_cv_rootsbindir="${EPREFIX}/sbin" |
988 |
- export libc_cv_slibdir="${EPREFIX}/$(get_libdir)" |
989 |
- |
990 |
- # We take care of patching our binutils to use both hash styles, |
991 |
- # and many people like to force gnu hash style only, so disable |
992 |
- # this overriding check. #347761 |
993 |
- export libc_cv_hashstyle=no |
994 |
- |
995 |
- # Overtime, generating info pages can be painful. So disable this for |
996 |
- # versions older than the latest stable to avoid the issue (this ver |
997 |
- # should be updated from time to time). #464394 #465816 |
998 |
- if ! version_is_at_least 2.17 ; then |
999 |
- export ac_cv_prog_MAKEINFO=: |
1000 |
- fi |
1001 |
- |
1002 |
- local builddir=$(builddir "$1") |
1003 |
- mkdir -p "${builddir}" |
1004 |
- cd "${builddir}" |
1005 |
- set -- "${S}"/configure "${myconf[@]}" |
1006 |
- echo "$@" |
1007 |
- "$@" || die "failed to configure glibc" |
1008 |
- |
1009 |
- # ia64 static cross-compilers are a pita in so much that they |
1010 |
- # can't produce static ELFs (as the libgcc.a is broken). so |
1011 |
- # disable building of the programs for those targets if it |
1012 |
- # doesn't work. |
1013 |
- # XXX: We could turn this into a compiler test, but ia64 is |
1014 |
- # the only one that matters, so this should be fine for now. |
1015 |
- if is_crosscompile && [[ ${CTARGET} == ia64* ]] ; then |
1016 |
- sed -i '1i+link-static = touch $@' config.make |
1017 |
- fi |
1018 |
- |
1019 |
- # If we're trying to migrate between ABI sets, we need |
1020 |
- # to lie and use a local copy of gcc. Like if the system |
1021 |
- # is built with MULTILIB_ABIS="amd64 x86" but we want to |
1022 |
- # add x32 to it, gcc/glibc don't yet support x32. |
1023 |
- if [[ -n ${GCC_BOOTSTRAP_VER} ]] && use multilib ; then |
1024 |
- echo 'main(){}' > "${T}"/test.c |
1025 |
- if ! $(tc-getCC ${CTARGET}) ${CFLAGS} ${LDFLAGS} "${T}"/test.c -Wl,-emain -lgcc 2>/dev/null ; then |
1026 |
- sed -i -e '/^CC = /s:$: -B$(objdir)/../'"gcc-${GCC_BOOTSTRAP_VER}/${ABI}:" config.make || die |
1027 |
- mkdir -p sunrpc |
1028 |
- cp $(which rpcgen) sunrpc/cross-rpcgen || die |
1029 |
- touch -t 202001010101 sunrpc/cross-rpcgen || die |
1030 |
- fi |
1031 |
- fi |
1032 |
-} |
1033 |
- |
1034 |
-toolchain-glibc_headers_configure() { |
1035 |
- export ABI=default |
1036 |
- |
1037 |
- local builddir=$(builddir "headers") |
1038 |
- mkdir -p "${builddir}" |
1039 |
- cd "${builddir}" |
1040 |
- |
1041 |
- # if we don't have a compiler yet, we can't really test it now ... |
1042 |
- # hopefully they don't affect header generation, so let's hope for |
1043 |
- # the best here ... |
1044 |
- local v vars=( |
1045 |
- ac_cv_header_cpuid_h=yes |
1046 |
- libc_cv_{386,390,alpha,arm,hppa,ia64,mips,{powerpc,sparc}{,32,64},sh,x86_64}_tls=yes |
1047 |
- libc_cv_asm_cfi_directives=yes |
1048 |
- libc_cv_broken_visibility_attribute=no |
1049 |
- libc_cv_c_cleanup=yes |
1050 |
- libc_cv_forced_unwind=yes |
1051 |
- libc_cv_gcc___thread=yes |
1052 |
- libc_cv_mlong_double_128=yes |
1053 |
- libc_cv_mlong_double_128ibm=yes |
1054 |
- libc_cv_ppc_machine=yes |
1055 |
- libc_cv_ppc_rel16=yes |
1056 |
- libc_cv_predef_fortify_source=no |
1057 |
- libc_cv_visibility_attribute=yes |
1058 |
- libc_cv_z_combreloc=yes |
1059 |
- libc_cv_z_execstack=yes |
1060 |
- libc_cv_z_initfirst=yes |
1061 |
- libc_cv_z_nodelete=yes |
1062 |
- libc_cv_z_nodlopen=yes |
1063 |
- libc_cv_z_relro=yes |
1064 |
- libc_mips_abi=${ABI} |
1065 |
- libc_mips_float=$([[ $(tc-is-softfloat) == "yes" ]] && echo soft || echo hard) |
1066 |
- # These libs don't have configure flags. |
1067 |
- ac_cv_lib_audit_audit_log_user_avc_message=no |
1068 |
- ac_cv_lib_cap_cap_init=no |
1069 |
- ) |
1070 |
- if ! version_is_at_least 2.25 ; then |
1071 |
- vars+=( |
1072 |
- libc_cv_predef_stack_protector=no |
1073 |
- ) |
1074 |
- fi |
1075 |
- einfo "Forcing cached settings:" |
1076 |
- for v in "${vars[@]}" ; do |
1077 |
- einfo " ${v}" |
1078 |
- export ${v} |
1079 |
- done |
1080 |
- |
1081 |
- # Blow away some random CC settings that screw things up. #550192 |
1082 |
- if [[ -d ${S}/sysdeps/mips ]]; then |
1083 |
- pushd "${S}"/sysdeps/mips >/dev/null |
1084 |
- sed -i -e '/^CC +=/s:=.*:= -D_MIPS_SZPTR=32:' mips32/Makefile mips64/n32/Makefile || die |
1085 |
- sed -i -e '/^CC +=/s:=.*:= -D_MIPS_SZPTR=64:' mips64/n64/Makefile || die |
1086 |
- if version_is_at_least 2.21 ; then |
1087 |
- # Force the mips ABI to the default. This is OK because the set of |
1088 |
- # installed headers in this phase is the same between the 3 ABIs. |
1089 |
- # If this ever changes, this hack will break, but that's unlikely |
1090 |
- # as glibc discourages that behavior. |
1091 |
- # https://crbug.com/647033 |
1092 |
- sed -i -e 's:abiflag=.*:abiflag=_ABIO32:' preconfigure || die |
1093 |
- fi |
1094 |
- popd >/dev/null |
1095 |
- fi |
1096 |
- |
1097 |
- local myconf=() |
1098 |
- myconf+=( |
1099 |
- --disable-sanity-checks |
1100 |
- --enable-hacker-mode |
1101 |
- --without-cvs |
1102 |
- --disable-werror |
1103 |
- --enable-bind-now |
1104 |
- --build=${CBUILD_OPT:-${CBUILD}} |
1105 |
- --host=${CTARGET_OPT:-${CTARGET}} |
1106 |
- --with-headers=$(alt_build_headers) |
1107 |
- --prefix="${EPREFIX}/usr" |
1108 |
- ${EXTRA_ECONF} |
1109 |
- ) |
1110 |
- |
1111 |
- local addons |
1112 |
- [[ -d ${S}/ports ]] && addons+=",ports" |
1113 |
- # Newer versions require nptl, so there is no addon for it. |
1114 |
- version_is_at_least 2.20 || addons+=",nptl" |
1115 |
- myconf+=( --enable-add-ons="${addons#,}" ) |
1116 |
- |
1117 |
- # Nothing is compiled here which would affect the headers for the target. |
1118 |
- # So forcing CC/CFLAGS is sane. |
1119 |
- set -- "${S}"/configure "${myconf[@]}" |
1120 |
- echo "$@" |
1121 |
- CC="$(tc-getBUILD_CC)" \ |
1122 |
- CFLAGS="-O1 -pipe" \ |
1123 |
- CPPFLAGS="-U_FORTIFY_SOURCE" \ |
1124 |
- LDFLAGS="" \ |
1125 |
- "$@" || die "failed to configure glibc" |
1126 |
-} |
1127 |
- |
1128 |
-toolchain-glibc_do_src_configure() { |
1129 |
- if just_headers ; then |
1130 |
- toolchain-glibc_headers_configure |
1131 |
- else |
1132 |
- want_linuxthreads && glibc_do_configure linuxthreads |
1133 |
- want_nptl && glibc_do_configure nptl |
1134 |
- fi |
1135 |
-} |
1136 |
- |
1137 |
-toolchain-glibc_src_configure() { |
1138 |
- foreach_abi toolchain-glibc_do_src_configure |
1139 |
-} |
1140 |
- |
1141 |
-toolchain-glibc_do_src_compile() { |
1142 |
- local t |
1143 |
- for t in linuxthreads nptl ; do |
1144 |
- if want_${t} ; then |
1145 |
- [[ ${EAPI:-0} == [01] ]] && glibc_do_configure ${t} |
1146 |
- emake -C "$(builddir ${t})" || die "make ${t} for ${ABI} failed" |
1147 |
- fi |
1148 |
- done |
1149 |
-} |
1150 |
- |
1151 |
-toolchain-glibc_src_compile() { |
1152 |
- if just_headers ; then |
1153 |
- [[ ${EAPI:-0} == [01] ]] && toolchain-glibc_headers_configure |
1154 |
- return |
1155 |
- fi |
1156 |
- |
1157 |
- foreach_abi toolchain-glibc_do_src_compile |
1158 |
-} |
1159 |
- |
1160 |
-glibc_src_test() { |
1161 |
- cd "$(builddir $1)" |
1162 |
- nonfatal emake -j1 check && return 0 |
1163 |
- einfo "make check failed - re-running with --keep-going to get the rest of the results" |
1164 |
- nonfatal emake -j1 -k check |
1165 |
- ewarn "make check failed for ${ABI}-${CTARGET}-$1" |
1166 |
- return 1 |
1167 |
-} |
1168 |
- |
1169 |
-toolchain-glibc_do_src_test() { |
1170 |
- local ret=0 t |
1171 |
- for t in linuxthreads nptl ; do |
1172 |
- if want_${t} ; then |
1173 |
- glibc_src_test ${t} |
1174 |
- : $(( ret |= $? )) |
1175 |
- fi |
1176 |
- done |
1177 |
- return ${ret} |
1178 |
-} |
1179 |
- |
1180 |
-toolchain-glibc_src_test() { |
1181 |
- # Give tests more time to complete. |
1182 |
- export TIMEOUTFACTOR=5 |
1183 |
- |
1184 |
- foreach_abi toolchain-glibc_do_src_test || die "tests failed" |
1185 |
-} |
1186 |
- |
1187 |
-toolchain-glibc_do_src_install() { |
1188 |
- local builddir=$(builddir $(want_linuxthreads && echo linuxthreads || echo nptl)) |
1189 |
- cd "${builddir}" |
1190 |
- |
1191 |
- emake install_root="${D}$(alt_prefix)" install || die |
1192 |
- |
1193 |
- if want_linuxthreads && want_nptl ; then |
1194 |
- einfo "Installing NPTL to $(alt_libdir)/tls/..." |
1195 |
- cd "$(builddir nptl)" |
1196 |
- dodir $(alt_libdir)/tls $(alt_usrlibdir)/nptl |
1197 |
- |
1198 |
- local l src_lib |
1199 |
- for l in libc libm librt libpthread libthread_db ; do |
1200 |
- # take care of shared lib first ... |
1201 |
- l=${l}.so |
1202 |
- if [[ -e ${l} ]] ; then |
1203 |
- src_lib=${l} |
1204 |
- else |
1205 |
- src_lib=$(eval echo */${l}) |
1206 |
- fi |
1207 |
- cp -a ${src_lib} "${ED}"$(alt_libdir)/tls/${l} || die "copying nptl ${l}" |
1208 |
- fperms a+rx $(alt_libdir)/tls/${l} |
1209 |
- dosym ${l} $(alt_libdir)/tls/$(scanelf -qSF'%S#F' ${src_lib}) |
1210 |
- |
1211 |
- # then grab the linker script or the symlink ... |
1212 |
- if [[ -L ${ED}$(alt_usrlibdir)/${l} ]] ; then |
1213 |
- dosym $(alt_libdir)/tls/${l} $(alt_usrlibdir)/nptl/${l} |
1214 |
- else |
1215 |
- sed \ |
1216 |
- -e "s:/${l}:/tls/${l}:g" \ |
1217 |
- -e "s:/${l/%.so/_nonshared.a}:/nptl/${l/%.so/_nonshared.a}:g" \ |
1218 |
- "${ED}"$(alt_usrlibdir)/${l} > "${ED}"$(alt_usrlibdir)/nptl/${l} |
1219 |
- fi |
1220 |
- |
1221 |
- # then grab the static lib ... |
1222 |
- src_lib=${src_lib/%.so/.a} |
1223 |
- [[ ! -e ${src_lib} ]] && src_lib=${src_lib/%.a/_pic.a} |
1224 |
- cp -a ${src_lib} "${ED}"$(alt_usrlibdir)/nptl/ || die "copying nptl ${src_lib}" |
1225 |
- src_lib=${src_lib/%.a/_nonshared.a} |
1226 |
- if [[ -e ${src_lib} ]] ; then |
1227 |
- cp -a ${src_lib} "${ED}"$(alt_usrlibdir)/nptl/ || die "copying nptl ${src_lib}" |
1228 |
- fi |
1229 |
- done |
1230 |
- |
1231 |
- # use the nptl linker instead of the linuxthreads one as the linuxthreads |
1232 |
- # one may lack TLS support and that can be really bad for business |
1233 |
- cp -a elf/ld.so "${ED}"$(alt_libdir)/$(scanelf -qSF'%S#F' elf/ld.so) || die "copying nptl interp" |
1234 |
- fi |
1235 |
- |
1236 |
- # Normally real_pv is ${PV}. Live ebuilds are exception, there we need |
1237 |
- # to infer upstream version: |
1238 |
- # '#define VERSION "2.26.90"' -> '2.26.90' |
1239 |
- local upstream_pv=$(sed -n -r 's/#define VERSION "(.*)"/\1/p' "${S}"/version.h) |
1240 |
- # Newer versions get fancy with libm linkage to include vectorized support. |
1241 |
- # While we don't really need a ldscript here, portage QA checks get upset. |
1242 |
- if [[ -e ${ED}$(alt_usrlibdir)/libm-${upstream_pv}.a ]] ; then |
1243 |
- dosym ../../$(get_libdir)/libm-${upstream_pv}.so $(alt_usrlibdir)/libm-${upstream_pv}.so |
1244 |
- fi |
1245 |
- |
1246 |
- # We'll take care of the cache ourselves |
1247 |
- rm -f "${ED}"/etc/ld.so.cache |
1248 |
- |
1249 |
- # Everything past this point just needs to be done once ... |
1250 |
- is_final_abi || return 0 |
1251 |
- |
1252 |
- # Make sure the non-native interp can be found on multilib systems even |
1253 |
- # if the main library set isn't installed into the right place. Maybe |
1254 |
- # we should query the active gcc for info instead of hardcoding it ? |
1255 |
- local i ldso_abi ldso_name |
1256 |
- local ldso_abi_list=( |
1257 |
- # x86 |
1258 |
- amd64 /lib64/ld-linux-x86-64.so.2 |
1259 |
- x32 /libx32/ld-linux-x32.so.2 |
1260 |
- x86 /lib/ld-linux.so.2 |
1261 |
- # mips |
1262 |
- o32 /lib/ld.so.1 |
1263 |
- n32 /lib32/ld.so.1 |
1264 |
- n64 /lib64/ld.so.1 |
1265 |
- # powerpc |
1266 |
- ppc /lib/ld.so.1 |
1267 |
- # s390 |
1268 |
- s390 /lib/ld.so.1 |
1269 |
- s390x /lib/ld64.so.1 |
1270 |
- # sparc |
1271 |
- sparc32 /lib/ld-linux.so.2 |
1272 |
- sparc64 /lib64/ld-linux.so.2 |
1273 |
- ) |
1274 |
- case $(tc-endian) in |
1275 |
- little) |
1276 |
- ldso_abi_list+=( |
1277 |
- # arm |
1278 |
- arm64 /lib/ld-linux-aarch64.so.1 |
1279 |
- # ELFv2 (glibc does not support ELFv1 on LE) |
1280 |
- ppc64 /lib64/ld64.so.2 |
1281 |
- ) |
1282 |
- ;; |
1283 |
- big) |
1284 |
- ldso_abi_list+=( |
1285 |
- # arm |
1286 |
- arm64 /lib/ld-linux-aarch64_be.so.1 |
1287 |
- # ELFv1 (glibc does not support ELFv2 on BE) |
1288 |
- ppc64 /lib64/ld64.so.1 |
1289 |
- ) |
1290 |
- ;; |
1291 |
- esac |
1292 |
- if [[ ${SYMLINK_LIB} == "yes" ]] && [[ ! -e ${ED}/$(alt_prefix)/lib ]] ; then |
1293 |
- dosym $(get_abi_LIBDIR ${DEFAULT_ABI}) $(alt_prefix)/lib |
1294 |
- fi |
1295 |
- for (( i = 0; i < ${#ldso_abi_list[@]}; i += 2 )) ; do |
1296 |
- ldso_abi=${ldso_abi_list[i]} |
1297 |
- has ${ldso_abi} $(get_install_abis) || continue |
1298 |
- |
1299 |
- ldso_name="$(alt_prefix)${ldso_abi_list[i+1]}" |
1300 |
- if [[ ! -L ${ED}/${ldso_name} && ! -e ${ED}/${ldso_name} ]] ; then |
1301 |
- dosym ../$(get_abi_LIBDIR ${ldso_abi})/${ldso_name##*/} ${ldso_name} |
1302 |
- fi |
1303 |
- done |
1304 |
- |
1305 |
- # With devpts under Linux mounted properly, we do not need the pt_chown |
1306 |
- # binary to be setuid. This is because the default owners/perms will be |
1307 |
- # exactly what we want. |
1308 |
- if in_iuse suid && ! use suid ; then |
1309 |
- find "${ED}" -name pt_chown -exec chmod -s {} + |
1310 |
- fi |
1311 |
- |
1312 |
- ################################################################# |
1313 |
- # EVERYTHING AFTER THIS POINT IS FOR NATIVE GLIBC INSTALLS ONLY # |
1314 |
- # Make sure we install some symlink hacks so that when we build |
1315 |
- # a 2nd stage cross-compiler, gcc finds the target system |
1316 |
- # headers correctly. See gcc/doc/gccinstall.info |
1317 |
- if is_crosscompile ; then |
1318 |
- # We need to make sure that /lib and /usr/lib always exists. |
1319 |
- # gcc likes to use relative paths to get to its multilibs like |
1320 |
- # /usr/lib/../lib64/. So while we don't install any files into |
1321 |
- # /usr/lib/, we do need it to exist. |
1322 |
- cd "${ED}"$(alt_libdir)/.. |
1323 |
- [[ -e lib ]] || mkdir lib |
1324 |
- cd "${ED}"$(alt_usrlibdir)/.. |
1325 |
- [[ -e lib ]] || mkdir lib |
1326 |
- |
1327 |
- dosym usr/include $(alt_prefix)/sys-include |
1328 |
- return 0 |
1329 |
- fi |
1330 |
- |
1331 |
- # Files for Debian-style locale updating |
1332 |
- dodir /usr/share/i18n |
1333 |
- sed \ |
1334 |
- -e "/^#/d" \ |
1335 |
- -e "/SUPPORTED-LOCALES=/d" \ |
1336 |
- -e "s: \\\\::g" -e "s:/: :g" \ |
1337 |
- "${S}"/localedata/SUPPORTED > "${ED}"/usr/share/i18n/SUPPORTED \ |
1338 |
- || die "generating /usr/share/i18n/SUPPORTED failed" |
1339 |
- cd "${WORKDIR}"/extra/locale |
1340 |
- dosbin locale-gen || die |
1341 |
- doman *.[0-8] |
1342 |
- insinto /etc |
1343 |
- doins locale.gen || die |
1344 |
- |
1345 |
- # Make sure all the ABI's can find the locales and so we only |
1346 |
- # have to generate one set |
1347 |
- local a |
1348 |
- keepdir /usr/$(get_libdir)/locale |
1349 |
- for a in $(get_install_abis) ; do |
1350 |
- if [[ ! -e ${ED}/usr/$(get_abi_LIBDIR ${a})/locale ]] ; then |
1351 |
- dosym /usr/$(get_libdir)/locale /usr/$(get_abi_LIBDIR ${a})/locale |
1352 |
- fi |
1353 |
- done |
1354 |
- |
1355 |
- cd "${S}" |
1356 |
- |
1357 |
- # Install misc network config files |
1358 |
- insinto /etc |
1359 |
- doins nscd/nscd.conf posix/gai.conf nss/nsswitch.conf || die |
1360 |
- doins "${WORKDIR}"/extra/etc/*.conf || die |
1361 |
- |
1362 |
- if ! in_iuse nscd || use nscd ; then |
1363 |
- doinitd "$(prefixify_ro "${WORKDIR}"/extra/etc/nscd)" || die |
1364 |
- |
1365 |
- local nscd_args=( |
1366 |
- -e "s:@PIDFILE@:$(strings "${ED}"/usr/sbin/nscd | grep nscd.pid):" |
1367 |
- ) |
1368 |
- version_is_at_least 2.16 || nscd_args+=( -e 's: --foreground : :' ) |
1369 |
- sed -i "${nscd_args[@]}" "${ED}"/etc/init.d/nscd |
1370 |
- |
1371 |
- # Newer versions of glibc include the nscd.service themselves. |
1372 |
- # TODO: Drop the $FILESDIR copy once 2.19 goes stable. |
1373 |
- if version_is_at_least 2.19 ; then |
1374 |
- systemd_dounit nscd/nscd.service || die |
1375 |
- newtmpfiles nscd/nscd.tmpfiles nscd.conf || die |
1376 |
- else |
1377 |
- systemd_dounit "${FILESDIR}"/nscd.service || die |
1378 |
- newtmpfiles "${FILESDIR}"/nscd.tmpfilesd nscd.conf || die |
1379 |
- fi |
1380 |
- else |
1381 |
- # Do this since extra/etc/*.conf above might have nscd.conf. |
1382 |
- rm -f "${ED}"/etc/nscd.conf |
1383 |
- fi |
1384 |
- |
1385 |
- echo 'LDPATH="include ld.so.conf.d/*.conf"' > "${T}"/00glibc |
1386 |
- doenvd "${T}"/00glibc || die |
1387 |
- |
1388 |
- for d in BUGS ChangeLog* CONFORMANCE FAQ NEWS NOTES PROJECTS README* ; do |
1389 |
- [[ -s ${d} ]] && dodoc ${d} |
1390 |
- done |
1391 |
- |
1392 |
- # Prevent overwriting of the /etc/localtime symlink. We'll handle the |
1393 |
- # creation of the "factory" symlink in pkg_postinst(). |
1394 |
- rm -f "${ED}"/etc/localtime |
1395 |
-} |
1396 |
- |
1397 |
-toolchain-glibc_headers_install() { |
1398 |
- local builddir=$(builddir "headers") |
1399 |
- cd "${builddir}" |
1400 |
- emake install_root="${D}$(alt_prefix)" install-headers || die |
1401 |
- if ! version_is_at_least 2.16 ; then |
1402 |
- insinto $(alt_headers)/bits |
1403 |
- doins bits/stdio_lim.h || die |
1404 |
- fi |
1405 |
- insinto $(alt_headers)/gnu |
1406 |
- doins "${S}"/include/gnu/stubs.h || die "doins include gnu" |
1407 |
- # Make sure we install the sys-include symlink so that when |
1408 |
- # we build a 2nd stage cross-compiler, gcc finds the target |
1409 |
- # system headers correctly. See gcc/doc/gccinstall.info |
1410 |
- dosym usr/include $(alt_prefix)/sys-include |
1411 |
-} |
1412 |
- |
1413 |
-toolchain-glibc_src_install() { |
1414 |
- if just_headers ; then |
1415 |
- export ABI=default |
1416 |
- toolchain-glibc_headers_install |
1417 |
- return |
1418 |
- fi |
1419 |
- |
1420 |
- foreach_abi toolchain-glibc_do_src_install |
1421 |
-} |
1422 |
- |
1423 |
-# Simple test to make sure our new glibc isn't completely broken. |
1424 |
-# Make sure we don't test with statically built binaries since |
1425 |
-# they will fail. Also, skip if this glibc is a cross compiler. |
1426 |
-# |
1427 |
-# If coreutils is built with USE=multicall, some of these files |
1428 |
-# will just be wrapper scripts, not actual ELFs we can test. |
1429 |
-glibc_sanity_check() { |
1430 |
- cd / #228809 |
1431 |
- |
1432 |
- # We enter ${ED} so to avoid trouble if the path contains |
1433 |
- # special characters; for instance if the path contains the |
1434 |
- # colon character (:), then the linker will try to split it |
1435 |
- # and look for the libraries in an unexpected place. This can |
1436 |
- # lead to unsafe code execution if the generated prefix is |
1437 |
- # within a world-writable directory. |
1438 |
- # (e.g. /var/tmp/portage:${HOSTNAME}) |
1439 |
- pushd "${ED}"/$(get_libdir) >/dev/null |
1440 |
- |
1441 |
- local x striptest |
1442 |
- for x in cal date env free ls true uname uptime ; do |
1443 |
- x=$(type -p ${x}) |
1444 |
- [[ -z ${x} || ${x} != ${EPREFIX}/* ]] && continue |
1445 |
- striptest=$(LC_ALL="C" file -L ${x} 2>/dev/null) || continue |
1446 |
- case ${striptest} in |
1447 |
- *"statically linked"*) continue;; |
1448 |
- *"ASCII text"*) continue;; |
1449 |
- esac |
1450 |
- # We need to clear the locale settings as the upgrade might want |
1451 |
- # incompatible locale data. This test is not for verifying that. |
1452 |
- LC_ALL=C \ |
1453 |
- ./ld-*.so --library-path . ${x} > /dev/null \ |
1454 |
- || die "simple run test (${x}) failed" |
1455 |
- done |
1456 |
- |
1457 |
- popd >/dev/null |
1458 |
-} |
1459 |
- |
1460 |
-toolchain-glibc_pkg_preinst() { |
1461 |
- # nothing to do if just installing headers |
1462 |
- just_headers && return |
1463 |
- |
1464 |
- # prepare /etc/ld.so.conf.d/ for files |
1465 |
- mkdir -p "${EROOT}"/etc/ld.so.conf.d |
1466 |
- |
1467 |
- # Default /etc/hosts.conf:multi to on for systems with small dbs. |
1468 |
- if [[ $(wc -l < "${EROOT}"/etc/hosts) -lt 1000 ]] ; then |
1469 |
- sed -i '/^multi off/s:off:on:' "${ED}"/etc/host.conf |
1470 |
- elog "Defaulting /etc/host.conf:multi to on" |
1471 |
- fi |
1472 |
- |
1473 |
- [[ ${ROOT} != "/" ]] && return 0 |
1474 |
- [[ -d ${ED}/$(get_libdir) ]] || return 0 |
1475 |
- [[ -z ${BOOTSTRAP_RAP} ]] && glibc_sanity_check |
1476 |
- |
1477 |
- # For newer EAPIs, this was run in pkg_pretend. |
1478 |
- if [[ ${EAPI:-0} == [0123] ]] ; then |
1479 |
- check_devpts |
1480 |
- fi |
1481 |
-} |
1482 |
- |
1483 |
-toolchain-glibc_pkg_postinst() { |
1484 |
- # nothing to do if just installing headers |
1485 |
- just_headers && return |
1486 |
- |
1487 |
- if ! tc-is-cross-compiler && [[ -x ${EROOT}/usr/sbin/iconvconfig ]] ; then |
1488 |
- # Generate fastloading iconv module configuration file. |
1489 |
- "${EROOT}"/usr/sbin/iconvconfig --prefix="${ROOT}" |
1490 |
- fi |
1491 |
- |
1492 |
- if ! is_crosscompile && [[ ${ROOT} == "/" ]] ; then |
1493 |
- # Reload init ... if in a chroot or a diff init package, ignore |
1494 |
- # errors from this step #253697 |
1495 |
- /sbin/telinit U 2>/dev/null |
1496 |
- |
1497 |
- # if the host locales.gen contains no entries, we'll install everything |
1498 |
- local locale_list="${EROOT}etc/locale.gen" |
1499 |
- if [[ -z $(locale-gen --list --config "${locale_list}") ]] ; then |
1500 |
- ewarn "Generating all locales; edit /etc/locale.gen to save time/space" |
1501 |
- locale_list="${EROOT}usr/share/i18n/SUPPORTED" |
1502 |
- fi |
1503 |
- locale-gen -j $(makeopts_jobs) --config "${locale_list}" |
1504 |
- fi |
1505 |
-} |
1506 |
- |
1507 |
-_TOOLCHAIN_GLIBC_ECLASS=1 |
1508 |
-fi |