1.下载并解压最新版gcc 7.2.0源码以及依赖包GMP,MPFR和MPC:
wget https://mirrors.ustc.edu.cn/gnu/gcc/gcc-7.2.0/gcc-7.2.0.tar.gz
wget https://gmplib.org/download/gmp/gmp-6.1.2.tar.xz
wget http://www.mpfr.org/mpfr-current/mpfr-3.1.6.tar.gz
wget ftp://ftp.gnu.org/gnu/mpc/mpc-1.0.3.tar.gz
2.按顺序编译安装:GMP->MPFR->MPC->GCC:
GMP
tar Jxvf gmp-6.1.2.tar.xz && mkdir build-gmp-6.1.2 && cd build-gmp-6.1.2 && ../gmp-6.1.2/configure
&& ccache make -j`getconf _NPROCESSORS_ONLN` && sudo make install && cd ..
MPFR
tar zxvf mpfr-3.1.6.tar.gz && mkdir build-mpfr-3.1.6 && cd build-mpfr-3.1.6 && ../mpfr-3.1.6/configure
&& ccache make -j`getconf _NPROCESSORS_ONLN` && sudo make install && cd ..
MPC
tar zxvf mpc-1.0.3.tar.gz && mkdir build-mpc-1.0.3 && cd build-mpc-1.0.3 && ../mpc-1.0.3/configure
&& ccache make -j`getconf _NPROCESSORS_ONLN` && sudo make install && cd ..
GCC
tar zxvf gcc-7.2.0.tar.gz && mkdir build-gcc-7.2.0 && cd build-gcc-7.2.0
&& ../gcc-7.2.0/configure --disable-multilib --enable-checking=release --enable-lanuages=c,c++ --prefix=/home/xxx/usr/local --program-suffix=_7.2_custom --enable-shared --enable-threads=posix
&& ccache make -j`getconf _NPROCESSORS_ONLN` && sudo make install && cd ..
4.查看是否安装成功:
gcc_7.2_custom -v
> 使用内建 specs。
> COLLECT_GCC=gcc_7.2_custom
> COLLECT_LTO_WRAPPER=/home/xxx/usr/local/libexec/gcc/x86_64-pc-linux-gnu/7.2.0/lto-wrapper
> 目标:x86_64-pc-linux-gnu
> 配置为:../gcc-7.2.0/configure --disable-multilib --enable-checking=release --enable-lanuages=c,c++ --prefix=/home/xxx/usr/local --program-prefix=user --program-suffix=custom : (reconfigured) ../gcc-7.2.0/configure --disable-multilib --enable-checking=release --enable-lanuages=c,c++ --prefix=/home/xxx/usr/local --program-suffix=_7.2_custom : (reconfigured) ../gcc-7.2.0/configure --disable-multilib --enable-checking=release --enable-lanuages=c,c++ --prefix=/home/john/usr/local --program-suffix=_7.2_custom --enable-shared --enable-threads=posix
> 线程模型:posix
> gcc 版本 7.2.0 (GCC)
5. 使用: