From fcc027677da55c41dcaea045f5b9ff8b088e6495 Mon Sep 17 00:00:00 2001 From: Bruce Dubbs Date: Sun, 7 Jun 2020 20:16:00 +0000 Subject: Initial commit of alternative cross LFS git-svn-id: http://svn.linuxfromscratch.org/LFS/branches/cross2@11897 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689 --- chapter06/glibc.xml | 980 +++++++--------------------------------------------- 1 file changed, 120 insertions(+), 860 deletions(-) (limited to 'chapter06/glibc.xml') diff --git a/chapter06/glibc.xml b/chapter06/glibc.xml index a422c8d3c..5213c23e5 100644 --- a/chapter06/glibc.xml +++ b/chapter06/glibc.xml @@ -5,7 +5,7 @@ %general-entities; ]> - + @@ -16,25 +16,25 @@ Glibc-&glibc-version; - + Glibc + tools - <para>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.</para> + <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" + href="../chapter06/glibc.xml" + xpointer="xpointer(/sect1/sect2[1]/para[1])"/> <segmentedlist> <segtitle>&buildtime;</segtitle> <segtitle>&diskspace;</segtitle> <seglistitem> - <seg>&glibc-ch6-sbu;</seg> - <seg>&glibc-ch6-du;</seg> + <seg>&glibc-ch5-sbu;</seg> + <seg>&glibc-ch5-du;</seg> </seglistitem> </segmentedlist> @@ -43,927 +43,187 @@ <sect2 role="installation"> <title>Installation of Glibc + First, create two symbolic links, which are needed for proper + operation of the dynamic library loader: + +ln -sfv ../lib/ld-linux-x86-64.so.2 $LFS/lib64 +ln -sfv ../lib/ld-linux-x86-64.so.2 $LFS/lib64/ld-lsb-x86-64.so.3 + Some of the Glibc programs use the non-FHS compliant - /var/db directory to store - their runtime data. Apply the following patch to make such programs - store their runtime data in the FHS-compliant locations: + /var/db directory to store their + runtime data. Apply the following patch to make such programs store their + runtime data in the FHS-compliant locations: + +patch -Np1 -i ../glibc-&glibc-version;-fhs-1.patch -patch -Np1 -i ../&glibc-fhs-patch; - - The Glibc documentation recommends building Glibc in a dedicated build directory: mkdir -v build cd build - Prepare Glibc for compilation: + Next, prepare Glibc for compilation: + +../configure \ + --prefix=/usr \ + --host=$LFS_TGT \ + --build=$(../scripts/config.guess) \ + --enable-kernel=&min-kernel; \ + --with-headers=$LFS/usr/include \ + libc_cv_slibdir=/lib + -../configure --prefix=/usr \ - --disable-werror \ - --enable-kernel=&min-kernel; \ - --enable-stack-protector=strong \ - --with-headers=/usr/include \ - libc_cv_slibdir=/lib - - The meaning of the options and new configure parameters: + The meaning of the configure options: - CC="gcc -ffile-prefix-map=$LFS_DIR=$DIR" + --host=$LFS_TGT, --build=$(../scripts/config.guess) - Make GCC record any references to files in /usr/lib/gcc/x86_64-lfs-linux-gnu - in result of the compilation as if the files resided in /usr/lib/gcc/x86_64-pc-linux-gnu. - This avoids introduction of invalid paths in debugging - symbols. + The combined effect of these switches is that Glibc's build system + configures itself to be cross-compiled, using the cross-linker and + cross-compiler in /tools. - --disable-werror + --enable-kernel=&min-kernel; - This option disables the -Werror option passed to - GCC. This is necessary for running the test suite. + This tells Glibc to compile the library with support + for &min-kernel; and later Linux kernels. Workarounds for older + kernels are not enabled. - --enable-stack-protector=strong - - This option increases system security by adding - extra code to check for buffer overflows, such as stack - smashing attacks. - - - - - --with-headers=/usr/include + --with-headers=$LFS/usr/include - This option tells the build system where to find the - kernel API headers. + This tells Glibc to compile itself against the headers recently + installed to the usr/include directory, so that it knows exactly what + features the kernel has and can optimize itself accordingly. libc_cv_slibdir=/lib - This variable sets the correct library for all - systems. We do not want lib64 to be used. + This ensures that the library is installed in /lib instead + of the default /lib64 on 64 bit machines. - - - - Compile the package: - -make - - - In this section, the test suite for Glibc is considered critical. - Do not skip it under any circumstance. - - - Generally a few tests do not pass. The test failures listed below - are usually safe to ignore. - - -case $(uname -m) in - i?86) ln -sfnv $PWD/elf/ld-linux.so.2 /lib ;; - x86_64) ln -sfnv $PWD/elf/ld-linux-x86-64.so.2 /lib ;; -esac - - The symbolic link above is needed to run the tests at this - stage of building in the chroot environment. It will be overwritten - in the install phase below. - -make check - - You may see some test failures. The Glibc test suite is - somewhat dependent on the host system. This is a list of the most common - issues seen for some versions of LFS: - - - - - misc/tst-ttyname - is known to fail in the LFS chroot environment. - - - - inet/tst-idna_name_classify - is known to fail in the LFS chroot environment. - - - - posix/tst-getaddrinfo4 and - posix/tst-getaddrinfo5 - may fail on some architectures. - - - - The nss/tst-nss-files-hosts-multi - test may fail for reasons that have not been determined. - - - - The rt/tst-cputimer{1,2,3} tests depend on - the host system kernel. Kernels 4.14.91–4.14.96, - 4.19.13–4.19.18, and 4.20.0–4.20.5 are known to - cause these tests to fail. - - - - - The math tests sometimes fail when running on - systems where the CPU is not a relatively new Intel or - AMD processor. - - - - Though it is a harmless message, the install stage of Glibc will - complain about the absence of /etc/ld.so.conf. - Prevent this warning with: - -touch /etc/ld.so.conf - - Fix the generated Makefile to skip an unneeded sanity check - that fails in the LFS partial environment: - - -sed '/test-installation/s@$(PERL)@echo not running@' -i ../Makefile - - Install the package: - -make install - - Install the configuration file and runtime directory for - nscd: - -cp -v ../nscd/nscd.conf /etc/nscd.conf -mkdir -pv /var/cache/nscd - - Install the systemd support files for - nscd: - - install -v -Dm644 ../nscd/nscd.tmpfiles /usr/lib/tmpfiles.d/nscd.conf -install -v -Dm644 ../nscd/nscd.service /lib/systemd/system/nscd.service - - Next, install the locales that can make the system respond in a - different language. None of the locales are required, but if some of them - are missing, the test suites of future packages would skip important - testcases. - - Individual locales can be installed using the - localedef program. E.g., the first - localedef command below combines the - /usr/share/i18n/locales/cs_CZ - charset-independent locale definition with the - /usr/share/i18n/charmaps/UTF-8.gz - charmap definition and appends the result to the - /usr/lib/locale/locale-archive file. - The following instructions will install the minimum set of - locales necessary for the optimal coverage of tests: - -mkdir -pv /usr/lib/locale -localedef -i POSIX -f UTF-8 C.UTF-8 2> /dev/null || true -localedef -i cs_CZ -f UTF-8 cs_CZ.UTF-8 -localedef -i de_DE -f ISO-8859-1 de_DE -localedef -i de_DE@euro -f ISO-8859-15 de_DE@euro -localedef -i de_DE -f UTF-8 de_DE.UTF-8 -localedef -i el_GR -f ISO-8859-7 el_GR -localedef -i en_GB -f UTF-8 en_GB.UTF-8 -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 en_US -f UTF-8 en_US.UTF-8 -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 fr_FR -f UTF-8 fr_FR.UTF-8 -localedef -i it_IT -f ISO-8859-1 it_IT -localedef -i it_IT -f UTF-8 it_IT.UTF-8 -localedef -i ja_JP -f EUC-JP ja_JP -localedef -i ja_JP -f SHIFT_JIS ja_JP.SIJS 2> /dev/null || true -localedef -i ja_JP -f UTF-8 ja_JP.UTF-8 -localedef -i ru_RU -f KOI8-R ru_RU.KOI8-R -localedef -i ru_RU -f UTF-8 ru_RU.UTF-8 -localedef -i tr_TR -f UTF-8 tr_TR.UTF-8 -localedef -i zh_CN -f GB18030 zh_CN.GB18030 -localedef -i zh_HK -f BIG5-HKSCS zh_HK.BIG5-HKSCS - - In addition, install the locale for your own country, language and - character set. - - Alternatively, install all locales listed in the - glibc-&glibc-version;/localedata/SUPPORTED file - (it includes every locale listed above and many more) at once with the - following time-consuming command: - -make localedata/install-locales - - Then use the localedef command to create and - install locales not listed in the - glibc-&glibc-version;/localedata/SUPPORTED file - in the unlikely case you need them. - - Glibc now uses libidn2 when resolving internationalized - domain names. This is a run time dependency. If this capability - is needed, the instructions for installing libidn2 are in the - BLFS libidn2 page. - - - - - - Configuring Glibc - - - /etc/nsswitch.conf - - - - /etc/localtime - - - - Adding nsswitch.conf - - The /etc/nsswitch.conf file needs to be created - because the Glibc defaults do not work well in a networked environment. - - - Create a new file /etc/nsswitch.conf by running the - following: - -cat > /etc/nsswitch.conf << "EOF" -# Begin /etc/nsswitch.conf - -passwd: files -group: files -shadow: files - -hosts: files dns -networks: files - -protocols: files -services: files -ethers: files -rpc: files - -# End /etc/nsswitch.conf -EOF - - - - - Adding time zone data - - Install and set up the time zone data with the following: -tar -xf ../../tzdata&tzdata-version;.tar.gz - -ZONEINFO=/usr/share/zoneinfo -mkdir -pv $ZONEINFO/{posix,right} - -for tz in etcetera southamerica northamerica europe africa antarctica \ - asia australasia backward pacificnew systemv; do - zic -L /dev/null -d $ZONEINFO ${tz} - zic -L /dev/null -d $ZONEINFO/posix ${tz} - zic -L leapseconds -d $ZONEINFO/right ${tz} -done - -cp -v zone.tab zone1970.tab iso3166.tab $ZONEINFO -zic -d $ZONEINFO -p America/New_York -unset ZONEINFO - - - The meaning of the zic commands: - - - zic -L /dev/null ... - - This creates posix time zones, without any leap seconds. It is - conventional to put these in both - zoneinfo and - zoneinfo/posix. It is - necessary to put the POSIX time zones in - zoneinfo, otherwise various - test-suites will report errors. On an embedded system, where space is - tight and you do not intend to ever update the time zones, you could save - 1.9MB by not using the posix - directory, but some applications or test-suites might produce some - failures. - - - - zic -L leapseconds ... - - This creates right time zones, including leap seconds. On an - embedded system, where space is tight and you do not intend to - ever update the time zones, or care about the correct time, you could - save 1.9MB by omitting the right - directory. - - - zic ... -p ... - - This creates the posixrules file. We use - New York because POSIX requires the daylight savings time rules - to be in accordance with US rules. - - - - - - One way to determine the local time zone is to run the following - script: - -tzselect - - After answering a few questions about the location, the script will - output the name of the time zone (e.g., - America/Edmonton). There are also some other possible - time zones listed in /usr/share/zoneinfo such as - Canada/Eastern or EST5EDT that - are not identified by the script but can be used. - - Then create the /etc/localtime file by - running: - -ln -sfv /usr/share/zoneinfo/<xxx> /etc/localtime - - Replace <xxx> with the name of the - time zone selected (e.g., Canada/Eastern). - - - - - Configuring the Dynamic Loader - - - /etc/ld.so.conf - - - By default, the dynamic loader (/lib/ld-linux.so.2) searches through - /lib and /usr/lib for dynamic libraries that are - needed by programs as they are run. However, if there are libraries in - directories other than /lib and - /usr/lib, these need to be added - to the /etc/ld.so.conf file in order for the - dynamic loader to find them. Two directories that are commonly known - to contain additional libraries are /usr/local/lib and /opt/lib, so add those directories to the - dynamic loader's search path. - - Create a new file /etc/ld.so.conf by running the - following: - -cat > /etc/ld.so.conf << "EOF" -# Begin /etc/ld.so.conf -/usr/local/lib -/opt/lib - -EOF - - If desired, the dynamic loader can also search a directory and - include the contents of files found there. Generally the files in - this include directory are one line specifying the desired library path. - To add this capability run the following commands: - -cat >> /etc/ld.so.conf << "EOF" -# Add an include directory -include /etc/ld.so.conf.d/*.conf - -EOF -mkdir -pv /etc/ld.so.conf.d - - - - - - Contents of Glibc - - - Installed programs - Installed libraries - Installed directories - - - catchsegv, gencat, getconf, getent, iconv, iconvconfig, ldconfig, - ldd, lddlibc4, locale, localedef, makedb, mtrace, nscd, - pcprofiledump, pldd, sln, sotruss, sprof, tzselect, xtrace, - zdump, and zic - ld-&glibc-version;.so, libBrokenLocale.{a,so}, libSegFault.so, libanl.{a,so}, - libc.{a,so}, libc_nonshared.a, - libcrypt.{a,so}, libdl.{a,so}, libg.a, libm.{a,so}, - libmcheck.a, libmemusage.so, libmvec.{a,so}, libnsl.{a,so}, - libnss_compat.so, libnss_dns.so, libnss_files.so, libnss_hesiod.so, - libpcprofile.so, libpthread.{a,so}, - libpthread_nonshared.a, libresolv.{a,so}, librt.{a,so}, - libthread_db.so, and libutil.{a,so} - /usr/include/arpa, /usr/include/bits, /usr/include/gnu, - /usr/include/net, /usr/include/netash, /usr/include/netatalk, - /usr/include/netax25, /usr/include/neteconet, /usr/include/netinet, - /usr/include/netipx, /usr/include/netiucv, /usr/include/netpacket, - /usr/include/netrom, /usr/include/netrose, /usr/include/nfs, - /usr/include/protocols, /usr/include/rpc, - /usr/include/sys, /usr/lib/audit, /usr/lib/gconv, /usr/lib/locale, - /usr/libexec/getconf, /usr/share/i18n, /usr/share/zoneinfo, - /var/cache/nscd, and /var/lib/nss_db - - - - - Short Descriptions - - - - - catchsegv - - Can be used to create a stack trace when a program - terminates with a segmentation fault - - catchsegv - - - - - - gencat - - Generates message catalogues - - gencat - - - - - - getconf - - Displays the system configuration values for file system - specific variables - - getconf - - - - - - getent - - Gets entries from an administrative database - - getent - - - - - - iconv - - Performs character set conversion - - iconv - - - - - - iconvconfig - - Creates fastloading iconv module configuration - files - - iconvconfig - - - - - - ldconfig - - Configures the dynamic linker runtime bindings - - ldconfig - - - - - - ldd - - Reports which shared libraries are required - by each given program or shared library - - ldd - - - - - - lddlibc4 - - Assists ldd with object files - - lddlibc4 - - - - - - locale + libc_cv_c_cleanup=yes - Prints various information about the current locale - - locale - + Similarly, we pass libc_cv_c_cleanup=yes through to the + configure script so that the test is skipped and C + cleanup handling support is configured. - - localedef - - Compiles locale specifications - - localedef - - - - - - makedb - - Creates a simple database from textual input - - makedb - - - - - - mtrace - - Reads and interprets a memory trace file and displays a summary - in human-readable format - - mtrace - - - - - - nscd - - A daemon that provides a cache for the most common name - service requests - - nscd - - - - - - pcprofiledump + + libc_cv_ctors_header=yes - Dump information generated by PC profiling - - pcprofiledump - + Similarly, we pass libc_cv_ctors_header=yes through to the + configure script so that the test is skipped and + gcc constructor support is configured. - + --> - - pldd - - Lists dynamic shared objects used by running processes - - pldd - - - - - - sln - - A statically linked ln program - - sln - - - + - - sotruss - - Traces shared library procedure calls of a specified command - - sotruss - - - + During this stage the following warning might appear: - - sprof - - Reads and displays shared object profiling data - - sprof - - - +
+configure: WARNING: +*** These auxiliary programs are missing or +*** incompatible versions: msgfmt +*** some features will be disabled. +*** Check the INSTALL file for required versions. +
- - tzselect - - Asks the user about the location of the system and reports - the corresponding time zone description - - tzselect - - - + The missing or incompatible msgfmt program is + generally harmless. This msgfmt program is part of the + Gettext package which the host distribution should provide. - - xtrace - - Traces the execution of a program by printing the currently - executed function - - xtrace - - - + There have been reports that this package may fail when + building as a "parallel make". If this occurs, rerun the make command + with a "-j1" option. - - zdump - - The time zone dumper - - zdump - - - + Compile the package: - - zic - - The time zone compiler - - zic - - - +make - - ld-&glibc-version;.so - - The helper program for shared library executables - - ld-&glibc-version;.so - - - + Install the package: - - libBrokenLocale - - Used internally by Glibc as a gross hack to get broken programs - (e.g., some Motif applications) running. See comments in - glibc-&glibc-version;/locale/broken_cur_max.c - for more information - - libBrokenLocale - - - +make DESTDIR=$LFS install - - libSegFault - - The segmentation fault signal handler, used by - catchsegv - - libSegFault - - - + + The meaning of the <command>make install</command> option: - - libanl + + DESTDIR=$LFS - An asynchronous name lookup library - - libanl - + The DESTDIR make variable is used by almost all + packages to define the location where the package should be + installed. If it is not set, it defaults to the root (/) directory. Here we specify that + the package be installed in $LFS + , which will become the root after . - - libc - - The main C library - - libc - - - + - - libcrypt - - The cryptography library - - libcrypt - - - + + At this point, it is imperative to stop and ensure that the basic + functions (compiling and linking) of the new toolchain are working as + expected. To perform a sanity check, run the following commands: - - libdl - - The dynamic linking interface library - - libdl - - - +echo 'int main(){}' > dummy.c +$LFS_TGT-gcc dummy.c +readelf -l a.out | grep '/ld-linux' - - libg - - Dummy library containing no functions. Previously was a runtime - library for g++ - - libg - - - + If everything is working correctly, there should be no errors, + and the output of the last command will be of the form: - - libm - - The mathematical library - - libm - - - +[Requesting program interpreter: /lib64/ld-linux-x86-64.so.2] - - libmcheck - - Turns on memory allocation checking when linked to - - libmcheck - - - + Note that for 32-bit machines, the interpreter name will be + /lib/ld-linux.so.2. - - libmemusage - - Used by memusage to help collect - information about the memory usage of a program - - libmemusage - - - + If the output is not shown as above or there was no output at all, + then something is wrong. Investigate and retrace the steps to find out + where the problem is and correct it. This issue must be resolved before + continuing on. - - libnsl - - The network services library - - libnsl - - - + Once all is well, clean up the test files: - - libnss - - The Name Service Switch libraries, containing functions for - resolving host names, user names, group names, aliases, services, - protocols, etc. - - libnss - - - +rm -v dummy.c a.out - - libpcprofile - - Can be preloaded to PC profile an executable - - libpcprofile - - - + - - libpthread - - The POSIX threads library - - libpthread - - - + Building packages in the next sections will serve as an + additional check that the toolchain has been built properly. If some + package, especially binutils-pass2 or gcc-pass2, fails to build, it is + an indication that something has gone wrong with the + previous Binutils, GCC, or Glibc installations. - - libresolv - - Contains functions for creating, sending, and interpreting - packets to the Internet domain name servers - - libresolv - - - + Now that our cross-toolchain is complete, finalize the installation + of the limits.h header. For doing so, run an utility provided by the GCC + developers: - - librt - - Contains functions providing most of the interfaces specified - by the POSIX.1b Realtime Extension - - librt - - - +$LFS/tools/libexec/gcc/$LFS_TGT/&gcc-version;/install-tools/mkheaders - - libthread_db - - Contains functions useful for building debuggers for - multi-threaded programs - - libthread_db - - - +
- - libutil - - Contains code for standard functions used in - many different Unix utilities - - libutil - - - + + - </variablelist> + <para>Details on this package are located in + <xref linkend="contents-glibc" role="."/></para> </sect2> -- cgit v1.2.3-54-g00ecf