Tl;dr

install gcc-9.3.0、make4.3、glibc-2.31 on centos7.

dependencies

docker run -it centos:7 bash
cat /etc/redhat-release
CentOS Linux release 7.8.2003 (Core)
/bin/cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup \
&& sed -i "s@#baseurl@baseurl@g" /etc/yum.repos.d/CentOS-Base.repo \
&& sed -i "s@mirrorlist=http@#mirrorlist=http@g" /etc/yum.repos.d/CentOS-Base.repo \
&& sed -i "s@baseurl=.*/centos@baseurl=https://mirrors.huaweicloud.com/centos@g" /etc/yum.repos.d/CentOS-Base.repo \
&& yum clean all \
&& yum makecache \
&& yum update -y \
&& yum groupinstall "Development Tools" -y \
&& yum install glibc-static libstdc++-static -y \
&& yum install python3 python3-devel wget -y \
&& gcc -v; \
ls -ltr /usr/lib64 |grep -E 'libc-|libstdc++'


## wget config proxy
cat > ~/.wgetrc <<EOF
https_proxy = http://proxy.yoyodyne.com:18023/
http_proxy = http://proxy.yoyodyne.com:18023/
ftp_proxy = http://proxy.yoyodyne.com:18023/
use_proxy = on
EOF

gcc-9.3.0

curl -fksSL https://mirrors.aliyun.com/gnu/gcc/gcc-9.3.0/gcc-9.3.0.tar.gz | tar -xvz
cd gcc-9.3.0/
./contrib/download_prerequisites

mkdir build
cd build

../configure \
--prefix=/usr \
--enable-checking=release \
--enable-language=c,c++ \
--disable-multilib

cat /proc/cpuinfo| grep "processor"| wc -l

make -j4
make install

make-4.3

curl -fksSL https://mirrors.aliyun.com/gnu/make/make-4.3.tar.gz | tar -xvz
cd make-4.3/
mkdir build
cd build
../configure --prefix=/usr
make
make install

gdb-8.3.1

curl -fksSL https://mirrors.ustc.edu.cn/gnu/gdb/gdb-8.3.1.tar.gz |tar -xvz
yum install texinfo libncurses5-dev -y
cd gdb-8.3.1
mkdir build
cd build
../configure --prefix=/usr

make
make install

glibc-2.31

curl -fksSL https://mirrors.aliyun.com/gnu/glibc/glibc-2.31.tar.gz | tar -xvz
cd glibc-2.31/
cat INSTALL | grep -E "newer|later"
mkdir build
cd build

../configure \
--prefix=/usr \
--disable-profile \
--enable-add-ons \
--with-headers=/usr/include \
--with-binutils=/usr/bin \
--enable-obsolete-nsl \
--disable-sanity-checks \
--disable-werror

#yum install python3

make -j4
make install
make localedata/install-locales
LD_SO=ld-linux-x86-64.so.2 CC="gcc -B/usr/bin/" /usr/bin/perl scripts/test-installation.pl /glibc-2.31/build/
/usr/bin/ld: cannot find -lnss_test2
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 '/glibc-2.31'
make: *** [Makefile:12: install] Error 2

# https://garlicspace.com/2020/07/18/centos7-%E5%8D%87%E7%BA%A7-glibc-gcc/


centos-release-scl-rh

yum update;
yum install centos-release-scl-rh -y;
yum update;
yum install devtoolset-9-toolchain -y
yum install devtoolset-8-toolchain -y
scl enable devtoolset-9 bash
#    or 
scl enable devtoolset-8 bash

debian10-gcc

docker run -it --rm debian:10

sed -i "s|deb.debian.org|mirrors.huaweicloud.com|g" /etc/apt/sources.list && \
sed -i "s|security.debian.org|mirrors.huaweicloud.com|g" /etc/apt/sources.list && \
apt-get clean && \
apt-get update && \
apt-get -y upgrade && \
apt-get install build-essential wget curl python3 python3-dev python3-distutils -yq



gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 8.3.0-6' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-8 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 8.3.0 (Debian 8.3.0-6)


ls -ltr /usr/lib/x86_64-linux-gnu/ |grep -E 'libstdc++'
-rw-r--r-- 1 root root 1570256 Apr  6  2019 libstdc++.so.6.0.25
lrwxrwxrwx 1 root root      19 Apr  6  2019 libstdc++.so.6 -> libstdc++.so.6.0.25

ls -ltr /lib/x86_64-linux-gnu/ |grep -E 'libc-|libstdc++'
lrwxrwxrwx 1 root root      12 May  1  2019 libc.so.6 -> libc-2.28.so
-rwxr-xr-x 1 root root 1824496 May  1  2019 libc-2.28.so

ref