Introduction
Usage
module load gcc/7.1.0 OR module load gcc/6.3.0 OR module load gcc/5.4.0 module load compilers/gcc-4.6.2
module load compilers/gcc-4.5.1
module load compilers/gcc-4.2.4
module load compilers/gcc-3.3
Installation
7.1.0
svn ls svn://gcc.gnu.org/svn/gcc/tags | grep gcc | grep release >>>>>>>>>>>>>>>>>>>>>>>>>> ... gcc_4_9_3_release/ gcc_4_9_4_release/ gcc_5_1_0_release/ gcc_5_2_0_release/ gcc_5_3_0_release/ gcc_5_4_0_release/ gcc_6_1_0_release/ >>>>>>>>>>>>>>>>>>>>>>>>>>> svn co svn://gcc.gnu.org/svn/gcc/tags/gcc_7_1_0_release/ cd /sw/gcc/src/gcc-7.1.0 ./contrib/download_prerequisites --- Run from /sw/gcc/src/gcc-7.1.0 --- Do not cd to the contrib directory >>>>>>>>>>>> All prerequisites downloaded successfully. >>>>>>>>>>>> mkdir /sw/gcc/src/gcc_7_1_0_build cd /sw/gcc/src/gcc_7_1_0_build ../gcc-7.1.0/configure --help 2>&1 | tee configureHelp.txt The above command would list the configure options available ../gcc-7.1.0/configure --prefix=/sw/gcc/7.1.0 2>&1 | tee configureLog.txt make 2>&1 | tee makeLog.txt make install 2>&1 | tee makeInstall.txt
6.3.0
mkdir /sw/gcc/src/gcc_6_3_0_build cd /sw/gcc/src/gcc_6_3_0_build ../gcc-6.3.0/configure --help 2>&1 | tee configureHelp.txt #The above command would list the configure options available ../gcc-6.3.0/configure --prefix=/sw/gcc/6.3.0 2>&1 | tee configureLog.txt make 2>&1 | tee makeLog.txt make install 2>&1 | tee makeInstall.txt
5.4.0
mkdir /sw/gcc/src/gcc_5_4_0_build cd /sw/gcc/src/gcc_5_4_0_build ../gcc-5.4.0/configure --help 2>&1 | tee configureHelp.txt #The above command would list the configure options available ../gcc-5.4.0/configure --prefix=/sw/gcc/5.4.0 2>&1 | tee configureLog.txt make 2>&1 | tee makeLog.txt make install 2>&1 | tee makeInstall.txt
Version 4.6.3
Reference: http://dipak-dudhabhate.blogspot.com.au/
yum install sharutils systemtap-sdt-devel gcc-java gcc-gnat libgnat ppl-devel yum install cloog-ppl-devel gmp-devel mpfr-devel zlib-static libmpc libmpc-devel yum install dejagnu glibc-static texinfo yum install elfutils-devel elfutils-libelf-devel libmpc-devel gtk2-devel libart_lgpl-devel alsa-lib-devel cd /sw/gcc/4.6.2/src Now download latest SRPM of binutils and GCC from Fedora16 repository. $ wget -c http://mirror.optus.net/fedora/linux/releases/16/Fedora/source/SRPMS/gcc-4.6.2-1.fc16.src.rpm $ wget -c http://mirror.optus.net/fedora/linux/releases/16/Fedora/source/SRPMS/binutils-2.21.53.0.1-2.fc16.src.rpm su - <yourusername> cd /sw/gcc/4.6.2/src Install SRPMS $ rpm -ivh binutils-2.21.53.0.1-2.fc16.src.rpm $ rpm -ivh gcc-4.6.2-1.fc16.src.rpm As GCC has dependency on binutils, we need to compile and install binutils RPMS first. So $ rpmbuild -ba ~/rpmbuild/SPECS/binutils.spec This will take long time to complete. When it is completed then you will see RPMS are created at /export/home/s2594054/rpmbuild/RPMS/x86_64 path. Install them using following command. (sudo rpm -i --prefix=/sw/gcc/4.6.2/binutils/2.21.53 binutils-*) $ sudo rpm -Uvh ~/rpmbuild/RPMS/x86_64/binutils-* Now we are ready to compile and create RPMS for gcc-4.6.2. We need to edit gcc.spec to change version of libmpc. $ sudo yum -y install glibc glibc-devel $ vim ~/rpmbuild/SPECS/gcc.spec Search for "0.8.1" and replace it by "0.8-3" because we have installed this version of libmpc.(Please see above). Comment the following line as well #cp -r -p $libstdcxx_doc_builddir/man/man3/* %{buildroot}%{_mandir}/man3/ Now build the rpm: rpmbuild -ba ~/rpmbuild/SPECS/gcc.spec
A sample gcc.spec is here
cd /sw/gcc/4.6.2/x86_64 rpm2cpio /rpmbuild/RPMS/x86_64/*.rpm | cpio -i -d cd /sw/gcc/4.6.2/binutils/2.21.53 rpm2cpio /data1/RPMS/gcc462/binutils-* | cpio -i -d
Version 4.7.1
cd /sw/gcc/4.7.1/src tar -zxvf gcc-4.7.1.tar.gz mkdir /sw/gcc/4.7.1/src/gcc-4.7.1-objdir cd /sw/gcc/4.7.1/src/gcc-4.7.1-objdir /sw/gcc/4.7.1/src/gcc-4.7.1/configure --prefix=/sw/gcc/4.7.1 --enable-languages=f95,c,c++ make make install
version gcc-4.5.1
mkdir -p /sw/gcc/4.5.1/ su - s123456 rpm -ivh gcc-4.5.1-4.fc14.src.rpm rpmbuild -ba ~/rpmbuild/SPECS/gcc.spec .... ... Wrote: /export/home/s2594054/rpmbuild/SRPMS/gcc-4.5.1-4.el6.src.rpm Wrote: /export/home/s2594054/rpmbuild/RPMS/x86_64/gcc-4.5.1-4.el6.x86_64.rpm Wrote: /export/home/s2594054/rpmbuild/RPMS/x86_64/libgcc-4.5.1-4.el6.x86_64.rpm Wrote: /export/home/s2594054/rpmbuild/RPMS/x86_64/gcc-c++-4.5.1-4.el6.x86_64.rpm Wrote: /export/home/s2594054/rpmbuild/RPMS/x86_64/libstdc++-4.5.1-4.el6.x86_64.rpm Wrote: /export/home/s2594054/rpmbuild/RPMS/x86_64/libstdc++-devel-4.5.1-4.el6.x86_64.rpm Wrote: /export/home/s2594054/rpmbuild/RPMS/x86_64/libstdc++-static-4.5.1-4.el6.x86_64.rpm Wrote: /export/home/s2594054/rpmbuild/RPMS/x86_64/libstdc++-docs-4.5.1-4.el6.x86_64.rpm Wrote: /export/home/s2594054/rpmbuild/RPMS/x86_64/gcc-objc-4.5.1-4.el6.x86_64.rpm Wrote: /export/home/s2594054/rpmbuild/RPMS/x86_64/gcc-objc++-4.5.1-4.el6.x86_64.rpm Wrote: /export/home/s2594054/rpmbuild/RPMS/x86_64/libobjc-4.5.1-4.el6.x86_64.rpm Wrote: /export/home/s2594054/rpmbuild/RPMS/x86_64/gcc-gfortran-4.5.1-4.el6.x86_64.rpm Wrote: /export/home/s2594054/rpmbuild/RPMS/x86_64/libgfortran-4.5.1-4.el6.x86_64.rpm Wrote: /export/home/s2594054/rpmbuild/RPMS/x86_64/libgomp-4.5.1-4.el6.x86_64.rpm Wrote: /export/home/s2594054/rpmbuild/RPMS/x86_64/libmudflap-4.5.1-4.el6.x86_64.rpm Wrote: /export/home/s2594054/rpmbuild/RPMS/x86_64/libmudflap-devel-4.5.1-4.el6.x86_64.rpm Wrote: /export/home/s2594054/rpmbuild/RPMS/x86_64/libmudflap-static-4.5.1-4.el6.x86_64.rpm Wrote: /export/home/s2594054/rpmbuild/RPMS/x86_64/gcc-java-4.5.1-4.el6.x86_64.rpm Wrote: /export/home/s2594054/rpmbuild/RPMS/x86_64/libgcj-4.5.1-4.el6.x86_64.rpm Wrote: /export/home/s2594054/rpmbuild/RPMS/x86_64/libgcj-devel-4.5.1-4.el6.x86_64.rpm Wrote: /export/home/s2594054/rpmbuild/RPMS/x86_64/libgcj-src-4.5.1-4.el6.x86_64.rpm Wrote: /export/home/s2594054/rpmbuild/RPMS/x86_64/cpp-4.5.1-4.el6.x86_64.rpm Wrote: /export/home/s2594054/rpmbuild/RPMS/x86_64/gcc-gnat-4.5.1-4.el6.x86_64.rpm Wrote: /export/home/s2594054/rpmbuild/RPMS/x86_64/libgnat-4.5.1-4.el6.x86_64.rpm Wrote: /export/home/s2594054/rpmbuild/RPMS/x86_64/libgnat-devel-4.5.1-4.el6.x86_64.rpm Wrote: /export/home/s2594054/rpmbuild/RPMS/x86_64/libgnat-static-4.5.1-4.el6.x86_64.rpm Wrote: /export/home/s2594054/rpmbuild/RPMS/x86_64/gcc-debuginfo-4.5.1-4.el6.x86_64.rpm cd /sw/gcc/4.5.1/x86_64 rpm2cpio /rpmbuild/RPMS/x86_64/*.rpm | cpio -i -d
Module file
module display compiler/gcc-4.5.1 ------------------------------------------------------------------- /sw/com/modulefiles/compilers/gcc-4.5.1: module-whatis loads the compiler/4.5.1-4 environment prepend-path PATH /sw/gcc//4.5.1/x86_64/usr/bin:/sw/gcc//4.5.1/x86_64/usr/libexec/gcc/x86_64-redhat-linux/4.5.1:/sw/gcc//4.5.1/x86_64/usr/libexec/getconf:/sw/gcc//4.5.1/x86_64/usr/sbin prepend-path LD_LIBRARY_PATH /sw/gcc//4.5.1/x86_64/usr/lib/gcc/x86_64-redhat-linux/4.5.1/32:/sw/gcc//4.5.1/x86_64/usr/lib/gcc/x86_64-redhat-linux/4.5.1:/sw/gcc//4.5.1/x86_64/lib:/sw/gcc//4.5.1/x86_64/lib64:/sw/gcc//4.5.1/x86_64/usr/lib64:/sw/gcc//4.5.1/x86_64/usr/lib setenv COMPILER gcc setenv CC gcc setenv FC gfortran setenv CXX g++ prepend-path C_INCLUDE_PATH /sw/gcc//4.5.1/x86_64/usr/lib/gcc/x86_64-redhat-linux/4.5.1/include:/sw/gcc//4.5.1/x86_64/usr/include prepend-path CPLUS_INCLUDE_PATH /sw/gcc//4.5.1/x86_64/usr/lib/gcc/x86_64-redhat-linux/4.5.1/include:/sw/gcc//4.5.1/x86_64/usr/include:/sw/gcc//4.5.1/x86_64/usr/include/c++/4.5.1 prepend-path INCLUDE /sw/gcc//4.5.1/x86_64/include:/sw/gcc//4.5.1/x86_64/usr/lib/gcc/x86_64-redhat-linux/4.5.1/include:/sw/gcc//4.5.1/x86_64/usr/include:/sw/gcc//4.5.1/x86_64/usr/include/c++/4.5.1 prepend-path MANPATH /sw/gcc//4.5.1/x86_64/usr/share/man -------------------------------------------------------------------
module display compilers/gcc-4.6.2 ------------------------------------------------------------------- /sw/com/modulefiles/compilers/gcc-4.6.2: module-whatis loads the compiler/4.6.2 environment prepend-path PATH /sw/gcc//4.6.2/x86_64/usr/bin:/sw/gcc//4.6.2/x86_64/usr/libexec/gcc/x86_64-redhat-linux/4.6.2:/sw/gcc//4.6.2/x86_64/usr/libexec/getconf:/sw/gcc//4.6.2/x86_64/usr/sbin prepend-path LD_LIBRARY_PATH /sw/gcc//4.6.2/x86_64/usr/lib/gcc/x86_64-redhat-linux/4.6.2/32:/sw/gcc//4.6.2/x86_64/usr/lib/gcc/x86_64-redhat-linux/4.6.2:/sw/gcc//4.6.2/x86_64/lib:/sw/gcc//4.6.2/x86_64/lib64:/sw/gcc//4.6.2/x86_64/usr/lib64:/sw/gcc//4.6.2/x86_64/usr/lib setenv COMPILER gcc setenv CC gcc setenv FC gfortran setenv CXX g++ prepend-path C_INCLUDE_PATH /sw/gcc//4.6.2/x86_64/usr/lib/gcc/x86_64-redhat-linux/4.6.2/include:/sw/gcc//4.6.2/x86_64/usr/include prepend-path CPLUS_INCLUDE_PATH /sw/gcc//4.6.2/x86_64/usr/lib/gcc/x86_64-redhat-linux/4.6.2/include:/sw/gcc//4.6.2/x86_64/usr/include:/sw/gcc//4.6.2/x86_64/usr/include/c++/4.6.2 prepend-path INCLUDE /sw/gcc//4.6.2/x86_64/include:/sw/gcc//4.6.2/x86_64/usr/lib/gcc/x86_64-redhat-linux/4.6.2/include:/sw/gcc//4.6.2/x86_64/usr/include:/sw/gcc//4.6.2/x86_64/usr/include/c++/4.6.2 prepend-path MANPATH /sw/gcc//4.6.2/x86_64/usr/share/man -------------------------------------------------------------------
Dependency
Old version gcc-4.2.4
Ref: http://www.trevorpounds.com/blog/?p=111
mkdir /sw/gcc/4.2.4/src tar -zxvf gcc-4.2.4.tar.gz cd /sw/gcc/4.2.4/src/gcc-4.2.4 mkdir /sw/gcc/4.2.4/src/gcc-4.2.4-objdir cd /sw/gcc/4.2.4/src/gcc-4.2.4-objdir ../gcc-4.2.4/configure --prefix=/sw/gcc/4.2.4/ --enable-languages=c,c++ make make install
Old version gcc-3.3
It looks like it won't compile with the latest version of gcc on redhat. Install the compat packages first
Install these packages: compat-gcc-34-3.4.6-19.el6.x86_64.rpm compat-gcc-34-c++-3.4.6-19.el6.x86_64.rpm compat-libstdc++-33-3.2.3-69.el6.x86_64.rpm compat-gcc-34-g77-3.4.6-19.el6.x86_64.rpm compat-libf2c-34-3.4.6-19.el6.x86_64.rpm rpm -ivh compat-gcc-34-g77-3.4.6-19.el6.x86_64.rpm compat-libf2c-34-3.4.6-19.el6.x86_64.rpm rpm -ivh compat-gcc-34-3.4.6-19.el6.x86_64.rpm compat-gcc-34-c++-3.4.6-19.el6.x86_64.rpm rpm -ivh compat-libstdc++-33-3.2.3-69.el6.x86_64.rpm export CC=gcc34 export FC=f77 export F77=f77 mkdir /sw/gcc/3.3/src cd /sw/gcc/3.3/src tar -zxvf gcc-3.3.tar.gz cd /sw/gcc/3.3/src/gcc-3.3 mkdir /sw/gcc/3.3/src/gcc-3.3-objdir cd /sw/gcc/3.3/src/gcc-3.3-objdir export CC=gcc34 ../gcc-3.3/configure --prefix=/sw/gcc/3.3/ --enable-languages=c,c++ -enable-multilib #make bootstrap make make install # Now compile for f77 make clean all module load compilers/gcc-3.3 ../gcc-3.3/configure --prefix=/sw/gcc/3.3 --enable-languages=f77,c,c++ -enable-multilib make make install
Version on the old cluster with Fedora Core 3
Install GCC-4.0.1 =================== No pre-req ... cd /opt/Apps/compilers/gcc/4.0.1/src mkdir /opt/Apps/compilers/gcc/4.0.1/gcc-4.0.1-objdir cd /opt/Apps/compilers/gcc/4.0.1/gcc-4.0.1-objdir ../../4.0.1/src/gcc-4.0.1/configure --prefix=/opt/Apps/compilers/gcc/4.0.1 --enable-languages=f95,c,c++ make make install Newer Version of GCC ==================== install pre-req gmp and mpfr (and for gcc-4.7.1 install mpc as well) Install GMP: ============ cd /opt/Apps/compilers/gmp/src/gmp-4.3.1 ./configure --prefix=/opt/Apps/compilers/gmp/4.3.1 make make check make install Install mpfr ============ cd /opt/Apps/compilers/mpfr/src/mpfr-3.1.1 ./configure --prefix=/opt/Apps/compilers/mpfr/3.1.1 --with-gmp=/opt/Apps/compilers/gmp/4.3.1 make make check make install Install mpc ============ mkdir -p /opt/Apps/compilers/mpc/0.8.2/src cd /opt/Apps/compilers/mpc/0.8.2/src ./configure --prefix=/opt/Apps/compilers/mpc/0.8.2 --with-gmp=/opt/Apps/compilers/gmp/4.3.1 --with-mpfr=/opt/Apps/compilers/mpfr/3.1.1 make make check make install GCC 4.4.3 =========== mkdir -p /opt/Apps/compilers/gcc/4.4.3/src cd /opt/Apps/compilers/gcc/4.4.3/src mkdir /opt/Apps/compilers/gcc/4.4.3/gcc-4.4.3-objdir cd /opt/Apps/compilers/gcc/4.4.3/gcc-4.4.3-objdir ../../4.4.3/src/gcc-4.4.3/configure --prefix=/opt/Apps/compilers/gcc/4.4.3 --enable-languages=f95,c,c++ --with-gmp=/opt/Apps/compilers/gmp/4.3.1 --with-mpfr=/opt/Apps/compilers/mpfr/3.1.1 make make install GCC-4.7.1 ========= mkdir /opt/Apps/compilers/gcc/4.7.1/src cd /opt/Apps/compilers/gcc/4.7.1/src mkdir /opt/Apps/compilers/gcc/4.7.1/gcc-4.7.1-objdir cd /opt/Apps/compilers/gcc/4.7.1/gcc-4.7.1-objdir ../../4.7.1/src/gcc-4.7.1/configure --prefix=/opt/Apps/compilers/gcc/4.7.1 --enable-languages=f95,c,c++ --with-gmp=/opt/Apps/compilers/gmp/4.3.1 --with-mpfr=/opt/Apps/compilers/mpfr/3.1.1 --with-mpc=/opt/Apps/compilers/mpc/0.8.2 make make install
Reference
1. http://gcc.gnu.org/
2. http://gcc.gnu.org/mirrors.html
3. http://dipak-dudhabhate.blogspot.com.au/
4. http://www.trevorpounds.com/blog/?p=111