[673b0d8] | 1 | <?xml version="1.0" encoding="ISO-8859-1"?>
|
---|
| 2 | <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
|
---|
| 3 | <!ENTITY % general-entities SYSTEM "../general.ent">
|
---|
| 4 | %general-entities;
|
---|
| 5 | ]>
|
---|
[3be4d97] | 6 | <sect1 id="ch-tools-gcc-pass1">
|
---|
[673b0d8] | 7 | <title>GCC-&gcc-version; - Pass 1</title>
|
---|
| 8 | <?dbhtml filename="gcc-pass1.html"?>
|
---|
[bc82645e] | 9 |
|
---|
[673b0d8] | 10 | <indexterm zone="ch-tools-gcc-pass1">
|
---|
| 11 | <primary sortas="a-GCC">GCC</primary>
|
---|
| 12 | <secondary>tools, pass 1</secondary></indexterm>
|
---|
[bc82645e] | 13 |
|
---|
[673b0d8] | 14 | <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="../chapter06/gcc.xml" xpointer="xpointer(/sect1/para[1])"/>
|
---|
[5888299] | 15 |
|
---|
[673b0d8] | 16 | <screen>&buildtime; 4.4 SBU
|
---|
| 17 | &diskspace; 300 MB</screen>
|
---|
| 18 |
|
---|
| 19 | <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="../chapter06/gcc.xml" xpointer="xpointer(/sect1/para[2])"/>
|
---|
[73aedd1d] | 20 |
|
---|
| 21 |
|
---|
| 22 | <sect2>
|
---|
| 23 | <title>Installation of GCC</title>
|
---|
| 24 |
|
---|
[ede9b9b] | 25 | <para>Unpack only the GCC-core tarball, as we won't be needing the C++ compiler
|
---|
[673b0d8] | 26 | nor the test suite here.</para>
|
---|
[73aedd1d] | 27 |
|
---|
[ede9b9b] | 28 | <para>This package is known to behave badly when you change its default
|
---|
| 29 | optimization flags (including the <emphasis>-march</emphasis> and
|
---|
| 30 | <emphasis>-mcpu</emphasis> options). Therefore, if you have defined any
|
---|
| 31 | environment variables that override default optimizations, such as CFLAGS and
|
---|
[673b0d8] | 32 | CXXFLAGS, we recommend un-setting them when building GCC.</para>
|
---|
[73aedd1d] | 33 |
|
---|
| 34 | <para>The GCC documentation recommends building GCC outside of the source
|
---|
| 35 | directory in a dedicated build directory:</para>
|
---|
| 36 |
|
---|
| 37 | <screen><userinput>mkdir ../gcc-build
|
---|
| 38 | cd ../gcc-build</userinput></screen>
|
---|
| 39 |
|
---|
[d27a27b] | 40 | <para>Prepare GCC for compilation:</para>
|
---|
[73aedd1d] | 41 |
|
---|
[673b0d8] | 42 | <screen><userinput>../gcc-&gcc-version;/configure --prefix=/tools \
|
---|
[9dfc02f] | 43 | --libexecdir=/tools/lib --with-local-prefix=/tools \
|
---|
| 44 | --disable-nls --enable-shared --enable-languages=c</userinput></screen>
|
---|
[73aedd1d] | 45 |
|
---|
| 46 | <para>The meaning of the configure options:</para>
|
---|
| 47 |
|
---|
| 48 | <itemizedlist>
|
---|
[17476c5] | 49 | <listitem><para><userinput>--with-local-prefix=/tools</userinput>: The
|
---|
[73aedd1d] | 50 | purpose of this switch is to remove <filename>/usr/local/include</filename>
|
---|
[90e3cb3] | 51 | from <command>gcc</command>'s include search path. This is not absolutely
|
---|
[73aedd1d] | 52 | essential; however, we want to try to minimize the influence of the host
|
---|
[673b0d8] | 53 | system, so this a sensible thing to do.</para></listitem>
|
---|
[73aedd1d] | 54 |
|
---|
| 55 | <listitem><para><userinput>--enable-shared</userinput>: This switch may
|
---|
| 56 | seem counter-intuitive at first. But using it allows the building of
|
---|
| 57 | <filename>libgcc_s.so.1</filename> and <filename>libgcc_eh.a</filename>, and
|
---|
| 58 | having <filename>libgcc_eh.a</filename> available ensures that the configure
|
---|
| 59 | script for Glibc (the next package we compile) produces the proper results.
|
---|
[90e3cb3] | 60 | Note that the <command>gcc</command> binaries will still be linked
|
---|
[ede9b9b] | 61 | statically, as this is controlled by the <emphasis>-static</emphasis>
|
---|
| 62 | value of BOOT_LDFLAGS in the next step.</para></listitem>
|
---|
[73aedd1d] | 63 |
|
---|
| 64 | <listitem><para><userinput>--enable-languages=c</userinput>: This option
|
---|
| 65 | ensures that only the C compiler is built. The option is only needed when you
|
---|
| 66 | have downloaded and unpacked the full GCC tarball.</para></listitem>
|
---|
| 67 | </itemizedlist>
|
---|
| 68 |
|
---|
| 69 | <para>Continue with compiling the package:</para>
|
---|
| 70 |
|
---|
| 71 | <screen><userinput>make BOOT_LDFLAGS="-static" bootstrap</userinput></screen>
|
---|
| 72 |
|
---|
| 73 | <para>The meaning of the make parameters:</para>
|
---|
| 74 |
|
---|
| 75 | <itemizedlist>
|
---|
| 76 | <listitem><para><userinput>BOOT_LDFLAGS="-static"</userinput>: This tells
|
---|
| 77 | GCC to link its programs statically.</para></listitem>
|
---|
| 78 |
|
---|
| 79 | <listitem><para><userinput>bootstrap</userinput>: This target doesn't just
|
---|
| 80 | compile GCC, but compiles it several times. It uses the programs compiled in
|
---|
| 81 | a first round to compile itself a second time, and then again a third time.
|
---|
| 82 | It then compares these second and third compiles to make sure it can
|
---|
| 83 | reproduce itself flawlessly, which most probably means that it was
|
---|
| 84 | compiled correctly.</para></listitem>
|
---|
| 85 | </itemizedlist>
|
---|
| 86 |
|
---|
[ede9b9b] | 87 | <para>Compilation is now complete, and at this point we would normally run the
|
---|
| 88 | test suite. But, as mentioned before, the test suite framework is not in place
|
---|
| 89 | yet. And there would be little point in running the tests anyhow, since the
|
---|
| 90 | programs from this first pass will soon be replaced.</para>
|
---|
[443cace] | 91 |
|
---|
[673b0d8] | 92 | <para>Now install the package:</para>
|
---|
[73aedd1d] | 93 |
|
---|
| 94 | <screen><userinput>make install</userinput></screen>
|
---|
| 95 |
|
---|
[ede9b9b] | 96 | <para>As a finishing touch we'll create a symlink. Many programs and scripts
|
---|
| 97 | run <command>cc</command> instead of <command>gcc</command>,
|
---|
[73aedd1d] | 98 | a thing meant to keep programs generic and therefore usable on all kinds of
|
---|
| 99 | Unix systems. Not everybody has the GNU C compiler installed. Simply running
|
---|
[90e3cb3] | 100 | <command>cc</command> leaves the system administrator free to decide what
|
---|
[73aedd1d] | 101 | C compiler to install, as long as there's a symlink pointing to it:</para>
|
---|
| 102 |
|
---|
[51fe215] | 103 | <screen><userinput>ln -s gcc /tools/bin/cc</userinput></screen>
|
---|
[73aedd1d] | 104 |
|
---|
| 105 | </sect2>
|
---|
[bc82645e] | 106 |
|
---|
[0868461] | 107 | <sect2><title/>
|
---|
[5888299] | 108 | <para>The details on this package are found in <xref linkend="contents-gcc"/>.</para>
|
---|
[0868461] | 109 | </sect2>
|
---|
[5888299] | 110 |
|
---|
[bc82645e] | 111 | </sect1>
|
---|