Annotation of /trunk/core/glibc/glibc-2.29-r13.smage2
Parent Directory | Revision Log
Revision 32919 -
(hide annotations)
(download)
Fri Oct 4 08:31:04 2019 UTC (4 years, 11 months ago) by niro
File size: 13431 byte(s)
Fri Oct 4 08:31:04 2019 UTC (4 years, 11 months ago) by niro
File size: 13431 byte(s)
-linux-libc-headers-5.3.2, binutils-2.32, glibc-2.27, gcc-9.2.0 toolchain - stage1
1 | niro | 32908 | # $Id$ |
2 | |||
3 | PNAME="glibc" | ||
4 | niro | 32919 | PVER="2.30" |
5 | PBUILD="r1" | ||
6 | niro | 32908 | |
7 | PCAT="sys-libs" | ||
8 | |||
9 | DESCRIPTION="GNU libc6 (also called glibc2) C library with NPTL Threads." | ||
10 | HOMEPAGE="http://www.gnu.org/software/libc/libc.html" | ||
11 | |||
12 | DEPEND=">= sys-apps/base-files-0.7 | ||
13 | >= sys-libs/tzdata-2019" | ||
14 | |||
15 | # we force headers to one specific version | ||
16 | niro | 32919 | SDEPEND="== sys-kernel/linux-libc-headers-5.2.1 |
17 | >= dev-lang/python3-3" | ||
18 | niro | 32908 | PROVIDE="virtual/glibc" |
19 | |||
20 | # functions to include in the mage file | ||
21 | SPECIAL_FUNCTIONS="fix_db_files" | ||
22 | |||
23 | SRCFILE="glibc-${PVER}.tar.xz" | ||
24 | SRCDIR="${BUILDDIR}/glibc-${PVER}" | ||
25 | |||
26 | ENVD_REV="1.2" | ||
27 | |||
28 | sminclude mtools | ||
29 | |||
30 | SRC_URI=( | ||
31 | ftp://sources.redhat.com/pub/glibc/releases/${SRCFILE} | ||
32 | ftp://sources.redhat.com/pub/glibc/snapshots/${SRCFILE} | ||
33 | gnu://${PNAME}/${SRCFILE} | ||
34 | mirror://${PNAME}/${SRCFILE} | ||
35 | mirror://${PNAME}/glibc.envd-${ENVD_REV} | ||
36 | mirror://${PNAME}/locale.gen-header | ||
37 | mirror://${PNAME}/locale-gen | ||
38 | mirror://${PNAME}/${PNAME}-2.17-syscalld-infinite-loop.patch | ||
39 | ) | ||
40 | |||
41 | # sed line: on 2 digits add an zero: 2.7 -> 2.7.0 | ||
42 | UP2DATE="updatecmd_gnu ${PNAME/-nptl/} | sed 's/^\([0-9]\.[0-9]\$\)/\1.0/'" | ||
43 | |||
44 | # glibc don't like strong CFLAGS | ||
45 | #export CFLAGS="${CFLAGS//-O?} -O2" | ||
46 | # glibc -> nptl thread don't like striping | ||
47 | # keep static libs to honor -static-pie or nptl/pthreads segfault may occur | ||
48 | msetfeature "!strip static" | ||
49 | |||
50 | # hack to fix NPTL issues with xen, only required on 32bit arches | ||
51 | if [[ ${ARCH} = i*86 ]] | ||
52 | then | ||
53 | export CFLAGS="${CFLAGS} -mno-tls-direct-seg-refs" | ||
54 | fi | ||
55 | |||
56 | ## glibc-2.6.1 and above needs march CFLAGS: -march=${ARCH} -mtune=generic | ||
57 | ## first filter -mtune and -march from flags | ||
58 | #for flag in ${CFLAGS} | ||
59 | #do | ||
60 | # case ${flag} in | ||
61 | # -mtune=*) continue ;; | ||
62 | # -march=*) continue ;; | ||
63 | # esac | ||
64 | # newflags="${newflags} ${flag}" | ||
65 | #done | ||
66 | #export CFLAGS="${newflags}" | ||
67 | # | ||
68 | ## than add our defaults for glibc | ||
69 | #[[ ${ARCH} = i*86 ]] && export CFLAGS="${CFLAGS} -march=${ARCH}" # only i*86 | ||
70 | #export CFLAGS="${CFLAGS} -mtune=generic" # all arches | ||
71 | #export CXXFLAGS="${CFLAGS}" | ||
72 | |||
73 | # use other linux-headers | ||
74 | [[ -z ${ALT_HEADERS} ]] && export ALT_HEADERS="/usr/include" | ||
75 | |||
76 | # kernel support | ||
77 | export ENABLE_KERNEL=3.2.0 | ||
78 | |||
79 | src_prepare() | ||
80 | { | ||
81 | munpack ${SRCFILE} || die | ||
82 | cd ${SRCDIR} | ||
83 | |||
84 | # fix a test case that fails when built using gcc-5.x | ||
85 | sed -i '/tst-audit2-ENV/i CFLAGS-tst-audit2.c += -fno-builtin' elf/Makefile || die | ||
86 | |||
87 | # fixes an infinite loop while syscall.d creation | ||
88 | # see: http://sourceware.org/bugzilla/show_bug.cgi?id=15711 | ||
89 | mpatch ${PNAME}-2.17-syscalld-infinite-loop.patch || die | ||
90 | # use 1.0 second instead of 0.5 (required by arch i686 builds on 64bit machines) | ||
91 | sed -i 's:0.5 seconds ago:1.0 seconds ago:' ${SRCDIR}/Makerules || die | ||
92 | |||
93 | # scripts/test-installation.pl sometime fails | ||
94 | # | ||
95 | # CC="gcc" /usr/bin/perl scripts/test-installation.pl | ||
96 | # /usr/src/glibc-2.16.0.bld/ | ||
97 | # Unmatched ( in regex; marked by <-- HERE in m/$( <-- HERE if $(abi-32-ld-soname),$(abi-32-ld-soname),ld/ at scripts/test-installation.pl line 172, <LDD> | ||
98 | # line 1 | ||
99 | sed -i 's:CC="$(CC)" $(PERL) scripts/test-installation.pl $(common-objpfx)::' Makefile || die | ||
100 | |||
101 | # binutils patch needs reconf | ||
102 | # autoconf --force || die | ||
103 | |||
104 | # fix permissions on some of the scripts | ||
105 | chmod u+x ${SRCDIR}/scripts/*.sh || die | ||
106 | |||
107 | install -d ${SRCDIR}/build || die | ||
108 | cd ${SRCDIR}/build | ||
109 | |||
110 | if [ ! -f /etc/ld.so.conf ] | ||
111 | then | ||
112 | touch /etc/ld.so.conf || die | ||
113 | fi | ||
114 | } | ||
115 | |||
116 | src_compile() | ||
117 | { | ||
118 | local myopts | ||
119 | |||
120 | # generic pathes | ||
121 | myopts="--prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info" | ||
122 | myopts+=" --with-headers=/usr/include" | ||
123 | # bugurl | ||
124 | myopts+=" --with-bugurl=http://bugs.magellan-linux.de/" | ||
125 | # disable profiling | ||
126 | myopts+=" --disable-profile" | ||
127 | # enable addons | ||
128 | myopts+=" --enable-add-ons" | ||
129 | # supported kernel-release | ||
130 | myopts+=" --enable-kernel=${ENABLE_KERNEL}" | ||
131 | # disable cvs and gd support | ||
132 | myopts+=" --without-cvs --without-gd" | ||
133 | # enable bindnow | ||
134 | myopts+=" --enable-bind-now" | ||
135 | # enable lock elision | ||
136 | myopts+=" --enable-lock-elision" | ||
137 | # disable -werror | ||
138 | myopts+=" --disable-werror" | ||
139 | # enable multi-arch | ||
140 | myopts+=" --enable-multi-arch" | ||
141 | # enable stackguard randomization | ||
142 | myopts+=" --enable-stackguard-randomization" | ||
143 | # enable stack protector | ||
144 | myopts+=" --enable-stack-protector=strong" | ||
145 | # enable static pie | ||
146 | myopts+=" --enable-static-pie" | ||
147 | # enable intel cet + branch tracking (IBT) and shadow stack (SHSTK) | ||
148 | myopts+=" --enable-cet" | ||
149 | |||
150 | # fortify_source not supported | ||
151 | export CPPFLAGS=${CPPFLAGS/-D_FORTIFY_SOURCE=2/} | ||
152 | |||
153 | # support multilib lib64 dir (x86_64 only) | ||
154 | if [[ ${ARCH} = x86_64 ]] | ||
155 | then | ||
156 | # first build a -m32 version | ||
157 | install -d ${SRCDIR}/build-m32 | ||
158 | cd ${SRCDIR}/build-m32 | ||
159 | |||
160 | # honor /usr move | ||
161 | echo "rootsbindir=/usr/sbin" >> ${SRCDIR}/build-m32/configparms || die | ||
162 | # make sure the -m32 libs goes really to /usr/lib | ||
163 | echo "slibdir=/usr/lib" >> ${SRCDIR}/build-m32/configparms || die | ||
164 | echo "rtlddir=/usr/lib" >> ${SRCDIR}/build-m32/configparms || die | ||
165 | |||
166 | CC="gcc -m32" CXX="g++ -m32" \ | ||
167 | CFLAGS="${CFLAGS//-march=${ARCH}} -march=i686" \ | ||
168 | CXXFLAGS="${CXXFLAGS//-march=${ARCH}} -march=i686" \ | ||
169 | ../configure \ | ||
170 | --build=${CHOST} \ | ||
171 | --host=i686-pc-linux-gnu \ | ||
172 | --libdir=/usr/lib \ | ||
173 | --libexecdir=/usr/lib/glibc \ | ||
174 | ${myopts} \ | ||
175 | || die | ||
176 | |||
177 | make PARALLELMFLAGS="${MAKEOPTS}" || die | ||
178 | fi | ||
179 | |||
180 | cd ${SRCDIR}/build | ||
181 | |||
182 | # honor /usr move | ||
183 | echo "rootsbindir=/usr/sbin" >> ${SRCDIR}/build/configparms || die | ||
184 | # make sure the -m64 libs goes really to /lib64 | ||
185 | echo "slibdir=/usr/$(mlibdir)" >> ${SRCDIR}/build/configparms || die | ||
186 | echo "rtlddir=/usr/$(mlibdir)" >> ${SRCDIR}/build/configparms || die | ||
187 | |||
188 | ../configure \ | ||
189 | --build=${CHOST} \ | ||
190 | --host=${CHOST} \ | ||
191 | --libdir=/usr/$(mlibdir) \ | ||
192 | --libexecdir=/usr/$(mlibdir)/glibc \ | ||
193 | ${myopts} \ | ||
194 | || die | ||
195 | |||
196 | make PARALLELMFLAGS="${MAKEOPTS}" || die | ||
197 | } | ||
198 | |||
199 | src_install() | ||
200 | { | ||
201 | if [[ ${ARCH} = x86_64 ]] | ||
202 | then | ||
203 | # install -m32 libs | ||
204 | cd ${SRCDIR}/build-m32 | ||
205 | make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} install || die | ||
206 | fi | ||
207 | |||
208 | cd ${SRCDIR}/build | ||
209 | make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} install || die | ||
210 | |||
211 | # do not generate the locales here, let it the user do with the locale-gen tool | ||
212 | # make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} localedata/install-locales || die | ||
213 | |||
214 | # install locales list and generate tools | ||
215 | # generate locale.gen file from localedata/SUPPORTED file | ||
216 | minstalletc locale.gen-header locale.gen || die | ||
217 | sed \ | ||
218 | -e 's:/: :g' \ | ||
219 | -e 's:\\: :g' \ | ||
220 | -e 's:SUPPORTED-LOCALES=::' \ | ||
221 | -e 's:\ \ $::g' \ | ||
222 | -e '/^#/d' \ | ||
223 | -e 's:^:#:g' \ | ||
224 | ${SRCDIR}/localedata/SUPPORTED \ | ||
225 | >> ${BINDIR}/etc/locale.gen || die | ||
226 | minstalldir /usr/sbin || die | ||
227 | minstallexec -s locale-gen /usr/sbin || die | ||
228 | |||
229 | # nsswitch configuration file | ||
230 | minstalletc ${SRCDIR}/nss/nsswitch.conf || die | ||
231 | |||
232 | # nscd configuration file | ||
233 | minstalletc ${SRCDIR}/nscd/nscd.conf || die | ||
234 | # systemd services, but do not include systemd.sminc to have a hard depend on systemd | ||
235 | minstalldir /usr/lib/systemd/system || die | ||
236 | minstallfile ${SRCDIR}/nscd/nscd.service /usr/lib/systemd/system || die | ||
237 | minstalldir /etc/tmpfiles.d || die | ||
238 | minstallfile ${SRCDIR}/nscd/nscd.tmpfiles /etc/tmpfiles.d/nscd.conf || die | ||
239 | |||
240 | # gai configuration file | ||
241 | minstalletc ${SRCDIR}/posix/gai.conf || die | ||
242 | |||
243 | # now in tzdata | ||
244 | ## we use Berlin as default | ||
245 | ## busybox compat | ||
246 | #local args | ||
247 | #if need_busybox_support /bin/cp | ||
248 | #then | ||
249 | # args="-f" | ||
250 | #else | ||
251 | # args="--remove-destination" | ||
252 | #fi | ||
253 | #cp ${args} ${BINDIR}/usr/share/zoneinfo/Europe/Berlin ${BINDIR}/etc/localtime || die | ||
254 | [ -f ${BINDIR}/etc/ld.so.conf ] && { rm -f ${BINDIR}/etc/ld.so.conf || die; } | ||
255 | [ -e ${BINDIR}/etc/ld.so.cache ] && { rm -rf ${BINDIR}/etc/ld.so.cache || die; } | ||
256 | |||
257 | # base environment | ||
258 | minstallenv glibc.envd-${ENVD_REV} 00glibc || die | ||
259 | if [[ ${ARCH} = x86_64 ]] | ||
260 | then | ||
261 | MCONFIG="/etc/env.d/00glibc" | ||
262 | maddconfig "LDPATH=\"/$(mlibdir)\"" || die | ||
263 | maddconfig "LDPATH=\"/usr/$(mlibdir)\"" || die | ||
264 | maddconfig "LDPATH=\"/usr/local/$(mlibdir)\"" || die | ||
265 | maddconfig "LDPATH=\"/opt/$(mlibdir)\"" || die | ||
266 | fi | ||
267 | |||
268 | # strip all binaries | ||
269 | find ${BINDIR} ! -type d | xargs --no-run-if-empty file | grep -v "pie executable" | grep "executable" | grep ELF | cut -f 1 -d : | xargs --no-run-if-empty strip --strip-unneeded || die | ||
270 | |||
271 | # strip all libraries | ||
272 | # want to be safe here; --strip-unneeded seems to cause pthread problems | ||
273 | # strip all but libpthread, libc and ld | ||
274 | install -d ${BUILDDIR}/thread-backup/$(mlibdir) || die | ||
275 | mv ${BINDIR}/usr/$(mlibdir)/lib{pthread,thread_db,c-}* ${BUILDDIR}/thread-backup/$(mlibdir)/ || die | ||
276 | mv ${BINDIR}/usr/$(mlibdir)/ld-* ${BUILDDIR}/thread-backup/$(mlibdir)/ || die | ||
277 | if [[ ${ARCH} = x86_64 ]] | ||
278 | then | ||
279 | install -d ${BUILDDIR}/thread-backup/lib || die | ||
280 | mv ${BINDIR}/usr/lib/lib{pthread,thread_db,c-}* ${BUILDDIR}/thread-backup/lib/ || die | ||
281 | mv ${BINDIR}/usr/lib/ld-* ${BUILDDIR}/thread-backup/lib/ || die | ||
282 | fi | ||
283 | |||
284 | # now strip but only debuging symbols | ||
285 | find ${BINDIR} ! -type d | xargs --no-run-if-empty file | grep "[shared object|pie executable]" | grep ELF | cut -f 1 -d : | xargs --no-run-if-empty strip --strip-debug || die | ||
286 | find ${BINDIR} ! -type d | xargs --no-run-if-empty file | grep "ar archive" | cut -f 1 -d : | xargs --no-run-if-empty strip --strip-debug || die | ||
287 | mv -f ${BUILDDIR}/thread-backup/$(mlibdir)/* ${BINDIR}/usr/$(mlibdir)/ || die | ||
288 | if [[ ${ARCH} = x86_64 ]] | ||
289 | then | ||
290 | mv -f ${BUILDDIR}/thread-backup/lib/* ${BINDIR}/usr/lib/ || die | ||
291 | fi | ||
292 | # remove stale directory | ||
293 | rm -rf ${BUILDDIR}/thread-backup || die | ||
294 | |||
295 | # prepare glibc for installation; slackware method | ||
296 | minstalldir /incoming || die | ||
297 | mv ${BINDIR}/usr/$(mlibdir)/*.so ${BINDIR}/incoming || die | ||
298 | mv ${BINDIR}/usr/$(mlibdir)/*.so.* ${BINDIR}/incoming || die | ||
299 | mv ${BINDIR}/incoming ${BINDIR}/usr/$(mlibdir)/incoming || die | ||
300 | mv ${BINDIR}/usr/$(mlibdir)/incoming/libSegFault.so ${BINDIR}/usr/$(mlibdir) || die | ||
301 | } | ||
302 | |||
303 | fix_db_files() | ||
304 | { | ||
305 | local i | ||
306 | local DB_ENTRY="${BUILDDIR}/${PKGNAME}" | ||
307 | |||
308 | for i in .files .symlinks .dirs | ||
309 | do | ||
310 | [ ! -f ${DB_ENTRY}/${i} ] && continue | ||
311 | [[ -z $(< ${DB_ENTRY}/${i}) ]] && continue | ||
312 | |||
313 | echo " fixing /usr/$(mlibdir)/incoming from db-entry '${i}' ..." | ||
314 | |||
315 | # /usr/lib/incoming -> empty line; sed2 removes all empty lines | ||
316 | #sed -i -e "s:/$(mlibdir)/incoming.*::g" -e '/^$/d' ${DB_ENTRY}/${i} | ||
317 | # do not simply emtpy the line, but change it the the correct path, | ||
318 | # so no stale libs are around if the package gets updated! | ||
319 | sed -i \ | ||
320 | -e "s:/usr/$(mlibdir)/incoming:/usr/$(mlibdir):g" \ | ||
321 | -e "s:/usr/$(mlibdir)/incoming.*::g" \ | ||
322 | -e '/^$/d' ${DB_ENTRY}/${i} | ||
323 | done | ||
324 | } | ||
325 | |||
326 | postinstall() | ||
327 | { | ||
328 | # first save the old libpthread.so.0; | ||
329 | # it will later used to determinate that there are no stale | ||
330 | # libpthreads that breaks ldconfig | ||
331 | local OLD_PTHREAD | ||
332 | OLD_PTHREAD="$(readlink ${MROOT}/usr/$(mlibdir)/libpthread.so.0)" | ||
333 | |||
334 | # slackware install method | ||
335 | |||
336 | # we cannot easily install the glibc libs, | ||
337 | # because our tools for cp etc needs them to run | ||
338 | |||
339 | local file | ||
340 | |||
341 | echo " Switching to new glibc ..." | ||
342 | # swap libraries on the fly: | ||
343 | if [ -x /usr/sbin/ldconfig -a -d /usr/$(mlibdir)/incoming ] && [[ -z ${MROOT} ]] | ||
344 | then | ||
345 | # first create copies of the incoming libraries: | ||
346 | cd /usr/$(mlibdir)/incoming | ||
347 | for file in $(find /usr/$(mlibdir)/incoming -type f) | ||
348 | do | ||
349 | if [ ! -r "../$(basename ${file}).incoming" ] | ||
350 | then | ||
351 | cp -a ${file} ../$(basename ${file}).incoming | ||
352 | fi | ||
353 | done | ||
354 | |||
355 | # then switch to them all at once: | ||
356 | /usr/sbin/ldconfig -l /usr/$(mlibdir)/*.incoming 2> /dev/null | ||
357 | |||
358 | # finally, rename them and clean up: | ||
359 | cd /usr/$(mlibdir) | ||
360 | for file in *.incoming | ||
361 | do | ||
362 | rm -f $(basename ${file} .incoming) | ||
363 | cp -a ${file} $(basename ${file} .incoming) | ||
364 | /usr/sbin/ldconfig -l $(basename ${file} .incoming) | ||
365 | rm -f ${file} | ||
366 | done | ||
367 | |||
368 | # no ldconfig? | ||
369 | # good, it's safe to just jam it on home (and make links below): | ||
370 | else | ||
371 | ( | ||
372 | cd ${MROOT}/usr/$(mlibdir)/incoming | ||
373 | for file in * | ||
374 | do | ||
375 | cp -a ${file} .. | ||
376 | done | ||
377 | |||
378 | local my_sym | ||
379 | local my_dest | ||
380 | |||
381 | # rebuild symlinks | ||
382 | echo " Recreating Symlinks:" | ||
383 | for i in $(find ${MROOT}/usr/$(mlibdir)/incoming -type l) | ||
384 | do | ||
385 | my_sym="$(readlink ${i})" | ||
386 | my_dest="$(basename ${i})" | ||
387 | |||
388 | echo " ${my_dest} -> ${my_dest}" | ||
389 | |||
390 | # assure to remove the old ones; | ||
391 | [ -L ${MROOT}/usr/$(mlibdir)/"${my_dest}" ] && \ | ||
392 | rm ${MROOT}/usr/$(mlibdir)/"${my_dest}" | ||
393 | |||
394 | ln -snf "${my_sym}" ${MROOT}/usr/$(mlibdir)/"${my_dest}" | ||
395 | done | ||
396 | ) | ||
397 | fi | ||
398 | |||
399 | # now, get rid of the temporary directory: | ||
400 | rm -rf ${MROOT}/usr/$(mlibdir)/incoming | ||
401 | |||
402 | # remove stale nptl libpthread-2.?.?.so, | ||
403 | # fix only needed for glibc with linuxthreads; | ||
404 | # prevent reloc errors such as: | ||
405 | # ls: error while loading shared libraries: libpthread.so.0: cannot open shared object file: No such file or directory | ||
406 | |||
407 | # get our new libpthread.so.0 | ||
408 | local NEW_PTHREAD | ||
409 | NEW_PTHREAD="$(readlink ${MROOT}/usr/$(mlibdir)/libpthread.so.0)" | ||
410 | |||
411 | if [ "${NEW_PTHREAD}" != "${OLD_PTHREAD}" ] | ||
412 | then | ||
413 | echo " Removing stale libpthread libraries ..." | ||
414 | for file in ${MROOT}/usr/$(mlibdir)/libpthread-* | ||
415 | do | ||
416 | if [ "$(basename ${file})" != "${NEW_PTHREAD}" ] | ||
417 | then | ||
418 | rm -f ${file} | ||
419 | fi | ||
420 | done | ||
421 | |||
422 | #rm -f /lib/${OLD_PTHREAD} | ||
423 | |||
424 | ln -snf ${NEW_PTHREAD} ${MROOT}/usr/$(mlibdir)/libpthread.so.0 | ||
425 | fi | ||
426 | |||
427 | if [ -x /usr/sbin/iconvconfig ] | ||
428 | then | ||
429 | # generate fastloading iconv module configuration file. | ||
430 | echo " Generate iconv module config ..." | ||
431 | /usr/sbin/iconvconfig --prefix=${MROOT}/ | ||
432 | fi | ||
433 | |||
434 | # not working with busybox | ||
435 | if ! need_busybox_support /sbin/telinit | ||
436 | then | ||
437 | # reloading init | ||
438 | echo " Reloading init ..." | ||
439 | [[ -z ${MROOT} ]] && /sbin/telinit U &> /dev/null | ||
440 | fi | ||
441 | |||
442 | # generating user def locales | ||
443 | echo " Generating user defined locales ..." | ||
444 | [[ -z ${MROOT} ]] && /usr/sbin/locale-gen | ||
445 | |||
446 | # now we must fix the mage db files | ||
447 | # to stop the annoying errors messages | ||
448 | fix_db_files | ||
449 | } |