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