Ignore:
Timestamp:
05/03/2020 09:02:51 PM (4 years ago)
Author:
Pierre Labastie <pieere@…>
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:
a715dec
Parents:
9d719e2
Message:

Make the new book

git-svn-id: http://svn.linuxfromscratch.org/LFS/branches/cross-chap5@11831 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689

File:
1 edited

Legend:

Unmodified
Added
Removed
  • chapter05/gcc-pass1.xml

    r9d719e2 refcb393  
    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>
    204         </listitem>
    205       </varlistentry>
    206 
    207       <varlistentry>
    208135        <term><parameter>--disable-shared</parameter></term>
    209136        <listitem>
    210137          <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>
     138          statically. We need this because the shared libraries require glibc,
     139          which is not yet installed on the target system.</para>
    213140        </listitem>
    214141      </varlistentry>
     
    250177<screen><userinput remap="make">make</userinput></screen>
    251178
    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 
    258179    <para>Install the package:</para>
    259180
    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 -->
     181    <screen><userinput remap="install">make install</userinput></screen>
     182
     183    <para>This build of GCC has installed a couple of internal system
     184    headers.  Normally one of them, <filename>limits.h</filename>, would in turn
     185    include the corresponding system <filename>limits.h</filename> header, in
     186    this case, <filename>$LFS/usr/include/limits.h</filename>. However, at the
     187    time of this build of gcc <filename>$LFS/usr/include/limits.h</filename>
     188    does not exist, so the internal header that has just been installed is a
     189    partial, self-contained file and does not include the extended features of
     190    the system header. This is adequate for building glibc, but the full
     191    internal header will be needed later.  Create a full version of the internal
     192    header using a command that is identical to what the GCC build system does
     193    in normal circumstances:</para>
     194
     195<screen><userinput remap="install">cd ..
     196cat gcc/limitx.h gcc/glimits.h gcc/limity.h > \
     197  `dirname $($LFS_TGT-gcc -print-libgcc-file-name)`/install-tools/include/limits.h</userinput></screen>
    272198  </sect2>
    273199
Note: See TracChangeset for help on using the changeset viewer.