Build GCC 5.2 on RHEL 6

To build GCC, we need other three components, GMP, MPC, and MPFR. And I found a lazy way to compile all of them together here. But because GMP, MPC, MPFR are compiled together with GCC, they’re certainly not installed before the new GCC is installed. So we can’t do make -k check to make a test after the compilation in this way. If you’d like to do a test, please go the traditional way, build and install them one by one seperately.

tar xf gcc-5.2.0.tar.bz2

tar xf gmp-6.0.0a.tar.xz
mv gmp-6.0.0 gcc-5.2.0/gmp

tar xf mpc-1.0.3.tar.gz
mv mpc-1.0.3 gcc-5.2.0/mpc

tar xf mpfr-3.1.3.tar.xz
mv mpfr-3.1.3 gcc-5.2.0/mpfr

mkdir gcc-5.2.0/gcc-build && cd gcc-5.2.0/gcc-build

# I don't have root privilege, so install to a subdir in my home directory
../configure --prefix=$HOME/gcc5 \
             --disable-multilib \
             --enable-languages=c,c++ \
             --enable-libstdcxx-threads \
             --enable-libstdcxx-time \
             --enable-shared \
             --enable-__cxa_atexit \
             --disable-libunwind-exceptions \
             --disable-libada \
             --host x86_64-redhat-linux-gnu \
             --build x86_64-redhat-linux-gnu \

# For clusters, you should request a compute node in slurm to do the compilation. Don't do these in head node
make -j4

make install

With --with-default-libstdcxx-abi=gcc4-compatible, we avoid recompiling all C++ libraries built using older GCC (prior to GCC 5.1). This ensures the default ABI is the old, GCC4-compatble one instead of the newly introduced CXX11 ABI. Check Configure – The GNU C++ Library for details.

Continue reading “Build GCC 5.2 on RHEL 6”