Note: I am on Ubuntu 17.04.
I was doing something very similar:
apt source libc6
cd glibc-2.24
dpkg-buildpackage # found in package dpkg-dev (which depends on a bunch of Perl scripts in libdpkg-perl)
This command should build an install-able package (but I wasn't patient enough to wait, since it iterates over several package configurations I don't think I need).
What I wanted to do was to reguild libc with debug information, using either:
dpkg-buildpackage
with export DEB_BUILD_OPTIONS=nostrip,noopt
, or
debuild
(found in package devscripts
), see here.
... but that is another story.
The dpkg-buildpackage
command emits logs, and within those logs, we find the configure command that is used (newlines for readability):
CC="x86_64-linux-gnu-gcc-6 -no-pie -fno-PIE" \
CXX="x86_64-linux-gnu-g++-6 -no-pie -fno-PIE" \
MIG="x86_64-linux-gnu-mig" \
AUTOCONF=false \
MAKEINFO=: \
/usr/src/glibc-2.24/configure \
--host=x86_64-linux-gnu \
--build=$configure_build \
--prefix=/usr \
--enable-add-ons=libidn,"" \
--without-selinux \
--enable-stackguard-randomization \
--enable-obsolete-rpc \
--with-pkgversion="Ubuntu GLIBC 2.24-9ubuntu2" \
--with-bugurl="https://bugs.launchpad.net/ubuntu/+source/glibc/+bugs" \
--with-headers=/usr/src/glibc-2.24/debian/include \
--enable-kernel=2.6.32 \
--with-selinux \
--enable-systemtap \
--enable-multi-arch
After some experimentation, I was able to reduce the number of essential flags required by the command, as follows:
# same as above
apt source libc6
cd glibc-2.24
# regenerate the configure script (not essential, but doesn't hurt)
touch configure.ac
autoconf
# extra setup (sets-up kernel and library headers for use with --with-headers)
make -f ./debian/rules
# cannot build in source tree anyways
mkdir -p build and cd build
MAKEINFO=: CFLAGS="-g -O2" CXXFLAGS="-g -O2" ../configure --prefix=/dbg --with-headers=/usr/src/glibc-2.24-git/debian/include --enable-add-ons=libidn
make -j 4
make install DESTDIR=$(pwd)/install # testing installation
make check # 'actual' testing
Notes:
- the call to
make -f ./debian/rules
is essential to enable use of --with-headers
- apparently, libc doesn't support debug builds (non-optimized, that is):
glibc cannot be compiled without optimization
(see here). Even -O1
is unsupported.
--enable-add-ons=libidn
: the default looks for 'add-ons' in all the sub-directories (equivalent to setting --enable-add-ons=fbtl,libidn,libpthread
, with v2.24). If I add either fbtl
or libpthread
to the list, I get errors, i.e.:
No rule to make target '/usr/src/glibc-2.24-git/build/bits/stdio_lim.st', needed by '/usr/src/glibc-2.24-git/build/bits/stdio_lim.h'
- In fact, libpthread gets built regardless of
--enable-add-ons
Additional notes:
- I use
--prefix=/dbg
so that I won't install on top of the system libraries (and I am content to use LD_LIBRARY_PATH
to find my dependencies). You will have to set --disable-sanity-checks
if you leave it to the default (/usr/local)
MAKEINFO=:
will avoid a small error later on (during make install
)
Also, even if make check
appears to work, some of the flags I removed might be important. I'm not an expert at building glibc.