Ignore:
Timestamp:
06/16/2020 11:56:28 AM (4 years ago)
Author:
Bruce Dubbs <bdubbs@…>
Branches:
10.0, 10.0-rc1, 10.1, 10.1-rc1, 11.0, 11.0-rc1, 11.0-rc2, 11.0-rc3, 11.1, 11.1-rc1, 11.2, 11.2-rc1, 11.3, 11.3-rc1, 12.0, 12.0-rc1, 12.1, 12.1-rc1, arm, bdubbs/gcc13, ml-11.0, multilib, renodr/libudev-from-systemd, s6-init, trunk, xry111/arm64, xry111/arm64-12.0, xry111/clfs-ng, xry111/lfs-next, xry111/loongarch, xry111/loongarch-12.0, xry111/loongarch-12.1, xry111/mips64el, xry111/pip3, xry111/rust-wip-20221008, xry111/update-glibc
Children:
9a05e45
Parents:
560065f (diff), 1cd5961 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Split Chapter 5 into three separate chapters.
Implement a new method of cross-building the LFS tool chain
and other tools to simplify the method of isolating the
new system from the original host. This will be the start of
LFS-10.0.

Move old trunk/BOOK to branches/old-trunk.

git-svn-id: http://svn.linuxfromscratch.org/LFS/trunk/BOOK@11946 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689

File:
1 edited

Legend:

Unmodified
Added
Removed
  • chapter05/gcc-pass1.xml

    r560065f r675606b  
    2626
    2727    <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
    28     href="../chapter06/gcc.xml"
     28    href="../chapter08/gcc.xml"
    2929    xpointer="xpointer(/sect1/sect2[1]/para[1])"/>
    3030
     
    3434
    3535      <seglistitem>
    36         <seg>&gcc-ch5p1-sbu;</seg>
    37         <seg>&gcc-ch5p1-du;</seg>
     36        <seg>&gcc-tmpp1-sbu;</seg>
     37        <seg>&gcc-tmpp1-du;</seg>
    3838      </seglistitem>
    3939    </segmentedlist>
     
    4444    <title>Installation of Cross GCC</title>
    4545
    46     <para>GCC now requires the GMP, MPFR and MPC packages. As these packages may
     46    <para>GCC requires the GMP, MPFR and MPC packages. As these packages may
    4747    not be included in your host distribution, they will be built with
    4848    GCC.  Unpack each package into the GCC source directory and rename the
     
    6363mv -v mpc-&mpc-version; mpc</userinput></screen>
    6464
    65     <para>The following command will change the location of GCC's default
    66     dynamic linker to use the one installed in <filename
    67     class="directory">/tools</filename>. It also removes <filename
    68     class="directory">/usr/include</filename> from GCC's include search path.
    69     Issue:</para>
    70 
    71 <screen><userinput remap="pre">for file in gcc/config/{linux,i386/linux{,64}}.h
    72 do
    73   cp -uv $file{,.orig}
    74   sed -e 's@/lib\(64\)\?\(32\)\?/ld@/tools&amp;@g' \
    75       -e 's@/usr@/tools@g' $file.orig &gt; $file
    76   echo '
    77 #undef STANDARD_STARTFILE_PREFIX_1
    78 #undef STANDARD_STARTFILE_PREFIX_2
    79 #define STANDARD_STARTFILE_PREFIX_1 "/tools/lib/"
    80 #define STANDARD_STARTFILE_PREFIX_2 ""' &gt;&gt; $file
    81   touch $file.orig
    82 done</userinput></screen>
    83 
    84     <para>In case the above seems hard to follow, let's break it down a bit.
    85     First we copy the files <filename>gcc/config/linux.h</filename>,
    86     <filename>gcc/config/i386/linux.h</filename>, and
    87     <filename>gcc/config/i386/linux64.h</filename> to a file of
    88     the same name but with an added suffix of <quote>.orig</quote>. Then the
    89     first sed expression prepends <quote>/tools</quote> to every instance of
    90     <quote>/lib/ld</quote>, <quote>/lib64/ld</quote> or
    91     <quote>/lib32/ld</quote>, while the second one replaces hard-coded
    92     instances of <quote>/usr</quote>. Next, we add our define statements which
    93     alter the default startfile prefix to the end of the file. Note that the
    94     trailing <quote>/</quote> in <quote>/tools/lib/</quote> is required.
    95     Finally, we use <command>touch</command> to update the timestamp on the
    96     copied files.  When used in conjunction with <command>cp -u</command>, this
    97     prevents unexpected changes to the original files in case the commands are
    98     inadvertently run twice.</para>
    99 
    100     <para>Finally, on x86_64 hosts, set the default directory name for
     65    <para>On x86_64 hosts, set the default directory name for
    10166    64-bit libraries to <quote>lib</quote>:</para>
    10267
     
    10873esac</userinput></screen>
    10974
    110 <!--
    111     <para>GCC doesn't detect stack protection correctly, which causes problems
    112     for the build of Glibc-&glibc-version;, so fix that by issuing the following
    113     command:</para>
    114 
    115 <screen><userinput remap="pre">sed -i '/k prot/agcc_cv_libc_provides_ssp=yes' gcc/configure</userinput></screen>
    116 -->
    117 
    118 <!--
    119     <para>Also fix a problem identified upstream:</para>
    120 
    121 <screen><userinput remap="pre">sed -i 's/if \((code.*))\)/if (\1 \&amp;\&amp; \!DEBUG_INSN_P (insn))/' gcc/sched-deps.c</userinput></screen>
    122 -->
    12375    <para>The GCC documentation recommends building GCC
    12476    in a dedicated build directory:</para>
     
    13183<screen><userinput remap="configure">../configure                                       \
    13284    --target=$LFS_TGT                              \
    133     --prefix=/tools                                \
     85    --prefix=$LFS/tools                            \
    13486    --with-glibc-version=2.11                      \
    13587    --with-sysroot=$LFS                            \
    13688    --with-newlib                                  \
    13789    --without-headers                              \
    138     --with-local-prefix=/tools                     \
    139     --with-native-system-header-dir=/tools/include \
     90    --enable-initfini-array                        \
    14091    --disable-nls                                  \
    14192    --disable-shared                               \
     
    182133
    183134      <varlistentry>
    184         <term><parameter>--with-local-prefix=/tools</parameter></term>
    185         <listitem>
    186           <para>The local prefix is the location in the system that GCC will search
    187           for locally installed include files. The default is <filename>/usr/local</filename>.
    188           Setting this to <filename>/tools</filename> helps keep the host location of
    189           <filename>/usr/local</filename> out of this GCC's search path.</para>
    190         </listitem>
    191       </varlistentry>
    192 
    193       <varlistentry>
    194         <term><parameter>--with-native-system-header-dir=/tools/include</parameter></term>
    195         <listitem>
    196           <para>By default, GCC searches <filename>/usr/include</filename> for
    197           system headers. In conjunction with the sysroot switch, this would
    198           normally translate to <filename>$LFS/usr/include</filename>. However
    199           the headers that will be installed in the next two sections will go
    200           to <filename>$LFS/tools/include</filename>. This switch ensures that
    201           gcc will find them correctly. In the second pass of GCC, this same
    202           switch will ensure that no headers from the host system are
    203           found.</para>
     135        <term><parameter>--enable-initfini-array</parameter></term>
     136        <listitem>
     137          <para>This switch forces the use of some internal data structures
     138          that are needed but cannot be detected when building a cross
     139          compiler.</para>
    204140        </listitem>
    205141      </varlistentry>
     
    209145        <listitem>
    210146          <para>This switch forces GCC to link its internal libraries
    211           statically. We do this to avoid possible issues with the host
    212           system.</para>
     147          statically. We need this because the shared libraries require glibc,
     148          which is not yet installed on the target system.</para>
     149        </listitem>
     150      </varlistentry>
     151
     152      <varlistentry>
     153        <term><parameter>--disable-multilib</parameter></term>
     154        <listitem>
     155          <para>On x86_64, LFS does not support a multilib configuration.
     156          This switch is harmless for x86.</para>
    213157        </listitem>
    214158      </varlistentry>
     
    216160      <varlistentry>
    217161        <term><parameter>--disable-decimal-float, --disable-threads,
    218               --disable-libatomic, --disable-libgomp, <!--- -disable-libmpx,-->
     162              --disable-libatomic, --disable-libgomp,
    219163        --disable-libquadmath, --disable-libssp, --disable-libvtv,
    220164        --disable-libstdcxx</parameter></term>
    221165        <listitem>
    222166          <para>These switches disable support for the decimal floating point
    223           extension, threading, libatomic, libgomp, <!--libmpx, --> libquadmath, libssp,
     167          extension, threading, libatomic, libgomp, libquadmath, libssp,
    224168          libvtv, and the C++ standard library respectively. These features
    225169          will fail to compile when building a cross-compiler and are not
     
    229173
    230174      <varlistentry>
    231         <term><parameter>--disable-multilib</parameter></term>
    232         <listitem>
    233           <para>On x86_64, LFS does not yet support a multilib configuration.
    234           This switch is harmless for x86.</para>
    235         </listitem>
    236       </varlistentry>
    237 
    238       <varlistentry>
    239175        <term><parameter>--enable-languages=c,c++</parameter></term>
    240176        <listitem>
     
    250186<screen><userinput remap="make">make</userinput></screen>
    251187
    252     <para>Compilation is now complete. At this point, the test suite would
    253     normally be run, but, as mentioned before, the test suite framework is
    254     not in place yet. The benefits of running the tests at this point
    255     are minimal since the programs from this first pass will soon be
    256     replaced.</para>
    257 
    258188    <para>Install the package:</para>
    259189
    260 <screen><userinput remap="install">make install</userinput></screen>
    261 <!--
    262     <para>Using <parameter>- -disable-shared</parameter> means that the
    263     <filename>libgcc_eh.a</filename> file isn't created and installed. The
    264     Glibc package depends on this library as it uses
    265     <parameter>-lgcc_eh</parameter> within its build system. This dependency
    266     can be satisfied by creating a symlink to <filename>libgcc.a</filename>,
    267     since that file will end up containing the objects normally contained in
    268     <filename>libgcc_eh.a</filename>:</para>
    269 
    270 <screen><userinput remap="install">ln -sv libgcc.a `$LFS_TGT-gcc -print-libgcc-file-name | sed 's/libgcc/&amp;_eh/'`</userinput></screen>
    271 -->
     190    <screen><userinput remap="install">make install</userinput></screen>
     191
     192    <para>This build of GCC has installed a couple of internal system
     193    headers.  Normally one of them, <filename>limits.h</filename>, would in turn
     194    include the corresponding system <filename>limits.h</filename> header, in
     195    this case, <filename>$LFS/usr/include/limits.h</filename>. However, at the
     196    time of this build of GCC <filename>$LFS/usr/include/limits.h</filename>
     197    does not exist, so the internal header that has just been installed is a
     198    partial, self-contained file and does not include the extended features of
     199    the system header. This is adequate for building glibc, but the full
     200    internal header will be needed later.  Create a full version of the internal
     201    header using a command that is identical to what the GCC build system does
     202    in normal circumstances:</para>
     203
     204<screen><userinput remap="install">cd ..
     205cat gcc/limitx.h gcc/glimits.h gcc/limity.h > \
     206  `dirname $($LFS_TGT-gcc -print-libgcc-file-name)`/install-tools/include/limits.h</userinput></screen>
    272207  </sect2>
    273208
Note: See TracChangeset for help on using the changeset viewer.