| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 | <sect1 id="ch-tools-gcc-pass1"><title>Installing GCC-&gcc-version; - Pass 1</title><?dbhtml filename="gcc-pass1.html" dir="chapter05"?><screen>&buildtime; &gcc-time-tools-pass1;&diskspace; &gcc-compsize-tools-pass1;</screen><literallayout>Official download location for GCC (&gcc-version;): <ulink url="ftp://ftp.gnu.org/pub/gnu/gcc/"/></literallayout>&aa-gcc-dep;<sect2><title> </title><para> </para></sect2><sect2><title>Installation of GCC</title><para>Unpack only the GCC-core tarball, as we won't be needing a C++ compilerfor the moment.</para><para>This package is known to behave badly when you have changed itsdefault optimization flags (including the -march and -mcpu options).Therefore, if you have defined any environment variables that overridedefault optimizations, such as CFLAGS and CXXFLAGS, we recommend unsettingor modifying 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-dir;/configure --prefix=/tools \    --with-local-prefix=/tools \    --disable-nls --enable-shared \    --enable-languages=c</userinput></screen><para>The meaning of the configure options:</para><itemizedlist><listitem><para><userinput>--with-local-prefix=/tools</userinput>: Thepurpose of this switch is to remove <filename>/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, thus making this a sensible thing to do.</para></listitem><listitem><para><userinput>--enable-shared</userinput>: 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 <command>gcc</command> binaries will still be linkedstatically, as this is controlled by the <command>-static</command>value of BOOT_LDFLAGS further on.</para></listitem><listitem><para><userinput>--enable-languages=c</userinput>: 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></itemizedlist><para>Continue with compiling the package:</para><screen><userinput>make BOOT_LDFLAGS="-static" bootstrap</userinput></screen><para>The meaning of the make parameters:</para><itemizedlist><listitem><para><userinput>BOOT_LDFLAGS="-static"</userinput>: This tellsGCC to link its programs statically.</para></listitem><listitem><para><userinput>bootstrap</userinput>: 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></itemizedlist><para>Compilation is now complete. This is the point where we would normallyrun the test suite. But as discussed earlier, we don't recommend running thetest suites for the temporary tools here in this chapter. However, even if westill wanted to run the GCC test suite, we're unable do so at this early stagebecause the test suite framework is not yet in place. Not only that, theprograms from this first pass will soon be overwritten by those installed inthe second pass.</para><para>And install the package:</para><screen><userinput>make install</userinput></screen><para>As a finishing touch we'll create the <filenameclass="symlink">/tools/bin/cc</filename> symlink. Many programs andscripts run <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><title> </title><para> </para><para>The details on this package are found in <xref linkend="contents-gcc"/>.</para><para> </para></sect2></sect1>
 |