From 8eb3fe49ba32604fd702d0e3c664d36f98b9733e Mon Sep 17 00:00:00 2001 From: Thomas Trepl Date: Mon, 1 Apr 2019 17:00:45 +0000 Subject: [PATCH] First apply of multilib-patch of April 1st, 2019 git-svn-id: http://svn.linuxfromscratch.org/LFS/branches/multilib@11566 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689 --- Makefile | 13 +++ chapter01/askforhelp.xml | 7 +- chapter01/changelog.xml | 6 +- chapter01/whatsnew.xml | 3 + chapter03/packages.xml | 18 ++++ chapter04/settingenviron.xml | 14 +++- chapter05/binutils-pass1.xml | 21 ++++- chapter05/binutils-pass2.xml | 49 ++++++++++- chapter05/chapter05.xml | 1 + chapter05/gcc-pass1.xml | 92 +++++++++++++++++--- chapter05/gcc-pass2.xml | 93 +++++++++++++++++---- chapter05/glibc.xml | 125 +++++++++++++++++++++++++++ chapter05/ncurses.xml | 54 ++++++++++++ chapter05/stripping.xml | 9 +- chapter05/util-linux.xml | 56 +++++++++++++ chapter05/xz.xml | 46 ++++++++++ chapter05/zlib.xml | 101 ++++++++++++++++++++++ chapter06/acl.xml | 52 ++++++++++++ chapter06/attr.xml | 55 ++++++++++++ chapter06/bzip2.xml | 48 +++++++++++ chapter06/chapter06.xml | 9 +- chapter06/createfiles.xml | 13 ++- chapter06/creatingdirs.xml | 17 +++- chapter06/eudev.xml | 73 ++++++++++++++++ chapter06/expat.xml | 56 +++++++++++++ chapter06/file.xml | 52 ++++++++++++ chapter06/gcc.xml | 44 ++++++++-- chapter06/glibc-32.xml | 158 +++++++++++++++++++++++++++++++++++ chapter06/glibc.xml | 1 + chapter06/gmp.xml | 104 +++++++++++++++++++++++ chapter06/isl.xml | 113 +++++++++++++++++++++++++ chapter06/kmod.xml | 64 ++++++++++++++ chapter06/libcap.xml | 38 +++++++++ chapter06/libelf.xml | 54 ++++++++++++ chapter06/libffi.xml | 68 +++++++++++++++ chapter06/libtool.xml | 54 ++++++++++++ chapter06/linux-firmware.xml | 50 +++++++++++ chapter06/ncurses.xml | 135 +++++++++++++++++++++++++++++- chapter06/openssl.xml | 64 ++++++++++++++ chapter06/readline.xml | 54 ++++++++++++ chapter06/revisedchroot.xml | 4 +- chapter06/strippingagain.xml | 37 +++++++- chapter06/systemd.xml | 143 +++++++++++++++++++++++++++++++ chapter06/util-linux.xml | 113 +++++++++++++++++++++++++ chapter06/xz.xml | 55 ++++++++++++ chapter06/zlib.xml | 49 +++++++++++ chapter08/grub.xml | 30 ++++++- chapter08/kernel.xml | 15 +++- chapter09/theend.xml | 31 ++++++- packages.ent | 16 ++++ prologue/architecture.xml | 33 ++++++-- prologue/bookinfo.xml | 11 ++- 52 files changed, 2544 insertions(+), 77 deletions(-) create mode 100644 chapter05/zlib.xml create mode 100644 chapter06/glibc-32.xml create mode 100644 chapter06/isl.xml create mode 100644 chapter06/linux-firmware.xml diff --git a/Makefile b/Makefile index f4a00ecc1..057e83465 100644 --- a/Makefile +++ b/Makefile @@ -34,6 +34,15 @@ else DUMPDIR ?= ~/lfs-sysd-commands endif +ifndef ARCH + ARCH = default +endif +ifneq ($(ARCH), default) + ifneq ($(ARCH), multilib) + $(error ARCH must be either 'default' (default if unset) or 'multilib'.) + endif +endif + book: validate profile-html @echo "Generating chunked XHTML files at $(BASEDIR)/ ..." $(Q)xsltproc --nonet \ @@ -130,6 +139,7 @@ validate: tmpdir --xinclude \ --output $(RENDERTMP)/lfs-html2.xml \ --stringparam profile.revision $(REV) \ + --stringparam profile.arch $(ARCH) \ stylesheets/lfs-xsl/profile.xsl \ index.xml @@ -160,6 +170,7 @@ $(BASEDIR)/wget-list: stylesheets/wget-list.xsl chapter03/chapter03.xml \ # $(Q)xsltproc --nonet --xinclude \ # --stringparam profile.revision $(REV) \ +# --stringparam profile.arch $(ARCH) \ # --output $(RENDERTMP)/sysd-wget.xml \ # stylesheets/lfs-xsl/profile.xsl \ # chapter03/chapter03.xml @@ -177,6 +188,7 @@ $(BASEDIR)/md5sums: stylesheets/wget-list.xsl chapter03/chapter03.xml \ $(Q)xsltproc --nonet --xinclude \ --stringparam profile.revision $(REV) \ + --stringparam profile.arch $(ARCH) \ --output $(RENDERTMP)/sysv-md5sum.xml \ stylesheets/lfs-xsl/profile.xsl \ chapter03/chapter03.xml @@ -194,6 +206,7 @@ $(BASEDIR)/md5sums: stylesheets/wget-list.xsl chapter03/chapter03.xml \ # $(Q)xsltproc --nonet \ # --output $(RENDERTMP)/lfs-html.xml \ # --stringparam profile.revision $(REV) \ +# --stringparam profile.arch $(ARCH) \ # stylesheets/lfs-xsl/profile.xsl \ # $(RENDERTMP)/lfs-full.xml diff --git a/chapter01/askforhelp.xml b/chapter01/askforhelp.xml index 70b9b5e44..9de08fbc6 100644 --- a/chapter01/askforhelp.xml +++ b/chapter01/askforhelp.xml @@ -39,8 +39,11 @@ The version of the book being used (in this case - &version; - &versiond;) + &version; + &version;-multilib + &versiond; + &versiond;-multilib) + The host distribution and version being used to create LFS diff --git a/chapter01/changelog.xml b/chapter01/changelog.xml index 771891e22..bf57c5aca 100644 --- a/chapter01/changelog.xml +++ b/chapter01/changelog.xml @@ -11,8 +11,10 @@ Changelog This is version - &version; - &versiond; + &version; + &version;-multilib + &versiond; + &versiond;-multilib of the Linux From Scratch book, dated &releasedate;. If this book is more than six months old, a newer and better version is probably already available. To find out, please check one of the diff --git a/chapter01/whatsnew.xml b/chapter01/whatsnew.xml index 4d6d2b607..c77d5dfbe 100644 --- a/chapter01/whatsnew.xml +++ b/chapter01/whatsnew.xml @@ -161,6 +161,9 @@ Linux-&linux-version; + + Linux-Firmware-&linux-firmware-version; + diff --git a/chapter03/packages.xml b/chapter03/packages.xml index a21f8e3a8..fcca03800 100644 --- a/chapter03/packages.xml +++ b/chapter03/packages.xml @@ -355,6 +355,15 @@ + + ISL (&isl-version;) - &isl-size;: + + Home page: + Download: + MD5 sum: &isl-md5; + + + Kbd (&kbd-version;) - &kbd-size;: @@ -450,6 +459,15 @@ + + Linux Firmware (&linux-firmware-version;) - &linux-firmware-size;: + + Home page: + Download: + MD5 sum: &linux-firmware-md5; + + + M4 (&m4-version;) - &m4-size;: diff --git a/chapter04/settingenviron.xml b/chapter04/settingenviron.xml index 02cd717d4..e0247df03 100644 --- a/chapter04/settingenviron.xml +++ b/chapter04/settingenviron.xml @@ -37,7 +37,7 @@ EOF .bashrc file instead. Create the .bashrc file now: -cat > ~/.bashrc << "EOF" +cat > ~/.bashrc << "EOF" set +h umask 022 LFS=/mnt/lfs @@ -45,6 +45,18 @@ LC_ALL=POSIX LFS_TGT=$(uname -m)-lfs-linux-gnu PATH=/tools/bin:/bin:/usr/bin export LFS LC_ALL LFS_TGT PATH +EOF + +cat > ~/.bashrc << "EOF" +set +h +umask 022 +LFS=/mnt/lfs +LC_ALL=POSIX +LFS_TGT=x86_64-lfs-linux-gnu +LFS_TGT32=i686-lfs-linux-gnu +LFS_TGTX32=x86_64-lfs-linux-gnux32 +PATH=/tools/bin:/bin:/usr/bin +export LFS LC_ALL LFS_TGT LFS_TGT32 LFS_TGTX32 PATH EOF The set +h command turns off diff --git a/chapter05/binutils-pass1.xml b/chapter05/binutils-pass1.xml index 458d89696..666046643 100644 --- a/chapter05/binutils-pass1.xml +++ b/chapter05/binutils-pass1.xml @@ -72,13 +72,22 @@ cd build Now prepare Binutils for compilation: -../configure --prefix=/tools \ +../configure --prefix=/tools \ --with-sysroot=$LFS \ --with-lib-path=/tools/lib \ --target=$LFS_TGT \ --disable-nls \ --disable-werror + ../configure --prefix=/tools \ + --with-sysroot=$LFS \ + --with-lib-path=/tools/lib:/tools/lib32:/tools/libx32 \ + --target=$LFS_TGT \ + --disable-nls \ + --disable-werror \ + --enable-64-bit-bfd \ + --enable-multilib + The meaning of the configure options: @@ -146,13 +155,19 @@ cd build tests at this point are minimal since the programs from this first pass will soon be replaced by those from the second. - If building on x86_64, create a symlink to ensure the sanity of + If building on x86_64, create a symlink to ensure the + sanity of the toolchain: + + Create a symlink to ensure the sanity of the toolchain: -case $(uname -m) in +case $(uname -m) in x86_64) mkdir -v /tools/lib && ln -sv lib /tools/lib64 ;; esac +mkdir -v /tools/lib && +ln -sv lib /tools/lib64 + Install the package: make install diff --git a/chapter05/binutils-pass2.xml b/chapter05/binutils-pass2.xml index 080c50916..535c0771d 100644 --- a/chapter05/binutils-pass2.xml +++ b/chapter05/binutils-pass2.xml @@ -50,7 +50,7 @@ cd build Prepare Binutils for compilation: -CC=$LFS_TGT-gcc \ +CC=$LFS_TGT-gcc \ AR=$LFS_TGT-ar \ RANLIB=$LFS_TGT-ranlib \ ../configure \ @@ -60,6 +60,18 @@ RANLIB=$LFS_TGT-ranlib \ --with-lib-path=/tools/lib \ --with-sysroot +CC=$LFS_TGT-gcc \ +AR=$LFS_TGT-ar \ +RANLIB=$LFS_TGT-ranlib \ +../configure \ + --prefix=/tools \ + --disable-nls \ + --disable-werror \ + --with-lib-path=/tools/lib:/tools/lib32:/tools/libx32 \ + --with-sysroot \ + --enable-64-bit-bfd \ + --enable-multilib + The meaning of the new configure options: @@ -72,7 +84,7 @@ RANLIB=$LFS_TGT-ranlib \ - + --with-lib-path=/tools/lib This tells the configure script to specify the library @@ -83,6 +95,19 @@ RANLIB=$LFS_TGT-ranlib \ + + --with-lib-path=/tools/lib:... + + This tells the configure script to specify the library + search path during the compilation of Binutils, resulting in + /tools/lib, + /tools/lib32 and + /tools/libx32 being passed + to the linker. This prevents the linker from searching through + library directories on the host. + + + --with-sysroot @@ -93,6 +118,20 @@ RANLIB=$LFS_TGT-ranlib \ + + --enable-64-bit-bfd + + TODO + + + + + --enable-multilib + + TODO + + + Compile the package: @@ -106,8 +145,12 @@ RANLIB=$LFS_TGT-ranlib \ Now prepare the linker for the Re-adjusting phase in the next chapter: -make -C ld clean +make -C ld clean make -C ld LIB_PATH=/usr/lib:/lib +cp -v ld/ld-new /tools/bin + +make -C ld clean +make -C ld LIB_PATH=/usr/lib:/lib:/usr/lib32:/lib32:/usr/libx32:/libx32 cp -v ld/ld-new /tools/bin diff --git a/chapter05/chapter05.xml b/chapter05/chapter05.xml index 3d82af568..ebccba382 100644 --- a/chapter05/chapter05.xml +++ b/chapter05/chapter05.xml @@ -20,6 +20,7 @@ + diff --git a/chapter05/gcc-pass1.xml b/chapter05/gcc-pass1.xml index b4d39ee9e..2cd76bc57 100644 --- a/chapter05/gcc-pass1.xml +++ b/chapter05/gcc-pass1.xml @@ -43,11 +43,17 @@ Installation of Cross GCC - GCC now requires the GMP, MPFR and MPC packages. As these packages may - not be included in your host distribution, they will be built with - GCC. Unpack each package into the GCC source directory and rename the - resulting directories so the GCC build procedures will automatically - use them: + GCC now requires the GMP, MPFR, and MPC packages. As + these packages may not be included in your host distribution, they will be + built with GCC. Unpack each package into the GCC source directory and + rename the resulting directories so the GCC build procedures will + automatically use them: + + GCC now requires the GMP, ISL, MPFR, and MPC packages. + As these packages may not be included in your host distribution, they will + be built with GCC. Unpack each package into the GCC source directory and + rename the resulting directories so the GCC build procedures will + automatically use them: There are frequent misunderstandings about this chapter. The procedures are the same as every other chapter as explained earlier ( -tar -xf ../mpfr-&mpfr-version;.tar.xz +tar -xf ../mpfr-&mpfr-version;.tar.xz mv -v mpfr-&mpfr-version; mpfr tar -xf ../gmp-&gmp-version;.tar.xz mv -v gmp-&gmp-version; gmp tar -xf ../mpc-&mpc-version;.tar.gz mv -v mpc-&mpc-version; mpc +tar -xf ../mpfr-&mpfr-version;.tar.xz +mv -v mpfr-&mpfr-version; mpfr +tar -xf ../gmp-&gmp-version;.tar.xz +mv -v gmp-&gmp-version; gmp +tar -xf ../mpc-&mpc-version;.tar.gz +mv -v mpc-&mpc-version; mpc +tar -xf ../isl-&isl-version;.tar.xz +mv -v isl-&isl-version; isl The following command will change the location of GCC's default dynamic linker to use the one installed in for file in gcc/config/{linux,i386/linux{,64}}.h do cp -uv $file{,.orig} - sed -e 's@/lib\(64\)\?\(32\)\?/ld@/tools&@g' \ + sed -e 's@/lib\(64\)\?\(32\)\?\(x32\)\?/ld@/tools&@g' \ -e 's@/usr@/tools@g' $file.orig > $file echo ' #undef STANDARD_STARTFILE_PREFIX_1 @@ -97,16 +111,27 @@ done prevents unexpected changes to the original files in case the commands are inadvertently run twice. - Finally, on x86_64 hosts, set the default directory name for - 64-bit libraries to lib: + Finally, on x86_64 hosts, set the default directory + name for 64-bit libraries to lib: -case $(uname -m) in +case $(uname -m) in x86_64) sed -e '/m64=/s/lib64/lib/' \ -i.orig gcc/config/i386/t-linux64 ;; esac +sed -e '/m64=/s/lib64/lib/' \ + -i.orig gcc/config/i386/t-linux64 +cat > gcc/config/i386/t-linux64 <<"EOF" +comma=, +MULTILIB_OPTIONS = $(subst $(comma),/,$(TM_MULTILIB_CONFIG)) +MULTILIB_DIRNAMES = $(patsubst m%, %, $(subst /, ,$(MULTILIB_OPTIONS))) +MULTILIB_OSDIRNAMES = m64=../lib$(call if_multiarch,:x86_64-linux-gnu) +MULTILIB_OSDIRNAMES+= m32=../lib32$(call if_multiarch,:i386-linux-gnu) +MULTILIB_OSDIRNAMES+= mx32=../libx32$(call if_multiarch,:x86_64-linux-gnux32) +EOF + + + + + + Fix an issue with isl-&isl-version;: + +sed -e "/#include <isl\/schedule_node.h>/ a#include <isl/id.h>\n#include <isl/space.h>" \ + -i gcc/graphite.h + The GCC documentation recommends building GCC in a dedicated build directory: @@ -128,7 +162,7 @@ cd build Prepare GCC for compilation: -../configure \ +../configure \ --target=$LFS_TGT \ --prefix=/tools \ --with-glibc-version=2.11 \ @@ -150,6 +184,31 @@ cd build --disable-libvtv \ --disable-libstdcxx \ --enable-languages=c,c++ + +../configure \ + --target=$LFS_TGT \ + --prefix=/tools \ + --with-glibc-version=2.11 \ + --with-sysroot=$LFS \ + --with-newlib \ + --without-headers \ + --with-local-prefix=/tools \ + --with-native-system-header-dir=/tools/include \ + --disable-nls \ + --disable-shared \ + --enable-multilib \ + --with-multilib-list=m32,m64,mx32 \ + --disable-decimal-float \ + --disable-threads \ + --disable-libatomic \ + --disable-libgomp \ + --disable-libmpx \ + --disable-libquadmath \ + --disable-libssp \ + --disable-libvtv \ + --disable-libstdcxx \ + --enable-languages=c,c++ + The meaning of the configure options: @@ -219,7 +278,7 @@ cd build - + --disable-multilib On x86_64, LFS does not yet support a multilib configuration. @@ -227,6 +286,15 @@ cd build + + --enable-multilib, + --with-multilib-list=m32,m64,mx32 + + LFS now supports a multilib configuration. Enable it for the + 32bit, the 64-bit, and the mixed mode. + + + --enable-languages=c,c++ diff --git a/chapter05/gcc-pass2.xml b/chapter05/gcc-pass2.xml index b5c56c161..8fe0874bc 100644 --- a/chapter05/gcc-pass2.xml +++ b/chapter05/gcc-pass2.xml @@ -73,7 +73,7 @@ esac for file in gcc/config/{linux,i386/linux{,64}}.h do cp -uv $file{,.orig} - sed -e 's@/lib\(64\)\?\(32\)\?/ld@/tools&@g' \ + sed -e 's@/lib\(64\)\?\(32\)\?\(x32\)\?/ld@/tools&@g' \ -e 's@/usr@/tools@g' $file.orig > $file echo ' #undef STANDARD_STARTFILE_PREFIX_1 @@ -83,31 +83,59 @@ do touch $file.orig done - If building on x86_64, change the default directory name for 64-bit - libraries to lib: + If building on x86_64, change the default directory + name for 64-bit libraries to lib: -case $(uname -m) in +case $(uname -m) in x86_64) sed -e '/m64=/s/lib64/lib/' \ -i.orig gcc/config/i386/t-linux64 ;; esac - As in the first build of GCC it requires the GMP, MPFR and MPC - packages. Unpack the tarballs and move them into the required directory - names: + Change the default directory name for 64-bit + libraries to lib: -tar -xf ../mpfr-&mpfr-version;.tar.xz +sed -e '/m64=/s/lib64/lib/' \ + -i.orig gcc/config/i386/t-linux64 +cat > gcc/config/i386/t-linux64 <<"EOF" +comma=, +MULTILIB_OPTIONS = $(subst $(comma),/,$(TM_MULTILIB_CONFIG)) +MULTILIB_DIRNAMES = $(patsubst m%, %, $(subst /, ,$(MULTILIB_OPTIONS))) +MULTILIB_OSDIRNAMES = m64=../lib$(call if_multiarch,:x86_64-linux-gnu) +MULTILIB_OSDIRNAMES+= m32=../lib32$(call if_multiarch,:i386-linux-gnu) +MULTILIB_OSDIRNAMES+= mx32=../libx32$(call if_multiarch,:x86_64-linux-gnux32) +EOF + + As in the first build of GCC it requires the GMP, + MPFR, and MPC packages. Unpack the tarballs and move them into the + required directory names: + + As in the first build of GCC it requires the GMP, + ISL, MPFR, and MPC packages. Unpack the tarballs and move them into the + required directory names: + +tar -xf ../mpfr-&mpfr-version;.tar.xz mv -v mpfr-&mpfr-version; mpfr tar -xf ../gmp-&gmp-version;.tar.xz mv -v gmp-&gmp-version; gmp tar -xf ../mpc-&mpc-version;.tar.gz mv -v mpc-&mpc-version; mpc - + Fix an issue with isl-&isl-version;: + +sed -e "/#include <isl\/schedule_node.h>/ a#include <isl/id.h>\n#include <isl/space.h>" \ + -i gcc/graphite.h -sed -i 's/if \((code.*))\)/if (\1 \&\& \!DEBUG_INSN_P (insn))/' gcc/sched-deps.c ---> Create a separate build directory again: mkdir -v build @@ -118,7 +146,7 @@ cd build Now prepare GCC for compilation: -CC=$LFS_TGT-gcc \ +CC=$LFS_TGT-gcc \ CXX=$LFS_TGT-g++ \ AR=$LFS_TGT-ar \ RANLIB=$LFS_TGT-ranlib \ @@ -132,6 +160,22 @@ RANLIB=$LFS_TGT-ranlib \ --disable-bootstrap \ --disable-libgomp +CC=$LFS_TGT-gcc \ +CXX=$LFS_TGT-g++ \ +AR=$LFS_TGT-ar \ +RANLIB=$LFS_TGT-ranlib \ +../configure \ + --prefix=/tools \ + --with-local-prefix=/tools \ + --with-native-system-header-dir=/tools/include \ + --enable-languages=c,c++ \ + --disable-libstdcxx-pch \ + --enable-multilib \ + --with-multilib-list=m32,m64,mx32 \ + --with-system-zlib \ + --disable-bootstrap \ + --disable-libgomp + The meaning of the new configure options: @@ -199,8 +243,27 @@ readelf -l a.out | grep ': /tools' [Requesting program interpreter: /tools/lib64/ld-linux-x86-64.so.2] - Note that the dynamic linker will be /tools/lib/ld-linux.so.2 - for 32-bit machines. + + Repeat the test for 32-bit: + +cc -m32 dummy.c +readelf -l a.out | grep ': /tools' + + In this case, the output shoud be: + +[Requesting program interpreter: /tools/lib/ld-linux.so.2] + + Repeat the test for x32-bit: + +cc -mx32 dummy.c +readelf -l a.out | grep ': /tools' + + In this case, the output shoud be: + +[Requesting program interpreter: /tools/lib/ld-linux-x32.so.2] + + Note that the dynamic linker will be + /tools/lib/ld-linux.so.2 for 32-bit machines. 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 diff --git a/chapter05/glibc.xml b/chapter05/glibc.xml index d8a4f6733..ba0c4107c 100644 --- a/chapter05/glibc.xml +++ b/chapter05/glibc.xml @@ -82,6 +82,13 @@ cd build + + --enable-multi-arch + + Enables glibc for multiarch environments. + + + --with-headers=/tools/include @@ -184,6 +191,124 @@ readelf -l a.out | grep ': /tools' + + Installation of Glibc 32-bit + + Clean the build directory for redoing glibc for 32-bit: +mkdir ../build32 +cd ../build32 + + Rebuild glibc for 32-bit: +echo slibdir=/tools/lib32 > configparms +BUILD_CC="gcc -m32" \ +CC="${LFS_TGT}-gcc -m32" \ +CXX="${LFS_TGT}-g++ -m32" \ +AR="${LFS_TGT}-ar" \ +RANLIB="${LFS_TGT}-ranlib" \ +../configure --prefix=/tools \ + --build=$(../scripts/config.guess) \ + --host=${LFS_TGT32} \ + --enable-kernel=&min-kernel; \ + --enable-multi-arch \ + --libdir=/tools/lib32 \ + --libexecdir=/tools/lib32 \ + --with-headers=/tools/include \ + --with-binutils=/tools/bin \ + libc_cv_forced_unwind=yes \ + libc_cv_c_cleanup=yes + + Now compile the 32-bit version of glibc: +make + + Install 32-bit version of glibc: +make install_root="${PWD}/DESTDIR" install +install -vdm755 /tools/lib32 +cp -Rv DESTDIR/tools/lib32/* /tools/lib32 +install -vm644 DESTDIR/tools/include/gnu/{lib-names,stubs}-32.h \ + /tools/include/gnu/ +ln -svf /tools/lib32/ld-linux.so.2 /tools/lib/ +cd .. + + + + + Installation of Glibc x32-bit + + Create a build directory for redoing glibc for x32-bit: +mkdir build32x +cd build32x + + Rebuild glibc for x32-bit: +echo slibdir=/tools/libx32 > configparms +BUILD_CC="gcc -mx32" \ +CC="${LFS_TGT}-gcc -mx32" \ +CXX="${LFS_TGT}-g++ -mx32" \ +AR="${LFS_TGT}-ar" \ +RANLIB="${LFS_TGT}-ranlib" \ +../configure --prefix=/tools \ + --build=$(../scripts/config.guess) \ + --host=${LFS_TGTX32} \ + --enable-kernel=&min-kernel; \ + --enable-multi-arch \ + --libdir=/tools/libx32 \ + --libexecdir=/tools/libx32 \ + --with-headers=/tools/include \ + --with-binutils=/tools/bin \ + libc_cv_forced_unwind=yes \ + libc_cv_c_cleanup=yes + + Now compile the x32-bit version of glibc: +make + + Install x32-bit version of glibc: +make install_root="${PWD}/DESTDIR" install +install -vdm755 /tools/libx32 +cp -Rv DESTDIR/tools/libx32/* /tools/libx32 +install -vm644 DESTDIR/tools/include/gnu/lib-names-x32.h \ + /tools/include/gnu/ +[ -e DESTDIR/tools/include/gnu/stubs-x32.h ] \ + && install -vm644 DESTDIR/tools/include/gnu/stubs-x32.h /tools/include/gnu/ \ + || ln -v /tools/include/gnu/stubs-64.h /tools/include/gnu/stubs-x32.h +ln -svf /tools/libx32/ld-linux-x32.so.2 /tools/lib/ + + + + 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: + +echo 'int main(){}' > dummy.c +$LFS_TGT-gcc -m32 dummy.c +readelf -l a.out | grep ': /tools' + + If everything is working correctly, there should be no errors, + and the output of the last command will be of the form: + +[Requesting program interpreter: /tools/lib/ld-linux.so.2] + + Redo test for x32-ABI: + +echo 'int main(){}' > dummy.c +$LFS_TGT-gcc -mx32 dummy.c +readelf -l a.out | grep ': /tools' + + Output should be like: + +[Requesting program interpreter: /tools/lib/ld-linux-x32.so.2] + + 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. + + Once all is well, clean up the test files: + +rm -v dummy.c a.out + + + + diff --git a/chapter05/ncurses.xml b/chapter05/ncurses.xml index c00135f12..b0681486c 100644 --- a/chapter05/ncurses.xml +++ b/chapter05/ncurses.xml @@ -112,6 +112,60 @@ ln -s libncursesw.so /tools/lib/libncurses.so</userinput></screen> </sect2> + <sect2 arch="multilib" role="installation"> + <title>Installation of Ncurses - 32 bit + + Prepare Ncurses for compilation: + +make distclean && +CC="${LFS_TGT}-gcc -m32" \ +./configure --prefix=/tools \ + --libdir=/tools/lib32 \ + --with-shared \ + --without-debug \ + --without-ada \ + --enable-widec \ + --enable-overwrite \ + --host="${LFS_TGT32}" + + Compile the package: + +make + + To test the results, issue: + +make check + + Install the package: + +make DESTDIR=$PWD/DESTDIR_32 install && +cp -Rv DESTDIR_32/tools/lib32/* /tools/lib32 + + + + + Installation of Ncurses - x32 bit + + Repeat for the x32-ABI: + +make distclean && +CC="${LFS_TGT}-gcc -mx32" \ +./configure --prefix=/tools \ + --libdir=/tools/libx32 \ + --with-shared \ + --without-debug \ + --without-ada \ + --enable-widec \ + --enable-overwrite \ + --host="${LFS_TGTX32}" + +make + +make DESTDIR=$PWD/DESTDIR_x32 install && +cp -Rv DESTDIR_x32/tools/libx32/* /tools/libx32 + + + diff --git a/chapter05/stripping.xml b/chapter05/stripping.xml index 10879d278..5902d300c 100644 --- a/chapter05/stripping.xml +++ b/chapter05/stripping.xml @@ -15,7 +15,10 @@ The executables and libraries built so far contain about 70 MB of unneeded debugging symbols. Remove those symbols with:</para> -<screen><userinput>strip --strip-debug /tools/lib/* +<screen arch="default"><userinput>strip --strip-debug /tools/lib/* +/usr/bin/strip --strip-unneeded /tools/{,s}bin/*</userinput></screen> + +<screen arch="multilib"><userinput>strip --strip-debug /tools/lib{,{,x}32}/* /usr/bin/strip --strip-unneeded /tools/{,s}bin/*</userinput></screen> <para>These commands will skip a number of files, reporting that it does not @@ -33,7 +36,9 @@ <para>Remove unneeded files:</para> -<screen><userinput>find /tools/{lib,libexec} -name \*.la -delete</userinput></screen> +<screen arch="default"><userinput>find /tools/{lib,libexec} -name \*.la -delete</userinput></screen> + +<screen arch="multilib"><userinput>find /tools/{lib{,{,x}32},libexec} -name \*.la -delete</userinput></screen> <para>At this point, you should have at least 3 GB of free space in <envar>$LFS</envar> that can be used to build and install Glibc and Gcc in diff --git a/chapter05/util-linux.xml b/chapter05/util-linux.xml index 96b8eec1f..203cea201 100644 --- a/chapter05/util-linux.xml +++ b/chapter05/util-linux.xml @@ -121,4 +121,60 @@ </sect2> + <sect2 arch="multilib" role="installation"> + <title>Installation of Util-Linux - 32 bit + + Prepare Util-Linux for compilation: + +make distclean && +CC="${LFS_TGT}-gcc -m32" \ +./configure \ + --prefix=/tools \ + --libdir=/tools/lib32 \ + --without-python \ + --disable-makeinstall-chown \ + --without-systemdsystemunitdir \ + --without-ncurses \ + --host="${LFS_TGT32}" \ + PKG_CONFIG="" + + Compile the package: + +make + + To test the results, issue: + +make check + + Install the package: + +make DESTDIR=$PWD/DESTDIR_32 install && +cp -Rv DESTDIR_32/tools/lib32/* /tools/lib32 + + + + + Installation of Util-Linux - x32 bit + + Repeat for the x32-ABI: + +make distclean && +CC="${LFS_TGT}-gcc -mx32" \ +./configure \ + --prefix=/tools \ + --libdir=/tools/libx32 \ + --without-python \ + --disable-makeinstall-chown \ + --without-systemdsystemunitdir \ + --without-ncurses \ + --host="${LFS_TGTX32}" \ + PKG_CONFIG="" + +make + +make DESTDIR=$PWD/DESTDIR_x32 install && +cp -Rv DESTDIR_x32/tools/libx32/* /tools/libx32 + + + diff --git a/chapter05/xz.xml b/chapter05/xz.xml index ea1ea4966..c753151a0 100644 --- a/chapter05/xz.xml +++ b/chapter05/xz.xml @@ -63,6 +63,52 @@ + + Installation of Xz - 32 bit + + Prepare Xz for compilation: + +make distclean && +CC="${LFS_TGT}-gcc -m32" \ +./configure \ + --prefix=/tools \ + --libdir=/tools/lib32 \ + --host="${LFS_TGT32}" + + Compile the package: + +make + + To test the results, issue: + +make check + + Install the package: + +make DESTDIR=$PWD/DESTDIR_32 install && +cp -Rv DESTDIR_32/tools/lib32/* /tools/lib32 + + + + + Installation of Xz - x32 bit + + Repeat for the x32-ABI: + +make distclean && +CC="${LFS_TGT}-gcc -mx32" \ +./configure \ + --prefix=/tools \ + --libdir=/tools/libx32 \ + --host="${LFS_TGTX32}" + +make + +make DESTDIR=$PWD/DESTDIR_x32 install && +cp -Rv DESTDIR_x32/tools/libx32/* /tools/libx32 + + + diff --git a/chapter05/zlib.xml b/chapter05/zlib.xml new file mode 100644 index 000000000..41259514e --- /dev/null +++ b/chapter05/zlib.xml @@ -0,0 +1,101 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" + "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [ + <!ENTITY % general-entities SYSTEM "../general.ent"> + %general-entities; +]> + +<sect1 arch="multilib" id="ch-tools-zlib" role="wrap"> + <?dbhtml filename="zlib.html"?> + + <sect1info condition="script"> + <productname>zlib</productname> + <productnumber>&zlib-version;</productnumber> + <address>&zlib-url;</address> + </sect1info> + + <title>Zlib-&zlib-version; + + + Zlib + + + + + + <para>The Zlib package contains compression and decompression routines used by + some programs.</para> + + <segmentedlist> + <segtitle>&buildtime;</segtitle> + <segtitle>&diskspace;</segtitle> + + <seglistitem> + <seg>&zlib-ch6-sbu;</seg> + <seg>&zlib-ch6-du;</seg> + </seglistitem> + </segmentedlist> + + </sect2> + + <sect2 role="installation"> + <title>Installation of Zlib + + Prepare Zlib for compilation: + +./configure --prefix=/tools + + Compile the package: + +make + + To test the results, issue: + +make check + + Install the package: + +make install + + + + + Installation of Zlib - 32 bit + + Prepare Zlib for compilation: + +make distclean && +CC="${LFS_TGT}-gcc -m32" ./configure --prefix=/tools --libdir=/tools/lib32 + + Compile the package: + +make + + To test the results, issue: + +make check + + Install the package: + +make DESTDIR=$PWD/DESTDIR_32 install && +cp -Rv DESTDIR_32/tools/lib32/* /tools/lib32 + + + + + Installation of Zlib - x32 bit + + Repeat for the x32-ABI: + +make distclean && +CC="${LFS_TGT}-gcc -mx32" ./configure --prefix=/tools --libdir=/tools/libx32 + +make + +make DESTDIR=$PWD/DESTDIR_x32 install && +cp -Rv DESTDIR_x32/tools/libx32/* /tools/libx32 + + + + + diff --git a/chapter06/acl.xml b/chapter06/acl.xml index cb5be400e..50d413d47 100644 --- a/chapter06/acl.xml +++ b/chapter06/acl.xml @@ -79,6 +79,58 @@ ln -sfv ../../lib/$(readlink /usr/lib/libacl.so) /usr/lib/libacl.so< + + Installation of Acl - 32-bit + + Clean previous build: + +make distclean + + Prepare Acl for compilation: + +CC="gcc -m32" ./configure \ + --prefix=/usr --libdir=/usr/lib32 \ + --disable-static --libexecdir=/usr/lib32 \ + --host=i686-pc-linux-gnu + + Compile the package: + +make + + Install the package: + +make DESTDIR=$(pwd)/DESTDIR install +cp -Rv DESTDIR/usr/lib32/* /usr/lib32 +rm -rf DESTDIR + + + + + Installation of Acl - x32-bit + + Clean previous build: + +make distclean + + Prepare Acl for compilation: + +CC="gcc -mx32" ./configure \ + --prefix=/usr --libdir=/usr/libx32 \ + --disable-static --libexecdir=/usr/libx32 \ + --host=x86_64-pc-linux-gnux32 + + Compile the package: + +make + + Install the package: + +make DESTDIR=$(pwd)/DESTDIR install +cp -Rv DESTDIR/usr/libx32/* /usr/libx32 +rm -rf DESTDIR + + + Contents of Acl diff --git a/chapter06/attr.xml b/chapter06/attr.xml index de93a2b43..193a19c91 100644 --- a/chapter06/attr.xml +++ b/chapter06/attr.xml @@ -78,6 +78,61 @@ ln -sfv ../../lib/$(readlink /usr/lib/libattr.so) /usr/lib/libattr.so + + Installation of Attr - 32-bit + + Clean previous build: + +make distclean + + Prepare Attr for compilation: + +CC="gcc -m32" ./configure \ + --prefix=/usr \ + --disable-static \ + --libdir=/usr/lib32 \ + --host=i686-pc-linux-gnu + + Compile the package: + +make + + Install the package: + +make DESTDIR=$(pwd)/DESTDIR install +cp -Rv DESTDIR/usr/lib32/* /usr/lib32 +rm -rf DESTDIR + + + + + Installation of Attr - x32-bit + + Clean previous build: + +make distclean + + Prepare Attr for compilation: + + +CC="gcc -mx32" ./configure \ + --prefix=/usr \ + --disable-static \ + --libdir=/usr/libx32 \ + --host=x86_64-pc-linux-gnux32 + + Compile the package: + +make + + Install the package: + +make DESTDIR=$(pwd)/DESTDIR install +cp -Rv DESTDIR/usr/libx32/* /usr/libx32 +rm -rf DESTDIR + + + Contents of Attr diff --git a/chapter06/bzip2.xml b/chapter06/bzip2.xml index 761bd7abb..028c37178 100644 --- a/chapter06/bzip2.xml +++ b/chapter06/bzip2.xml @@ -97,6 +97,54 @@ ln -sv bzip2 /bin/bzcat + + Installation of Bzip2 - 32-bit + + Clean previous build: + +make clean + + Compile the package: + +sed -e "s/^CC=.*/CC=gcc -m32/" \ + -i Makefile{,-libbz2_so} +make -f Makefile-libbz2_so +make libbz2.a + + Install the package: + +install -Dm755 libbz2.so.1.0.6 /usr/lib32/libbz2.so.1.0.6 +ln -sf libbz2.so.1.0.6 /usr/lib32/libbz2.so +ln -sf libbz2.so.1.0.6 /usr/lib32/libbz2.so.1 +ln -sf libbz2.so.1.0.6 /usr/lib32/libbz2.so.1.0 +install -Dm644 libbz2.a /usr/lib32/libbz2.a + + + + + Installation of Bzip2 - x32-bit + + Clean previous build: + +make clean + + Compile the package: + +sed -e "s/^CC=.*/CC=gcc -mx32/" \ + -i Makefile{,-libbz2_so} +make -f Makefile-libbz2_so +make libbz2.a + + Install the package: + +install -Dm755 libbz2.so.1.0.6 /usr/libx32/libbz2.so.1.0.6 +ln -sf libbz2.so.1.0.6 /usr/libx32/libbz2.so +ln -sf libbz2.so.1.0.6 /usr/libx32/libbz2.so.1 +ln -sf libbz2.so.1.0.6 /usr/libx32/libbz2.so.1.0 +install -Dm644 libbz2.a /usr/libx32/libbz2.a + + + Contents of Bzip2 diff --git a/chapter06/chapter06.xml b/chapter06/chapter06.xml index d6025c52a..d79e9bfe1 100644 --- a/chapter06/chapter06.xml +++ b/chapter06/chapter06.xml @@ -21,6 +21,10 @@ + + + + @@ -30,6 +34,7 @@ + @@ -82,12 +87,11 @@ - - + @@ -97,6 +101,7 @@ + diff --git a/chapter06/createfiles.xml b/chapter06/createfiles.xml index e4daa3cb2..e47e131f4 100644 --- a/chapter06/createfiles.xml +++ b/chapter06/createfiles.xml @@ -39,13 +39,24 @@ will be replaced by real files throughout the course of this chapter after the software has been installed: -ln -sv /tools/bin/{bash,cat,chmod,dd,echo,ln,mkdir,pwd,rm,stty,touch} /bin +ln -sv /tools/bin/{bash,cat,chmod,dd,echo,ln,mkdir,pwd,rm,stty,touch} /bin ln -sv /tools/bin/{env,install,perl,printf} /usr/bin ln -sv /tools/lib/libgcc_s.so{,.1} /usr/lib ln -sv /tools/lib/libstdc++.{a,so{,.6}} /usr/lib install -vdm755 /usr/lib/pkgconfig +ln -sv bash /bin/sh +ln -sv /tools/bin/{bash,cat,chmod,dd,echo,ln,mkdir,pwd,rm,stty,touch} /bin +ln -sv /tools/bin/{env,install,perl,printf} /usr/bin +for lib in lib{,32,x32}; do + ln -sv /tools/$lib/libgcc_s.so{,.1} /usr/$lib + ln -sv /tools/$lib/libstdc++.{a,so{,.6}} /usr/$lib +done +ln -sv /usr/libx32 / + +install -vdm755 /usr/lib{,32,x32}/pkgconfig + ln -sv bash /bin/sh + + + Installation of Eudev - 32-bit + + Clean previous build: + +make distclean + + Prepare Eudev for compilation: + +CC="gcc -m32" \ +./configure --host=i686-pc-linux-gnu \ + --prefix=/usr \ + --bindir=/sbin \ + --sbindir=/sbin \ + --libdir=/usr/lib32 \ + --sysconfdir=/etc \ + --libexecdir=/lib32 \ + --with-rootprefix= \ + --with-rootlibdir=/usr/lib32 \ + --disable-manpages \ + --disable-static \ + --config-cache + + Compile the package: + +make + + Install the package: + +make DESTDIR=$PWD/DESTDIR install +cp -Rv DESTDIR/usr/lib32/* /usr/lib32 +rm -rf DESTDIR + + + + + + + Installation of Eudev - x32-bit + + Clean previous build: + +make distclean + + Prepare Eudev for compilation: + +CC="gcc -mx32" \ +./configure --prefix=/usr \ + --bindir=/sbin \ + --sbindir=/sbin \ + --libdir=/usr/libx32 \ + --sysconfdir=/etc \ + --libexecdir=/libx32 \ + --with-rootprefix= \ + --with-rootlibdir=/usr/libx32 \ + --disable-manpages \ + --disable-static \ + --config-cache + + Compile the package: + +make + + Install the package: + +make DESTDIR=$PWD/DESTDIR install +cp -Rv DESTDIR/usr/libx32/* /usr/libx32 +rm -rf DESTDIR + + + Configuring Eudev diff --git a/chapter06/expat.xml b/chapter06/expat.xml index df9f709c9..c44085739 100644 --- a/chapter06/expat.xml +++ b/chapter06/expat.xml @@ -69,6 +69,62 @@ + + Installation of Expat - 32-bit + + Clean previous build but keep precompiled doc because it + cannot be rebuilt in this stage of the system: + +sed -e "/^am__append_1/ s/doc//" -i Makefile +make clean + + Prepare Expat for compilation: + +CC="gcc -m32" ./configure \ + --prefix=/usr \ + --libdir=/usr/lib32 \ + --host=i686-pc-linux-gnu + + Compile the package: + +make + + Install the package: + +make DESTDIR=$PWD/DESTDIR install +cp -Rv DESTDIR/usr/lib32/* /usr/lib32 +rm -rf DESTDIR + + + + + Installation of Zlib - x32-bit + + Clean previous build: + +sed -e "/^am__append_1/ s/doc//" -i Makefile +make clean + + Prepare Expat for compilation: + + +CC="gcc -mx32" ./configure \ + --prefix=/usr \ + --libdir=/usr/libx32 \ + --host=x86_64-pc-linux-gnux32 + + Compile the package: + +make + + Install the package: + +make DESTDIR=$PWD/DESTDIR install +cp -Rv DESTDIR/usr/libx32/* /usr/libx32 +rm -rf DESTDIR + + + Contents of Expat diff --git a/chapter06/file.xml b/chapter06/file.xml index b5e28f244..1cd665b04 100644 --- a/chapter06/file.xml +++ b/chapter06/file.xml @@ -59,6 +59,58 @@ + + Installation of File - 32-bit + + Clean previous build: + +make distclean + + Prepare File for compilation: + +CC="gcc -m32" ./configure \ + --prefix=/usr \ + --libdir=/usr/lib32 \ + --host=i686-pc-linux-gnu + + Compile the package: + +make + + Install the package: + +make DESTDIR=$PWD/DESTDIR install +cp -Rv DESTDIR/usr/lib32/* /usr/lib32 +rm -rf DESTDIR + + + + + Installation of File - x32-bit + + Clean previous build: + +make distclean + + Prepare File for compilation: + + +CC="gcc -mx32" ./configure \ + --prefix=/usr \ + --libdir=/usr/libx32 \ + --host=x86_64-pc-linux-gnux32 + + Compile the package: + +make + + Install the package: + +make DESTDIR=$PWD/DESTDIR install +cp -Rv DESTDIR/usr/libx32/* /usr/libx32 +rm -rf DESTDIR + + Contents of File diff --git a/chapter06/gcc.xml b/chapter06/gcc.xml index d1aba35db..96fbb1e53 100644 --- a/chapter06/gcc.xml +++ b/chapter06/gcc.xml @@ -41,21 +41,41 @@ Installation of GCC - If building on x86_64, change the default directory name for 64-bit - libraries to lib: + If building on x86_64, change the default directory + name for 64-bit libraries to lib: -case $(uname -m) in +case $(uname -m) in x86_64) sed -e '/m64=/s/lib64/lib/' \ -i.orig gcc/config/i386/t-linux64 ;; esac + Change the default directory name for 64-bit + libraries to lib: + +sed -e '/m64=/s/lib64/lib/' \ + -i.orig gcc/config/i386/t-linux64 +cat > gcc/config/i386/t-linux64 <<"EOF" +comma=, +MULTILIB_OPTIONS = $(subst $(comma),/,$(TM_MULTILIB_CONFIG)) +MULTILIB_DIRNAMES = $(patsubst m%, %, $(subst /, ,$(MULTILIB_OPTIONS))) +MULTILIB_OSDIRNAMES = m64=../lib$(call if_multiarch,:x86_64-linux-gnu) +MULTILIB_OSDIRNAMES+= m32=../lib32$(call if_multiarch,:i386-linux-gnu) +MULTILIB_OSDIRNAMES+= mx32=../libx32$(call if_multiarch,:x86_64-linux-gnux32) +EOF + Remove the symlink created earlier as the final gcc includes will be installed here: rm -f /usr/lib/gcc + + Fix an issue with isl-&isl-version;: + +sed -e "/#include <isl\/schedule_node.h>/ a#include <isl/id.h>\n#include <isl/space.h>" \ + -i gcc/graphite.h + The GCC documentation recommends building GCC in a dedicated build directory: mkdir -v build @@ -63,7 +83,7 @@ cd build Prepare GCC for compilation: -SED=sed \ +SED=sed \ ../configure --prefix=/usr \ --enable-languages=c,c++ \ --disable-multilib \ @@ -71,6 +91,14 @@ cd build --disable-libmpx \ --with-system-zlib +SED=sed \ +../configure --prefix=/usr \ + --enable-languages=c,c++ \ + --enable-multilib \ + --with-multilib-list=m32,m64,mx32 \ + --disable-bootstrap \ + --with-system-zlib + Note that for other languages, there are some prerequisites that are not yet available. See the BLFS Book @@ -265,10 +293,10 @@ SEARCH_DIR("/usr/local/lib") SEARCH_DIR("/lib") SEARCH_DIR("/usr/lib"); - A 32-bit system may see a few different directories. For example, here - is the output from an i686 machine: + A 32-bit system may see a few different directories. + For example, here is the output from an i686 machine: -SEARCH_DIR("/usr/i686-pc-linux-gnu/lib32") +SEARCH_DIR("/usr/i686-pc-linux-gnu/lib32") SEARCH_DIR("/usr/local/lib32") SEARCH_DIR("/lib32") SEARCH_DIR("/usr/lib32") @@ -324,7 +352,7 @@ SEARCH_DIR("/usr/lib"); Finally, move a misplaced file: mkdir -pv /usr/share/gdb/auto-load/usr/lib -mv -v /usr/lib/*gdb.py /usr/share/gdb/auto-load/usr/lib +mv -v /usr/lib/libstdc++*gdb.py /usr/share/gdb/auto-load/usr/lib diff --git a/chapter06/glibc-32.xml b/chapter06/glibc-32.xml new file mode 100644 index 000000000..fd5a8dddf --- /dev/null +++ b/chapter06/glibc-32.xml @@ -0,0 +1,158 @@ + + + %general-entities; +]> + + + + + + glibc-32 + &glibc-version; +
&glibc-url;
+
+ + Glibc-&glibc-version; - 32-bit + + + Glibc-32 + + + + Installation of Glibc - 32-bit + +patch -Np1 -i ../&glibc-fhs-patch; + + Remove a file that may be left over from a previous build attempt: + +mv /usr/include/limits.h{,.backup} + + The Glibc documentation recommends building Glibc + in a dedicated build directory: + +mkdir -v build +cd build + + Prepare Glibc for compilation: + +CC="gcc -m32 -ffile-prefix-map=/tools=/usr -isystem /usr/include" \ +CXX="g++ -m32 -ffile-prefix-map=/tools=/usr -isystem /usr/include" \ +../configure --prefix=/usr \ + --disable-werror \ + --enable-kernel=&min-kernel; \ + --enable-stack-protector=strong \ + --enable-multi-arch \ + --libdir=/usr/lib32 \ + --libexecdir=/usr/lib32 \ + --with-headers=/usr/include \ + libc_cv_slibdir=/usr/lib32 \ + i686-pc-linux-gnu + + Compile the package: + +make + + Install the package: + +sed '/test-installation/s@$(PERL)@echo not running@' -i ../Makefile +make install_root=$PWD/DESTDIR install +mv -v DESTDIR/usr/lib32/* /usr/lib32/ +install -vm644 DESTDIR/usr/include/gnu/{lib-names,stubs}-32.h \ + /usr/include/gnu/ +ln -svf ../usr/lib32/ld-linux.so.2 /lib/ld-linux.so.2 +ln -svf ../usr/lib32/ld-linux.so.2 /lib/ld-lsb.so.3 +ln -svf ../lib/locale /usr/lib32/locale + + Configure the linker cache configuration: + +echo "/usr/lib32" > /etc/ld.so.conf.d/lib32.conf +ldconfig + + Do cleanup: + +cd .. +rm -rf build + + + + + Glibc - x32-bit + + The Glibc documentation recommends building Glibc + in a dedicated build directory: + +mkdir -v build +cd build + + Prepare Glibc for compilation: + +CC="gcc -mx32 -ffile-prefix-map=/tools=/usr -isystem /usr/include" \ +CXX="g++ -mx32 -ffile-prefix-map=/tools=/usr -isystem /usr/include" \ +../configure --prefix=/usr \ + --disable-werror \ + --enable-kernel=&min-kernel; \ + --enable-stack-protector=strong \ + --enable-multi-arch \ + --libdir=/usr/libx32 \ + --with-headers=/usr/include \ + libc_cv_slibdir=/usr/libx32 \ + x86_64-pc-linux-gnux32 + + Compile the package: + +make + + Install the package: + +sed '/test-installation/s@$(PERL)@echo not running@' -i ../Makefile +make install_root=$PWD/DESTDIR install +mv -v DESTDIR/usr/libx32/* /usr/libx32/ +install -vm644 DESTDIR/usr/include/gnu/lib-names-x32.h /usr/include/gnu/ +[ -e DESTDIR/usr/include/gnu/stubs-x32.h ] \ + && install -vm644 DESTDIR/usr/include/gnu/stubs-x32.h /usr/include/gnu/ \ + || ln -v /usr/include/gnu/stubs-64.h /usr/include/gnu/stubs-x32.h +ln -svf ../usr/libx32/ld-linux-x32.so.2 /lib/ld-linux-x32.so.2 +ln -svf ../lib/locale /usr/libx32/locale + + + Configure the linker cache configuration: + +echo "/usr/libx32" > /etc/ld.so.conf.d/libx32.conf +ldconfig + + Do cleanup: + +cd .. +rm -rf build + + Restore the file we moved temporarily away: + +mv /usr/include/limits.h{.backup,} + + + +
+ diff --git a/chapter06/glibc.xml b/chapter06/glibc.xml index 04a7d6f5f..5a6106529 100644 --- a/chapter06/glibc.xml +++ b/chapter06/glibc.xml @@ -96,6 +96,7 @@ cd build --disable-werror \ --enable-kernel=&min-kernel; \ --enable-stack-protector=strong \ + --with-headers=/usr/include \ libc_cv_slibdir=/lib diff --git a/chapter06/gmp.xml b/chapter06/gmp.xml index d7e13e256..8c20188c9 100644 --- a/chapter06/gmp.xml +++ b/chapter06/gmp.xml @@ -120,6 +120,110 @@ make install-html
+ + + Installation of GMP - 32-bit + + Clean previous build: + +make distclean + + Generic libraries can be created by running + the following: + +cp -v configfsf.guess config.guess +cp -v configfsf.sub config.sub + + Prepare GMP for compilation: + +ABI="32" \ +CC="gcc -m32" \ +CXX="g++ -m32" \ +./configure \ + --prefix=/usr \ + --disable-static \ + --enable-cxx \ + --libdir=/usr/lib32 \ + --host=i686-pc-linux-gnu + + Compile the package: + +make + + + The test suite for GMP in this section is considered critical. + Do not skip it under any circumstances. + + + Test the results: + +make check 2>&1 | tee gmp-check-log + + Ensure that all 190 tests in the test suite passed. + Check the results by issuing the following command: + +awk '/# PASS:/{total+=$3} ; END{print total}' gmp-check-log + + Install the package: + +make DESTDIR=$PWD/DESTDIR install +cp -Rv DESTDIR/usr/lib32/* /usr/lib32 +rm -rf DESTDIR + + + + + + Installation of GMP - x32-bit + + Clean previous build: + +make distclean + + Generic libraries can be created by running + the following: + +cp -v configfsf.guess config.guess +cp -v configfsf.sub config.sub + + Prepare GMP for compilation: + +ABI="x32" \ +CC="gcc -mx32" \ +CXX="g++ -mx32" \ +./configure \ + --prefix=/usr \ + --disable-static \ + --enable-cxx \ + --libdir=/usr/libx32 \ + --host=x86_64-pc-linux-gnux32 + + Compile the package: + +make + + + The test suite for GMP in this section is considered critical. + Do not skip it under any circumstances. + + + Test the results: + +make check 2>&1 | tee gmp-check-log + + Ensure that all 190 tests in the test suite passed. + Check the results by issuing the following command: + +awk '/# PASS:/{total+=$3} ; END{print total}' gmp-check-log + + Install the package: + +make DESTDIR=$PWD/DESTDIR install +cp -Rv DESTDIR/usr/libx32/* /usr/libx32 +rm -rf DESTDIR + + + Contents of GMP diff --git a/chapter06/isl.xml b/chapter06/isl.xml new file mode 100644 index 000000000..8420101af --- /dev/null +++ b/chapter06/isl.xml @@ -0,0 +1,113 @@ + + + %general-entities; +]> + + + + + + isl + &isl-version; +
&isl-url;
+
+ + ISL-&isl-version; + + + ISL + + + + + + <para>ISL is a thread-safe C library for manipulating sets and relations + of integer points bounded by affine constraints.</para> + + <segmentedlist> + <segtitle>&buildtime;</segtitle> + <segtitle>&diskspace;</segtitle> + + <seglistitem> + <seg>&isl-ch6-sbu;</seg> + <seg>&isl-ch6-du;</seg> + </seglistitem> + </segmentedlist> + + </sect2> + + <sect2 role="installation"> + <title>Installation of ISL + + Prepare ISL for compilation: + +./configure --prefix=/usr \ + --disable-static \ + --docdir=/usr/share/doc/isl-&isl-version; + + + The meaning of the new configure options: + + + --docdir=/usr/share/doc/isl-&isl-version; + + This variable specifies the correct place for the + documentation. + + + + + + Compile the package: + +make + + Install the package and its documentation: + +make install +install -vd /usr/share/doc/isl-&isl-version; +install -m644 doc/{CodingStyle,manual.pdf,SubmittingPatches,user.pod} \ + /usr/share/doc/isl-&isl-version; + + Finally, move a misplaced file: + +mkdir -pv /usr/share/gdb/auto-load/usr/lib +mv -v /usr/lib/libisl*gdb.py /usr/share/gdb/auto-load/usr/lib + + + + + Contents of ISL + + + Installed Libraries + Installed directory + + + libisl.so + /usr/share/doc/isl-&isl-version; + + + + + Short Descriptions + + + + + libisl + + Contains integer set manipulation functions + + libisl + + + + + + + +
+ diff --git a/chapter06/kmod.xml b/chapter06/kmod.xml index 6cc3eb168..8c0b50ce5 100644 --- a/chapter06/kmod.xml +++ b/chapter06/kmod.xml @@ -97,6 +97,70 @@ ln -sfv kmod /bin/lsmod
+ + Installation of Kmod - 32-bit + + Clean previous build but keep man pages as they cannot be recreated + since xsltproc isn't installed yet: + +sed -e "s/^CLEANFILES =.*/CLEANFILES =/" -i man/Makefile +make clean + + Prepare Kmod for compilation: + +CC="gcc -m32" ./configure \ + --prefix=/usr \ + --bindir=/bin \ + --libdir=/usr/lib32 \ + --sysconfdir=/etc \ + --with-xz --with-zlib \ + --host=i686-pc-linux-gnu \ + --with-rootlibdir=/usr/lib32 + + Compile the package: + +make + + Install the package: + +make DESTDIR=$PWD/DESTDIR install +cp -Rv DESTDIR/usr/lib32/* /usr/lib32 +rm -rf DESTDIR + + + + + Installation of Kmod - x32-bit + + Clean previous build: + +sed -e "s/^CLEANFILES =.*/CLEANFILES =/" -i man/Makefile +make clean + + Prepare Kmod for compilation: + +CC="gcc -mx32" ./configure \ + --prefix=/usr \ + --bindir=/bin \ + --libdir=/usr/libx32 \ + --sysconfdir=/etc \ + --with-xz \ + --with-zlib \ + --host=x86_64-pc-linux-gnux32 \ + --with-rootlibdir=/usr/libx32 + + Compile the package: + +make + + Install the package: + +make DESTDIR=$PWD/DESTDIR install +cp -Rv DESTDIR/usr/libx32/* /usr/libx32 +rm -rf DESTDIR + + + Contents of Kmod diff --git a/chapter06/libcap.xml b/chapter06/libcap.xml index 7b6bcabdc..2d2bcd20e 100644 --- a/chapter06/libcap.xml +++ b/chapter06/libcap.xml @@ -92,6 +92,44 @@ ln -sfv ../../lib/$(readlink /usr/lib/libcap.so) /usr/lib/libcap.so< + + Installation of Libcap - 32-bit + + Clean previous build: + +make distclean + + Compile the package: + +make CC="gcc -m32 -march=i686" + + Install the package: + +make lib=lib32 prefix=$PWD/DESTDIR/usr -C libcap install +cp -Rv DESTDIR/usr/lib32/* /usr/lib32 +rm -rf DESTDIR + + + + + Installation of Libcap - x32-bit + + Clean previous build: + +make distclean + + Compile the package: + +make CC="gcc -mx32" + + Install the package: + +make lib=libx32 prefix=$PWD/DESTDIR/usr -C libcap install +cp -Rv DESTDIR/usr/libx32/* /usr/libx32 +rm -rf DESTDIR + + + Contents of Libcap diff --git a/chapter06/libelf.xml b/chapter06/libelf.xml index e7f1ee3cd..d5766d02a 100644 --- a/chapter06/libelf.xml +++ b/chapter06/libelf.xml @@ -63,6 +63,60 @@ install -vm644 config/libelf.pc /usr/lib/pkgconfig + + Installation of Libelf - 32-bit + + Clean previous build: + +make distclean + + Prepare Libelf for compilation: + +CC="gcc -m32" ./configure \ + --prefix=/usr \ + --libdir=/usr/lib32 \ + --host=i686-pc-linux-gnu + + Compile the package: + +make + + Install the package: + +make DESTDIR=$PWD/DESTDIR -C libelf install +install -vDm644 config/libelf.pc DESTDIR/usr/lib32/pkgconfig/libelf.pc +cp -Rv DESTDIR/usr/lib32/* /usr/lib32 +rm -rf DESTDIR + + + + + Installation of Libelf - x32-bit + + Clean previous build: + +make distclean + + Prepare Libelf for compilation: + +CC="gcc -mx32" ./configure \ + --prefix=/usr \ + --libdir=/usr/libx32 \ + --host=x86_64-pc-linux-gnux32 + + Compile the package: + +make + + Install the package: + +make DESTDIR=$PWD/DESTDIR -C libelf install +install -vDm644 config/libelf.pc DESTDIR/usr/libx32/pkgconfig/libelf.pc +cp -Rv DESTDIR/usr/libx32/* /usr/libx32 +rm -rf DESTDIR + + + Contents of Libelf diff --git a/chapter06/libffi.xml b/chapter06/libffi.xml index 360ddf521..c1d2f3aed 100644 --- a/chapter06/libffi.xml +++ b/chapter06/libffi.xml @@ -98,6 +98,74 @@ sed -e '/^includedir/ s/=.*$/=@includedir@/' \ + + + Installation of Libffi - 32-bit + + Clean previous build: + +make distclean + + Prepare Libffi for compilation: + +CC="gcc -m32" CXX="g++ -m32" \ +./configure \ + --prefix=/usr \ + --disable-static \ + --libdir=/usr/lib32 \ + --with-gcc-arch=i686 \ + --host=i686-pc-linux-gnu + + Compile the package: + +make + + To test the results, issue: + +make check + + Install the package: + +make DESTDIR=$PWD/DESTDIR install +cp -Rv DESTDIR/usr/lib32/* /usr/lib32 +rm -rf DESTDIR + + + + + + Installation of Libffi - x32-bit + + Clean previous build: + +make distclean + + Prepare Libffi for compilation: + +CC="gcc -mx32" CXX="g++ -mx32" \ +./configure \ + --prefix=/usr \ + --disable-static \ + --with-gcc-arch=x86_64 \ + --libdir=/usr/libx32 \ + --host=x86_64-unknown-linux-gnux32 + + Compile the package: + +make + + To test the results, issue: + +make check + + Install the package: + +make DESTDIR=$PWD/DESTDIR install +cp -Rv DESTDIR/usr/libx32/* /usr/libx32 +rm -rf DESTDIR + + + Contents of Libffi diff --git a/chapter06/libtool.xml b/chapter06/libtool.xml index 5de045f40..2795e3500 100644 --- a/chapter06/libtool.xml +++ b/chapter06/libtool.xml @@ -71,6 +71,60 @@ + + Installation of Libtool - 32-bit + + Clean previous build: + +make distclean + + Prepare Libtool for compilation: + +CC="gcc -m32" ./configure \ + --prefix=/usr \ + --libdir=/usr/lib32 \ + --host=i686-pc-linux-gnu + + Compile the package: + +make + + Install the package: + +make DESTDIR=$(pwd)/DESTDIR install +cp -Rv DESTDIR/usr/lib32/* /usr/lib32 +rm -rf DESTDIR + + + + + Installation of Libtool - x32-bit + + Clean previous build: + +make distclean + + Prepare Libtool for compilation: + + +CC="gcc -mx32" ./configure \ + --prefix=/usr \ + --libdir=/usr/libx32 \ + --host=x86_64-pc-linux-gnux32 + + Compile the package: + +make + + Install the package: + +make DESTDIR=$(pwd)/DESTDIR install +cp -Rv DESTDIR/usr/libx32/* /usr/libx32 +rm -rf DESTDIR + + + + Contents of Libtool diff --git a/chapter06/linux-firmware.xml b/chapter06/linux-firmware.xml new file mode 100644 index 000000000..ffe8d4c79 --- /dev/null +++ b/chapter06/linux-firmware.xml @@ -0,0 +1,50 @@ + + + %general-entities; +]> + + + + + + linux-firmware + &linux-firmware-version; +
&linux-firmware-url;
+
+ + Linux-Firmware-&linux-firmware-version; + + + Linux-Firmware + + + + + + <para>The Linux-Firmware package contains propietary kernel "blobs" + required for some specific hardware.</para> + + <segmentedlist> + <segtitle>&buildtime;</segtitle> + <segtitle>&diskspace;</segtitle> + + <seglistitem> + <seg>&linux-firmware-ch6-sbu;</seg> + <seg>&linux-firmware-ch6-du;</seg> + </seglistitem> + </segmentedlist> + + </sect2> + + <sect2 role="installation"> + <title>Installation of Linux-Firmware + + Install the Linux-Firmware package with the following commands: + +cp -Rv * /lib/firmware + + + +
diff --git a/chapter06/ncurses.xml b/chapter06/ncurses.xml index b37f1f69c..9d6daff82 100644 --- a/chapter06/ncurses.xml +++ b/chapter06/ncurses.xml @@ -47,13 +47,21 @@ Prepare Ncurses for compilation: -./configure --prefix=/usr \ +./configure --prefix=/usr \ --mandir=/usr/share/man \ --with-shared \ --without-debug \ --without-normal \ --enable-pc-files \ --enable-widec +./configure --prefix=/usr \ + --mandir=/usr/share/man \ + --with-shared \ + --without-debug \ + --without-normal \ + --enable-pc-files \ + --enable-widec \ + --with-pkg-config-libdir=/usr/lib/pkgconfig The meaning of the new configure options: @@ -88,6 +96,15 @@
+ + --with-pkg-config-libdir=/usr/lib/pkgconfig + + This switch forces .pc to be installed in /usr/lib/pkgconfig. If + not set, .pc files gets installed in /usr/lib32 even for 64bit binaries. + + + + Compile the package: @@ -139,7 +156,6 @@ ln -sfv libncurses.so /usr/lib/libcurses.so cp -v -R doc/* /usr/share/doc/ncurses-&ncurses-version; - The instructions above don't create non-wide-character Ncurses libraries since no package installed by compiling from sources would link against them at runtime. However, the only known binary-only @@ -148,7 +164,7 @@ cp -v -R doc/* /usr/share/doc/ncurses-&ncurses-version; application or to be compliant with LSB, build the package again with the following commands: -make distclean +make distclean ./configure --prefix=/usr \ --with-shared \ --without-normal \ @@ -157,10 +173,123 @@ cp -v -R doc/* /usr/share/doc/ncurses-&ncurses-version; --with-abi-version=5 make sources libs cp -av lib/lib*.so.5* /usr/lib + + + Installation of Ncurses - 32-bit + + Clean previous build: + +make distclean + + Prepare Ncurses for compilation: + +CC="gcc -m32" CXX="g++ -m32" \ + ./configure --prefix=/usr \ + --libdir=/usr/lib32 \ + --mandir=/usr/share/man \ + --with-shared \ + --without-debug \ + --without-normal \ + --enable-pc-files \ + --enable-widec \ + --host=i686-pc-linux-gnu \ + --with-pkg-config-libdir=/usr/lib32/pkgconfig + + Compile the package: + +make -j1 + + Install the package: + +make DESTDIR=$PWD/DESTDIR install +for lib in ncurses form panel menu ; do + rm -vf DESTDIR/usr/lib32/lib${lib}.so + echo "INPUT(-l${lib}w)" > DESTDIR/usr/lib32/lib${lib}.so + ln -svf ${lib}w.pc DESTDIR/usr/lib32/pkgconfig/$lib.pc +done +rm -vf DESTDIR/usr/lib32/libcursesw.so +echo "INPUT(-lncursesw)" > DESTDIR/usr/lib32/libcursesw.so +ln -sfv libncurses.so DESTDIR/usr/lib32/libcurses.so +cp -Rv DESTDIR/usr/lib32/* /usr/lib32 +rm -rf DESTDIR + + If desired, make the version 5 libraries in 32bit as well: + +make distclean +CC="gcc -m32" CXX="g++ -m32" \ + ./configure --prefix=/usr \ + --with-shared \ + --without-normal \ + --without-debug \ + --without-cxx-binding \ + --with-abi-version=5 \ + --host=i686-pc-linux-gnu +make -j1 sources libs +cp -av lib/lib*.so.5* /usr/lib32 + + + + + Installation of Ncurses - x32-bit + + Clean previous build: + +make distclean + + Prepare Ncurses for compilation: + +CC="gcc -mx32" CXX="g++ -mx32" \ + ./configure --prefix=/usr \ + --libdir=/usr/libx32 \ + --mandir=/usr/share/man \ + --with-shared \ + --without-debug \ + --without-normal \ + --enable-pc-files \ + --enable-widec \ + --host=x86_64-pc-linux-gnux32 \ + --with-pkg-config-libdir=/usr/libx32/pkgconfig + + Compile the package: + +make -j1 + + Install the package: + +make DESTDIR=$PWD/DESTDIR install +for lib in ncurses form panel menu ; do + rm -vf DESTDIR/usr/libx32/lib${lib}.so + echo "INPUT(-l${lib}w)" > DESTDIR/usr/libx32/lib${lib}.so + ln -svf ${lib}w.pc DESTDIR/usr/libx32/pkgconfig/$lib.pc +done +rm -vf DESTDIR/usr/libx32/libcursesw.so +echo "INPUT(-lncursesw)" > DESTDIR/usr/libx32/libcursesw.so +ln -sfv libncurses.so DESTDIR/usr/libx32/libcurses.so +cp -Rv DESTDIR/usr/libx32/* /usr/libx32 +rm -rf DESTDIR + + + + Contents of Ncurses diff --git a/chapter06/openssl.xml b/chapter06/openssl.xml index 34e4ade29..839270e9a 100644 --- a/chapter06/openssl.xml +++ b/chapter06/openssl.xml @@ -74,6 +74,70 @@ cp -vfr doc/* /usr/share/doc/openssl-&openssl-version; + + + Installation of OpenSSL - 32-bit + + Clean previous build: + +make distclean + + Prepare OpenSSL for compilation: + +MACHINE="i686" \ +CC="gcc -m32 -march=i686" \ +CXX="g++ -m32 -march=i686" \ + ./config \ + --prefix=/usr \ + --libdir=/usr/lib32 \ + --openssldir=/etc/ssl \ + --libdir=lib32 \ + shared \ + zlib-dynamic + + Compile the package: + +make + Install the package: + +make DESTDIR=$PWD/DESTDIR install +cp -Rv DESTDIR/usr/lib32/* /usr/lib32 +rm -rf DESTDIR + + + + + + Installation of OpenSSL - x32-bit + + Clean previous build: + +make distclean + + Prepare OpenSSL for compilation: + +MACHINE="x86_64" \ +CC="gcc -mx32" \ +CXX="g++ -mx32" \ + ./config \ + --prefix=/usr \ + --libdir=/usr/libx32 \ + --openssldir=/etc/ssl \ + --libdir=libx32 \ + shared \ + zlib-dynamic + + Compile the package: + +make + Install the package: + +make DESTDIR=$PWD/DESTDIR install +cp -Rv DESTDIR/usr/libx32/* /usr/libx32 +rm -rf DESTDIR + + + Contents of OpenSSL diff --git a/chapter06/readline.xml b/chapter06/readline.xml index 7f5b2191a..2a73c1b35 100644 --- a/chapter06/readline.xml +++ b/chapter06/readline.xml @@ -92,6 +92,60 @@ ln -sfv ../../lib/$(readlink /usr/lib/libhistory.so ) /usr/lib/libhistory.so + + Installation of Readline - 32-bit + + Clean previous build: + +make distclean + + Prepare Readline for compilation: + +CC="gcc -m32 -march=i686" ./configure \ + --prefix=/usr \ + --libdir=/usr/lib32 \ + --disable-static \ + --host=i686-pc-linux-gnu + + Compile the package: + +make + + Install the package: + +make DESTDIR=$PWD/DESTDIR install +cp -Rv DESTDIR/usr/lib32/* /usr/lib32 +rm -rf DESTDIR + + + + + Installation of Readline - x32-bit + + Clean previous build: + +make distclean + + Prepare Readline for compilation: + +CC="gcc -mx32" ./configure \ + --prefix=/usr \ + --libdir=/usr/libx32 \ + --disable-static \ + --host=x86_64-pc-linux-gnux32 + + Compile the package: + +make + + Install the package: + +make DESTDIR=$PWD/DESTDIR install +cp -Rv DESTDIR/usr/libx32/* /usr/libx32 +rm -rf DESTDIR + + + Contents of Readline diff --git a/chapter06/revisedchroot.xml b/chapter06/revisedchroot.xml index 10e68daea..6adf21c71 100644 --- a/chapter06/revisedchroot.xml +++ b/chapter06/revisedchroot.xml @@ -62,7 +62,9 @@ rm -f /usr/lib/libz.a files and generally unneeded on a linux system. None of these are necessary at this point. To remove them, run: -find /usr/lib /usr/libexec -name \*.la -delete +find /usr/lib /usr/libexec -name \*.la -delete + +find /usr/lib{,{,x}32} /usr/libexec -name \*.la -delete For more information about libtool archive files, see the BLFS section "About Libtool diff --git a/chapter06/strippingagain.xml b/chapter06/strippingagain.xml index eef553173..715d5dbd0 100644 --- a/chapter06/strippingagain.xml +++ b/chapter06/strippingagain.xml @@ -33,7 +33,7 @@ -save_lib="ld-&glibc-version;.so libc-&glibc-version;.so libpthread-&glibc-version;.so libthread_db-&libthread_db-version;.so" +save_lib="ld-&glibc-version;.so libc-&glibc-version;.so libpthread-&glibc-version;.so libthread_db-&libthread_db-version;.so" cd /lib @@ -54,6 +54,30 @@ for LIB in $save_usrlib; do objcopy --add-gnu-debuglink=$LIB.dbg $LIB done +unset LIB save_lib save_usrlib + +save_lib="ld-&glibc-version;.so libc-&glibc-version;.so libpthread-&glibc-version;.so libthread_db-&libthread_db-version;.so" + +cd /lib + +for LIB in $save_lib; do + objcopy --only-keep-debug $LIB $LIB.dbg + strip --strip-unneeded $LIB + objcopy --add-gnu-debuglink=$LIB.dbg $LIB +done + +save_usrlib="libquadmath.so.&libquadmath-version; libstdc++.so.&libstdcpp-version; + libitm.so.&libitm-version; libatomic.so.&libatomic-version;" + +for libdir in /usr/lib{,{,x}32}; do + cd $libdir + for LIB in $save_usrlib; do + objcopy --only-keep-debug $LIB $LIB.dbg + strip --strip-unneeded $LIB + objcopy --add-gnu-debuglink=$LIB.dbg $LIB + done +done + unset LIB save_lib save_usrlib Before performing the stripping, take special care to ensure that @@ -80,12 +104,21 @@ unset LIB save_lib save_usrlib Now the binaries and libraries can be safely stripped: -/tools/bin/find /usr/lib -type f -name \*.a \ +/tools/bin/find /usr/lib -type f -name \*.a \ -exec /tools/bin/strip --strip-debug {} ';' /tools/bin/find /lib /usr/lib -type f \( -name \*.so* -a ! -name \*dbg \) \ -exec /tools/bin/strip --strip-unneeded {} ';' +/tools/bin/find /{bin,sbin} /usr/{bin,sbin,libexec} -type f \ + -exec /tools/bin/strip --strip-all {} ';' + +/tools/bin/find /usr/lib{,{,x}32} -type f -name \*.a \ + -exec /tools/bin/strip --strip-debug {} ';' + +/tools/bin/find /lib /usr/lib{,{,x}32} -type f \( -name \*.so* -a ! -name \*dbg \) \ + -exec /tools/bin/strip --strip-unneeded {} ';' + /tools/bin/find /{bin,sbin} /usr/{bin,sbin,libexec} -type f \ -exec /tools/bin/strip --strip-all {} ';' diff --git a/chapter06/systemd.xml b/chapter06/systemd.xml index 0537c6fac..5f621676c 100644 --- a/chapter06/systemd.xml +++ b/chapter06/systemd.xml @@ -210,6 +210,149 @@ chmod 755 /lib/systemd/systemd-user-sessions + + + + Installation of systemd - 32-bit + + If still in the build directory, step out: +cd .. + + Clean previous build: + +rm -rf build + + Create a symlink to work around missing xsltproc: + +ln -sf /tools/bin/true /usr/bin/xsltproc + + Because we have not yet installed the final version of Util-Linux, + create links to the libraries in the approprite location: + +for file in /tools/lib32/lib{blkid,mount,uuid}*; do + ln -sf $file /usr/lib32/ +done + + Set up the man pages: + +tar -xf ../systemd-man-pages-&systemd-version;.tar.xz + + Prepare systemd for compilation: + + cd build +PKG_CONFIG_PATH="/usr/lib32/pkgconfig:/tools/lib32/pkgconfig" \ +CC="gcc -m32 -march=i686" \ +CXX="g++ -m32 -march=i686" \ +LANG=en_US.UTF-8 \ +meson --prefix=/usr \ + --sysconfdir=/etc \ + --localstatedir=/var \ + -Dblkid=true \ + -Dbuildtype=release \ + -Ddefault-dnssec=no \ + -Dfirstboot=false \ + -Dinstall-tests=false \ + -Dkill-path=/bin/kill \ + -Dkmod-path=/bin/kmod \ + -Dldconfig=false \ + -Dmount-path=/bin/mount \ + -Drootprefix= \ + -Drootlibdir=/usr/lib32 \ + -Dsplit-usr=true \ + -Dsulogin-path=/sbin/sulogin \ + -Dsysusers=false \ + -Dumount-path=/bin/umount \ + -Db_lto=false \ + .. + + Compile the package: + +LANG=en_US.UTF-8 ninja + + Install the package: + +LANG=en_US.UTF-8 DESTDIR=$PWD/DESTDIR ninja install +cp -Rv DESTDIR/usr/lib32/* /usr/lib32 +rm -rf DESTDIR +rm -f /usr/bin/xsltproc + + + + + + + Installation of systemd - x32-bit + + If still in the build directory, step out: +cd .. + + Clean previous build: + +rm -rf build + + Create a symlink to work around missing xsltproc: + +ln -sf /tools/bin/true /usr/bin/xsltproc + + Because we have not yet installed the final version of Util-Linux, + create links to the libraries in the approprite location: + +for file in /tools/libx32/lib{blkid,mount,uuid}*; do + ln -sf $file /usr/libx32/ +done + + Set up the man pages: + +tar -xf ../systemd-man-pages-&systemd-version;.tar.xz + + Fix an issue on x32: + +sed '/log_debug/s@PRI_TIMEX@PRIi64@' -i src/timesync/timesyncd-manager.c +sed '/long drift_freq;/s@long @int64_t @' -i src/timesync/timesyncd-manager.h + + Prepare systemd for compilation: + +cd build +PKG_CONFIG_PATH="/tools/libx32/pkgconfig:/usr/libx32/pkgconfig" \ +CC="gcc -mx32" \ +CXX="g++ -mx32" \ +CFLAGS+="-Wno-error=shift-overflow" \ +CXXFLAGS+="-Wno-error=shift-overflow" \ +LANG=en_US.UTF-8 \ +meson --prefix=/usr \ + --sysconfdir=/etc \ + --localstatedir=/var \ + -Dblkid=true \ + -Dbuildtype=release \ + -Ddefault-dnssec=no \ + -Dfirstboot=false \ + -Dinstall-tests=false \ + -Dkill-path=/bin/kill \ + -Dkmod-path=/bin/kmod \ + -Dldconfig=false \ + -Dmount-path=/bin/mount \ + -Drootprefix= \ + -Drootlibdir=/usr/libx32 \ + -Dsplit-usr=true \ + -Dsulogin-path=/sbin/sulogin \ + -Dsysusers=false \ + -Dumount-path=/bin/umount \ + -Db_lto=false \ + .. + + Compile the package: + +LANG=en_US.UTF-8 ninja + + Install the package: + +LANG=en_US.UTF-8 DESTDIR=$PWD/DESTDIR ninja install +cp -Rv DESTDIR/usr/libx32/* /usr/libx32 +rm -rf DESTDIR +rm -f /usr/bin/xsltproc + + + Contents of systemd diff --git a/chapter06/util-linux.xml b/chapter06/util-linux.xml index 58788f4cf..3cc6e8076 100644 --- a/chapter06/util-linux.xml +++ b/chapter06/util-linux.xml @@ -52,6 +52,7 @@ + Installation of Util-linux + + Installation of Util-linux - 32-bit + + Clean previous build: + +make distclean + + Prepare Util-linux for compilation: + +CC="gcc -m32" \ +./configure ADJTIME_PATH=/var/lib/hwclock/adjtime \ + --docdir=/usr/share/doc/util-linux-&util-linux-version; \ + --disable-chfn-chsh \ + --disable-login \ + --disable-nologin \ + --disable-su \ + --disable-setpriv \ + --disable-runuser \ + --disable-pylibmount \ + --disable-static \ + --without-python \ + --without-systemd \ + --libdir=/usr/lib32 \ + --host=i686-pc-linux-gnu \ + --without-systemdsystemunitdir \ + --enable-libmount-force-mountinfo + +CC="gcc -m32" \ +./configure ADJTIME_PATH=/var/lib/hwclock/adjtime \ + --docdir=/usr/share/doc/util-linux-&util-linux-version; \ + --disable-chfn-chsh \ + --disable-login \ + --disable-nologin \ + --disable-su \ + --disable-setpriv \ + --disable-runuser \ + --disable-pylibmount \ + --disable-static \ + --without-python \ + --libdir=/usr/lib32 \ + --host=i686-pc-linux-gnu \ + --enable-libmount-force-mountinfo + + Compile the package: + +make + + Install the package: + +make DESTDIR=$PWD/DESTDIR install +cp -Rv DESTDIR/usr/lib32/* /usr/lib32 +rm -rf DESTDIR + + + + + + Installation of Util-linux - x32-bit + + Clean previous build: + +make distclean + + Prepare Util-linux for compilation: + +CC="gcc -mx32" \ +./configure ADJTIME_PATH=/var/lib/hwclock/adjtime \ + --docdir=/usr/share/doc/util-linux-&util-linux-version; \ + --disable-chfn-chsh \ + --disable-login \ + --disable-nologin \ + --disable-su \ + --disable-setpriv \ + --disable-runuser \ + --disable-pylibmount \ + --disable-static \ + --without-python \ + --without-systemd \ + --without-systemdsystemunitdir \ + --libdir=/usr/libx32 \ + --host=x86_64-pc-linux-gnux32 \ + --enable-libmount-force-mountinfo + +CC="gcc -mx32" \ +./configure ADJTIME_PATH=/var/lib/hwclock/adjtime \ + --docdir=/usr/share/doc/util-linux-&util-linux-version; \ + --disable-chfn-chsh \ + --disable-login \ + --disable-nologin \ + --disable-su \ + --disable-setpriv \ + --disable-runuser \ + --disable-pylibmount \ + --disable-static \ + --without-python \ + --libdir=/usr/libx32 \ + --host=x86_64-pc-linux-gnux32 \ + --enable-libmount-force-mountinfo + + Compile the package: + +make + + Install the package: + +make DESTDIR=$PWD/DESTDIR install +cp -Rv DESTDIR/usr/libx32/* /usr/libx32 +rm -rf DESTDIR + + + Contents of Util-linux diff --git a/chapter06/xz.xml b/chapter06/xz.xml index 5a342b2ff..16280c904 100644 --- a/chapter06/xz.xml +++ b/chapter06/xz.xml @@ -68,6 +68,61 @@ ln -svf ../../lib/$(readlink /usr/lib/liblzma.so) /usr/lib/liblzma.so + + Installation of Xz - 32-bit + + Clean previous build: + +make distclean + + Prepare Xz for compilation: + +CC="gcc -m32" ./configure \ + --prefix=/usr \ + --disable-static \ + --libdir=/usr/lib32 \ + --host=i686-pc-linux-gnu + + Compile the package: + +make + + Install the package: + +make DESTDIR=$PWD/DESTDIR install +cp -Rv DESTDIR/usr/lib32/* /usr/lib32 +rm -rf DESTDIR + + + + + Installation of Xz - x32-bit + + Clean previous build: + +make distclean + + Prepare Xz for compilation: + + +CC="gcc -mx32" ./configure \ + --prefix=/usr \ + --disable-static \ + --libdir=/usr/libx32 \ + --host=x86_64-pc-linux-gnux32 + + Compile the package: + +make + + Install the package: + +make DESTDIR=$PWD/DESTDIR install +cp -Rv DESTDIR/usr/libx32/* /usr/libx32 +rm -rf DESTDIR + + + Contents of Xz diff --git a/chapter06/zlib.xml b/chapter06/zlib.xml index 2dcc49413..871c245c4 100644 --- a/chapter06/zlib.xml +++ b/chapter06/zlib.xml @@ -67,6 +67,55 @@ ln -sfv ../../lib/$(readlink /usr/lib/libz.so) /usr/lib/libz.so + + Installation of Zlib - 32-bit + + Clean previous build: + +make distclean + + Prepare Zlib for compilation: + + +CC="gcc -m32 -march=i686" \ +./configure --prefix=/usr \ + --libdir=/usr/lib32 + + Compile the package: + +make + + Install the package: + +make DESTDIR=$PWD/DESTDIR install +cp -Rv DESTDIR/usr/lib32/* /usr/lib32 +rm -rf DESTDIR + + + + + Installation of Zlib - x32-bit + +make distclean + + Prepare Zlib for compilation: + +CC="gcc -mx32" \ +./configure --prefix=/usr \ + --libdir=/usr/libx32 + + Compile the package: + +make + + Install the package: + +make DESTDIR=$PWD/DESTDIR install +cp -Rv DESTDIR/usr/libx32/* /usr/libx32 +rm -rf DESTDIR + + + Contents of Zlib diff --git a/chapter08/grub.xml b/chapter08/grub.xml index bb1125b05..904a7c1cf 100644 --- a/chapter08/grub.xml +++ b/chapter08/grub.xml @@ -139,7 +139,7 @@ xorriso -as cdrecord -v dev=/dev/cdrw blank=as_needed grub-img.isoGenerate /boot/grub/grub.cfg: - cat > /boot/grub/grub.cfg << "EOF" + cat > /boot/grub/grub.cfg << "EOF" # Begin /boot/grub/grub.cfg set default=0 set timeout=5 @@ -152,7 +152,7 @@ menuentry "GNU/Linux, Linux &linux-version;-lfs-&version;" { } EOF - cat > /boot/grub/grub.cfg << "EOF" + cat > /boot/grub/grub.cfg << "EOF" # Begin /boot/grub/grub.cfg set default=0 set timeout=5 @@ -165,6 +165,32 @@ menuentry "GNU/Linux, Linux &linux-version;-lfs-&versiond;" { } EOF + cat > /boot/grub/grub.cfg << "EOF" +# Begin /boot/grub/grub.cfg +set default=0 +set timeout=5 + +insmod ext2 +set root=(hd0,2) + +menuentry "GNU/Linux, Linux &linux-version;-lfs-&version;-multilib" { + linux /boot/vmlinuz-&linux-version;-lfs-&version;-multilib root=/dev/sda2 ro +} +EOF + + cat > /boot/grub/grub.cfg << "EOF" +# Begin /boot/grub/grub.cfg +set default=0 +set timeout=5 + +insmod ext2 +set root=(hd0,2) + +menuentry "GNU/Linux, Linux &linux-version;-lfs-&versiond;-multilib" { + linux /boot/vmlinuz-&linux-version;-lfs-&versiond;-multilib root=/dev/sda2 ro +} +EOF + From GRUB's perspective, the kernel files are relative to the partition used. If you diff --git a/chapter08/kernel.xml b/chapter08/kernel.xml index 89cc8dd76..3bb82bea3 100644 --- a/chapter08/kernel.xml +++ b/chapter08/kernel.xml @@ -235,9 +235,14 @@ Kernel hacking ---> the automatic setup of the boot process described in the next section. The following command assumes an x86 architecture: -cp -iv arch/x86/boot/bzImage /boot/vmlinuz-&linux-version;-lfs-&version; +cp -iv arch/x86/boot/bzImage /boot/vmlinuz-&linux-version;-lfs-&version; + +cp -iv arch/x86/boot/bzImage /boot/vmlinuz-&linux-version;-lfs-&version;-multilib + +cp -iv arch/x86/boot/bzImage /boot/vmlinuz-&linux-version;-lfs-&versiond; + +cp -iv arch/x86/boot/bzImage /boot/vmlinuz-&linux-version;-lfs-&versiond;-multilib -cp -iv arch/x86/boot/bzImage /boot/vmlinuz-&linux-version;-lfs-&versiond; System.map is a symbol file for the kernel. It maps the function entry points of every function in the kernel API, @@ -346,8 +351,10 @@ EOF config-&linux-version;, - vmlinuz-&linux-version;-lfs-&version;, - vmlinuz-&linux-version;-lfs-&versiond;, + vmlinuz-&linux-version;-lfs-&version;, + vmlinuz-&linux-version;-lfs-&versiond;, + vmlinuz-&linux-version;-lfs-&version;-multilib, + vmlinuz-&linux-version;-lfs-&versiond;-multilib, and System.map-&linux-version; /lib/modules, /usr/share/doc/linux-&linux-version; diff --git a/chapter09/theend.xml b/chapter09/theend.xml index 0df3de5a5..d365903fc 100644 --- a/chapter09/theend.xml +++ b/chapter09/theend.xml @@ -28,12 +28,20 @@ Create an /etc/os-release file required by systemd: -cat > /etc/os-release << "EOF" +cat > /etc/os-release << "EOF" NAME="Linux From Scratch" VERSION="&versiond;" ID=lfs PRETTY_NAME="Linux From Scratch &versiond;" VERSION_CODENAME="<your name here>" +EOF + +cat > /etc/os-release << "EOF" +NAME="Linux From Scratch" +VERSION="&versiond;" +ID=lfs +PRETTY_NAME="Linux From Scratch &versiond; Multlib" +VERSION_CODENAME="<your name here>" EOF It may be a good idea to create an @@ -42,7 +50,8 @@ EOF out which LFS version is installed on the system. Create this file by running: -echo &version; > /etc/lfs-release +echo &version; > /etc/lfs-release +echo &version;-multilib > /etc/lfs-release Creating the file /etc/lfs-release is recommended for compatibility with @@ -56,18 +65,32 @@ EOF new system with respect to the Linux Standards Base (LSB). To create this file, run: -cat > /etc/lsb-release << "EOF" +cat > /etc/lsb-release << "EOF" DISTRIB_ID="Linux From Scratch" DISTRIB_RELEASE="&version;" DISTRIB_CODENAME="<your name here>" DISTRIB_DESCRIPTION="Linux From Scratch" EOF -cat > /etc/lsb-release << "EOF" +cat > /etc/lsb-release << "EOF" DISTRIB_ID="Linux From Scratch" DISTRIB_RELEASE="&versiond;" DISTRIB_CODENAME="<your name here>" DISTRIB_DESCRIPTION="Linux From Scratch" +EOF + +cat > /etc/lsb-release << "EOF" +DISTRIB_ID="Linux From Scratch" +DISTRIB_RELEASE="&version;-multilib" +DISTRIB_CODENAME="<your name here>" +DISTRIB_DESCRIPTION="Linux From Scratch" +EOF + +cat > /etc/lsb-release << "EOF" +DISTRIB_ID="Linux From Scratch" +DISTRIB_RELEASE="&versiond;-multilib" +DISTRIB_CODENAME="<your name here>" +DISTRIB_DESCRIPTION="Linux From Scratch" EOF Be sure to put some sort of customization for the field diff --git a/packages.ent b/packages.ent index 27597dddb..e5957a14c 100644 --- a/packages.ent +++ b/packages.ent @@ -357,6 +357,14 @@ + + + + + + + + @@ -441,6 +449,14 @@ + + + + + + + + diff --git a/prologue/architecture.xml b/prologue/architecture.xml index a6a456c83..fdcfb02a1 100644 --- a/prologue/architecture.xml +++ b/prologue/architecture.xml @@ -40,13 +40,13 @@ builds on the same hardware. Modern 64-bit systems are considerably faster than older 64-bit systems and the LFS authors recommend building on a 64-bit system when given a choice. -The default 64-bit build that results from LFS is considered a "pure" -64-bit system. That is, it supports 64-bit executables only. Building a -"multi-lib" system requires compiling many applications twice, once for a -32-bit system and once for a 64-bit system. This is not directly supported in -LFS because it would interfere with the educational objective of providing the -instructions needed for a straightforward base Linux system. You can refer to -the Cross Linux From Scratch +The default 64-bit build that results from LFS is +considered a "pure" 64-bit system. That is, it supports 64-bit executables only. +Building a "multi-lib" system requires compiling many applications twice, once +for a 32-bit system and once for a 64-bit system. This is not directly supported +in LFS because it would interfere with the educational objective of providing +the instructions needed for a straightforward base Linux system. You can refer +to the Cross Linux From Scratch project for this advanced topic. +You are reading the +LFS-&version;-multilib book. Building a multilib system +requires compiling many applications three times: once for the primary +64-bit architecture; once for the minor 32-bit architecture; and once again for +the 32-bit architecture with 64-bit memory extensions. + +Multilib goes a bit beyond the basic educational approach +of LFS which is to teach you how to build a Linux system. If you haven't +previously built by the standard LFS book, you are encouraged to do so before +attempting this edition. + +Continue only if you meet the following requirements: + + you have a x86_64 compatible machine + you already have experience with LFS + you have a need for 32-bit support + + + diff --git a/prologue/bookinfo.xml b/prologue/bookinfo.xml index 1a9f2c9ab..dc6cd899a 100644 --- a/prologue/bookinfo.xml +++ b/prologue/bookinfo.xml @@ -7,8 +7,10 @@ Linux From Scratch - Version &version; - Version &versiond; + Version &version; + Version &versiond; + Version &version;-multilib + Version &versiond;-multilib @@ -29,6 +31,11 @@ Editor: DJ Lucas + + + Editor: Thomas + Trepl +