GCC from Source
The following instructions are for those who wish to build their own custom GCC compiler stack.
Due to the general nature of the following document, the commands you see here are for reference and should not blindly be 'cut and pasted' into your terminal.
Prerequisites
A sane, modern developers environment (toolchain). Examples how to do this for several popular operating systems:
Macintosh: Xcode (
xcode-select --install
)Windows: Windows Subsystem for Linux (WSL)
In addition, a chosen Linux flavor below
Ubuntu: (
apt install build-essential
)CentOS/Rocky: (
dnf groupinstall 'Development Tools'
)OpenSUSE: (
zypper install --type pattern devel_basis
)
Different operating systems leverage different means by which to obtain a developers environment. We assume the reader is intricately familiar with their platform of choice, and has established such an environment before proceeding.
GCC
We need a modern C++17 capable compiler. Our minimum requirements are: GCC 7.5.0, Clang 10.0.1. This section will focus on building a GCC 12.2.1 compiler stack.
Obtain GCC source:
curl -L -O http://mirrors.concertpass.com/gcc/releases/gcc-12.2.1/gcc-12.2.1.tar.gz
tar -xf gcc-12.2.1.tar.gz -C .
Obtain GCC pre-reqs:
cd gcc-12.2.1
./contrib/download_prerequisites
Configure GCC using the recommended arguments:
mkdir gcc-build
cd gcc-build
../configure --prefix=/target/installation/path/gcc-12.2.1 \
--disable-multilib \
--enable-languages=c,c++,fortran,jit \
--enable-checking=release \
--enable-host-shared \
--with-pic
With configure
complete (and error free), build and install GCC:
make -j 6
make install
Follow the onscreen instructions on how to make use of your new compiler.
MPICH
Check and see if you already have an MPI wrapper available on your machine. One simple way of doing so, is to perform a which
on several MPI wrapper binaries:
which mpicc mpicxx mpif90
If the above command returns with paths to their respected binaries, you will want to work with your system package manager to remove or suppress it.
Having two completely different MPI wrappers being made available simultaneously is prone to failure.
Download MPICH 4.0.2
curl -L -O http://www.mpich.org/static/downloads/4.0.2/mpich-4.0.2.tar.gz
tar -xf mpich-4.0.2.tar.gz -C .
Create an out-of-tree build location and configure MPICH using the recommended arguments:
mkdir mpich-4.0.2/gcc-build
cd mpich-4.0.2/gcc-build
../configure --prefix=/target/installation/path/mpich-4.0.2 \
--enable-shared \
--enable-sharedlibs=gcc \
--enable-fast=O2 \
--enable-debuginfo \
--enable-totalview \
--enable-two-level-namespace \
CC=gcc \
CXX=g++ \
FC=gfortran \
F77=gfortran \
F90='' \
CFLAGS='' \
CXXFLAGS='' \
FFLAGS='-fallow-argument-mismatch' \
FCFLAGS='-fallow-argument-mismatch' \
F90FLAGS='' \
F77FLAGS=''
With configure
complete and error free, build and install MPICH:
make -j 6
make install
Follow the onscreen instructions on how to make use of your new MPI wrapper.
With the compiler stack ready, you can proceed to the next section: