Installing GCC-2.95.3

Estimated build time:           22 minutes
Estimated required disk space:  168 MB

Installation of GCC

This package is known to behave badly when you have changed its default optimization flags (including the -march and -mcpu options). GCC is best left alone, so we recommend you unsetting CFLAGS, CXXFLAGS and other such variables/settings that would change the default optimization that it comes with.

Install GCC by running the following commands:

patch -Np1 -i ../gcc-2.95.3-2.patch &&
mkdir ../gcc-build &&
cd ../gcc-build &&
../gcc-2.95.3/configure --prefix=/usr --enable-languages=c,c++ \
   --disable-nls --disable-shared --enable-threads=posix &&
make BOOT_LDFLAGS=-static bootstrap &&
make prefix=$LFS/usr install &&
cd $LFS/lib &&
ln -sf ../usr/bin/cpp &&
cd $LFS/usr/lib &&
ln -sf ../bin/cpp &&
cd $LFS/usr/bin &&
ln -sf gcc cc &&
rmdir $LFS/usr/*-gnu/include &&
rmdir $LFS/usr/*-gnu

Command explanations

patch -Np1 -i ../gcc-2.95.3-2.patch: This new patch deals with incorrect handling of weak symbols, the over-optimization of calls to those weak symbols, an atexit issue and the __dso_handle symbol required for atexit's proper function.

make BOOT_LDFLAGS=-static: This is the equivalent to make LDFLAGS=-static as we use with other packages to compile them statically.

--prefix=/usr: This is NOT a typo. GCC hard codes some paths while compiling and so we need to pass /usr as the prefix during ./configure. We pass the real install prefix during the make install command later.

--enable-languages=c,c++: This only builds the C and C++ compilers and not the other available compilers as they are, on the average, not often used. If those other compilers are needed, the --enable-languages parameter can be omitted.

--enable-threads=posix: This enables C++ exception handling for multithreaded code.

ln -sf ../usr/bin/cpp: This creates the $LFS/lib/cpp symlink. Some packages explicitly try to find cpp in /lib.

ln -sf ../bin/cpp: This creates the $LFS/usr/lib/cpp symlink as there are packages that expect cpp to be in /usr/lib.

rmdir $LFS/usr/*-gnu/include and rmdir $LFS/usr/*-gnu: These directories are created as empty directories by GCC and serve absolutely no purpose whatsoever. It's related to cross-compilers but that doesn't apply to us and it's considered a bug in GCC that you can't turn that off, especially since they end up being empty directories. So we remove them manually.

Contents of gcc-2.95.3

Program Files

c++, c++filt, cc (link to gcc), cc1, cc1plus, collect2, cpp, cpp0, g++, gcc, gcov, protoize and unprotoize

Descriptions

cc, cc1, cc1plus, gcc

These are the C compiler. A compiler translates source code in text format to a format that a computer understands. After a source code file is compiled into an object file, a linker will create an executable file from one or more of these compiler generated object files.

c++, cc1plus, g++

These are the C++ compiler; the equivalent of cc and gcc etc.

c++filt

c++filt is used to demangle C++ symbols.

collect2

No description is currently available.

cpp, cpp0

cpp pre-processes a source file, such as including the contents of header files into the source file. It's a good idea to not do this manually to save a lot of time. Someone just inserts a line like #include <filename>. The preprocessor inserts the contents of that file into the source file. That's one of the things a preprocessor does.

gcov

No description is currently available.

protoize

Optional additional program which converts old-style pre-ANSI functions or definitions to new-style ANSI C prototypes. (default file for looking known ones up is /usr/lib/gcc-lib/<arch>/<version>/SYSCALLS.c.X)

unprotoize

Optional additional program which converts prototypes made by protoize back to original old-style pre-ANSI (correct job only when converted before with protoize)

Library Files

libgcc.a, libiberty.a, libstdc++.[a,so]

libgcc

libgcc.a is a run-time support file for gcc.Most of the time, on most machines, libgcc.a is not actually necessary.

libiberty

libiberty is a collection of subroutines used by various GNU programs including getopt, obstack, strerror, strtol and strtoul.

libstdc++

libstdc++ is the C++ library. It is used by C++ programs and contains functions that are frequently used in C++ programs. This way the programmer doesn't have to write certain functions (such as writing a string of text to the screen) from scratch every time he creates a program.

Dependencies

GCC-2.95.3 needs the following to be installed:


bash: sh
binutils: ar, as, ld, nm, ranlib
diffutils: cmp
fileutils: chmod, cp, ln, ls, mkdir, mv, rm, touch
find: find
gcc: cc, cc1, collect2, cpp0, gcc
grep: egrep, grep
make: make
patch: patch
sed: sed
sh-utils: basename, dirname, echo, expr, hostname, sleep, true, uname
tar: tar
texinfo: install-info, makeinfo
textutils: cat, tail, tr