升级gcc9.3和glib2.31

升级gcc9.3和glib2.31

软件版本
gcc9.3.0
make4.3
glibc2.31
节点IP系统功能CPU内存硬盘
node110.80.10.1centos7.9gcc、glibc16核心32GB20GB

node1

下载安装gcc:

下载地址:http://ftp.gnu.org/gnu/gcc/

编译参数:https://gcc.gnu.org/install/configure.html

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# yum install -y bzip2 gcc gcc-c++
# cd /usr/local/src/
# wget https://mirrors.aliyun.com/gnu/gcc/gcc-9.3.0/gcc-9.3.0.tar.gz
# tar -xzvf gcc-9.3.0.tar.gz
# cd gcc-9.3.0/
# wget https://mirrors.aliyun.com/gnu/gmp/gmp-6.1.0.tar.bz2
# wget https://mirrors.aliyun.com/gnu/mpfr/mpfr-3.1.4.tar.bz2
# wget https://mirrors.aliyun.com/gnu/mpc/mpc-1.0.3.tar.gz
# wget http://gcc.gnu.org/pub/gcc/infrastructure/isl-0.18.tar.bz2
# ./contrib/download_prerequisites
# mkdir build && cd build
# grep "^language=" ../gcc/*/config-lang.in
# ../configure --enable-checking=release --enable-language=c,c++ --disable-multilib --prefix=/usr
# make -j 16
# make -j 16 install

查看gcc版本:

1
2
3
4
5
6
7
8
# ls /usr/lib64/libstdc++*
/usr/lib64/libstdc++.a /usr/lib64/libstdc++fs.la /usr/lib64/libstdc++.so /usr/lib64/libstdc++.so.6.0.19 /usr/lib64/libstdc++.so.6.0.28-gdb.py
/usr/lib64/libstdc++fs.a /usr/lib64/libstdc++.la /usr/lib64/libstdc++.so.6 /usr/lib64/libstdc++.so.6.0.28
# gcc --version
gcc (GCC) 9.3.0
Copyright (C) 2019 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.

下载安装make:

下载地址:https://ftp.gnu.org/gnu/make/

1
2
3
4
5
6
7
# cd /usr/local/src/
# wget https://mirrors.aliyun.com/gnu/make/make-4.3.tar.gz
# tar -xzvf make-4.3.tar.gz
# cd make-4.3/
# mkdir build && cd build
# ../configure --prefix=/usr
# make -j 16 && make -j 16 install

查看make版本:

1
2
3
4
5
6
7
# 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.

下载安装glibc:

下载地址:https://ftp.gnu.org/gnu/glibc/

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# cd /usr/local/src/
# wget https://mirrors.aliyun.com/gnu/glibc/glibc-2.31.tar.gz
# tar -xzvf glibc-2.31.tar.gz
# cd glibc-2.31/
# cat INSTALL | grep -E "newer|later"
this option if you want to compile the GNU C Library with a newer
GCC 8 and binutils 2.29 or later. Note that when CET is enabled,
x86-64 processors as well as Intel Pentium Pro or newer.
to build without this option (for example, if building with a newer
The tests (and later installation) use some pre-existing files of the
* GNU 'make' 4.0 or newer
* GCC 6.2 or newer
building the GNU C Library, as newer compilers usually produce
* 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
to have the header files from a 3.2 or newer kernel around for
reference. (For the ia64 architecture, you need version 3.2.18 or newer
# mkdir build && cd build
# yum install -y python3 bison texinfo binutils
# ../configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin --disable-sanity-checks --disable-werror
# make -j 16
# make -j 16 install

忽略make install报错:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
collect2: error: ld returned 1 exit status
Execution of gcc -B/usr/bin/ failed!
The script has found some problems with your installation!
Please read the FAQ and the README file and check the following:
- Did you change the gcc specs file (necessary after upgrading from
Linux libc5)?
- Are there any symbolic links of the form libXXX.so to old libraries?
Links like libm.so -> libm.so.5 (where libm.so.5 is an old library) are wrong,
libm.so should point to the newly installed glibc file - and there should be
only one such link (check e.g. /lib and /usr/lib)
You should restart this script from your build directory after you've
fixed all problems!
Btw. the script doesn't work if you're installing GNU libc not as your
primary library!
make[1]: *** [Makefile:120: install] Error 1
make[1]: Leaving directory '/usr/local/src/glibc-2.31'
make: *** [Makefile:12: install] Error 2

继续安装:

1
# make -j 16 localedata/install-locales

查看glibc版本:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# ll /lib64/libc.so*
-rw-r--r-- 1 root root 253 May 20 10:56 /lib64/libc.so
lrwxrwxrwx 1 root root 12 May 20 10:57 /lib64/libc.so.6 -> libc-2.31.so
# strings /lib64/libc.so.6 | grep ^GLIBC
GLIBC_2.2.5
GLIBC_2.2.6
GLIBC_2.3
GLIBC_2.3.2
GLIBC_2.3.3
GLIBC_2.3.4
GLIBC_2.4
GLIBC_2.5
GLIBC_2.6
GLIBC_2.7
GLIBC_2.8
GLIBC_2.9
GLIBC_2.10
GLIBC_2.11
GLIBC_2.12
GLIBC_2.13
GLIBC_2.14
GLIBC_2.15
GLIBC_2.16
GLIBC_2.17
GLIBC_2.18
GLIBC_2.22
GLIBC_2.23
GLIBC_2.24
GLIBC_2.25
GLIBC_2.26
GLIBC_2.27
GLIBC_2.28
GLIBC_2.29
GLIBC_2.30
GLIBC_PRIVATE
GLIBC_2.29
GLIBC_2.26
GLIBC_2.25
GLIBC_2.28
GLIBC_2.23
GLIBC_2.8
GLIBC_2.30
GLIBC_2.5
GLIBC_2.9
GLIBC_2.7
GLIBC_2.6
GLIBC_2.18
GLIBC_2.11
GLIBC_2.16
GLIBC_2.13
GLIBC_2.2.6