<< Back to man.ChinaUnix.net

5.8. Glibc-2.3.4-20040701

The Glibc package contains the main C library. This library provides the basic routines for allocating memory, searching directories, opening and closing files, reading and writing files, string handling, pattern matching, arithmetic, and so on.

Approximate build time: 11.8 SBU

Required disk space: 800 MB

Glibc installation depends on: Bash, Binutils, Coreutils, Diffutils, Gawk, GCC, Gettext, Grep, Make, Perl, Sed, and Texinfo

5.8.1. Installation of Glibc

This package is known to have issues when its default optimization flags (including the -march and -mcpu options) are changed. If any environment variables that override default optimizations have been defined, such as CFLAGS and CXXFLAGS, unset them when building Glibc.

It should be noted that compiling Glibc in any way other than the method suggested in this book puts the stability of the system at risk.

The Glibc documentation recommends building Glibc outside of the source directory in a dedicated build directory:

mkdir ../glibc-build
cd ../glibc-build

Next, prepare Glibc for compilation:

../glibc-2.3.4-20040701/configure --prefix=/tools \
    --disable-profile --enable-add-ons=nptl --with-tls \
    --with-__thread --enable-kernel=2.6.0 \
    --with-binutils=/tools/bin --without-gd --without-cvs \
    --with-headers=/tools/glibc-kernheaders

The meaning of the configure options:

--disable-profile

This builds the libraries without profiling information. Omit this option if profiling on the temporary tools is necessary.

--enable-add-ons=nptl

This tells Glibc to use the NPTL add-on as its threading library.

--with-tls

This tells Glibc to include support for Thread-Local Storage (TLS). This is required in order for NPTL to work.

--with-__thread

This option tells Glibc to include thread support. It is required in order for TLS to be properly compiled.

--enable-kernel=2.6.0

This tells Glibc to compile the library with support for 2.6.x Linux kernels.

--with-binutils=/tools/bin

While not required, this switch ensures that there are no errors pertaining to which Binutils programs get used during the Glibc build.

--without-gd

This prevents the build of the memusagestat program, which insists on linking against the host's libraries (libgd, libpng, libz, etc.).

--without-cvs

This prevents the Makefile files from attempting automatic CVS checkouts when using a CVS snapshot. While this command is not required, it is recommended because it suppresses an annoying, but harmless, warning about a missing autoconf program.

--with-headers=/tools/glibc-kernheaders

This tells Glibc to compile itself against the “raw” kernel headers, so that it knows exactly what features the kernel has and can optimize itself accordingly.

During this stage the following warning might appear:

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

The missing or incompatible msgfmt program is generally harmless, but it can sometimes cause issues when running the test suite. This msgfmt program is part of the Gettext package which the host distribution should provide. If msgfmt is present but deemed incompatible, upgrade the host system's Gettext package or continue without it and see if the test suite runs without problems regardless.

Compile the package:

make

Compilation is now complete. As mentioned earlier, running the test suites for the temporary tools installed in this chapter is not mandatory. To run the Glibc test suite (if desired), the following command will do so:

make check

For a discussion of test failures that are of particular importance, please see Section 6.11, “Glibc-2.3.4-20040701.”

In this chapter, some tests can be adversely effected by existing tools or environmental issues on the host system. Glibc test suite failures in this chapter are typically not worrisome. The Glibc installed in Chapter 6 is the one that will ultimately end up being used, so that is the one that needs to pass most tests (even in Chapter 6, some failures could still occur, for example, with the math tests).

When experiencing a failure, make a note of it, then continue by reissuing the make check command. The test suite should pick up where it left off and continue. This stop-start sequence can be circumvented by issuing a make -k check command. If using this option, be sure to log the output so that the log file can be examined for failures later.

The install stage of Glibc will issue a harmless warning at the end about the absence of /tools/etc/ld.so.conf. Prevent this warning with:

mkdir /tools/etc
touch /tools/etc/ld.so.conf

Install the package:

make install

Different countries and cultures have varying conventions for how to communicate. These conventions range from the format for representing dates and times to more complex issues, such as the language spoken. The “internationalization” of GNU programs works by locale.

[Note]

Note

If the test suites are not being run in this chapter (as per the recommendation), there is no need to install the locales now. The appropriate locales will be installed in the next chapter.

To install the Glibc locales anyway, use the following command:

make localedata/install-locales

To save time, an alternative to running the previous command (which generates and installs every locale Glibc is aware of) is to install only those locales that are wanted and needed. This can be achieved by using the localedef command. Information on this command is located in the INSTALL file in the Glibc source. However, there are a number of locales that are essential in order for the tests of future packages to pass, in particular, the libstdc++ tests from GCC. The following instructions, instead of the install-locales target used above, will install the minimum set of locales necessary for the tests to run successfully:

mkdir -p /tools/lib/locale
localedef -i de_DE -f ISO-8859-1 de_DE
localedef -i de_DE@euro -f ISO-8859-15 de_DE@euro
localedef -i en_HK -f ISO-8859-1 en_HK
localedef -i en_PH -f ISO-8859-1 en_PH
localedef -i en_US -f ISO-8859-1 en_US
localedef -i es_MX -f ISO-8859-1 es_MX
localedef -i fa_IR -f UTF-8 fa_IR
localedef -i fr_FR -f ISO-8859-1 fr_FR
localedef -i fr_FR@euro -f ISO-8859-15 fr_FR@euro
localedef -i it_IT -f ISO-8859-1 it_IT
localedef -i ja_JP -f EUC-JP ja_JP

Details on this package are located in Section 6.11.4, “Contents of Glibc.”