工具链准备:rhel56安装时包含所有开发需要的包。
编译binutils-2.24(便以前先打补丁0ef76c4和27b829e):
./configure --disable-nls --disable-shared --build=x86_64-redhat-linux --host=x86_64-redhat-linux --target=x86_64-redhat-linux --disable-multilib --prefix=/opt/gcc-4.9.2
make all install "CFLAGS=-O3" "LDFLAGS=-s"
编译gcc-4.9.2(编译前拷贝gmp-6.0.0a、mpfr-3.1.2、mpc-1.0.2代码至gcc-4.9.2代码根目录,对应的文件夹名要去掉版本内容,分别为gmp、mpfr、mpc):
./configure --enable-languages=c,c++ --build=x86_64-redhat-linux --host=x86_64-redhat-linux --target=x86_64-redhat-linux --disable-multilib --prefix=/opt/gcc-4.9.2 --disable-libstdcxx-pch --disable-lto --disable-nls --enable-checking=release
make bootstrap install "CFLAGS=-g0 -O3" "CXXFLAGS=-g0 -O3 -std=gnu++11" "CFLAGS_FOR_TARGET=-g0 -O3" "CXXFLAGS_FOR_TARGET=-g0 -O3 -std=gnu++11" "BOOT_CFLAGS=-g0 -O3" "BOOT_CXXFLAGS=-g0 -O3 -std=gnu++11"
cd /opt/gcc-4.9.2/bin & ./strip ./*
参考了newen的mingw-gcc编译脚本