Micah P. Dombrowski / Aug 21 2019

Build GCC 9

Install distro GCC and required development libraries.

apt-get -qq update
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends \
  build-essential gfortran cmake automake libtool libltdl-dev pkg-config \
  gcc-multilib libgmp-dev libmpfr-dev libmpc-dev libisl-dev libzstd-dev gnat
apt-get clean
rm -r /var/lib/apt/lists/* # Clear package list so it isn't stale

Download GCC source.

FILENAME="gcc-${GCC_VERSION}.tar.xz"
URLBASE="http://mirror.koddos.net/gcc/releases/gcc-${GCC_VERSION}"
FILEURL="${URLBASE}/${FILENAME}"

wget --progress=dot ${URLBASE}/sha512.sum
wget --progress=dot:giga $FILEURL
grep -e "${FILENAME}$" sha512.sum | sha512sum -c -
cp -v $FILENAME /results/
gcc-9.2.0.tar.xz

Extract.

tar -Jxf 
gcc-9.2.0.tar.xz

Configure and build.

mkdir -p gcc-build
cd gcc-build
export CFLAGS="-march=sandybridge"
export CPPFLAGS="${CFLAGS}" CXXFLAGS="${CFLAGS}"
/gcc-${GCC_VERSION}/configure --prefix=/opt/gcc \
  --enable-languages=c,c++,fortran,objc,obj-c++ \
  --enable-checking=release --enable-multilib
cd gcc-build
export CFLAGS="-march=sandybridge"
export CPPFLAGS="${CFLAGS}" CXXFLAGS="${CFLAGS}"
make -j8 --silent
cd gcc-build
make install-strip
cd /opt
tar -Jcf /results/gcc9-20190821.tar.xz gcc
gcc9-20190821.tar.xz