Changeset 4e82d47 for chapter05


Ignore:
Timestamp:
12/05/2008 08:46:02 PM (15 years ago)
Author:
Jeremy Huntwork <jhuntwork@…>
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, 6.5, 6.6, 6.7, 6.8, 7.0, 7.1, 7.2, 7.3, 7.4, 7.5, 7.5-systemd, 7.6, 7.6-systemd, 7.7, 7.7-systemd, 7.8, 7.8-systemd, 7.9, 7.9-systemd, 8.0, 8.1, 8.2, 8.3, 8.4, 9.0, 9.1, 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:
6f2cc22
Parents:
6e88633
Message:

Bring in DIY's next generation build method. Move GRUB to chapter 8.

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

Location:
chapter05
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • chapter05/adjusting.xml

    r6e88633 r4e82d47  
    1313  <para>Now that the temporary C libraries have been installed, all
    1414  tools compiled in the rest of this chapter should be linked against
    15   these libraries. In order to accomplish this, the linker and the
    16   compiler's specs file need to be adjusted.</para>
     15  these libraries. In order to accomplish this, the cross-compiler's
     16  specs file needs to be adjusted to point to the new dynamic linker
     17  in <filename class="directory">/tools</filename>.</para>
    1718
    18   <para>The linker, adjusted at the end of the first pass of Binutils, needs
    19   to be renamed so that it can be properly found and used. First, backup the
    20   original linker, then replace it with the adjusted linker. We'll also
    21   create a link to its counterpart in <filename class="directory">
    22   /tools/$(gcc -dumpmachine)/bin</filename>:</para>
    23 
    24 <screen><userinput>mv -v /tools/bin/{ld,ld-old}
    25 mv -v /tools/$(gcc -dumpmachine)/bin/{ld,ld-old}
    26 mv -v /tools/bin/{ld-new,ld}
    27 ln -sv /tools/bin/ld /tools/$(gcc -dumpmachine)/bin/ld</userinput></screen>
    28 
    29   <para>From this point onwards, everything will link only against the
    30   libraries in <filename class="directory">/tools/lib</filename>.</para>
    31 
    32   <para>The next task is to point GCC to the new dynamic linker. This is done by
    33   dumping GCC's <quote>specs</quote> file to a location where GCC will look for it
    34   by default. A simple <command>sed</command> substitution then alters the
     19  <para>This is done by dumping the compiler's <quote>specs</quote> file to a
     20  location where it will look for it by default.
     21  A simple <command>sed</command> substitution then alters the
    3522  dynamic linker that GCC will use. The principle here is to find all references
    3623  to the dynamic linker file in <filename class="directory">/lib</filename>
     
    4734
    4835<!-- Ampersands are needed to allow copy and paste -->
    49 <screen><userinput>gcc -dumpspecs | sed 's@/lib\(64\)\?/ld@/tools&amp;@g' &gt; \
    50   `dirname $(gcc -print-libgcc-file-name)`/specs</userinput></screen>
    51 
    52   <para>During the build process, GCC runs a script
    53   (<command>fixincludes</command>) that scans the system for header files
    54   that may need to be fixed (they might contain syntax errors, for example),
    55   and installs the fixed versions in a private include directory. There is a
    56   possibility that, as a result of this process, some header files from the
    57   host system have found their way into GCC's private include directory. As
    58   the rest of this chapter only requires the headers from GCC and Glibc,
    59   which have both been installed at this point, any <quote>fixed</quote>
    60   headers can safely be removed. This helps to avoid any host headers
    61   polluting the build environment. Run the following commands to remove the
    62   header files in GCC's private include directory (you may find it easier to
    63   copy and paste these commands, rather than typing them by hand, due to
    64   their length):</para>
    65 
    66 <!-- && used to ease copy and pasting -->
    67 <screen><userinput>GCC_FIXED=`dirname $(gcc -print-libgcc-file-name)`/include-fixed &amp;&amp;
    68 find ${GCC_FIXED}/* -maxdepth 0 -xtype d -exec rm -rvf '{}' \; &amp;&amp;
    69 rm -vf `grep -l "DO NOT EDIT THIS FILE" ${GCC_FIXED}/*` &amp;&amp;
    70 unset GCC_FIXED</userinput></screen>
     36<screen><userinput>SPECS=`dirname $($LFS_TGT-gcc -print-libgcc-file-name)`/specs
     37$LFS_TGT-gcc -dumpspecs | sed \
     38  -e 's@/lib\(64\)\?/ld@/tools&amp;@g' \
     39  -e "/^\*cpp:$/{n;s,$, -isystem /tools/include,}" &gt; $SPECS
     40echo "New specs file is: $SPECS"
     41unset SPECS</userinput></screen>
    7142
    7243  <caution>
     
    7647
    7748<screen><userinput>echo 'main(){}' &gt; dummy.c
    78 cc dummy.c
     49$LFS_TGT-gcc -B/tools/lib dummy.c
    7950readelf -l a.out | grep ': /tools'</userinput></screen>
    8051
     
    9263    then something is wrong. Investigate and retrace the steps to find out
    9364    where the problem is and correct it. This issue must be resolved before
    94     continuing on. First, perform the sanity check again, using
    95     <command>gcc</command> instead of <command>cc</command>. If this works,
    96     then the <filename class="symlink">/tools/bin/cc</filename> symlink is
    97     missing. Revisit <xref linkend="ch-tools-gcc-pass1" role=","/> and install
    98     the symlink. Next, ensure that the <envar>PATH</envar> is correct. This
    99     can be checked by running <command>echo $PATH</command> and verifying that
    100     <filename class="directory">/tools/bin</filename> is at the head of the
    101     list. If the <envar>PATH</envar> is wrong it could mean that you are not
    102     logged in as user <systemitem class="username">lfs</systemitem> or that
    103     something went wrong back in <xref linkend="ch-tools-settingenviron"
    104     role="."/> Another option is that something may have gone wrong with the
     65    continuing on. Something may have gone wrong with the
    10566    specs file amendment above. In this case, redo the specs file amendment,
    10667    being careful to copy-and-paste the commands.</para>
     
    11273  </caution>
    11374
    114   <note><para>Building Tcl in the next section will serve as an additional check that
    115   the toolchain has been built properly.  If Tcl fails to build, it is an
    116   indication that something has gone wrong with the Binutils, GCC, or Glibc
    117   installation, but not with Tcl itself.</para></note>
     75  <note><para>Building Binutils in the next section will serve as an additional check that
     76  the toolchain has been built properly. If Binutils fails to build, it is an
     77  indication that something has gone wrong with the previous Binutils, GCC, or Glibc
     78  installations.</para></note>
    11879
    11980</sect1>
  • chapter05/binutils-pass1.xml

    r6e88633 r4e82d47  
    4242
    4343  <sect2 role="installation">
    44     <title>Installation of Binutils</title>
     44    <title>Installation of Cross Binutils</title>
    4545
    4646    <para>It is important that Binutils be the first package compiled
     
    7171    <para>Now prepare Binutils for compilation:</para>
    7272
    73 <screen><userinput remap="configure">CC="gcc -B/usr/bin/" ../binutils-&binutils-version;/configure \
    74     --prefix=/tools --disable-nls --disable-werror</userinput></screen>
     73<screen><userinput remap="configure">../binutils-&binutils-version;/configure \
     74    --target=$LFS_TGT --prefix=/tools \
     75    --disable-nls --disable-werror</userinput></screen>
    7576
    7677    <variablelist>
     
    7879
    7980      <varlistentry>
    80         <term><envar>CC="gcc -B/usr/bin/"</envar></term>
     81        <term><envar>--target=$LFS_TGT</envar></term>
    8182        <listitem>
    82           <para>This forces <command>gcc</command> to prefer the linker from
    83           the host in <filename class="directory">/usr/bin</filename>. This
    84           is necessary on some hosts where the new <command>ld</command>
    85           built here is not compatible with the host's <command>gcc</command>.
     83          <para>Because the machine description in the <envar>LFS_TGT</envar>
     84          variable is slightly different than the value returned by the
     85          config.guess script, this switch will tell the configure script to
     86          adjust Binutil's build system for building a cross linker.
    8687          </para>
    8788        </listitem>
     
    125126    first pass will soon be replaced by those from the second.</para>
    126127
    127     <para>Create a symlink to ensure the sanity of our toolchain:</para>
     128    <para>If building on x86_64, create a symlink to ensure the sanity of
     129    the toolchain:</para>
    128130
    129 <screen><userinput remap="install">mkdir -v /tools/lib
    130 ln -sv lib /tools/lib64</userinput></screen>
     131<screen><userinput remap="install">case $(uname -m) in
     132  x86_64) mkdir -v /tools/lib &amp;&amp; ln -sv lib /tools/lib64 ;;
     133esac</userinput></screen>
    131134
    132135    <para>Install the package:</para>
    133136
    134137<screen><userinput remap="install">make install</userinput></screen>
    135 
    136     <para>Finally, prepare the linker for the <quote>Adjusting</quote> phase
    137     later on:</para>
    138 
    139 <screen><userinput remap="adjust">make -C ld clean
    140 make -C ld LIB_PATH=/tools/lib
    141 cp -v ld/ld-new /tools/bin</userinput></screen>
    142 
    143     <variablelist>
    144       <title>The meaning of the make parameters:</title>
    145 
    146       <varlistentry>
    147         <term><parameter>-C ld clean</parameter></term>
    148         <listitem>
    149           <para>This tells the make program to remove all compiled
    150           files in the <filename class="directory">ld</filename>
    151           subdirectory.</para>
    152         </listitem>
    153       </varlistentry>
    154 
    155       <varlistentry>
    156         <term><parameter>-C ld LIB_PATH=/tools/lib</parameter></term>
    157         <listitem>
    158           <para>This option rebuilds everything in the <filename
    159           class="directory">ld</filename> subdirectory. Specifying the
    160           <envar>LIB_PATH</envar> Makefile variable on the command line
    161           allows us to override the default value and point it to the
    162           temporary tools location. The value of this variable specifies
    163           the linker's default library search path. This preparation is
    164           used later in the chapter.</para>
    165         </listitem>
    166       </varlistentry>
    167 
    168     </variablelist>
    169138
    170139  </sect2>
  • chapter05/binutils-pass2.xml

    r6e88633 r4e82d47  
    4242
    4343  <sect2 role="installation">
    44     <title>Re-installation of Binutils</title>
     44    <title>Installation of Binutils</title>
    4545
    4646    <para>Binutils does not recognize versions of Texinfo newer than 4.9.  Fix
     
    5656    <para>Prepare Binutils for compilation:</para>
    5757
    58 <screen><userinput remap="configure">../binutils-&binutils-version;/configure --prefix=/tools \
    59     --disable-nls --with-lib-path=/tools/lib</userinput></screen>
     58<screen><userinput remap="configure">CC="$LFS_TGT-gcc -B/tools/lib/" \
     59   AR=$LFS_TGT-ar RANLIB=$LFS_TGT-ranlib \
     60   ../binutils-&binutils-version;/configure --prefix=/tools \
     61   --disable-nls --with-lib-path=/tools/lib</userinput></screen>
    6062
    6163    <variablelist>
    6264      <title>The meaning of the new configure options:</title>
     65
     66      <varlistentry>
     67        <term><parameter>CC="$LFS_TGT-gcc -B/tools/lib/" AR=$LFS_TGT-ar RANLIB=$LFS_TGT-ranlib</parameter></term>
     68        <listitem>
     69          <para>Because this is really a native build of Binutils, setting these
     70          variables ensures that the build system uses the cross-compiler and
     71          associated tools instead of the ones on the host system.</para>
     72        </listitem>
     73      </varlistentry>
    6374
    6475      <varlistentry>
     
    7990<screen><userinput remap="make">make</userinput></screen>
    8091
    81     <para>Compilation is now complete. As discussed earlier, running the
    82     test suite is not mandatory for the temporary tools here in this
    83     chapter. To run the Binutils test suite anyway, issue the following
    84     command:</para>
    85 
    86 <screen><userinput remap="test">make check</userinput></screen>
    87 
    8892    <para>Install the package:</para>
    8993
     
    96100make -C ld LIB_PATH=/usr/lib:/lib
    97101cp -v ld/ld-new /tools/bin</userinput></screen>
     102
     103    <variablelist>
     104      <title>The meaning of the make parameters:</title>
     105
     106      <varlistentry>
     107        <term><parameter>-C ld clean</parameter></term>
     108        <listitem>
     109          <para>This tells the make program to remove all compiled
     110          files in the <filename class="directory">ld</filename>
     111          subdirectory.</para>
     112        </listitem>
     113      </varlistentry>
     114
     115      <varlistentry>
     116        <term><parameter>-C ld LIB_PATH=/usr/lib:/lib</parameter></term>
     117        <listitem>
     118          <para>This option rebuilds everything in the <filename
     119          class="directory">ld</filename> subdirectory. Specifying the
     120          <envar>LIB_PATH</envar> Makefile variable on the command line
     121          allows us to override the default value of the temporary tools
     122          and point it to the proper final path. The value of this variable
     123          specifies the linker's default library search path. This
     124          preparation is used in the next chapter.</para>
     125        </listitem>
     126      </varlistentry>
     127
     128    </variablelist>
    98129
    99130  </sect2>
  • chapter05/chapter05.xml

    r6e88633 r4e82d47  
    2020  <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="glibc.xml"/>
    2121  <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="adjusting.xml"/>
     22  <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="binutils-pass2.xml"/>
     23  <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="gcc-pass2.xml"/>
    2224  <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="tcl.xml"/>
    2325  <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="expect.xml"/>
    2426  <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="dejagnu.xml"/>
    25   <!-- <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="gmp.xml"/>
    26   <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="mpfr.xml"/> -->
    27   <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="gcc-pass2.xml"/>
    28   <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="binutils-pass2.xml"/>
    2927  <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="ncurses.xml"/>
    3028  <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="bash.xml"/>
  • chapter05/gcc-pass1.xml

    r6e88633 r4e82d47  
    4242
    4343  <sect2 role="installation">
    44     <title>Installation of GCC</title>
     44    <title>Installation of Cross GCC</title>
    4545
    4646    <para>GCC now requires the GMP and MPFR packages. As these packages may
     
    6161    <para>Prepare GCC for compilation:</para>
    6262
    63 <screen><userinput remap="configure">CC="gcc -B/usr/bin/" ../gcc-&gcc-version;/configure --prefix=/tools \
    64     --with-local-prefix=/tools --disable-nls --disable-shared --disable-libssp \
    65     --disable-multilib --enable-languages=c</userinput></screen>
     63<screen><userinput remap="configure">../gcc-&gcc-version;/configure \
     64    --target=$LFS_TGT --prefix=/tools \
     65    --disable-nls --disable-shared --disable-multilib \
     66    --disable-decimal-float --disable-threads \
     67    --disable-libmudflap --disable-libssp \
     68    --disable-libgomp --enable-languages=c</userinput></screen>
    6669
    6770    <variablelist>
    6871      <title>The meaning of the configure options:</title>
    69 
    70       <varlistentry>
    71         <term><envar>CC="gcc -B/usr/bin/"</envar></term>
    72         <listitem>
    73           <para>This forces <command>gcc</command> to prefer the linker from
    74           the host in <filename class="directory">/usr/bin</filename>. This
    75           is necessary on some hosts where the new <command>ld</command>
    76           built in the previous section is not compatible with the host's
    77           <command>gcc</command>.</para>
    78         </listitem>
    79       </varlistentry>
    80 
    81       <varlistentry>
    82         <term><parameter>--with-local-prefix=/tools</parameter></term>
    83         <listitem>
    84           <para>The purpose of this switch is to remove <filename
    85           class="directory">/usr/local/include</filename> from
    86           <command>gcc</command>'s include search path. This is not
    87           absolutely essential, however, it helps to minimize the
    88           influence of the host system.</para>
    89         </listitem>
    90       </varlistentry>
    9172
    9273      <varlistentry>
     
    10081
    10182      <varlistentry>
    102         <term><parameter>--disable-libssp</parameter></term>
     83        <term><parameter>--disable-decimal-float, --disable-threads, --disable-libmudflap, --disable-libssp, --disable-libgomp</parameter></term>
    10384        <listitem>
    104           <para>This switch prevents a conflict with older versions of
    105           glibc which can cause the build to fail.</para>
     85          <para>These switches disable support for the decimal floating point extension,
     86          threading, libmudflap, libssp and libgomp respectively. These features will fail
     87          to compile when building a cross-compiler and are not necessary for the task of
     88          cross-compiling the temporary libc.</para>
     89        </listitem>
     90      </varlistentry>
     91
     92      <varlistentry>
     93        <term><parameter>--disable-multilib</parameter></term>
     94        <listitem>
     95          <para>On x86_64, LFS does not yet support a multilib configuration.
     96          This switch is harmless for x86.</para>
    10697        </listitem>
    10798      </varlistentry>
     
    115106      </varlistentry>
    116107
    117       <varlistentry>
    118         <term><parameter>--disable-multilib</parameter></term>
    119         <listitem>
    120           <para>We currently only want to build support for 64-bit libraries.</para>
    121         </listitem>
    122       </varlistentry>
    123 
    124108    </variablelist>
    125109
    126     <para>The following command will compile GCC not once, but several times. It
    127     uses the programs compiled in a first round to compile itself a second time,
    128     and then again a third time. It then compares these second and third compiles
    129     to make sure it can reproduce itself flawlessly. This is called
    130     <quote>bootstrapping</quote>. Building GCC in this way ensures that it was
    131     compiled correctly and is now the default configuration for the released
    132     package. Continue with compiling by running:</para>
     110    <para>Compile GCC by running:</para>
    133111
    134112<screen><userinput remap="make">make</userinput></screen>
     
    147125    <filename>libgcc_eh.a</filename> file isn't created and installed. The
    148126    Glibc package depends on this library as it uses
    149     <parameter>-lgcc_eh</parameter> within its build system. We can satisfy
    150     that dependency by creating a symlink to <filename>libgcc.a</filename>,
     127    <parameter>-lgcc_eh</parameter> within its build system. This dependency
     128    can be satisfied by creating a symlink to <filename>libgcc.a</filename>,
    151129    since that file will end up containing the objects normally contained in
    152130    <filename>libgcc_eh.a</filename>.</para>
    153131
    154 <screen><userinput remap="install">ln -vs libgcc.a `gcc -print-libgcc-file-name | \
     132<screen><userinput remap="install">ln -vs libgcc.a `$LFS_TGT-gcc -print-libgcc-file-name | \
    155133    sed 's/libgcc/&amp;_eh/'`</userinput></screen>
    156 
    157     <para>As a finishing touch, create a symlink. Many programs and scripts
    158     run <command>cc</command> instead of <command>gcc</command>, which is
    159     used to keep programs generic and therefore usable on all kinds of UNIX
    160     systems where the GNU C compiler is not always installed. Running
    161     <command>cc</command> leaves the system administrator free to decide
    162     which C compiler to install:</para>
    163 
    164 <screen><userinput remap="install">ln -vs gcc /tools/bin/cc</userinput></screen>
    165134
    166135  </sect2>
  • chapter05/gcc-pass2.xml

    r6e88633 r4e82d47  
    4242
    4343  <sect2 role="installation">
    44     <title>Re-installation of GCC</title>
    45 
    46     <para>The tools required to test GCC and Binutils&mdash;Tcl, Expect
    47     and DejaGNU&mdash;are installed now. GCC and Binutils can now be
    48     rebuilt, linking them against the new Glibc and testing them properly
    49     (if running the test suites in this chapter). Please note that these
    50     test suites are highly dependent on properly functioning PTYs which
    51     are provided by the host. PTYs are most commonly implemented via the
    52     <systemitem class="filesystem">devpts</systemitem> file system. Check
    53     to see if the host system is set up correctly in this regard by
    54     performing a quick test:</para>
    55 
    56 <screen><userinput remap="test">expect -c "spawn ls"</userinput></screen>
    57 
    58     <para>The response might be:</para>
    59 
    60 <screen><computeroutput>The system has no more ptys.
    61 Ask your system administrator to create more.</computeroutput></screen>
    62 
    63     <para>If the above message is received, the host does not have its PTYs
    64     set up properly. In this case, there is no point in running the test
    65     suites for GCC and Binutils until this issue is resolved. Please consult
    66     the LFS FAQ at <ulink url="&lfs-root;/lfs/faq.html#no-ptys"/> for more
    67     information on how to get PTYs working.</para>
    68 
    69     <para>As previously explained in <xref linkend="ch-tools-adjusting"/>,
    70     under normal circumstances the GCC <command>fixincludes</command> script
     44    <title>Installation of GCC</title>
     45
     46    <para>Versions of GCC later than 4.3 will treat this build as if
     47    it were a relocated compiler and disallow searching for startfiles in
     48    the location specified by <parameter>--prefix</parameter>. Since this
     49    will not be a relocated compiler, and the startfiles in
     50    <filename class="directory">/tools</filename> are crucial to building
     51    a working compiler linked to the libs in <filename class="directory">/tools</filename>,
     52    apply the following patch which partially reverts GCC to its old behavior:</para>
     53
     54<screen><userinput remap="pre">patch -Np1 -i ../&gcc-startfiles-patch;</userinput></screen>
     55
     56    <para>Under normal circumstances the GCC <command>fixincludes</command> script
    7157    is run in order to fix potentially broken header files. As GCC-&gcc-version;
    7258    and Glibc-&glibc-version; have already been installed at this point, and
     
    8167sed 's@\./fixinc\.sh@-c true@' gcc/Makefile.in.orig &gt; gcc/Makefile.in</userinput></screen>
    8268
    83     <para>The bootstrap build performed in <xref linkend="ch-tools-gcc-pass1"/>
    84     built GCC with the <option>-fomit-frame-pointer</option> compiler flag.
    85     Non-bootstrap builds omit this flag by default, so apply the following
    86     <command>sed</command> to use it in order to ensure consistent compiler
    87     builds:</para>
     69    <para>Non-bootstrap builds omit the <option>-fomit-frame-pointer</option>
     70    build flag by default, and the goal should be to produce a compiler that is
     71    exactly the same as if it were bootstrapped. Apply the following
     72    <command>sed</command> command to force the build to use the flag:</para>
    8873
    8974<screen><userinput remap="pre">cp -v gcc/Makefile.in{,.tmp}
     
    9277
    9378    <para>The following command will change the location of GCC's default
    94     dynamic linker to use the one we installed in
     79    dynamic linker to use the one installed in
    9580    <filename class="directory">/tools</filename>. It also removes <filename
    9681    class="directory">/usr/include</filename> from GCC's include search path.
     
    10691  sed -e 's@/lib\(64\)\?\(32\)\?/ld@/tools&amp;@g' \
    10792  -e 's@/usr@/tools@g' $file.orig &gt; $file
    108   echo "
     93  echo '
    10994#undef STANDARD_INCLUDE_DIR
    110 #define STANDARD_INCLUDE_DIR 0" &gt;&gt; $file
     95#define STANDARD_INCLUDE_DIR 0
     96#define STANDARD_STARTFILE_PREFIX_1 ""
     97#define STANDARD_STARTFILE_PREFIX_2 ""' &gt;&gt; $file
    11198  touch $file.orig
    11299done</userinput></screen>
     
    121108    <quote>/lib64/ld</quote> or <quote>/lib32/ld</quote>, while the second one
    122109    replaces hard-coded instances of <quote>/usr</quote>. Then we add our define
    123     statements which alter the include search path to the end of the file. Finally,
    124     we use <command>touch</command> to update the timestamp on the copied files.
     110    statements which alter the include search path and the default startfile prefix
     111    to the end of the file.
     112    Finally, we use <command>touch</command> to update the timestamp on the copied files.
    125113    When used in conjunction with <command>cp -u</command>, this prevents unexpected
    126114    changes to the original files in case the command is inadvertently run twice.
    127115    </para>
    128116
    129     <para>Unsetting the multlib spec for GCC ensures that it
     117    <para>On x86_64, unsetting the multlib spec for GCC ensures that it
    130118    won't attempt to link against libraries on the host:</para>
    131119
    132 <screen><userinput remap="pre">for file in $(find gcc/config -name t-linux64) ; do \
    133    cp -v $file{,.orig}
    134    sed '/MULTILIB_OSDIRNAMES/d' $file.orig &gt; $file
    135 done</userinput></screen>
     120<screen><userinput remap="pre">case $(uname -m) in
     121  x86_64)
     122    for file in $(find gcc/config -name t-linux64) ; do \
     123      cp -v $file{,.orig}
     124      sed '/MULTILIB_OSDIRNAMES/d' $file.orig &gt; $file
     125    done
     126  ;;
     127esac</userinput></screen>
    136128
    137129    <para>As in the first build of GCC it requires the GMP and MPFR packages.
     
    153145    <para>Now prepare GCC for compilation:</para>
    154146
    155 <screen><userinput remap="configure">../gcc-&gcc-version;/configure --prefix=/tools \
     147<screen><userinput remap="configure">CC="$LFS_TGT-gcc -B/tools/lib/" \
     148    AR=$LFS_TGT-ar RANLIB=$LFS_TGT-ranlib \
     149    ../gcc-&gcc-version;/configure --prefix=/tools \
    156150    --with-local-prefix=/tools --enable-clocale=gnu \
    157151    --enable-shared --enable-threads=posix \
     
    228222<screen><userinput remap="make">make</userinput></screen>
    229223
    230     <para>Compilation is now complete. As previously mentioned, running the test
    231     suites for the temporary tools compiled in this chapter is not mandatory.
    232     To run the GCC test suite anyway, use the following command:</para>
    233 
    234 <screen><userinput remap="test">make -k check</userinput></screen>
    235 
    236     <para>The <parameter>-k</parameter> flag is used to make the test suite run
    237     through to completion and not stop at the first failure. The GCC test
    238     suite is very comprehensive and is almost guaranteed to generate a few
    239     failures.</para>
    240 
    241     <para>For a discussion of test failures that are of particular
    242     importance, please see <xref linkend="ch-system-gcc" role="."/></para>
    243 
    244224    <para>Install the package:</para>
    245225
    246226<screen><userinput remap="install">make install</userinput></screen>
    247227
    248     <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
    249     href="adjusting.xml"
    250     xpointer="xpointer(/sect1/caution[1])"/>
     228    <para>As a finishing touch, create a symlink. Many programs and scripts
     229    run <command>cc</command> instead of <command>gcc</command>, which is
     230    used to keep programs generic and therefore usable on all kinds of UNIX
     231    systems where the GNU C compiler is not always installed. Running
     232    <command>cc</command> leaves the system administrator free to decide
     233    which C compiler to install:</para>
     234
     235<screen><userinput remap="install">ln -vs gcc /tools/bin/cc</userinput></screen>
     236
     237  <caution>
     238    <para>At this point, it is imperative to stop and ensure that the basic
     239    functions (compiling and linking) of the new toolchain are working as
     240    expected. To perform a sanity check, run the following commands:</para>
     241
     242<screen><userinput>echo 'main(){}' &gt; dummy.c
     243cc dummy.c
     244readelf -l a.out | grep ': /tools'</userinput></screen>
     245
     246    <para>If everything is working correctly, there should be no errors,
     247    and the output of the last command will be of the form:</para>
     248
     249<screen><computeroutput>[Requesting program interpreter:
     250    /tools/lib/ld-linux.so.2]</computeroutput></screen>
     251
     252    <para>Note that <filename class="directory">/tools/lib</filename>, or
     253    <filename class="directory">/tools/lib64</filename> for 64-bit machines
     254    appears as the prefix of the dynamic linker.</para>
     255
     256    <para>If the output is not shown as above or there was no output at all,
     257    then something is wrong. Investigate and retrace the steps to find out
     258    where the problem is and correct it. This issue must be resolved before
     259    continuing on. First, perform the sanity check again, using
     260    <command>gcc</command> instead of <command>cc</command>. If this works,
     261    then the <filename class="symlink">/tools/bin/cc</filename> symlink is
     262    missing. Install the symlink as per above.
     263    Next, ensure that the <envar>PATH</envar> is correct. This
     264    can be checked by running <command>echo $PATH</command> and verifying that
     265    <filename class="directory">/tools/bin</filename> is at the head of the
     266    list. If the <envar>PATH</envar> is wrong it could mean that you are not
     267    logged in as user <systemitem class="username">lfs</systemitem> or that
     268    something went wrong back in <xref linkend="ch-tools-settingenviron"
     269    role="."/></para>
     270
     271    <para>Once all is well, clean up the test files:</para>
     272
     273<screen><userinput>rm -v dummy.c a.out</userinput></screen>
     274
     275  </caution>
    251276
    252277  </sect2>
  • chapter05/glibc.xml

    r6e88633 r4e82d47  
    4444    <title>Installation of Glibc</title>
    4545
    46     <para>Fix a potential issue if <filename>/etc/ld.so.preload</filename> is
    47     used on the host system.</para>
    48 
    49 <screen><userinput remap="pre">sed -i 's@/etc/ld.so.preload@/tools/etc/ld.so.preload@' elf/rtld.c</userinput></screen>
    50 
    5146    <para>The Glibc documentation recommends building Glibc outside of the source
    5247    directory in a dedicated build directory:</para>
     
    7267
    7368<screen><userinput remap="configure">../glibc-&glibc-version;/configure --prefix=/tools \
     69    --host=$LFS_TGT --build=$(../glibc-&glibc-version;/scripts/config.guess) \
    7470    --disable-profile --enable-add-ons \
    75     --enable-kernel=2.6.0 --with-binutils=/tools/bin \
    76     --without-gd --with-headers=/tools/include \
    77     --without-selinux</userinput></screen>
     71    --enable-kernel=2.6.0 --with-headers=/tools/include \
     72    libc_cv_forced_unwind=yes libc_cv_c_cleanup=yes</userinput></screen>
    7873
    7974    <variablelist>
    8075      <title>The meaning of the configure options:</title>
     76
     77      <varlistentry>
     78        <term><parameter>--host=$LFS_TGT, --build=$(../glibc-&glibc-version;/scripts/config.guess)</parameter></term>
     79        <listitem>
     80          <para>The combined effect of these switches is that Glibc's build system
     81          configures itself to cross-compile, using the cross-linker and
     82          cross-compiler in <filename class="directory">/tools</filename>.</para>
     83        </listitem>
     84      </varlistentry>
    8185
    8286      <varlistentry>
     
    105109
    106110      <varlistentry>
    107         <term><parameter>--with-binutils=/tools/bin</parameter></term>
    108         <listitem>
    109           <para>While not required, this switch ensures that there are
    110           no errors pertaining to which Binutils programs get used during the
    111           Glibc build.</para>
    112         </listitem>
    113       </varlistentry>
    114 
    115       <varlistentry>
    116         <term><parameter>--without-gd</parameter></term>
    117         <listitem>
    118           <para>This prevents the build of the <command>memusagestat</command>
    119           program, which insists on linking against the host's libraries
    120           (libgd, libpng, libz, etc.).</para>
    121         </listitem>
    122       </varlistentry>
    123 
    124       <varlistentry>
    125111        <term><parameter>--with-headers=/tools/include</parameter></term>
    126112        <listitem>
     
    132118
    133119      <varlistentry>
    134         <term><parameter>--without-selinux</parameter></term>
     120        <term><parameter>libc_cv_forced_unwind=yes</parameter></term>
    135121        <listitem>
    136           <para>When building from hosts that include SELinux functionality
    137           (e.g., Fedora Core 3), Glibc will build with support for SELinux.
    138           As the LFS tools environment does not contain support for SELinux, a
    139           Glibc compiled with such support will fail to operate correctly.</para>
     122          <para>The build requires support for forced unwind, but because it is
     123          being cross compiled, it cannot auto detect it. Setting this variable
     124          on the command line explicitly tells the configure script that support
     125          is available.</para>
     126        </listitem>
     127      </varlistentry>
     128      <varlistentry>
     129        <term><parameter>libc_cv_c_cleanup=yes</parameter></term>
     130        <listitem>
     131          <para>The build also requires support for C cleanup handling, which it
     132          cannot auto detect when being cross compiled. Enable it explicitly.</para>
    140133        </listitem>
    141134      </varlistentry>
     
    168161    run at this time because we do not have a C++ compiler yet.</para>
    169162
    170     <para>The install stage of Glibc will issue a harmless warning at the
    171     end about the absence of <filename>/tools/etc/ld.so.conf</filename>.
    172     Prevent this warning with:</para>
    173 
    174 <screen><userinput remap="install">mkdir -v /tools/etc
    175 touch /tools/etc/ld.so.conf</userinput></screen>
    176 
    177163    <para>Install the package:</para>
    178164
  • chapter05/toolchaintechnotes.xml

    r6e88633 r4e82d47  
    1515  understand everything in this section. Most of this information will be
    1616  clearer after performing an actual build. This section can be referred
    17   back to at any time during the process.</para>
     17  to at any time during the process.</para>
    1818
    1919  <para>The overall goal of <xref linkend="chapter-temporary-tools"/> is to
     
    5555  <itemizedlist>
    5656    <listitem>
    57       <para>The process is similar in principle to cross-compiling, whereby
    58       tools installed in the same prefix work in cooperation, and thus utilize
    59       a little GNU <quote>magic</quote></para>
     57      <para>Slightly adjusting the name of the working platform ensures that
     58      the first build of Binutils and GCC produces a compatible cross-linker
     59      and cross-compiler. Instead of producing binaries for another architecture,
     60      the cross-linker and cross-compiler will produce binaries compatible with
     61      the current hardware.</para>
    6062    </listitem>
    6163    <listitem>
    62       <para>Careful manipulation of the standard linker's library search path
    63       ensures programs are linked only against chosen libraries</para>
     64      <para>The temporary libraries are cross-compiled. This removes all
     65      dependency on the host system, lessens the chance of headers or libraries
     66      from the host corrupting the new tools and allows for the possibility of
     67      building both 32-bit and 64-bit libraries on 64-bit capable hardware.</para>
    6468    </listitem>
    6569    <listitem>
Note: See TracChangeset for help on using the changeset viewer.