%general-entities; ]> gcc &gcc-version;
&gcc-url;
GCC-&gcc-version; - Pass 1 GCC tools, pass 1 <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>&gcc-ch5p1-sbu;</seg> <seg>&gcc-ch5p1-du;</seg> </seglistitem> </segmentedlist> </sect2> <sect2 role="installation"> <title>Installation of GCC The GCC documentation recommends building GCC outside of the source directory in a dedicated build directory: mkdir -v ../gcc-build cd ../gcc-build Set the --with-arch flag if the machine is x86: test $(uname -m | grep i?86) && WITHARCH="--with-arch=i486" Prepare GCC for compilation: CC="gcc -B/usr/bin/" ../gcc-&gcc-version;/configure --prefix=/tools \ --with-local-prefix=/tools --disable-nls --disable-shared \ --enable-languages=c --disable-multilib \ $WITHARCH unset WITHARCH The meaning of the configure options: CC="gcc -B/usr/bin/" This forces gcc to prefer the linker from the host in /usr/bin. This is necessary on some hosts where the new ld built in the previous section is not compatible with the host's gcc. --with-local-prefix=/tools The purpose of this switch is to remove /usr/local/include from gcc's include search path. This is not absolutely essential, however, it helps to minimize the influence of the host system. --disable-shared This forces gcc to link its internal libraries statically. We do this to avoid possible issues with the host system. --enable-languages=c This option ensures that only the C compiler is built. --disable-multilib We currently only want to build support for 64-bit libraries. --with-arch=i486 On x86 machines Glibc-&glibc-version; needs to be built for a minimum architecture of i486. In fact, Glibc developers suggest setting the compiler flag -march=i486 when compiling it. However, by using the above parameter for the GCC build, we can set a default value for -march at the compiler level, ensuring that the entire system is built consistently, i.e., for the same cpu-type. Of course, values greater or more specific than i486 could be used. See man gcc for other acceptable cpu-types. Keep in mind that using an incompatible cpu-type for the machine will result in breakage. The advantage of i486 is that it is a generic option and will work for all modern x86 machines. The following command will compile GCC not once, but several times. It uses the programs compiled in a 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 can reproduce itself flawlessly. This is called bootstrapping. Building GCC in this way ensures that it was compiled correctly and is now the default configuration for the released package. Continue with compiling by running: make Compilation is now complete. At this point, the test suite would normally be run, but, as mentioned before, the test suite framework is not in place yet. The benefits of running the tests at this point are minimal since the programs from this first pass will soon be replaced. Install the package: make install Using --disable-shared means that the file libgcc_eh.a isn't created and installed. The next package, Glibc, depends on this library as it uses -lgcc_eh within its build system. We can satisfy that dependency by creating a symlink to libgcc.a, since that file will end up containing the objects normally contained in libgcc_eh.a. ln -vs libgcc.a `gcc -print-libgcc-file-name | \ sed 's/libgcc/&_eh/'` As a finishing touch, create a symlink. Many programs and scripts run cc instead of gcc, which is used to keep programs generic and therefore usable on all kinds of UNIX systems where the GNU C compiler is not always installed. Running cc leaves the system administrator free to decide which C compiler to install: ln -vs gcc /tools/bin/cc <para>Details on this package are located in <xref linkend="contents-gcc" role="."/></para> </sect2> </sect1>