工具鏈準備: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編譯腳本