Magellan Linux

Annotation of /trunk/core/glibc/glibc-2.30-r1.smage2

Parent Directory Parent Directory | Revision Log Revision Log


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