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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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>
Note: See TracChangeset for help on using the changeset viewer.