KylinV10/: 麒麟gcc7.3.0升级到gcc10.3.1

需求点:

1、Gnu官方没有gcc10.3.1这种版本源码,只有gcc10.3.0;
2、Gcc10.3.1是通过10.3.1+Patch而来的,一般是由麒麟/欧拉/统信等厂商打的patch;
3、Patch的版本也可能不止一个,比如有gcc-10.3.1-65、gcc-10.3.1-66等,65/66就是patch版本;
4、Gcc7.3升级到11.4有时候会存在版本过高导致编译出错,所以需要10.3.1。

.

确认当前内核 及 当前内核编译时用的gcc版本

uname -a && cat /proc/version

.

方案1: 用源码编译来升级

编译机为:openEuler 22.03 (LTS-SP4)

1、安装编译环境

dnf groupinstall "Development Tools"
dnf install \ gmp-devel mpfr-devel libmpc-devel isl-devel \ zlib-devel flex bison texinfo wget git \ rpm-build rpmdevtools elfutils-libelf-devel
dnf install python3
rpmdev-setuptree
#生成编译目录结构
.

2、准备gcc10.3.0源码

wget https://repo.openeuler.org/openEuler-22.03-LTS-SP4/update/source/Packages/gcc-10.3.1-67.oe2203sp4.src.rpm

rpm -ivh gcc-10.3.1-*.src.rpm
cd ~/rpmbuild/BUILD
tar xf ../SOURCES/gcc-10.3.0.tar.xz
cd gcc-10.3.0


#打官方patch,打完就是gcc-10.3.1了
rpmbuild -bp ~/rpmbuild/SPECS/gcc.spec
.

3、开始编译gcc-10.3.1

#建议在4C8G以上的机器上编译,否则各种编译崩溃
mkdir ~/gcc-build && cd ~/gcc-build
../rpmbuild/BUILD/gcc-10.3.0/configure \ --prefix=/usr/local/gcc-10.3.1 \ --enable-languages=c,c++ \ --disable-multilib \ --disable-bootstrap
make -j$(nproc)
make install

.

.

方案2: 用官方gcc相关的rpm包升级

如果是麒麟、欧拉、统信、CentOS等,一般官方有对应版本的rpm包,关联需要安装的rpm包清单如下:

cpp-10.3.1-67.x86_64.rpm
gcc-10.3.1-67.x86_64.rpm
gcc-c++-10.3.1-67.x86_64.rpm
gcc-debuginfo-10.3.1-67.x86_64.rpm
gcc-debugsource-10.3.1-67.x86_64.rpm
gcc-gdb-plugin-10.3.1-67.x86_64.rpm
gcc-gfortran-10.3.1-67.x86_64.rpm
gcc-objc++-10.3.1-67.x86_64.rpm
gcc-objc-10.3.1-67.x86_64.rpm
gcc-plugin-devel-10.3.1-67.x86_64.rpm
libasan-10.3.1-67.x86_64.rpm
libasan-static-10.3.1-67.x86_64.rpm
libatomic-10.3.1-67.x86_64.rpm
libatomic-static-10.3.1-67.x86_64.rpm
libgcc-10.3.1-67.x86_64.rpm
libgccjit-10.3.1-67.x86_64.rpm
libgccjit-devel-10.3.1-67.x86_64.rpm
libgfortran-10.3.1-67.x86_64.rpm
libgfortran-static-10.3.1-67.x86_64.rpm
libgomp-10.3.1-67.x86_64.rpm
libitm-10.3.1-67.x86_64.rpm
libitm-devel-10.3.1-67.x86_64.rpm
libitm-static-10.3.1-67.x86_64.rpm
liblsan-10.3.1-67.x86_64.rpm
liblsan-static-10.3.1-67.x86_64.rpm
libobjc-10.3.1-67.x86_64.rpm
libquadmath-10.3.1-67.x86_64.rpm
libquadmath-devel-10.3.1-67.x86_64.rpm
libquadmath-static-10.3.1-67.x86_64.rpm
libstdc++-10.3.1-67.x86_64.rpm
libstdc++-devel-10.3.1-67.x86_64.rpm
libstdc++-static-10.3.1-67.x86_64.rpm
libtsan-10.3.1-67.x86_64.rpm
libtsan-static-10.3.1-67.x86_64.rpm
libubsan-10.3.1-67.x86_64.rpm
libubsan-static-10.3.1-67.x86_64.rpm

.

方案3:懒人专用系列

下载后放到:/usr/local/,解压

gcc-10.3.1-binary-x86_64.tar.gz(MD5: 2e15d73bb56e9e40bdc333243e96e2ab)
gcc-10.3.1-rpm-x86_64.tar.gz(MD5: 4c23219c6e93d776947b3360cb2c8012)

.

使用新版gcc

echo 'export PATH=/usr/local/gcc-10.3.1/bin:$PATH' >> ~/.bashrc
echo 'export LD_LIBRARY_PATH=/usr/local/gcc-10.3.1/lib64:$LD_LIBRARY_PATH' >> ~/.bashrc
source ~/.bashrc

查看版本:
gcc --version
g++ --version
.

.

.

Comments

No comments yet. Why don’t you start the discussion?

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注