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

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.

Contents

The GCC package contains compilers, preprocessors and the GNU C++ Library.

Description

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.

Preprocessor

A preprocessor 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.

C++ Library

The C++ library is used by C++ programs. The C++ library 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:


sh from the bash package

ar from the binutils package
as from the binutils package
ld from the binutils package
nm from the binutils package
ranlib from the binutils package

cmp from the diffutils package

chmod from the fileutils package
cp from the fileutils package
ln from the fileutils package
ls from the fileutils package
mkdir from the fileutils package
mv from the fileutils package
rm from the fileutils package
touch from the fileutils package

find from the find package

gcc from the gcc package
cc from the gcc package

egrep from the grep package
grep from the grep package

make from the make package

mawk from the mawk package

sed from the sed package

basename from the sh-utils package
echo from the sh-util package
expr from the sh-utils package
sleep from the sh-utils package
true from the sh-utils package
uname from the sh-utils package

tar from the tar package

makeinfo from the texinfo package

cat from the textutils package
head from the textutils package
sort from the textutils package
tail from the textutils package
tr from the textutils package
uniq from the textutils package