Estimated build time: 3.9 SBU Estimated required disk space: 326 MB |
(Last checked against version 3.1.)
The GCC package contains the GNU compiler collection, including the C and C++ compilers.
GCC installs the following files:
c++, c++filt, cc (link to gcc), cc1, cc1plus, collect2, cpp, cpp0, g++, gcc, gccbug, gcov and tradcpp0
libgcc.a, libgcc_eh.a, libgcc_s.so, libiberty.a, libstdc++.[a,so], libsupc++.a
(Last checked against version 2.95.3.)
Bash: sh
Binutils: ar, as, ld, nm, ranlib
Coreutils: basename, cat, chmod, cp, dirname, echo, expr, hostname, ln
ls, mkdir, mv, rm, sleep, tail, touch, tr, true, uname
Diffutils: cmp
Find: find
GCC: cc, cc1, collect2, cpp0, gcc
Grep: egrep, grep
Make: make
Sed: sed
Tar: tar
Texinfo: install-info, makeinfo
Unpack only the GCC-core tarball, as we won't be needing a C++ compiler for the moment.
Note: Even though GCC is an important toolchain package, we are not going to run the testsuite at this early stage. First, the testsuite framework is not yet in place and second, the programs from this first pass will soon be overwritten by those installed in the second pass.
This package is known to behave badly when you have changed its default optimization flags (including the -march and -mcpu options). Therefore, if you have defined any environment variables that override default optimizations, such as CFLAGS and CXXFLAGS, we recommend unsetting or modifying them when building GCC.
It is recommended by the GCC installation documentation to build GCC outside of the source directory in a dedicated directory:
mkdir ../gcc-build cd ../gcc-build |
Prepare GCC to be compiled:
../gcc-3.3.1/configure --prefix=/tools \ --with-local-prefix=/tools \ --disable-nls --enable-shared \ --enable-languages=c |
The meaning of the new configure options:
--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, we want to try to minimize the influence of the host system, thus making this a sensible thing to do.
--enable-shared: This switch may seem counter-intuitive at first. But using it allows the building of libgcc_s.so.1 and libgcc_eh.a, and having libgcc_eh.a available ensures that the configure script for Glibc (the next package we compile) produces the proper results. Note that the gcc binaries will still be linked statically, as this is controlled by the -static value of BOOT_LDFLAGS further on.
--enable-languages=c: This option ensures that only the C compiler is built. The option is only needed when you have downloaded and unpacked the full GCC tarball.
Continue with compiling the package:
make BOOT_LDFLAGS="-static" bootstrap |
The meaning of the make parameters:
BOOT_LDFLAGS="-static": This tells GCC to link its programs statically.
bootstrap: This target doesn't just compile GCC, but compiles it 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, which most probably means that it was compiled correctly.
And install the package:
make install |
As a finishing touch we'll create the /tools/bin/cc symlink. Many programs and scripts run cc instead of gcc, a thing meant to keep programs generic and therefore usable on all kinds of Unix systems. Not everybody has the GNU C compiler installed. Simply running cc leaves the system administrator free to decide what C compiler to install, as long as there's a symlink pointing to it:
ln -sf gcc /tools/bin/cc |