Tuesday, July 8, 2008

Bootstrapping GCC-4.x.x: Prerequisites

In this post, I will be discussing the general process of compiling GCC, along with how to obtain the necessary source code for GCC and its prerequisites.

Bootstrapping a compiler is the process of building the compiler from source code that is written in the target computing language itself with minimal external resources. Therefore, when bootstrapping GCC-4.x.x, the system must containing a working C compiler and some pre-requisite libraries.

For the GCC-4.3.x series of compilers, the pre-requisite libraries are the GNU Multi-Precision Arithmetic library (GMP-4.1+) and the Multi-Precision Floating-Point with Rounding library (MPFR-2.3.0+). Earlier version of GCC-4.x.x only required these libraries when building the GCC GFORTRAN compiler; however, in all recent GCC versions, these libraries are required for building the compiler. Many modern UNIX/Linux systems come with these libraries pre-installed, however you must be sure to check the version of the included libraries against the version requirements for the specific GCC-4.x.x compiler you desire to bootstrap. Some of the older versions of these libraries contain bugs that can adversely affect the accuracy of the resulting bootstrapped compiler. The version numbers for the preinstalled prerequisite libraries can be found in the header files, gmp.h and mpfr.h, respectively.

GCC-4.x.x is an open source compiler collection know as the Gnu Compiler Collection (GCC), whose homepage is locate at http://gcc.gnu.org. The GCC homepage contains a wealth of information straight from the developer and user community. To download the desired version of GCC, just follow the appropriate links on the GCC homepage to one of the many ftp or http mirror sites. The source code comes in the form of a compressed tarball ending in ".tar.bz2". Once the source has been downloaded to your computer, put it in a build folder with a name such as "BuildDir" and expand the tarball with the following command: "tar -xjvf gcc_tarball_name.tar.bz2".

The GMP is another opensource project, whose homepage is located at http://gmplib.org. Just following the links on the homepage to download the desired GMP source code. Move the tarball to your "BuildDir" and expand the tarball. If the tarball ends with ".tar.gz", it can be expanded with the command: "tar -xzvf source_name.tar.gz". Similarly, MPFR is also an open source project, with it's homepage located at http://www.mpfr.org. Again, follow the links to download the appropriate source, move it to your "BuildDir", and expand the tarball.

Congratulations, you now have all the necessary source code to bootstrap GCC. In my next post, I will walk you through compiling and checking both the GMP and the MPFR libraries. I will also shared some of my experiences and tips for avoiding trouble down the road.

Until next time, God Bless and Have a great day!!!

No comments: