Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


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