Table of Contents

Installing or Building Compilers


This page regroups the commands to build GCC or related to other compilers. If you get an error using these instructions, do not hesitate to mail me.

Few notes before we start :

 echo | gcc -v -x c -E - 


Building GCC


To build GCC, you need another GCC and 3 libraries: GMP, MPFR, and MPC.
Note that all instructions are provided here : http://gcc.gnu.org/install/index.html
I strongly recommend referring to these instructions if you encounter any problem. Note that the documentation to build Graphite GCC is not complete.

I suggest starting with the default libraries furnished by the GCC team, available at : ftp://gcc.gnu.org/pub/gcc/infrastructure/

If you are on a console, here are the exact files locations :
ftp://gcc.gnu.org/pub/gcc/infrastructure/gmp-4.3.2.tar.bz2
ftp://gcc.gnu.org/pub/gcc/infrastructure/mpfr-2.4.2.tar.bz2
ftp://gcc.gnu.org/pub/gcc/infrastructure/mpc-0.8.1.tar.gz

If you want using new versions of these libraries, the web sites are :
http://gmplib.org/
http://www.mpfr.org/
http://www.multiprecision.org/

Now, download your GCC from ftp://gcc.gnu.org/pub/gcc/releases/
We will use here the GCC 4.6.3: ftp://gcc.gnu.org/pub/gcc/releases/gcc-4.6.3/gcc-4.6.3.tar.bz2

There are now two ways to do it, with pro and cons :

For information, my GCC and Kernel version used to build here are :

$ gcc --version
gcc (GCC) 4.4.6 20110731 (Red Hat 4.4.6-3)
$ uname -a
Linux Gorky 2.6.32-220.el6.x86_64 GNU/Linux


Simple Build


First method consist in extracting GCC and then extracting all of the 3 libraries inside the GCC source directory and rename them as gmp, mpfr and mpc :

mkdir $HOME/GCC-BUILD
cd $HOME/GCC-BUILD
wget ftp://gcc.gnu.org/pub/gcc/releases/gcc-4.6.3/gcc-4.6.3.tar.bz2
tar jxvf gcc-4.6.3.tar.bz2
cd gcc-4.6.3
wget ftp://gcc.gnu.org/pub/gcc/infrastructure/gmp-4.3.2.tar.bz2
tar jxvf gmp-4.3.2.tar.bz2
mv gmp-4.3.2 gmp
wget ftp://gcc.gnu.org/pub/gcc/infrastructure/mpfr-2.4.2.tar.bz2
tar jxvf mpfr-2.4.2.tar.bz2
mv mpfr-2.4.2 mpfr
wget ftp://gcc.gnu.org/pub/gcc/infrastructure/mpc-0.8.1.tar.gz
tar jxvf mpc-0.8.1.tar.gz
mv mpc-0.8.1 mpc

Then, GCC should never be built inside its source directory, configure and build in another directory :

mkdir ../build
cd ../build

We suppose you want to install GCC in /soft/gcc-4.6.3, and that you want C, C++ and FORTRAN. I voluntary disabled multilib, because I suppose you are on a x64 (64bits) system and already have a GCC installed and glibc with it. No need to add support for x86 (32bits) for this new GCC. Note also that if you want to know how your previous GCC was build, you can use :

 echo | gcc -v -x c -E -

Now, configure :

../gcc-4.6.3/./configure --prefix=/soft/gcc-4.6.3 --enable-languages=c,c++,objc,obj-c++,fortran --disable-multilib

After this, if everything is OK, launch the compilation, using: make
or if you want to use all of your CPU cores :

export NUM_CORES=`cat /proc/cpuinfo | grep processor | wc -l`
make -j $NUM_CORES

This step is long, because for its safety, GCC will compile himself once, and then compile itself twice to confirm its integrity. 3 steps then.

After, check that your GCC is correct, using :

make -k check

And to finish, if the check ran without errors, install it :

make install

Now, to use your new GCC, you simply need to export few environment variables :

export GCCHOME=/soft/gcc-4.6.3
export  PATH=/soft/gcc-4.6.3/bin:$PATH
export  MANPATH=/soft/gcc-4.6.3/share/man:$MANPATH
export  LD_LIBRARY_PATH=/soft/gcc-4.6.3/lib64:$LD_LIBRARY_PATH
export COMPILER=gcc
export COMPILER_VER=4.6.3
export CC=gcc
export CXX=g++
export F77=gfortran
export F90=gfortran
export FC=gfortran

Check if everything is correct :

which gcc; gcc --version

Note that these variables will last until you close your terminal session. You can add them in your shell init file (for bash: .bashrc, for csh: .cshrc, etc) to make it permanent.


Standard Build


Second method is recommended for HPC users: building everything separately, in a certain order.

cd $HOME
wget ftp://gcc.gnu.org/pub/gcc/infrastructure/gmp-4.3.2.tar.bz2
tar jxvf gmp-4.3.2.tar.bz2
cd gmp-4.3.2
./configure --prefix=/soft/gmp/4.3.2 --enable-cxx
make -j 8
make check
make install
cd ..
 
wget ftp://gcc.gnu.org/pub/gcc/infrastructure/mpfr-2.4.2.tar.bz2
tar jxvf mpfr-2.4.2.tar.bz2
cd mpfr-2.4.2
./configure --prefix=/soft/mpfr/2.4.2 --with-gmp=/soft/gmp/4.3.2
make -j 8
make check
make install
cd ..
 
wget ftp://gcc.gnu.org/pub/gcc/infrastructure/mpc-0.8.1.tar.gz
tar jxvf mpc-0.8.1.tar.gz
cd mpc-0.8.1
./configure --prefix=/soft/mpc/0.8.1 --with-gmp=/soft/gmp/4.3.2 --with-mpfr=/soft/mpfr/2.4.2
make -j 8
make check
make install
cd ..

Add libs to environment variable, do not forget this step :

export LD_LIBRARY_PATH=/soft/gmp/4.3.2/lib:/soft/mpfr/2.4.2/lib:/soft/mpc/0.8.1/lib:$LD_LIBRARY_PATH
 
wget ftp://gcc.gnu.org/pub/gcc/releases/gcc-4.6.3/gcc-4.6.3.tar.bz2
tar jxvf gcc-4.6.3.tar.bz2
cd gcc-4.6.3
../gcc-4.6.3/./configure --prefix=/soft/gcc-4.6.3 --enable-languages=c,c++,objc,obj-c++,fortran --disable-multilib --with-gmp=/soft/gmp/4.3.2 --with-mpfr=/soft/mpfr/2.4.2 --with-mpc=/soft/mpc/0.8.1
make -j 8
make -k check
make install

Again, to use this GCC, just add it to environment variables :

export GCCHOME=/soft/gcc-4.6.3
export  PATH=/soft/gcc-4.6.3/bin:$PATH
export  MANPATH=/soft/gcc-4.6.3/share/man:$MANPATH
export  LD_LIBRARY_PATH=/soft/gcc-4.6.3/lib64:$LD_LIBRARY_PATH
export COMPILER=gcc
export COMPILER_VER=4.6.3
export CC=gcc
export CXX=g++
export F77=gfortran
export F90=gfortran
export FC=gfortran


Graphite Build


Last way to build GCC is to build a Graphite GCC. BEWARE ! This GCC is experimental, and tricky to build, use it only if needed. The following documentation can be found on GCC web site : http://gcc.gnu.org/wiki/Graphite_Build. However, it lacks some important parts. To build Graphite GCC, you need to use the second method, with 2 additional libraries: PPL and Cloog For PPL.
http://www.cloog.org/
http://bugseng.com/products/ppl/

I strongly recommend using the ones provided by GCC, they do not seems to be compatible at first use, but they are, trust me.

Here we go, restart from scratch, and follow these steps without omitting anything (the enable-cxx is a pre-requite for PPL).

cd $HOME
wget ftp://gcc.gnu.org/pub/gcc/infrastructure/gmp-4.3.2.tar.bz2
tar jxvf gmp-4.3.2.tar.bz2
cd gmp-4.3.2
./configure --prefix=/soft/gmp/4.3.2 --enable-cxx
make -j 8
make check
make install
cd ..
 
wget ftp://gcc.gnu.org/pub/gcc/infrastructure/ppl-0.11.tar.gz
tar xvzf ppl-0.11.tar.gz
cd ppl-0.11
./configure --prefix=/soft/ppl/0.11 --with-gmp-prefix=/soft/gmp/4.3.2 LDFLAGS="-L/soft/gmp/4.3.2/lib" CPPFLAGS="-I/soft/gmp/4.3.2/include" --enable-optimization=speed
make -j 8
make check
make install
cd ..
 
wget ftp://gcc.gnu.org/pub/gcc/infrastructure/cloog-ppl-0.15.11.tar.gz
tar xvzf cloog-ppl-0.15.11.tar.gz
cd cloog-ppl-0.15.11
./configure --prefix=/soft/cloog-ppl/0.15.11 --with-gmp=/soft/gmp/4.3.2 --with-ppl=/soft/ppl/0.11
make -j 8
make check
make install
cd ..
 
wget ftp://gcc.gnu.org/pub/gcc/infrastructure/mpfr-2.4.2.tar.bz2
tar jxvf mpfr-2.4.2.tar.bz2
cd mpfr-2.4.2
./configure --prefix=/soft/mpfr/2.4.2 --with-gmp=/soft/gmp/4.3.2
make -j 8
make check
make install
cd ..
 
wget ftp://gcc.gnu.org/pub/gcc/infrastructure/mpc-0.8.1.tar.gz
tar jxvf mpc-0.8.1.tar.gz
cd mpc-0.8.1
./configure --prefix=/soft/mpc/0.8.1 --with-gmp=/soft/gmp/4.3.2 --with-mpfr=/soft/mpfr/2.4.2
make -j 8
make check
make install
cd ..
 
export LD_LIBRARY_PATH=/soft/gmp/4.3.2/lib:/soft/mpfr/2.4.2/lib:/soft/mpc/0.8.1/lib:/soft/ppl/0.11/lib:/soft/cloog-ppl/0.15.11/lib:$LD_LIBRARY_PATH
 
wget ftp://gcc.gnu.org/pub/gcc/releases/gcc-4.6.3/gcc-4.6.3.tar.bz2
tar jxvf gcc-4.6.3.tar.bz2
cd gcc-4.6.3
../gcc-4.6.3/./configure --prefix=/soft/gcc-4.6.3 --enable-languages=c,c++,objc,obj-c++,fortran --disable-multilib --with-gmp=/soft/gmp/4.3.2 --with-mpfr=/soft/mpfr/2.4.2 --with-mpc=/soft/mpc/0.8.1
make -j 8

Before you go any further, note that the test will not work (you will get errors like “make[2]: autogen: Command not found”). However, if the build (make -j 8) made it without errors, you can suppose it is sufficient to ignore the check and go directly to install. Do not forget that GCC Graphit is experimental.

make -k check
make install

Again, to use this GCC, just add it to environment variables :

export GCCHOME=/soft/gcc-4.6.3
export  PATH=/soft/gcc-4.6.3/bin:$PATH
export  MANPATH=/soft/gcc-4.6.3/share/man:$MANPATH
export  LD_LIBRARY_PATH=/soft/gcc-4.6.3/lib64:$LD_LIBRARY_PATH
export COMPILER=gcc
export COMPILER_VER=4.6.3
export CC=gcc
export CXX=g++
export F77=gfortran
export F90=gfortran
export FC=gfortran

You should be able to add new compiling options like -floop-interchange -floop-strip-mine -floop-block

Here are a list of errors you could encounter :

checking for the GMP library version 4.1.3 or above... no
configure: error: Cannot find GMP version 4.1.3 or higher.
GMP is the GNU Multi-Precision library:
see http://www.swox.com/gmp/ for more information.
When compiling the GMP library, do not forget to enable the C++ interface:
add --enable-cxx to the configuration options.

Means first of all that you forgot to compile GMP with the –enable-cxx flag. Then, even with this flag, the configure cannot find GMP. Take a lok at the config.log :

configure:11105: checking for the GMP library version 4.1.3 or above
configure:11194: g++ -o conftest -g -O2 -frounding-math conftest.cpp -lgmpxx -lgmp >&5
conftest.cpp:83:19: error: gmpxx.h: No such file or directory

The configure cannot find gmpxx.h… Note that you indicated it the GMP directory. There is a BUG. You can use –with-gmp-prefix or –with-gmp, it does not use it. The trick is to add the includes and the libraries in the compiler flags : LDFLAGS=“-L/soft/gmp/4.3.2/lib” CPPFLAGS=“-I/soft/gmp/4.3.2/include”

And then…

checking for the GMP library version 4.1.3 or above... yes

- if you still encounter this error, upgrade to gmp-5.0.5.

checking for suffix of object files... configure: error: in `/home/manu/gcc/gcc/i686-pc-linux-gnu/libgcc':
configure: error: cannot compute suffix of object files: cannot compile
See `config.log' for more details.
make[2]: *** [configure-stage1-target-libgcc] Error 1
make[2]: Leaving directory `/home/manu/gcc/gcc'

See here : http://gcc.gnu.org/wiki/FAQ#configure_suffix

You simply forgot to add GMP, MPFR and MPC into your LD_LIBRARY_PATH. Example :

export LD_LIBRARY_PATH=/soft/gmp/4.3.2/lib:/soft/mpfr/2.4.2/lib:/soft/mpc/0.8.1/lib:$LD_LIBRARY_PATH

You can find a lot of additional information in this topic : http://gcc.gnu.org/ml/gcc-help/2012-07/msg00129.html.


Building R


Version : 2.15.2
Compiler : intel icc 12.1.3

./configure --prefix=/soft/R/2.15.2 --enable-R-shlib --enable-R-static-lib --enable-static --enable-shared CC=icc CFLAGS="-g -O3 -wd188 -ip -mp" F77=ifort FLAGS="-g -O3 -mp" CXX=icpc CXXFLAGS="-g -O3 -mp" FC=ifort FCFLAGS="-g -O3 -mp"
make
make check
make install

Then, to add packages, simply download them (url, replace mypackage by the name of the package : http://cran.r-project.org/web/packages/mypackage/index.html). Then, use the auto-install tool (example) :

wget http://cran.r-project.org/src/contrib/Rcpp_0.10.2.tar.gz
tar xvzf Rcpp_0.10.2.tar.gz
R CMD INSTALL Rcpp

If you get dependency issues, download the packages required. You barely need 2 or 3 additional packages to resolve dependency issues.


Installing Intel 13.3


Version: Intel 13, update 3, parallel studio x86_64

OS: Ubuntu 12.04 Amd64, CentOS 6.4, SLES 11 SP3. (Be careful, the intel 13 installer do not know Ubuntu 13.04 for now, and will not install properly: works, but always need to specify system include directories and libs).

Install pre-requite :

On ubuntu :

sudo apt-get install build-essential openjdk-7-jre gcc-multilib libstdc++6

On CentOS Amd64, you need to link kernel source to make the installer detect them.

yum -y install java7 gcc-c++-4.4.7-3.el6.x86_64 libstdc++-4.4.7-3.el6.i686 yum -y install kernel-devel kernel-source

Then creat a link (depending on your kernel of course) :

ln -s /usr/src/kernels/2.6.32-358.11.1.el6.x86_64 /usr/src/linux-2.6.32-358.6.2.el6.x86_64

Then launch the install :

sudo ./install.sh

The installer is simple to use. Skip optional pre-requite step if the only pre-requite is potrace protection is active, we will deal with it after.

After the installation, the installer will give you this :

To get started using Intel(R) VTune(TM) Amplifier XE 2013 Update 5:
- To set your environment variables: source /soft/compiler/intel-13.3/vtune_amplifier_xe_2013/amplxe-vars.sh
- To start the graphical user interface: amplxe-gui
- To use the command-line interface: amplxe-cl
- For more getting started resources: /soft/compiler/intel-13.3/vtune_amplifier_xe_2013/documentation/en/welcomepage/get_started.html.
To get started using Intel(R) Inspector XE 2013 Update 5:
- To set your environment variables: source /soft/compiler/intel-13.3/inspector_xe_2013/inspxe-vars.sh
- To start the graphical user interface: inspxe-gui
- To use the command-line interface: inspxe-cl
- For more getting started resources: /soft/compiler/intel-13.3/inspector_xe_2013/documentation/en/welcomepage/get_started.html.
To get started using Intel(R) Advisor XE 2013 Update 2:
- To set your environment variables: source /soft/compiler/intel-13.3/advisor_xe_2013/advixe-vars.sh
- To start the graphical user interface: advixe-gui
- To use the command-line interface: advixe-cl
- For more getting started resources: /soft/compiler/intel-13.3/advisor_xe_2013/documentation/en/welcomepage/get_started.html.
To get started using Intel(R) Composer XE 2013 Update 3 for Linux*:
- Set the environment variables for a terminal window using one of the
following (replace "intel64" with "ia32" if you are using a 32-bit
platform).
For csh/tcsh:
$ source /soft/compiler/intel-13.3/bin/compilervars.csh intel64
For bash:
$ source /soft/compiler/intel-13.3/bin/compilervars.sh intel64
To invoke the installed compilers:
For C++: icpc
For C: icc
For Fortran: ifort
 
To get help, append the -help option or precede with the man command.
- For more getting started resources:
 
/soft/compiler/intel-13.3/composer_xe_2013/Documentation/en_US/get_started_lc.htm.
 
/soft/compiler/intel-13.3/composer_xe_2013/Documentation/en_US/get_started_lf.htm.

Keep that somewhere, you will need it. To simply use the compilers, launch them using the given script above :

source /soft/compiler/intel-13.3/bin/compilervars.sh intel64

If you want to use the Amplifier, use :

source /soft/compiler/intel-13.3/vtune_amplifier_xe_2013/amplxe-vars.sh

Not that the amplifier will not work properly because of potrace protection on Ubuntu system. However, deactivating potrace is a security leak. I suggest you do not use the next command on a server, but only on a workstation. Note that this command effect will not stay at next reboot. To deactivate potrace, login as root and use :

sudo su
echo 0 > /proc/sys/kernel/yama/ptrace_scope
exit