, , , , , ,

GCC supports two types of builds: combined-tree and separate-tree.

A combined-tree consists of all the source trees of gcc and binutils/gdb/newlib/pre-requisite libraries. This can be created by simply merging all the source trees in the respective order.

GCC, binutils etc., share the same top-level configure script and Makefile. However, in order to create a combined-tree, one must use sources from the same date, as there are various shared directories (include, libiberty), and they have to be the same. If you try to mix source trees from different dates, such as from different official releases, build may fail. You have been warned.

For a separate-tree build, you build the different components separately.

Our Scope : We will now look at a native combined-tree bootstrap build of gcc, binutils, GMP, MPFR, MPC, ISL, CLOOG on i686-pc-linux-gnu and testing the default testsuite of C,C++ using dejagnu test framework after the successful build.

The source archives used:

GCC 4.8.3 (gcc-4.8.3.tar.bz2), Binutils (binutils-2.24.tar.bz2), GMP (gmp-5.1.3.tar.bz2), MPFR (mpfr-3.1.2.tar.bz2), MPC (mpc-1.0.1.tar.bz2), ISL (isl-0.12.2.tar.bz2), CLOOG(cloog-0.18.1.tar.gz).

Combined-tree build:

Download all the source archives into a directory.

$ mkdir localbuild-gcc-4-8-3

Un-tar all the archives in this directory.

$ cd localbuild-gcc-4-8-3
localbuild-gcc-4-8-3$ tar -jxf gcc-4.8.3.tar.bz2
localbuild-gcc-4-8-3$ tar -jxf binutils-2.24.tar.bz2
localbuild-gcc-4-8-3$ tar -jxf gmp-5.1.3.tar.bz2
localbuild-gcc-4-8-3$ tar -jxf mpfr-3.1.2.tar.bz2
localbuild-gcc-4-8-3$ tar -jxf mpc-1.0.1.tar.bz2
localbuild-gcc-4-8-3$ tar -jxf isl-0.12.2.tar.bz2
localbuild-gcc-4-8-3$ tar -xzf cloog-0.18.1.tar.gz

Create a dir ‘combined’ where symlinks to the source trees to be created

localbuild-gcc-4-8-3$ mkdir combined && cd combined

#Create symlinks to the gcc source tree - Files in the gcc tree are master copy.
#So, maintain the following order without fail.  
localbuild-gcc-4-8-3/combined$ ln -s ../gcc-4.8.3/* .

#Create symlinks to the binutils source tree. Ignore several complaints from ln about existing links
localbuild-gcc-4-8-3/combined$ ln -s ../binutils-2.24/* .

#Create symlinks to GMP,MPFR,MPC,ISL,CLOOG source trees without version numbers in links
localbuild-gcc-4-8-3/combined$ ln -s ../gmp-5.1.3 gmp 
localbuild-gcc-4-8-3/combined$ ln -s ../mpfr-3.1.2 mpfr 
localbuild-gcc-4-8-3/combined$ ln -s ../mpc-1.0.1 mpc 
localbuild-gcc-4-8-3/combined$ ln -s ../isl-0.12.2 isl 
localbuild-gcc-4-8-3/combined$ ln -s ../cloog-0.18.1 cloog 

Combined tree is ready now.

Create a ‘build’ dir outside the combined-tree source. Configure & Build GCC from ‘build’ dir

localbuild-gcc-4-8-3/combined$ cd .. 
localbuild-gcc-4-8-3$ mkdir build && cd build  

#Export build environment variables. For native build, host=build=target

#To know host info, use config.guess script 
localbuild-gcc-4-8-3/build$ ../combined/config.guess

localbuild-gcc-4-8-3/build$ export host=i686-pc-linux-gnu
localbuild-gcc-4-8-3/build$ export build=$host
localbuild-gcc-4-8-3/build$ export target=$host
localbuild-gcc-4-8-3/build$ export prefix=/usr/local/gcc-4-8-3 

#Configure - Enabling 'C','C++' languages
#Configuring combined-tree - Since it includes binutils, --enable-shared NOT to be used. Build fails in stage2 if this option is used. You have been warned.
localbuild-gcc-4-8-3/build$ ../combined/configure --host=$host --build=$build --target=$target --prefix=/usr/local/gcc-4-8-3 --disable-nls --disable-werror --disable-multilib --enable-__cxa_atexit --enable-c99 --enable-long-long --enable-threads=posix --enable-checking=release --enable-libstdcxx-time --enable-languages=c,c++

#Parallel Build
localbuild-gcc-4-8-3/build$ make -j 2

Combined-tree build of gcc,binutils should succeed now.

Testing and Installing
To test the testsuites of C,C++ present in the source tree, dejagnu test framework should be installed.
dejagnu test framework requirements: tcl, expect, dejagnu, autogen

Run the testsuites

#make -j N is for parallel build
#make -k check. This is to instruct - DO NOT stop, even if some errors are encountered during testing.
localbuild-gcc-4-8-3/build$ make -j 2 -k check

#Running the testsuites will take a long time (~2 hrs).

#While running the testsuite, DejaGnu might emit some harmless messages resembling ‘WARNING: Couldn't find the global #config file.’ or ‘WARNING: Couldn't find tool init file’ that can be ignored.

#Install the toolchain
localbuild-gcc-4-8-3/build$ make install 

Test Results:

#To check test results, use 'contrib/test_summary' shell script present in combined-tree.
#This should be run in 'build' dir.
localbuild-gcc-4-8-3/build$ ../combined/contrib/test_summary

All the test results will be displayed on the shell.