Sunday, March 24, 2013

Building gcc 4.8

So apparently on 22 March 2013, GNU put gcc 4.8.0 into production.  So I decided to build it on my home computer (AMD Phenom2, Ubuntu 12.04 64-bit)

Here are the steps that I took for a pretty smooth installation.

Edit: I initially used 4.1, however, I have since built gcc-4.8.0 on other (non-debian) based systems where I have not had root access. Step 4.2 should work in those cases. This has worked on CentOS 5.9 on an IvyBridge Core i7 and CentOS 6.3 on a SandyBridge based Xeon. My prefix directory in those cases were $HOME/app/gcc/4.8.0.
  1. Download the source code
  2. Unzip the file (tar -xjf <file name> for .bz2 file, like what I linked to)
  3. Make a build directory (mkdir gcc-build && cd gcc-build)
  4. Install some supporting parts 
    1. Option 1: sudo apt-get install libgmp-dev libmpfr-dev libmpc-dev libc6-dev libc6-dev-i386
    2. Option 2 (from source code directory): contrib/download_prerequisites (prereqs will then be built as well)
  5. Run configuration (../gcc-4.8.0/configure --prefix=/app/gcc/4.8.0)
  6. make
  7. sudo make install
I use environment modules, so I've put together a module file in modulefiles/compiler/gcc/4.8.0 which currently looks like this:

 
#%Modules1.0
##
##

conflict compiler

prepend-path PATH /app/gcc/4.8.0/bin
prepend-path LD_LIBRARY_PATH /app/gcc/4.8.0/lib64
prepend-path MANPATH /app/gcc/4.8.0/share/man
prepend-path C_INCLUDE_PATH /app/gcc/4.8.0/include
prepend-path CPLUS_INCLUDE_PATH /app/gcc/4.8.0/include

setenv CC /app/gcc/4.8.0/bin/gcc
setenv CXX /app/gcc/4.8.0/bin/g++
setenv FC /app/gcc/4.8.0/bin/gfortran

After that, a 'module load compiler/gcc/4.8.0' and the 4.8 version of gcc, g++, and gfortran are my default C, C++ and FORTRAN compilers. Pretty simple over all.

No comments:

Post a Comment