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-pass2.xml

    r9d719e2 refcb393  
    5555mv -v mpc-&mpc-version; mpc</userinput></screen>
    5656
    57     <para>Once again, change the location of GCC's default dynamic linker to
    58     use the one installed in <filename
    59     class="directory">/tools</filename>.</para>
    60 
    61 <screen><userinput remap="pre">for file in gcc/config/{linux,i386/linux{,64}}.h
    62 do
    63   cp -uv $file{,.orig}
    64   sed -e 's@/lib\(64\)\?\(32\)\?/ld@/tools&amp;@g' \
    65       -e 's@/usr@/tools@g' $file.orig &gt; $file
    66   echo '
    67 #undef STANDARD_STARTFILE_PREFIX_1
    68 #undef STANDARD_STARTFILE_PREFIX_2
    69 #define STANDARD_STARTFILE_PREFIX_1 "/tools/lib/"
    70 #define STANDARD_STARTFILE_PREFIX_2 ""' &gt;&gt; $file
    71   touch $file.orig
    72 done</userinput></screen>
    73 
    7457    <para>If building on x86_64, change the default directory name for 64-bit
    7558    libraries to <quote>lib</quote>:</para>
     
    8265esac</userinput></screen>
    8366
    84     <para>Our first build of GCC has installed a couple of internal system
    85     headers.  Normally one of them, <filename>limits.h</filename>, will in turn
    86     include the corresponding system <filename>limits.h</filename> header, in
    87     this case, <filename>/tools/include/limits.h</filename>. However, at the
    88     time of the first build of gcc <filename>/tools/include/limits.h</filename>
    89     did not exist, so the internal header that GCC installed is a partial,
    90     self-contained file and does not include the extended features of the
    91     system header. This was adequate for building the temporary libc, but this
    92     build of GCC now requires the full internal header.  Create a full version
    93     of the internal header using a command that is identical to what the GCC
    94     build system does in normal circumstances:</para>
    95 
    96 <screen><userinput remap="pre">cat gcc/limitx.h gcc/glimits.h gcc/limity.h &gt; \
    97   `dirname $($LFS_TGT-gcc -print-libgcc-file-name)`/include-fixed/limits.h</userinput></screen>
    98 <!--
    99     <para>For x86 machines, the limited number of registers is a bottleneck
    100     for the system.  Free one up by not using a frame pointer that is not
    101     needed:</para>
    102 
    103 <screen><userinput remap="pre">case `uname -m` in
    104   i?86) sed -i 's/^T_CFLAGS =$/&amp; -fomit-frame-pointer/' gcc/Makefile.in ;;
    105 esac</userinput></screen>
    106 -->
    10767    <para>Create a separate build directory again:</para>
    10868
    10969<screen><userinput remap="pre">mkdir -v build
    11070cd       build</userinput></screen>
     71
     72    <para>Create a symlink that allos libgcc to be built with posix threads
     73    support:</para>
     74
     75<screen><userinput remap="pre">mkdir -pv $LFS_TGT/libgcc
     76ln -s ../../../libgcc/gthr-posix.h $LFS_TGT/libgcc/gthr-default.h</userinput></screen>
    11177
    11278    <para>Before starting to build GCC, remember to unset any environment
     
    11581    <para>Now prepare GCC for compilation:</para>
    11682
    117 <screen><userinput remap="configure">CC=$LFS_TGT-gcc                                    \
    118 CXX=$LFS_TGT-g++                                   \
    119 AR=$LFS_TGT-ar                                     \
    120 RANLIB=$LFS_TGT-ranlib                             \
    121 ../configure                                       \
    122     --prefix=/tools                                \
    123     --with-local-prefix=/tools                     \
    124     --with-native-system-header-dir=/tools/include \
    125     --enable-languages=c,c++                       \
    126     --disable-libstdcxx-pch                        \
     83<screen><userinput remap="configure">../configure                                       \
     84    --build=$(../config.guess)                     \
     85    --host=$LFS_TGT                                \
     86    --prefix=/usr                                  \
     87    CC_FOR_TARGET=$LFS_TGT-gcc                     \
     88    --with-build-sysroot=$LFS                      \
     89    --enable-initfini-array                        \
     90    --disable-nls                                  \
    12791    --disable-multilib                             \
    128     --disable-bootstrap                            \
    129     --disable-libgomp</userinput></screen>
     92    --disable-decimal-float                        \
     93    --disable-libatomic                            \
     94    --disable-libgomp                              \
     95    --disable-libquadmath                          \
     96    --disable-libssp                               \
     97    --disable-libvtv                               \
     98    --disable-libstdcxx                            \
     99    --enable-languages=c,c++</userinput></screen>
    130100
    131101    <variablelist>
    132       <title>The meaning of the new configure options:</title>
     102      <title>The meaning of the new configure options:</title><!-- WIP -->
    133103
    134104      <varlistentry>
    135         <term><parameter>--enable-languages=c,c++</parameter></term>
     105        <term><parameter>-with-build-sysroot=$LFS</parameter></term>
    136106        <listitem>
    137           <para>This option ensures that both the C and C++ compilers are
    138           built.</para>
     107          <para>Normally, using <parameter>--host=</parameter> ensures that
     108          a cross-compiler is used for building gcc, and that compiler knows
     109          that it has to look for headers and libraries in <filename
     110          class="directory">$LFS</filename>. But the build system of GCC uses
     111          other tools, which are not aware of this location. This switch is
     112          needed to have them find the needed files in <filename
     113          class="directory">$LFS</filename>, and not on the host.</para>
    139114        </listitem>
    140115      </varlistentry>
    141116
    142117      <varlistentry>
    143         <term><parameter>--disable-libstdcxx-pch</parameter></term>
     118        <term><parameter>--enable-initfini-array</parameter></term>
    144119        <listitem>
    145           <para>Do not build the pre-compiled header (PCH) for
    146           <filename class="libraryfile">libstdc++</filename>. It takes up a
    147           lot of space, and we have no use for it.</para>
    148         </listitem>
    149       </varlistentry>
    150 
    151       <varlistentry>
    152         <term><parameter>--disable-bootstrap</parameter></term>
    153         <listitem>
    154           <para>For native builds of GCC, the default is to do a "bootstrap"
    155           build. This does not just compile GCC, but compiles it several times.
    156           It uses the programs compiled in a first round to compile itself a
    157           second time, and then again a third time.  The second and third
    158           iterations are compared to make sure it can reproduce itself
    159           flawlessly. This also implies that it was compiled correctly.
    160           However, the LFS build method should provide a solid compiler
    161           without the need to bootstrap each time.</para>
     120          <para>This option is automatically enabled when building a native
     121          compiler with a native compiler on x86. But here, we build with
     122          a cross compiler, so we need to explicitely set this option.</para>
    162123        </listitem>
    163124      </varlistentry>
     
    171132    <para>Install the package:</para>
    172133
    173 <screen><userinput remap="install">make install</userinput></screen>
     134<screen><userinput remap="install">make DESTDIR=$LFS install</userinput></screen>
    174135
    175136    <para>As a finishing touch, create a symlink. Many programs and scripts
     
    180141    which C compiler to install:</para>
    181142
    182 <screen><userinput remap="install">ln -sv gcc /tools/bin/cc</userinput></screen>
    183 
    184   <caution>
    185     <para>At this point, it is imperative to stop and ensure that the basic
    186     functions (compiling and linking) of the new toolchain are working as
    187     expected. To perform a sanity check, run the following commands:</para>
    188 
    189 <screen><userinput>echo 'int main(){}' &gt; dummy.c
    190 cc dummy.c
    191 readelf -l a.out | grep ': /tools'</userinput></screen>
    192 
    193     <para>If everything is working correctly, there should be no errors,
    194     and the output of the last command will be of the form:</para>
    195 
    196 <screen><computeroutput>[Requesting program interpreter: /tools/lib64/ld-linux-x86-64.so.2]</computeroutput></screen>
    197 
    198     <para>Note that the dynamic linker will be /tools/lib/ld-linux.so.2
    199     for 32-bit machines.</para>
    200 
    201     <para>If the output is not shown as above or there was no output at all,
    202     then something is wrong. Investigate and retrace the steps to find out
    203     where the problem is and correct it. This issue must be resolved before
    204     continuing on. First, perform the sanity check again, using
    205     <command>gcc</command> instead of <command>cc</command>. If this works,
    206     then the <filename class="symlink">/tools/bin/cc</filename> symlink is
    207     missing. Install the symlink as per above.
    208     Next, ensure that the <envar>PATH</envar> is correct. This
    209     can be checked by running <command>echo $PATH</command> and verifying that
    210     <filename class="directory">/tools/bin</filename> is at the head of the
    211     list. If the <envar>PATH</envar> is wrong it could mean that you are not
    212     logged in as user <systemitem class="username">lfs</systemitem> or that
    213     something went wrong back in <xref linkend="ch-preps-settingenviron"
    214     role="."/></para>
    215 
    216     <para>Once all is well, clean up the test files:</para>
    217 
    218 <screen><userinput>rm -v dummy.c a.out</userinput></screen>
    219 
    220   </caution>
     143<screen><userinput remap="install">ln -sv gcc $LFS/usr/bin/cc</userinput></screen>
    221144
    222145  </sect2>
Note: See TracChangeset for help on using the changeset viewer.