User Tools

Site Tools


nix:gcc

This is an old revision of the document!


GCC

GCC Versions that are already installed on CS infrastructure

Usually, we install multiple versions. The default version of GCC probably won't be changed system wide… ever.

We are now taking more advantage of environment modules. This means depending on when you read this you could load the version of GCC you want to use.

$ module --terse avail |grep gcc
/etc/environment-modules/modules:
gcc/4.9.4
gcc/5.5.0
gcc/6.5.0
gcc/7.5.0
gcc/8.4.0
gcc/9.3.0
gcc/10.2.0


$ module load gcc/4.9.4

$ echo "$PATH | $INCLUDE | $LD_LIBRARY_PATH | $MANPATH"
/usr/local/gcc/4.9.4/bin:/home/kauffman3/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/opt/puppetlabs/bin 
| /usr/local/gcc/4.9.4/include | /usr/local/gcc/4.9.4/lib | 
/usr/local/gcc/4.9.4/man:/usr/share/man

$ gcc --version
gcc (GCC) 4.9.4

$ module unload gcc

Building GCC in your home directory

https://gcc.gnu.org/wiki/InstallingGCC

You will want to prepare a sandwich and a drink once we start compiling.

Requirements

  1. About 6.5G of scratch space.
  2. ~1G for the actual install. This means if you require a higher quota you will need to request this before proceeding.

You will want to use /var/tmp, /tmp, or /local as the place to checkout and build GCC.

Example

#!/bin/bash

gccversion='7.1.0'
PREFIX="$HOME/.local/gcc/${gccversion}"

# Building gcc
gccversionuc="${gccversion//./_}"

INSTALLDIR=/tmp/$USER
mkdir -p $INSTALLDIR
cd $INSTALLDIR

svn co svn://gcc.gnu.org/svn/gcc/tags/gcc_${gccversionuc}_release gcc-${gccversion}
cd gcc-${gccversion}
./contrib/download_prerequisites
cd ../
mkdir objdir
cd objdir
$PWD/../gcc-${gccversion}/configure \
  --prefix=$PREFIX \
  --enable-languages=c,c++,fortran,go \
  --enable-shared \
  --enable-multiarch \
  --enable-threads=posix
make -j4
make install

# clean up
rm -r $INSTALLDIR/objdir

export PATH=$HOME/$PREFIX/bin:$PATH
export LD_LIBRARY_PATH=$HOME/$PREFIX/lib:$LD_LIBRARY_PATH

echo "You should add the following to your .bashrc"
echo "to make the exports permanent"
echo "  export PATH=\$HOME/$PREFIX/bin:\$PATH"
echo "  export LD_LIBRARY_PATH=\$HOME/$PREFIX/lib:\$LD_LIBRARY_PATH"

Troubleshooting

'module' command not found

To resolve you may have to do the following:

source /etc/profile.d/modules.sh
/var/lib/dokuwiki/data/attic/nix/gcc.1611167068.txt.gz · Last modified: 2021/01/20 12:24 by kauffman

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki