Table of Contents
Gnu Compiler Collection
Here are some hints about the Gcc compiler. The main purpose of this page is to help my bad memory.
Installation
Gcc manages sources throught a SVN repository, located at svn://gcc.gnu.org/svn/gcc. There exists several development branches, the main, as usual, is located in the trunk
branch.
To get your copy of the latest Gcc sources, performs a checkout:
svn checkout svn://gcc.gnu.org/svn/gcc/trunk gcc-trunk
The compiler is installed using standard Gnu tools:
./configure make make install
Here are a list of usefull configure options:
–prefix
installation prefix–enable-languages=lang[,lang]*
compilers/runtimes to generates–disable-nls
disable Native Language Support
This example configures Gcc to be installed in the $MY_GCC_ROOT
directory. The compiler will be built with C and Fortran support, while Native Language Support is disabled.
./configure --prefix=$MY_GCC_ROOT \ --enable-languages=c,fortran \ --disable-nls
After configuration, the compiler building process is started with the make
command. If you have enought computational power, a parallel build can be performed:
make -j 17
On many cases the number of parallel workers can be set to twice the number of cpus/cores plus one.
On a two-cpu, quad-core Intel Xeon 2 Ghz the compilation process took approximatly 20 minutes.
At last, the compiler is installed throught the make install
command.
Source Tree Layout
The source tree contains both compiler and runtime sources.
By compiler we intend the various front-ends, optization passes and back-ends. They can be found in the gcc
directory.
In the other hand, directories starting with the lib
prefix seem contain libraries helping gcc providing translation and runtime services.
The following table summarize some of them:
Directory | Contains |
---|---|
libcpp | the C pre-processor |
libgcc | functionalities that cannot be covered with assembly |
libgomp | the Gnu implementation of the Omp runtime |
libgcc
Some functionalities, for example a call to memcmp
, may or may be not handled through direct assembly generation. For example, in an architecute there exists a MEMCMP
instructions, allowing to map the call to memcp
to this instruction. On other architectures, in order to provide an implementation of memcmp
, the compiler emit a call to a custom version of memcmp
, provided by itself.
The implementation of these routines are provided through the libgcc library.
libgomp
Contains the implementation of the Omp runtime. The main interface, knonw as Gnu Omp, is exposed through the libgomp.h
file.
In the root directory, it is possible to find all architecture-indipendent code. The sources of a specific architecture, like locks or barriers low-level implementations, are stored in the config
subdirectory.
For example the barrier.c
file implements the GOMP_barrier
functions, who uses gmp_team_barrier_wait
to wait other threads at a barrier. This function is implemented many times, one for each architecture.
There can be multiple level of indirections. Indeed the linux
architecture contains processor-specific code, that is isolated in a private directory (e.g linux/x86
).