Automatic merge of trunk into multilib

This commit is contained in:
Thomas Trepl (Moody) 2022-10-31 00:30:10 +01:00
commit 1a76da03d8
5 changed files with 61 additions and 44 deletions

View File

@ -91,7 +91,7 @@ cd build</userinput></screen>
<term><parameter>--prefix=$LFS/tools</parameter></term> <term><parameter>--prefix=$LFS/tools</parameter></term>
<listitem> <listitem>
<para>This tells the configure script to prepare to install the <para>This tells the configure script to prepare to install the
binutils programs in the <filename Binutils programs in the <filename
class="directory">$LFS/tools</filename> directory.</para> class="directory">$LFS/tools</filename> directory.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>

View File

@ -50,9 +50,9 @@
use them:</para> use them:</para>
<note><para>There are frequent misunderstandings about this chapter. The <note><para>There are frequent misunderstandings about this chapter. The
procedures are the same as every other chapter as explained earlier (<xref procedures are the same as every other chapter, as explained earlier (<xref
linkend='buildinstr'/>). First extract the gcc tarball from the sources linkend='buildinstr'/>). First, extract the gcc-&gcc-version; tarball from the sources
directory and then change to the directory created. Only then should you directory, and then change to the directory created. Only then should you
proceed with the instructions below.</para></note> proceed with the instructions below.</para></note>
<screen><userinput remap="pre">tar -xf ../mpfr-&mpfr-version;.tar.xz <screen><userinput remap="pre">tar -xf ../mpfr-&mpfr-version;.tar.xz
@ -142,9 +142,9 @@ cd build</userinput></screen>
<varlistentry> <varlistentry>
<term><parameter>--with-glibc-version=&glibc-version;</parameter></term> <term><parameter>--with-glibc-version=&glibc-version;</parameter></term>
<listitem> <listitem>
<para>This option specifies the version of glibc which will be <para>This option specifies the version of Glibc which will be
used on the target. It is not relevant to the libc of the host used on the target. It is not relevant to the libc of the host
distro because everything compiled by pass1 gcc will run in the distro because everything compiled by pass1 GCC will run in the
chroot environment, which is isolated from libc of the host chroot environment, which is isolated from libc of the host
distro.</para> distro.</para>
</listitem> </listitem>
@ -187,7 +187,7 @@ cd build</userinput></screen>
<term><parameter>--disable-shared</parameter></term> <term><parameter>--disable-shared</parameter></term>
<listitem> <listitem>
<para>This switch forces GCC to link its internal libraries <para>This switch forces GCC to link its internal libraries
statically. We need this because the shared libraries require glibc, statically. We need this because the shared libraries require Glibc,
which is not yet installed on the target system.</para> which is not yet installed on the target system.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
@ -246,7 +246,7 @@ cd build</userinput></screen>
time of this build of GCC <filename>$LFS/usr/include/limits.h</filename> time of this build of GCC <filename>$LFS/usr/include/limits.h</filename>
does not exist, so the internal header that has just been installed is a does not exist, so the internal header that has just been installed is a
partial, self-contained file and does not include the extended features of partial, self-contained file and does not include the extended features of
the system header. This is adequate for building glibc, but the full the system header. This is adequate for building Glibc, but the full
internal header will be needed later. Create a full version of the internal internal header will be needed later. Create a full version of the internal
header using a command that is identical to what the GCC build system does header using a command that is identical to what the GCC build system does
in normal circumstances:</para> in normal circumstances:</para>

View File

@ -61,13 +61,13 @@ ln -sfv ../lib/ld-linux-x86-64.so.2 $LFS/lib64/ld-lsb-x86-64.so.3</userinput></s
<note> <note>
<para> <para>
The above command is correct. The <command>ln</command> command has The above command is correct. The <command>ln</command> command has
a few syntactic versions, so be sure to check several syntactic versions, so be sure to check
<command>info coreutils ln</command> and <filename>ln(1)</filename> <command>info coreutils ln</command> and <filename>ln(1)</filename>
before reporting what you may think is an error. before reporting what may appear to be an error.
</para> </para>
</note> </note>
<para>Some of the Glibc programs use the non-FHS compliant <para>Some of the Glibc programs use the non-FHS-compliant
<filename class="directory">/var/db</filename> directory to store their <filename class="directory">/var/db</filename> directory to store their
runtime data. Apply the following patch to make such programs store their runtime data. Apply the following patch to make such programs store their
runtime data in the FHS-compliant locations:</para> runtime data in the FHS-compliant locations:</para>
@ -139,7 +139,7 @@ cd build</userinput></screen>
<term><parameter>libc_cv_slibdir=/usr/lib</parameter></term> <term><parameter>libc_cv_slibdir=/usr/lib</parameter></term>
<listitem> <listitem>
<para>This ensures that the library is installed in /usr/lib instead <para>This ensures that the library is installed in /usr/lib instead
of the default /lib64 on 64 bit machines.</para> of the default /lib64 on 64-bit machines.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
@ -157,11 +157,11 @@ cd build</userinput></screen>
<para>The missing or incompatible <command>msgfmt</command> program is <para>The missing or incompatible <command>msgfmt</command> program is
generally harmless. This <command>msgfmt</command> program is part of the generally harmless. This <command>msgfmt</command> program is part of the
Gettext package which the host distribution should provide.</para> Gettext package, which the host distribution should provide.</para>
<note><para>There have been reports that this package may fail when <note><para>There have been reports that this package may fail when
building as a "parallel make". If this occurs, rerun the make command building as a "parallel make". If that occurs, rerun the make command
with a "-j1" option.</para></note> with the "-j1" option.</para></note>
<para>Compile the package:</para> <para>Compile the package:</para>
@ -172,9 +172,9 @@ cd build</userinput></screen>
<warning><para>If <envar>LFS</envar> is not properly set, and despite the <warning><para>If <envar>LFS</envar> is not properly set, and despite the
recommendations, you are building as recommendations, you are building as
<systemitem class="username">root</systemitem>, the next command will <systemitem class="username">root</systemitem>, the next command will
install the newly built glibc to your host system, which most likely install the newly built Glibc to your host system, which will almost
will render it unusable. So double check that the environment is certainly render it unusable. So double-check that the environment is
correctly set, before running the following command.</para></warning> correctly set, and that you are not &root;, before running the following command.</para></warning>
<screen><userinput remap="install">make DESTDIR=$LFS install</userinput></screen> <screen><userinput remap="install">make DESTDIR=$LFS install</userinput></screen>
@ -188,15 +188,15 @@ cd build</userinput></screen>
packages to define the location where the package should be packages to define the location where the package should be
installed. If it is not set, it defaults to the root (<filename installed. If it is not set, it defaults to the root (<filename
class="directory">/</filename>) directory. Here we specify that class="directory">/</filename>) directory. Here we specify that
the package be installed in <filename class="directory">$LFS the package is installed in <filename class="directory">$LFS
</filename>, which will become the root after <xref linkend= </filename>, which will become the root directory in <xref linkend=
"ch-tools-chroot"/>.</para> "ch-tools-chroot"/>.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
</variablelist> </variablelist>
<para>Fix hardcoded path to the executable loader in <para>Fix a hard coded path to the executable loader in the
<command>ldd</command> script:</para> <command>ldd</command> script:</para>
<screen><userinput remap="install">sed '/RTLDLIST=/s@/usr@@g' -i $LFS/usr/bin/ldd</userinput></screen> <screen><userinput remap="install">sed '/RTLDLIST=/s@/usr@@g' -i $LFS/usr/bin/ldd</userinput></screen>
@ -217,10 +217,10 @@ readelf -l a.out | grep ld-linux</userinput></screen>
<para arch="default">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> <filename>/lib/ld-linux.so.2</filename>.</para>
<para>If the output is not shown as above or there was no output at all, <para>If the output is not as shown above, or there is no output at all,
then something is wrong. Investigate and retrace the steps to find out 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 where the problem is and correct it. This issue must be resolved before
continuing on.</para> continuing.</para>
<para>Once all is well, clean up the test file:</para> <para>Once all is well, clean up the test file:</para>
@ -228,14 +228,14 @@ readelf -l a.out | grep ld-linux</userinput></screen>
</caution> </caution>
<note><para>Building packages in the next chapter will serve as an <note><para>Building the packages in the next chapter will serve as an
additional check that the toolchain has been built properly. If some additional check that the toolchain has been built properly. If some
package, especially binutils-pass2 or gcc-pass2, fails to build, it is package, especially Binutils-pass2 or GCC-pass2, fails to build, it is
an indication that something has gone wrong with the an indication that something has gone wrong with the
previous Binutils, GCC, or Glibc installations.</para></note> preceding Binutils, GCC, or Glibc installations.</para></note>
<para>Now that our cross-toolchain is complete, finalize the installation <para>Now that our cross-toolchain is complete, finalize the installation
of the limits.h header. For doing so, run a utility provided by the GCC of the limits.h header. To do this, run a utility provided by the GCC
developers:</para> developers:</para>
<screen><userinput>$LFS/tools/libexec/gcc/$LFS_TGT/&gcc-version;/install-tools/mkheaders</userinput></screen> <screen><userinput>$LFS/tools/libexec/gcc/$LFS_TGT/&gcc-version;/install-tools/mkheaders</userinput></screen>

View File

@ -28,7 +28,7 @@
to compile C++ code to compile C++ code
(part of GCC is written in C++), but we had to defer its installation (part of GCC is written in C++), but we had to defer its installation
when we built <xref linkend="ch-tools-gcc-pass1"/> when we built <xref linkend="ch-tools-gcc-pass1"/>
because it depends on glibc, which was not yet available in the target because Libstdc++ depends on Glibc, which was not yet available in the target
directory. directory.
</para> </para>
@ -53,12 +53,12 @@
<filename>gcc-&gcc-version;</filename> directory.</para> <filename>gcc-&gcc-version;</filename> directory.</para>
</note> </note>
<para>Create a separate build directory for libstdc++ and enter it:</para> <para>Create a separate build directory for Libstdc++ and enter it:</para>
<screen><userinput remap="pre">mkdir -v build <screen><userinput remap="pre">mkdir -v build
cd build</userinput></screen> cd build</userinput></screen>
<para>Prepare libstdc++ for compilation:</para> <para>Prepare Libstdc++ for compilation:</para>
<screen arch="ml_32,ml_x32,ml_all"><userinput remap="configure">../libstdc++-v3/configure \ <screen arch="ml_32,ml_x32,ml_all"><userinput remap="configure">../libstdc++-v3/configure \
--host=$LFS_TGT \ --host=$LFS_TGT \
@ -83,7 +83,7 @@ cd build</userinput></screen>
<varlistentry> <varlistentry>
<term><parameter>--host=...</parameter></term> <term><parameter>--host=...</parameter></term>
<listitem> <listitem>
<para>Specifies that the cross compiler we have just built <para>Specifies that the cross-compiler we have just built
should be used instead of the one in should be used instead of the one in
<filename>/usr/bin</filename>.</para> <filename>/usr/bin</filename>.</para>
</listitem> </listitem>
@ -108,27 +108,27 @@ cd build</userinput></screen>
<term><parameter>--with-gxx-include-dir=/tools/$LFS_TGT/include/c++/&gcc-version;</parameter></term> <term><parameter>--with-gxx-include-dir=/tools/$LFS_TGT/include/c++/&gcc-version;</parameter></term>
<listitem> <listitem>
<para>This specifies the installation directory for include files. <para>This specifies the installation directory for include files.
Because libstdc++ is the standard C++ library for LFS, this Because Libstdc++ is the standard C++ library for LFS, this
directory should match the location where the C++ compiler directory should match the location where the C++ compiler
(<command>$LFS_TGT-g++</command>) would search for the (<command>$LFS_TGT-g++</command>) would search for the
standard C++ include files. In a normal build, this information standard C++ include files. In a normal build, this information
is automatically passed to the libstdc++ <command>configure</command> is automatically passed to the Libstdc++ <command>configure</command>
options from the top level directory. In our case, this information options from the top level directory. In our case, this information
must be explicitly given. must be explicitly given.
The C++ compiler will prepend the sysroot path The C++ compiler will prepend the sysroot path
<filename class="directory">$LFS</filename> (specified building <filename class="directory">$LFS</filename> (specified when building
GCC pass 1) to the include file search path, so it will actually GCC-pass1) to the include file search path, so it will actually
search in search in
<filename class="directory">$LFS/tools/$LFS_TGT/include/c++/&gcc-version;</filename>. <filename class="directory">$LFS/tools/$LFS_TGT/include/c++/&gcc-version;</filename>.
The combination of the <parameter>DESTDIR</parameter> The combination of the <parameter>DESTDIR</parameter>
variable (in the <command>make install</command> command below) variable (in the <command>make install</command> command below)
and this switch ensures to install the headers there.</para> and this switch causes the headers to be installed there.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
</variablelist> </variablelist>
<para>Compile libstdc++ by running:</para> <para>Compile Libstdc++ by running:</para>
<screen><userinput remap="make">make</userinput></screen> <screen><userinput remap="make">make</userinput></screen>
@ -137,7 +137,7 @@ cd build</userinput></screen>
<screen><userinput remap="install">make DESTDIR=$LFS install</userinput></screen> <screen><userinput remap="install">make DESTDIR=$LFS install</userinput></screen>
<para>Remove the libtool archive files because they are harmful for <para>Remove the libtool archive files because they are harmful for
cross compilation:</para> cross-compilation:</para>
<screen><userinput remap="install">rm -v $LFS/usr/lib/lib{stdc++,stdc++fs,supc++}.la</userinput></screen> <screen><userinput remap="install">rm -v $LFS/usr/lib/lib{stdc++,stdc++fs,supc++}.la</userinput></screen>

View File

@ -145,7 +145,7 @@
<title>Implementation of Cross-Compilation for LFS</title> <title>Implementation of Cross-Compilation for LFS</title>
<note> <note>
<para>All the packages involved with cross-compilation use an <para>All the cross-compiled packages in this book use an
autoconf-based building system. The autoconf-based building system autoconf-based building system. The autoconf-based building system
accepts system types in the form cpu-vendor-kernel-os, accepts system types in the form cpu-vendor-kernel-os,
referred to as the system triplet. Since the vendor field is often referred to as the system triplet. Since the vendor field is often
@ -257,11 +257,28 @@
paragraph is that cc1 is unable to build a fully functional libstdc++, but paragraph is that cc1 is unable to build a fully functional libstdc++, but
this is the only compiler available for building the C/C++ libraries this is the only compiler available for building the C/C++ libraries
during stage 2. Of course, the compiler built by stage 2, cc-lfs, during stage 2. Of course, the compiler built by stage 2, cc-lfs,
would be able to build those libraries, but (1) the build system of would be able to build those libraries, but:</para>
gcc does not know cc-lfs can run on pc, and (2) using cc-lfs on pc
would create a risk of linking to the pc libraries, since cc-lfs is a native <itemizedlist>
compiler. So we have to re-build libstdc++ later as a part of <listitem>
gcc stage 2.</para> <para>
Generally cc-lfs cannot run on pc (the host distro). Despite the
triplets of pc and lfs are compatible to each other, an executable
for lfs will depend on glibc-&glibc-version; while the host distro
may utilize a different libc implementation (for example, musl) or
a previous release of glibc (for example, glibc-2.13).
</para>
</listitem>
<listitem>
<para>
Even if cc-lfs happens to run on pc, using it on pc would create
a risk of linking to the pc libraries, since cc-lfs is a native
compiler.
</para>
</listitem>
</itemizedlist>
<para>So we have to re-build libstdc++ later as a part of gcc stage 2.</para>
<para>In &ch-final; (or <quote>stage 3</quote>), all the packages needed for <para>In &ch-final; (or <quote>stage 3</quote>), all the packages needed for
the LFS system are built. Even if a package has already been installed into the LFS system are built. Even if a package has already been installed into