Topic: Tryout for temporary newer glibc
Hello,
just wanted to share the modifications I had done for having a newer glibc. Taken the version 2.27-2 from Arch Linux therefore as it is compatible for compiling with gcc-6 - another friendly reminder that we need a newer development-stack as version 6 reached its end of life.
Getting the files from here. The PKGBUILD is:
# $Id$
# Maintainer: Bartłomiej Piotrowski <bpiotrowski@archlinux.org>
# Contributor: Allan McRae <allan@archlinux.org>
# toolchain build order: inux-libre-lts-api-headers->glibc->binutils->gcc->binutils->glibc
# NOTE: valgrind requires rebuilt with each major glibc version
pkgbase=glibc
pkgname=(glibc lib32-glibc)
pkgver=2.27
pkgrel=2.hyperbola0
arch=(x86_64)
url='http://www.gnu.org/software/libc'
license=(GPL LGPL)
makedepends=(git gd lib32-gcc-libs)
options=(!strip staticlibs)
_commit=23158b08a0908f381459f273a984c6fd328363cb
#source=(git+https://sourceware.org/git/glibc.git#commit=$_commit
source=(https://ftp.gnu.org/gnu/glibc/glibc-$pkgver.tar.xz{,.sig}
locale.gen.txt
locale-gen
lib32-glibc.conf
bz20338.patch
nscd.initd)
validpgpkeys=(7273542B39962DF7B299931416792B4EA25340F8) # Carlos O'Donell
sha512sums=('7c5581154487d38d173ce1feb944e60207139cca148bccf066eaae322c0c2d219423bdcfa15c7f9be1b5e45dfc43c641cc5d80d3c3c65837d08a83cdb4e2a147'
'SKIP'
'3d9facc6da5159dcd877473c8a4d77006ef5615e2619ef743255112bfa136baf65239367222e87e7ada823d5c7d747aa5204f8365a806141e5884477898ccd14'
'd92e6ba83ee86c3602e74c52bf5f99ca751f3867edb894dd22c179003cd58a1b4e11237a293a54fe126edafd5add78a65bf3368826b8bfa40451ee374e301961'
'37858ae269bcf0d9d5adf5ac440ffeb9f5b71cce427ca85ff8cf9de6ae4d6011f8e71b83ec4aa183ab2ce248b563b5452e3d0d4b769a26f410d27bb8a31769a4'
'ee6cb58bf3f79a702f483318afcd733fe4284609e1755dad7ec0d510c11835a2c850dc2e59e8846b7b0a4d1aff6aacace15eeb9824794fff0d8da84712de9a53'
'8e9797f6cc7963d7c3233059591fd15c424c5dfa215b618336227982015b27b7a0532735ca70e9f269637e3ab1124c014efb3ce31ade2263a134c545448d89f5')
prepare() {
mkdir -p glibc-build lib32-glibc-build
[[ -d glibc-$pkgver ]] && ln -s glibc-$pkgver glibc
cd glibc
local i; for i in ${source[@]}; do
case ${i%::*} in
*.patch)
msg2 "Applying ${i}"
patch -p1 -i "$srcdir/${i}"
;;
esac
done
}
build() {
local _configure_flags=(
--prefix=/usr
--with-headers=/usr/include
--with-bugurl=https://issues.hyperbola.info/
--enable-add-ons
--enable-obsolete-rpc
--enable-kernel=2.6.32
--enable-bind-now
--enable-lock-elision
--enable-multi-arch
--enable-stack-protector=strong
--enable-stackguard-randomization
--disable-profile
--disable-werror
)
cd "$srcdir/glibc-build"
echo "slibdir=/lib" >> configparms
echo "rtlddir=/lib" >> configparms
echo "sbindir=/usr/sbin" >> configparms
echo "rootsbindir=/sbin" >> configparms
echo "vardbdir=/var/lib/misc" >> configparms
# remove fortify for building libraries
CPPFLAGS=${CPPFLAGS/-D_FORTIFY_SOURCE=2/}
"$srcdir/glibc/configure" \
--libdir=/usr/lib \
--libexecdir=/usr/libexec \
${_configure_flags[@]}
# build libraries with fortify disabled
echo "build-programs=no" >> configparms
make -j4
# re-enable fortify for programs
sed -i "/build-programs=/s#no#yes#" configparms
echo "CC += -D_FORTIFY_SOURCE=2" >> configparms
echo "CXX += -D_FORTIFY_SOURCE=2" >> configparms
make -j4
cd "$srcdir/lib32-glibc-build"
export CC="gcc -m32 -mstackrealign"
export CXX="g++ -m32 -mstackrealign"
echo "slibdir=/lib32" >> configparms
echo "rtlddir=/lib32" >> configparms
echo "sbindir=/usr/sbin" >> configparms
echo "rootsbindir=/sbin" >> configparms
# remove fortify for building libraries
CPPFLAGS=${CPPFLAGS/-D_FORTIFY_SOURCE=2/}
CFLAGS=${CFLAGS/-fno-plt/}
CXXFLAGS=${CXXFLAGS/-fno-plt/}
"$srcdir/glibc/configure" \
--host=i686-pc-linux-gnu \
--libdir=/usr/lib32 \
--libexecdir=/usr/libexec \
${_configure_flags[@]}
# build libraries with fortify disabled
echo "build-programs=no" >> configparms
make -j4
# re-enable fortify for programs
sed -i "/build-programs=/s#no#yes#" configparms
echo "CC += -D_FORTIFY_SOURCE=2" >> configparms
echo "CXX += -D_FORTIFY_SOURCE=2" >> configparms
make -j4
}
check() {
cd glibc-build
# remove fortify in preparation to run test-suite
sed -i '/FORTIFY/d' configparms
# some failures are "expected"
make check || true
}
package_glibc() {
pkgdesc='GNU C Library, with OpenRC support'
depends=('linux-libre-lts-api-headers>=4.9' tzdata filesystem)
optdepends=('gd: for memusagestat')
install=glibc.install
backup=(etc/gai.conf
etc/locale.gen
etc/nscd.conf)
groups=(base)
install -dm755 "$pkgdir/etc"
touch "$pkgdir/etc/ld.so.conf"
make -C glibc-build install_root="$pkgdir" install
rm -f "$pkgdir"/etc/ld.so.{cache,conf}
cd glibc
install -dm755 "$pkgdir"/usr/lib/locale
install -m644 nscd/nscd.conf "$pkgdir/etc/nscd.conf"
install -Dm755 ${srcdir}/nscd.initd ${pkgdir}/etc/init.d/nscd
install -m644 posix/gai.conf "$pkgdir"/etc/gai.conf
install -m755 "$srcdir/locale-gen" "$pkgdir/usr/sbin"
# Create /etc/locale.gen
install -m644 "$srcdir/locale.gen.txt" "$pkgdir/etc/locale.gen"
sed -e '1,3d' -e 's|/| |g' -e 's|\\| |g' -e 's|^|#|g' \
"$srcdir/glibc/localedata/SUPPORTED" >> "$pkgdir/etc/locale.gen"
if check_option 'debug' n; then
find "$pkgdir"/usr/bin -type f -executable -exec strip $STRIP_BINARIES {} + 2> /dev/null || true
find "$pkgdir"/usr/lib -name '*.a' -type f -exec strip $STRIP_STATIC {} + 2> /dev/null || true
# Do not strip these for gdb and valgrind functionality, but strip the rest
find "$pkgdir"/usr/lib \
-not -name 'ld-*.so' \
-not -name 'libc-*.so' \
-not -name 'libpthread-*.so' \
-not -name 'libthread_db-*.so' \
-name '*-*.so' -type f -exec strip $STRIP_SHARED {} + 2> /dev/null || true
fi
# install license files
install -dm755 ${pkgdir}/usr/share/licenses/${pkgname}
install -m644 ${srcdir}/glibc-${pkgver}/{COPYING{,.LIB},LICENSES} ${pkgdir}/usr/share/licenses/${pkgname}
}
package_lib32-glibc() {
pkgdesc='GNU C Library (32-bit)'
depends=("glibc=$pkgver")
cd lib32-glibc-build
make install_root="$pkgdir" install
rm -rf "$pkgdir"/{etc,sbin,usr/{bin,sbin,share},var}
# We need to keep 32 bit specific header files
find "$pkgdir/usr/include" -type f -not -name '*-32.h' -delete
# Dynamic linker
mkdir ${pkgdir}/lib
ln -s ../lib32/ld-linux.so.2 "$pkgdir/lib/"
# Add lib32 paths to the default library search path
install -Dm644 "$srcdir/lib32-glibc.conf" "$pkgdir/etc/ld.so.conf.d/lib32-glibc.conf"
# Symlink /usr/lib32/locale to /usr/lib/locale
ln -s ../lib/locale "$pkgdir/usr/lib32/locale"
if check_option 'debug' n; then
find "$pkgdir"/usr/lib32 -name '*.a' -type f -exec strip $STRIP_STATIC {} + 2> /dev/null || true
find "$pkgdir"/usr/lib32 \
-not -name 'ld-*.so' \
-not -name 'libc-*.so' \
-not -name 'libpthread-*.so' \
-not -name 'libthread_db-*.so' \
-name '*-*.so' -type f -exec strip $STRIP_SHARED {} + 2> /dev/null || true
fi
# install license files
install -dm755 ${pkgdir}/usr/share/licenses/${pkgname}
install -m644 ${srcdir}/glibc-${pkgver}/{COPYING{,.LIB},LICENSES} ${pkgdir}/usr/share/licenses/${pkgname}
}Please note therefore, that you also need to modify the file lib32-glibc.conf and build an INIT-script for nscd as the version coming up from Arch Linux uses systemd completely. So you should therefore also have a look onto the glibc here at Hyperbola. I'm testing this one for some days now and it is running very well. Happy hacking! ![]()
Certainly anyone who has the power to make you believe absurdities has the power to make you commit injustices: For a life of every being full with peace and kindness, including diversity and freedom. Capitalism is destroying our minds, the planet itself and the universe in the end!