diff options
Diffstat (limited to 'chapter05')
-rw-r--r-- | chapter05/binutils-pass1.xml | 15 | ||||
-rw-r--r-- | chapter05/gcc-pass1.xml | 52 | ||||
-rw-r--r-- | chapter05/glibc.xml | 159 | ||||
-rw-r--r-- | chapter05/libstdc++.xml | 10 |
4 files changed, 227 insertions, 9 deletions
diff --git a/chapter05/binutils-pass1.xml b/chapter05/binutils-pass1.xml index e17c2fc92..5d9e21fd7 100644 --- a/chapter05/binutils-pass1.xml +++ b/chapter05/binutils-pass1.xml @@ -70,11 +70,17 @@ cd build</userinput></screen> <para>Now prepare Binutils for compilation:</para> - <screen><userinput remap="configure">../configure --prefix=$LFS/tools \ + <screen arch="default"><userinput remap="configure">../configure --prefix=$LFS/tools \ --with-sysroot=$LFS \ --target=$LFS_TGT \ --disable-nls \ --disable-werror</userinput></screen> +<screen arch="ml_32,ml_x32,ml_all"><userinput remap="configure">../configure --prefix=$LFS/tools \ + --with-sysroot=$LFS \ + --target=$LFS_TGT \ + --disable-nls \ + --disable-werror \ + --enable-multilib</userinput></screen> <variablelist> <title>The meaning of the configure options:</title> @@ -123,6 +129,13 @@ cd build</userinput></screen> </listitem> </varlistentry> + <varlistentry arch="ml_32,ml_x32,ml_all"> + <term><parameter>--enable-multilib</parameter></term> + <listitem> + <para>Enables multilib support.</para> + </listitem> + </varlistentry> + </variablelist> <para>Continue with compiling the package:</para> diff --git a/chapter05/gcc-pass1.xml b/chapter05/gcc-pass1.xml index 0cd852ee6..f686e6ea5 100644 --- a/chapter05/gcc-pass1.xml +++ b/chapter05/gcc-pass1.xml @@ -60,18 +60,28 @@ 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</userinput></screen> +mv -v mpc-&mpc-version; mpc</userinput> +<userinput remap="pre" arch="ml_32,ml_x32,ml_all">tar -xf ../isl-&isl-version;.tar.xz +mv -v isl-&isl-version; isl</userinput></screen> - <para>On x86_64 hosts, set the default directory name for + <para arch="default">On x86_64 hosts, set the default directory name for 64-bit libraries to <quote>lib</quote>:</para> -<screen><userinput remap="pre">case $(uname -m) in +<screen arch="default"><userinput remap="pre">case $(uname -m) in x86_64) sed -e '/m64=/s/lib64/lib/' \ -i.orig gcc/config/i386/t-linux64 ;; esac</userinput></screen> + <para arch="ml_32,ml_x32,ml_all">Change the default directory name for + libraries:</para> + +<screen arch="ml_32,ml_x32,ml_all"><userinput remap="pre">sed -e '/m64=/s/lib64/lib/' \ + -e '/m32=/s/m32=.*/m32=..\/lib32$(call if_multiarch,:i386-linux-gnu)/' \ + -i.orig gcc/config/i386/t-linux64 +</userinput></screen> + <para>The GCC documentation recommends building GCC in a dedicated build directory:</para> @@ -80,7 +90,7 @@ cd build</userinput></screen> <para>Prepare GCC for compilation:</para> -<screen><userinput remap="configure">../configure \ +<screen arch="default"><userinput remap="configure">../configure \ --target=$LFS_TGT \ --prefix=$LFS/tools \ --with-glibc-version=2.11 \ @@ -100,6 +110,31 @@ cd build</userinput></screen> --disable-libvtv \ --disable-libstdcxx \ --enable-languages=c,c++</userinput></screen> +<screen arch="ml_32,ml_x32,ml_all"><userinput remap="configure" + arch="ml_32">mlist=m64,m32</userinput><userinput remap="configure" + arch="ml_x32">mlist=m64,mx32</userinput><userinput remap="configure" + arch="ml_all">mlist=m64,m32,mx32</userinput> +<userinput remap="configure">../configure \ + --target=$LFS_TGT \ + --prefix=$LFS/tools \ + --with-glibc-version=2.11 \ + --with-sysroot=$LFS \ + --with-newlib \ + --without-headers \ + --enable-initfini-array \ + --disable-nls \ + --disable-shared \ + --enable-multilib --with-multilib-list=$mlist \ + --disable-decimal-float \ + --disable-threads \ + --disable-libatomic \ + --disable-libgomp \ + --disable-libquadmath \ + --disable-libssp \ + --disable-libvtv \ + --disable-libstdcxx \ + --enable-languages=c,c++</userinput></screen> + <variablelist> <title>The meaning of the configure options:</title> @@ -149,13 +184,20 @@ cd build</userinput></screen> </listitem> </varlistentry> - <varlistentry> + <varlistentry arch="default"> <term><parameter>--disable-multilib</parameter></term> <listitem> <para>On x86_64, LFS does not support a multilib configuration. This switch is harmless for x86.</para> </listitem> </varlistentry> + <varlistentry arch="ml_32,ml_x32,ml_all"> + <term><parameter>--enable-multilib --with-multilib-list=...</parameter></term> + <listitem> + <para>LFS canbe used to support multilib. Which they are is + specified in the multilib list.</para> + </listitem> + </varlistentry> <varlistentry> <term><parameter>--disable-decimal-float, --disable-threads, diff --git a/chapter05/glibc.xml b/chapter05/glibc.xml index 37a222bd1..07cda22df 100644 --- a/chapter05/glibc.xml +++ b/chapter05/glibc.xml @@ -47,13 +47,16 @@ for x86_64, create a compatibility symbolic link required for proper operation of the dynamic library loader:</para> -<screen><userinput remap="pre">case $(uname -m) in +<screen arch="default"><userinput remap="pre">case $(uname -m) in i?86) ln -sfv ld-linux.so.2 $LFS/lib/ld-lsb.so.3 ;; x86_64) 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 ;; esac</userinput></screen> +<!-- no ld-linux.so.2 here as multilib is based on x86_64, not on i686 --> +<screen arch="ml_32,ml_x32,ml_all"><userinput remap="pre">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</userinput></screen> <para>Some of the Glibc programs use the non-FHS compliant <filename class="directory">/var/db</filename> directory to store their @@ -76,13 +79,21 @@ cd build</userinput></screen> <para>Next, prepare Glibc for compilation:</para> -<screen><userinput remap="configure">../configure \ +<screen arch="default"><userinput remap="configure">../configure \ --prefix=/usr \ --host=$LFS_TGT \ --build=$(../scripts/config.guess) \ --enable-kernel=&min-kernel; \ --with-headers=$LFS/usr/include \ libc_cv_slibdir=/usr/lib</userinput></screen> +<screen arch="ml_32,ml_x32,ml_all"><userinput remap="configure">../configure \ + --prefix=/usr \ + --host=$LFS_TGT \ + --build=$(../scripts/config.guess) \ + --enable-kernel=&min-kernel; \ + --with-headers=$LFS/usr/include \ + --enable-multi-arch \ + libc_cv_slibdir=/usr/lib</userinput></screen> <variablelist> <title>The meaning of the configure options:</title> @@ -195,7 +206,7 @@ readelf -l a.out | grep '/ld-linux'</userinput></screen> <screen><computeroutput>[Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]</computeroutput></screen> - <para>Note that for 32-bit machines, the interpreter name will be + <para arch="default">Note that for 32-bit machines, the interpreter name will be <filename>/lib/ld-linux.so.2</filename>.</para> <para>If the output is not shown as above or there was no output at all, @@ -223,6 +234,148 @@ readelf -l a.out | grep '/ld-linux'</userinput></screen> </sect2> + <!-- - - - - - - - - - --> + <!-- Multilib - 32bit --> + <!-- - - - - - - - - - --> + <sect2 arch="ml_32,ml_all"> + <title>Building Glibc - 32bit</title> + + <para>Now recompile for m32. The extracted source can be + reused but needs to be cleaned before installing the m32 + version of Glibc.</para> + + <para>Clear the build directory and remove artefacts from + previous build:</para> + +<screen><userinput remap="pre">make clean +find .. -name "*.a" -delete</userinput></screen> + + <para>Configure Glibc for m32 with the following commands:</para> + +<screen><userinput remap="configure">CC="$LFS_TGT-gcc -m32" \ +CXX="$LFS_TGT-g++ -m32" \ +../configure \ + --prefix=/usr \ + --host=$LFS_TGT32 \ + --build=$(../scripts/config.guess) \ + --enable-kernel=&min-kernel; \ + --with-headers=$LFS/usr/include \ + --enable-multi-arch \ + --libdir=/usr/lib32 \ + --libexecdir=/usr/lib32 \ + libc_cv_slibdir=/usr/lib32</userinput></screen> + + <para>Compile the package:</para> + +<screen><userinput remap="make">make</userinput></screen> + + <para>Install the package:</para> + +<screen><userinput remap="install">make DESTDIR=$PWD/DESTDIR install +cp -a DESTDIR/usr/lib32 $LFS/usr/ +install -vm644 DESTDIR/usr/include/gnu/{lib-names,stubs}-32.h \ + $LFS/usr/include/gnu/ +ln -svf ../lib32/ld-linux.so.2 $LFS/lib/ld-linux.so.2</userinput></screen> + + + <caution> + <para>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:</para> + +<screen><userinput>echo 'int main(){}' > dummy.c +$LFS_TGT-gcc -m32 dummy.c +readelf -l a.out | grep '/ld-linux'</userinput></screen> + + <para>If everything is working correctly, there should be no errors, + and the output of the last command will be of the form:</para> + +<screen><computeroutput>[Requesting program interpreter: /lib/ld-linux.so.2]</computeroutput></screen> + + <para>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.</para> + + <para>Once all is well, clean up the test files:</para> + +<screen><userinput>rm -v dummy.c a.out</userinput></screen> + + </caution> + + </sect2><!-- m32 --> + + <!-- - - - - - - - - - --> + <!-- Multilib - x32bit --> + <!-- - - - - - - - - - --> + + <sect2 arch="ml_x32,ml_all"> + <title>Building Glibc - x32bit</title> + + <para>Now recompile for mx32. The extracted source can be + reused but needs to be cleaned before installing the mx32 + version of Glibc.</para> + + <para>Clear the build directory and remove artefacts from + previous build:</para> + +<screen><userinput remap="pre">make clean +find .. -name "*.a" -delete</userinput></screen> + + <para>Configure Glibc for mx32 with the following commands:</para> + +<screen><userinput remap="configure">CC="$LFS_TGT-gcc -mx32" \ +CXX="$LFS_TGT-g++ -mx32" \ +../configure \ + --prefix=/usr \ + --host=$LFS_TGTX32 \ + --build=$(../scripts/config.guess) \ + --enable-kernel=&min-kernel; \ + --with-headers=$LFS/usr/include \ + --enable-multi-arch \ + --libdir=/usr/libx32 \ + --libexecdir=/usr/libx32 \ + libc_cv_slibdir=/usr/libx32</userinput></screen> + + <para>Compile the package:</para> + +<screen><userinput remap="make">make</userinput></screen> + + <para>Install the package:</para> + +<screen><userinput remap="install">make DESTDIR=$PWD/DESTDIR install +cp -a DESTDIR/usr/libx32 $LFS/usr/ +install -vm644 DESTDIR/usr/include/gnu/{lib-names,stubs}-x32.h \ + $LFS/usr/include/gnu/ +ln -svf ../libx32/ld-linux-x32.so.2 $LFS/lib/ld-linux-x32.so.2</userinput></screen> + + <caution> + <para>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:</para> + +<screen><userinput>echo 'int main(){}' > dummy.c +$LFS_TGT-gcc -mx32 dummy.c +readelf -l a.out | grep '/ld-linux-x32'</userinput></screen> + + <para>If everything is working correctly, there should be no errors, + and the output of the last command will be of the form:</para> + +<screen><computeroutput>[Requesting program interpreter: /libx32/ld-linux-x32.so.2]</computeroutput></screen> + + <para>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.</para> + + <para>Once all is well, clean up the test files:</para> + +<screen><userinput>rm -v dummy.c a.out</userinput></screen> + + </caution> + + </sect2><!-- mx32 --> + <sect2 role="content"> <title/> diff --git a/chapter05/libstdc++.xml b/chapter05/libstdc++.xml index 68da1f7c2..9820a3d02 100644 --- a/chapter05/libstdc++.xml +++ b/chapter05/libstdc++.xml @@ -81,6 +81,16 @@ cd build</userinput></screen> </listitem> </varlistentry> + <varlistentry arch="ml_32,ml_x32,ml_all"> + <term><parameter>--disable-multilib</parameter></term> + <listitem> + <para>Even when building the multilib version, this switch is + given. This is because the additionally built libraries are + not required in this stage and some disk space and compile + time can be saved.</para> + </listitem> + </varlistentry> + <varlistentry> <term><parameter>--disable-libstdcxx-pch</parameter></term> <listitem> |