build gcc from source
git clone https://gcc.gnu.org/git/gcc.git
cd gcc
# download prerequisites
cd gcc
./contrib/download_prerequisites
# create build directory
cd ..
mkdir gcc-build
cd gcc-build
# build
../gcc/configure
--prefix=${INSTALLDIR}
--enable-shared
--enable-threads=posix
--enable-__cxa_atexit
--enable-clocale=gnu
--enable-languages=all
--enable-multilib
make
make install