6.13. Installing Glibc-2.2.5

Estimated build time:           14.71 SBU
Estimated required disk space:  369 MB

6.13.1. Installation of Glibc

This package requires its patch to be applied before you can install it. Make sure it's unpacked before running the installation commands.

Before starting to install glibc, you must cd into the glibc-2.2.5 directory and unpack glibc-linuxthreads inside the glibc-2.2.5 directory, not in /usr/src as you normally would do.

This package is known to behave badly when you have changed its default optimization flags (including the -march and -mcpu options). Glibc is best left alone. Therefore, if you have defined any environment variables that override default optimizations, such as CFLAGS and CXXFLAGS, we recommend unsetting or modifying them when building Glibc. You have been warned.

Also, don't pass the --enable-kernel option to the configure script. It's known to cause segmentation faults when other packages like fileutils, make and tar are linked against it.

Basically, compiling Glibc in any other way than the book suggests is putting your system at very high risk.

Install Glibc by running the following commands:

patch -Np1 -i ../glibc-2.2.5-2.patch &&
touch /etc/ld.so.conf &&
mkdir ../glibc-build &&
cd ../glibc-build &&
../glibc-2.2.5/configure --prefix=/usr --disable-profile \
    --enable-add-ons --libexecdir=/usr/bin &&
echo "cross-compiling = no" > configparms &&
make &&
make install &&
make localedata/install-locales &&
exec /static/bin/bash --login

An alternative to running make localedata/install-locales is to only install those locales which you need or want. This can be achieved using the localedef command. Information on this can be found in the INSTALL file in the glibc-2.2.5 tree. One thing to note is that the localedef program assumes that the /usr/lib/locale directory exists, so you need to create it first.

The Linux Threads man pages are not going to be installed at this point because it requires a working Perl installation. We'll install Perl later on in this chapter, so we'll come back to the Linux Threads man page installation after that.

During the configure stage you will see the following warning:

configure: warning:
*** These auxiliary programs are missing or too old: msgfmt
*** some features will be disabled.
*** Check the INSTALL file for required versions.

The missing msgfmt (from the gettext package which we will install later in this chapter) won't cause any problems. msgfmt is used to generate the binary translation files that are used to make your system talk in a different language. Because these translation files have already been generated for you, there is no need for msgfmt. You'd only need msgfmt if you change the translation source files (the *.po files in the po subdirectory) which would require you to re-generate the binary files.

6.13.2. Command explanations

patch -Np1 -i ../glibc-2.2.5-2.patch: This patch converts all occurrences of $(PERL) to /usr/bin/perl in the malloc/Makefile file. This is done because Glibc can't autodetect the location of perl because perl has yet to be installed. The patch also replaces all occurrences of root with 0 in the login/Makefile file. This is done because Glibc itself isn't installed yet and therefore username to userid resolving isn't working yet, so a chown root file will fail, however it'll work fine if you use straight IDs.

The patch also contains a few bug fixes and security fixes. In particular it contains the "errlist", "dns resolver", "xdr_array", "calloc", "thread exit", "udivdi3", "math test", "restrict_arr" and "divbyzero" fixes which are documented at http://www.zipworld.com.au/~gschafer/lfs-tweaks.html.

touch /etc/ld.so.conf: One of the final steps of the Glibc installation is running ldconfig to update the dynamic loader cache. If this file doesn't exist, the installation will abort with an error that it can't read the file, so we simply create an empty file (the empty file will have Glibc default to using /lib and /usr/lib which is fine).

--disable-profile: This disables the building of libraries with profiling information. This command may be omitted if you plan to do profiling.

--enable-add-ons: This enables the add-on that we install with Glibc, linuxthreads

--libexecdir=/usr/bin: This will cause the pt_chown program to be installed in the /usr/bin directory.

echo "cross-compiling = no" > configparms: We do this because we are only building for our own system. Cross-compiling is used, for instance, to build a package for an Apple Power PC on an Intel system. The reason Glibc thinks we're cross-compiling is that it can't compile a test program to determine this, so it automatically defaults to a cross-compiler. Compiling the test program fails because Glibc hasn't been installed yet.

exec /static/bin/bash --login: This command will start a new bash shell which will replace the current shell. This is done to get rid of the "I have no name!" message in the command prompt, which was caused by bash's inability to resolve a user ID to a user name (which in turn was caused by the absence of Glibc).

6.13.3. Contents of Glibc

Last checked against version 2.2.5.

6.13.3.2. Descriptions

6.13.3.4. Descriptions

6.13.4. Glibc Installation Dependencies

Last checked against version 2.2.5.

Bash: sh
Binutils: ar, as, ld, ranlib, readelf
Diffutils: cmp
Fileutils: chmod, cp, install, ln, mknod, mv, mkdir, rm, touch
Gcc: cc, cc1, collect2, cpp, gcc
Grep: egrep, grep
Gzip: gzip
Make: make
Gawk: gawk
Sed: sed
Sh-utils: date, expr, hostname, pwd, uname
Texinfo: install-info, makeinfo
Textutils: cat, cut, sort, tr