| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 | <?xml version="1.0" encoding="ISO-8859-1"?><!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [  <!ENTITY % general-entities SYSTEM "../general.ent">  %general-entities;]><sect1 id="ch-tools-gcc-pass1" role="wrap"><title>GCC-&gcc-version; - Pass 1</title><?dbhtml filename="gcc-pass1.html"?><indexterm zone="ch-tools-gcc-pass1"><primary sortas="a-GCC">GCC</primary><secondary>tools, pass 1</secondary></indexterm><sect2 role="package"><title/><xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="../chapter06/gcc.xml" xpointer="xpointer(/sect1/sect2[1]/para[1])"/><segmentedlist><segtitle>&buildtime;</segtitle><segtitle>&diskspace;</segtitle><seglistitem><seg>4.4 SBU</seg><seg>300 MB</seg></seglistitem></segmentedlist><xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="../chapter06/gcc.xml" xpointer="xpointer(/sect1/sect2[1]/segmentedlist[2])"/></sect2><sect2 role="installation"><title>Installation of GCC</title><para>Unpack only the GCC-core tarball, as we won't be needing the C++ compilernor the test suite here.</para><para>This package is known to behave badly when you change its defaultoptimization flags (including the <parameter>-march</parameter> and<parameter>-mcpu</parameter> options). Therefore, if you have defined anyenvironment variables that override default optimizations, such as CFLAGS andCXXFLAGS, we recommend un-setting them when building GCC.</para><para>The GCC documentation recommends building GCC outside of the sourcedirectory in a dedicated build directory:</para><screen><userinput>mkdir ../gcc-buildcd ../gcc-build</userinput></screen><para>Prepare GCC for compilation:</para><screen><userinput>../gcc-&gcc-version;/configure --prefix=/tools \    --libexecdir=/tools/lib --with-local-prefix=/tools \    --disable-nls --enable-shared --enable-languages=c</userinput></screen><para>The meaning of the configure options:</para><variablelist><varlistentry><term><parameter>--with-local-prefix=/tools</parameter></term><listitem><para>The purpose of this switch is to remove <filename class="directory">/usr/local/include</filename>from <command>gcc</command>'s include search path. This is not absolutelyessential; however, we want to try to minimize the influence of the hostsystem, so this a sensible thing to do.</para></listitem></varlistentry><varlistentry><term><parameter>--enable-shared</parameter></term><listitem><para>This switch mayseem counter-intuitive at first. But using it allows the building of<filename>libgcc_s.so.1</filename> and <filename>libgcc_eh.a</filename>, andhaving <filename>libgcc_eh.a</filename> available ensures that the configurescript for Glibc (the next package we compile) produces the proper results.Note that the GCC binaries will still be linkedstatically, as this is controlled by the <parameter>-static</parameter>value of BOOT_LDFLAGS in the next step.</para></listitem></varlistentry><varlistentry><term><parameter>--enable-languages=c</parameter></term><listitem><para>This optionensures that only the C compiler is built. The option is only needed when youhave downloaded and unpacked the full GCC tarball.</para></listitem></varlistentry></variablelist><para>Continue with compiling the package:</para><screen><userinput>make BOOT_LDFLAGS="-static" bootstrap</userinput></screen><para>The meaning of the make parameters:</para><variablelist><varlistentry><term><parameter>BOOT_LDFLAGS="-static"</parameter></term><listitem><para>This tells GCC to link its programs statically.</para></listitem></varlistentry><varlistentry><term><parameter>bootstrap</parameter></term><listitem><para>This target doesn't justcompile GCC, but compiles it several times. It uses the programs compiled ina first round to compile itself a second time, and then again a third time.It then compares these second and third compiles to make sure it canreproduce itself flawlessly, which most probably means that it wascompiled correctly.</para></listitem></varlistentry></variablelist><para>Compilation is now complete, and at this point we would normally run thetest suite. But, as mentioned before, the test suite framework is not in placeyet. And there would be little point in running the tests anyhow, since theprograms from this first pass will soon be replaced.</para><para>Now install the package:</para><screen><userinput>make install</userinput></screen><para>As a finishing touch we'll create a symlink. Many programs and scriptsrun <command>cc</command> instead of <command>gcc</command>,a thing meant to keep programs generic and therefore usable on all kinds ofUnix systems. Not everybody has the GNU C compiler installed. Simply running<command>cc</command> leaves the system administrator free to decide whatC compiler to install, as long as there's a symlink pointing to it:</para><screen><userinput>ln -s gcc /tools/bin/cc</userinput></screen></sect2><sect2 role="content"><title/><para>The details on this package are found in <xref linkend="contents-gcc"/>.</para></sect2></sect1>
 |