GCC 15.1.0 下载:
官方:https://ftp.gnu.org/gnu/gcc/gcc-15.1.0/
阿里云:https://mirrors.aliyun.com/gnu/gcc/gcc-15.1.0/
清华大学:https://mirrors.tuna.tsinghua.edu.cn/gnu/gcc/gcc-15.1.0/
华中科技大学:https://mirrors.hust.edu.cn/gnu/gcc/gcc-15.1.0/
南京大学:https://mirrors.nju.edu.cn/gnu/gcc/gcc-15.1.0/
编译环境:
- Ubuntu 16.04.7 LTS armv7l
- GLIBC 2.23
系统自带 GCC 编译参数:
1 2 3 4 5 6 7 8
| $ gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/arm-linux-gnueabihf/5/lto-wrapper Target: arm-linux-gnueabihf Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.12' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libitm --disable-libquadmath --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-armhf/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-armhf --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-armhf --with-arch-directory=arm --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --enable-multilib --disable-sjlj-exceptions --with-arch=armv7-a --with-fpu=vfpv3-d16 --with-float=hard --with-mode=thumb --disable-werror --enable-multilib --enable-checking=release --build=arm-linux-gnueabihf --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf Thread model: posix gcc version 5.4.0 20160609 (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.12)
|
编译
1 2 3 4 5 6 7 8 9 10
| ./contrib/download_prerequisites
mkdir -p build && cd build ../configure --prefix=/opt/gcc-15.1.0 --with-gcc-major-version-only --program-suffix=-15 --enable-languages=c,c++ --enable-shared --disable-werror --disable-multilib --disable-checking --build=arm-linux-gnueabihf --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf
make make install-strip
|
期间会碰到一个错误:
1
| ../../gcc/hwint.h:62:5: error: #error "Unable to find a suitable type for HOST_WIDE_INT"
|
解决方法:
1
| unset CPLUS_INCLUDE_PATH
|
(来自 https://www.cnblogs.com/haiyang21/p/10828134.html)
然后开始漫长的编译过程,我在 RK3288 开发板上编译的,大概花了24小时左右。
最后用dpkg
打包为.deb
文件,方便以后使用。
管理多个 GCC
用update-alternatives
管理多个 gcc 版本:
1 2 3 4
| update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 5 update-alternatives --install /usr/bin/gcc gcc /usr/local/bin/gcc-15 15 update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-5 5 update-alternatives --install /usr/bin/g++ g++ /usr/local/bin/g++-15 15
|
验证一下:
1 2 3 4 5 6 7 8 9
| $ gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/local/bin/../libexec/gcc/arm-linux-gnueabihf/15/lto-wrapper Target: arm-linux-gnueabihf Configured with: ../configure --prefix=/opt/gcc-15.1.0 --with-gcc-major-version-only --program-suffix=-15 --enable-languages=c,c++ --enable-shared --disable-werror --disable-multilib --disable-checking --build=arm-linux-gnueabihf --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf Thread model: posix Supported LTO compression algorithms: zlib gcc version 15.1.0 (GCC)
|