一、gcc升级
1、Developer Toolset升级
红帽提供了一个开发工具包来管理gcc版本,这样做的好处是随时切换版本,并且可以并存多个版本,不破坏原有gcc环境。
文档地址:https://access.redhat.com/documentation/en-us/red_hat_developer_toolset/8/
devtoolset版本 | 对应gcc版本 |
---|---|
devtoolset-3 | gcc4.x.x |
devtoolset-4 | gcc5.x.x |
devtoolset-6 | gcc6x.x |
devtoolset-7 | gcc7.x.x |
devtoolset-8 | gcc8.x.x |
devtoolset-9 | gcc9.x.x |
devtoolset-10 | gcc10.x.x |
1、安装devtoolset包
yum -y install centos-release-scl
yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils
2、激活gcc版本
scl enable devtoolset-9 bash
3、永久生效
echo "source /opt/rh/devtoolset-9/enable" >>/etc/profile
source /etc/profile
2、编译安装升级
通过devtoolset升级虽然方便且不会对系统造成意外的问题,但是没有办法升级一些和gcc相关的库,所以有时候还是需要编译安装升级。
1、查看gcc版本
# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)
2、安装升级依赖
# yum install -y gcc-c++ glibc-devel mpfr-devel libmpc-devel gmp-devel glibc-devel bzip2
3、下载安装包
# wget https://mirrors.aliyun.com/gnu/gcc/gcc-9.3.0/gcc-9.3.0.tar.gz
# tar zxf gcc-9.3.0.tar.gz
# cd gcc-9.3.0
# ./contrib/download_prerequisites
4、编译安装
# ./configure --enable-checking=release --enable-language=c,c++ --disable-multilib --prefix=/usr
# make -j `nproc` && make install
5、加载动态连接库
# ldconfig -v
6、检查gcc版本
# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/9.3.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../configure --enable-checking=release --enable-language=c,c++ --disable-multilib --prefix=/usr
Thread model: posix
gcc version 9.3.0 (GCC)
二、make升级
1、查看版本
# make -v
GNU Make 3.82
Built for x86_64-redhat-linux-gnu
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
2、安装依赖
# yum -y install gcc gcc+
3、下载安装包
注意:make不要升级到4.4版本,会导致编译失败,原因是make4.4版本向后不兼容。
# wget https://mirrors.aliyun.com/gnu/make/make-4.3.tar.gz
# tar zxf make-4.3.tar.gz
# cd make-4.3
4、编译安装
# ./configure --prefix=/usr/local/make
# make -j `nproc` && make install
5、建立软连接
# ln -sf /usr/local/make/bin/make /usr/bin/make
6、检查make版本
# make --version
GNU Make 4.3
Built for x86_64-pc-linux-gnu
Copyright (C) 1988-2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
三、gdb升级
1、下载软件包
# wget https://mirrors.aliyun.com/gnu/gdb/gdb-14.1.tar.gz
2、编译安装
# tar zxf gdb-14.1.tar.gz
# ./configure --prefix=/usr/
# make -j `nproc` && make install
3、查看版本
# gdb --version
GNU gdb (GDB) 14.1
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
四、glibc升级
事先声明:不到万不得已不要升级!!!
Glibc 不可用会导致:bash 无法使用、yum/rpm 无法使用、无法解析名称空间、无法切换用户等,基本相当于系统不可用。
1、查看glibc函数库版本
# ldd --version
ldd (GNU libc) 2.17
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.
# strings /lib64/libc.so.6 | grep -E "^GLIBC" | sort -V -r | uniq
GLIBC_PRIVATE
GLIBC_2.17
GLIBC_2.16
GLIBC_2.15
GLIBC_2.14
GLIBC_2.13
GLIBC_2.12
GLIBC_2.11
GLIBC_2.10
GLIBC_2.9
GLIBC_2.8
GLIBC_2.7
GLIBC_2.6
GLIBC_2.5
GLIBC_2.4
GLIBC_2.3.4
GLIBC_2.3.3
GLIBC_2.3.2
GLIBC_2.3
GLIBC_2.2.6
GLIBC_2.2.5
2、安装依赖
# yum -y install texinfo python3 bison
# cat INSTALL | grep -E "newer|later" | grep "*"
* GNU 'make' 4.0 or newer
* GCC 6.2 or newer
* GNU 'binutils' 2.25 or later
* GNU 'texinfo' 4.7 or later
* GNU 'bison' 2.7 or later
* GNU 'sed' 3.02 or newer
* Python 3.4 or later
* GDB 7.8 or later with support for Python 2.7/3.4 or later
* GNU 'gettext' 0.10.36 or later
3、下载安装包
# wget https://mirrors.aliyun.com/gnu/glibc/glibc-2.31.tar.gz
# tar zxf glibc-2.31.tar.gz
# cd glibc-2.31
4、编译安装
# mkdir build
# cd build/
# ../configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin --disable-sanity-checks --disable-werror
# make -j `nproc`
# vim ../scripts/test-installation.pl
128 && $name ne "nss_test1" && $name ne "libgcc_s") { # 修改为下面这句
128 && $name ne "nss_test1" && $name ne "nss_test2" && $name ne "nss_nis" && $name ne "nss_nisplus" && $name ne "libgcc_s") {
# make install
# make localedata/install-locales
libm.so已经连接到新版本
# ls -l /lib64/libc.so.6
lrwxrwxrwx. 1 root root 12 Feb 7 12:44 /lib64/libc.so.6 -> libc-2.31.so
5、检查版本
# ldd --version
ldd (GNU libc) 2.31
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.
# strings /lib64/libc.so.6 | grep -E "^GLIBC" | sort -V -r | uniq
GLIBC_PRIVATE
GLIBC_2.30
GLIBC_2.29
GLIBC_2.28
GLIBC_2.27
GLIBC_2.26
GLIBC_2.25
GLIBC_2.24
GLIBC_2.23
GLIBC_2.22
GLIBC_2.18
GLIBC_2.17
GLIBC_2.16
GLIBC_2.15
GLIBC_2.14
GLIBC_2.13
GLIBC_2.12
GLIBC_2.11
GLIBC_2.10
GLIBC_2.9
GLIBC_2.8
GLIBC_2.7
GLIBC_2.6
GLIBC_2.5
GLIBC_2.4
GLIBC_2.3.4
GLIBC_2.3.3
GLIBC_2.3.2
GLIBC_2.3
GLIBC_2.2.6
GLIBC_2.2.5
五、git升级
1、查看当前版本
# git --version
git version 1.8.3.1
2、配置存储库
根据自身网络情况任选其一,因为两个库都在外网可能无法访问或访问慢
# yum -y install https://packages.endpointdev.com/rhel/7/os/x86_64/endpoint-repo.x86_64.rpm # End Point 库(推荐)
# rpm -ivh http://opensource.wandisco.com/centos/7/git/x86_64/wandisco-git-release-7-1.noarch.rpm # wandisco 库
3、更新旧版本
# yum -y update git
4、查看新版本
# git --version
git version 2.43.0
六、curl升级
1、报错原因
执行命令后提示以下报错
curl: option --data-raw: is unknown
查看当前版本号
# curl -V
curl 7.29.0 (x86_64-redhat-linux-gnu) libcurl/7.29.0 NSS/3.90 zlib/1.2.7 libidn/1.28 libssh2/1.8.0
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp scp sftp smtp smtps telnet tftp
Features: AsynchDNS GSS-Negotiate IDN IPv6 Largefile NTLM NTLM_WB SSL libz unix-sockets
CentOS 7默认的curl版本(例如7.29)中可能没有此选项,而更新的版本(如7.78)则支持
2、安装
1、编译安装新版本
wget https://curl.se/download/curl-8.8.0.tar.gz
tar zxf curl-8.8.0.tar.gz
cd curl-8.8.0/
./configure --prefix=/usr/local/curl --without-ssl
make -j && make install
2、配置环境变量
chmod 755 -R /usr/local/curl
chmod 755 /usr/bin/curl
mv /usr/bin/curl{,.bak20240527}
cp /usr/local/curl/bin/curl /usr/bin/curl
cp /etc/profile{,.bak20231015}
echo "export PATH=$PATH:/usr/local/curl/bin" >> /etc/profile
source /etc/profile
3、查看新版本
# curl -V
curl 8.8.0 (x86_64-pc-linux-gnu) libcurl/8.8.0 zlib/1.2.7
Release-Date: 2024-05-22
Protocols: dict file ftp gopher http imap ipfs ipns mqtt pop3 rtsp smtp telnet tftp
Features: alt-svc AsynchDNS IPv6 Largefile libz threadsafe UnixSockets
评论区