Skip to content

Instantly share code, notes, and snippets.

@zhulianhua
Last active May 29, 2016 14:49
Show Gist options
  • Save zhulianhua/015c1ee8ae98c2b03f62 to your computer and use it in GitHub Desktop.
Save zhulianhua/015c1ee8ae98c2b03f62 to your computer and use it in GitHub Desktop.
Build gcc-5.2.0 on cluster
##Make build dir
mkdir ~/build/gcc
cd ~/build/gcc
##Download packages
wget -c ftp://gcc.gnu.org/pub/gcc/infrastructure/gmp-4.3.2.tar.bz2
wget -c ftp://gcc.gnu.org/pub/gcc/infrastructure/mpfr-2.4.2.tar.bz2
wget -c ftp://gcc.gnu.org/pub/gcc/infrastructure/mpc-0.8.1.tar.gz
wget -c ftp://gcc.gnu.org/pub/gcc/infrastructure/isl-0.14.tar.bz2
wget -c ftp://gcc.gnu.org/pub/gcc/releases/gcc-5.2.0/gcc-5.2.0.tar.gz
##Untar souce code
tar jxf gmp-4.3.2.tar.bz2
tar jxf mpfr-2.4.2.tar.bz2
tar zxf mpc-0.8.1.tar.gz
tar jxf isl-0.14.tar.bz2
tar zxf gcc-5.2.0.tar.gz
## create install dirs
sudo mkdir /opt/local/gmp-4.3.2
sudo mkdir /opt/local/mpfr-2.4.2
sudo mkdir /opt/local/mpc-0.8.1
sudo mkdir /opt/local/isl-0.14
sudo mkdir /opt/local/gcc-5.2.0
##Build gmp
cd ~/build/gcc/gmp-4.3.2
./configure --with-prefix=/opt/local/gmp-4.3.2
make -j12
sudo make install
##Build mpfr
cd ~/build/gcc/mpfr-2.4.2
./configure --with-prefix=/opt/local/mpfr-2.4.2 \
--with-gmp=/opt/local/gmp-4.3.2
make -j12
sudo make install
##Build mpc
cd ~/build/gcc/mpc-0.8.1
./configure --with-prefix=/opt/local/mpc-0.8.1 \
--with-gmp=/opt/local/gmp-4.3.2 \
--with-mprf=/opt/local/mpfr-2.4.2
make -j12
sudo make install
##Build isl
cd ~/build/gcc/isl-0.14
./configure --prefix=/opt/local/isl-0.14 \
--with-gmp-prefix=/opt/local/gmp-4.3.2
make -j12
sudo make install
##Build gcc
cd ~/build/gcc/gcc-5.2.0
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/local/gmp-0.8.1/lib
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/local/mpfr-2.4.2/lib
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/local/mpc-0.8.1/lib
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/local/isl-0.14/lib
mkdir build-gcc
cd build-gcc
../configure --prefix=/opt/local/gcc-5.2.0 \
--with-mpfr=/opt/local/mpfr-2.4.2 \
--with-mpc=/opt/local/mpc-0.8.1 \
--with-gmp=/opt/local/gmp-4.3.2 \
--with-isl=/opt/local/isl-0.14 \
--disable-multilib
make -j 12
sudo make install
sudo cat <<EOF > /opt/modules/gcc/5.2.0
#%Module1.0#####################################################################
##
##gcc 5.2.0 modulefile
##
module-whatis "GCC 5.2.0 (gcc, g++, gfortran)"
conflict gcc
prepend-path PATH /opt/local/gcc-5.2.0/bin
prepend-path LD_LIBRARY_PATH /opt/local/gcc-5.2.0/lib64
prepend-path LD_LIBRARY_PATH /opt/local/isl-0.14/lib
prepend-path LD_LIBRARY_PATH /opt/local/gmp-4.3.2/lib
prepend-path LD_LIBRARY_PATH /opt/local/mpfr-2.4.2/lib
prepend-path LD_LIBRARY_PATH /opt/local/mpc-0.8.1/lib
prepend-path LIBRARY_PATH /opt/local/gcc-5.2.0/lib64
prepend-path MANPATH /opt/local/gcc-5.2.0/share/man
setenv CC gcc
setenv CXX g++
setenv FC gfortran
setenv F77 gfortran
setenv F90 gfortran
EOF
## Add module path
echo "export MODULESPATH=$MODULESPATH:/opt/modules" >> ~/.bashrc
# Test
module load gcc/5.2.0
which gcc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment