Upgrading GCC
Purpose
In CentOS 7.6, the default GCC version is 4.8.5 and glibc version is 2.17. Software compilation requires certain GCC and glibc versions. Upgrading the GCC and glibc versions in the VMs can improve the performance of some programs.
Procedure
The tables below describe the recommended versions of GCC and glibc and their dependencies in the VM OSs.
Compiler |
Version |
How to Obtain |
|---|---|---|
GCC |
7.3.0 or later |
|
glibc |
2.27 |
Dependency |
Version |
How to Obtain |
|---|---|---|
gmp |
6.1.2 |
|
mpfr |
3.1.5 |
|
mpc |
1.0.3 |
|
isl |
0.18 |
- Download the preceding software packages to the /home directory.
1 2 3 4 5 6
cd /home wget https://ftp.gnu.org/gnu/gcc/gcc-7.3.0/gcc-7.3.0.tar.gz wget https://ftp.gnu.org/gnu/libc/glibc-2.27.tar.gz wget https://ftp.gnu.org/gnu/gmp/gmp-6.1.2.tar.bz2 wget https://ftp.gnu.org/gnu/mpc/mpc-1.0.3.tar.gz wget http://isl.gforge.inria.fr/isl-0.18.tar.bz2
- Install gmp.
1 2 3 4 5 6
cd /home tar -xvf /home/gmp-6.1.2.tar.bz2 cd /home/gmp-6.1.2 ./configure --prefix=/usr/local/gmp-6.1.2 make -j make install
- Install mpfr.
1 2 3 4 5 6
cd /home tar -zxvf mpfr-3.1.5.tar.gz cd /home/mpfr-3.1.5 ./configure --prefix=/usr/local/mpfr-3.1.5 --with-gmp=/usr/local/gmp-6.1.2 make -j make install
- Install mpc.
1 2 3 4 5 6
cd /home tar -zxvf mpc-1.0.3.tar.gz cd /home/mpc-1.0.3 ./configure -prefix=/usr/local/mpc-1.0.3 -with-gmp=/usr/local/gmp-6.1.2 -with-mpfr=/usr/local/mpfr-3.1.5 make -j make install
- Install isl.
1 2 3 4 5 6 7
cd /home tar -xvf /home/isl-0.18.tar.bz2 cd /home/isl-0.18 yum -y install gmp-devel ./configure --prefix=/usr/local/isl-0.18 --with-gmp=/usr/local/gmp-6.1.2 make make install
- Install GCC. (Version 7.3.0 is used as an example.)
1 2 3 4 5 6 7 8
cd /home tar -zxvf gcc-7.3.0.tar.gz cd /home/gcc-7.3.0 ./configure --prefix=/usr/local/gcc-7.3.0 --enable-languages=c,c++,fortran --enable-shared --enable-linker-build-id --without-included-gettext --enable-threads=posix --disable-multilib --disable-nls --disable-libsanitizer --disable-browser-plugin --enable-checking=release --build=aarch64-linux --with-gmp=/usr/local/gmp-6.1.2 --with-mpfr=/usr/local/mpfr-3.1.5 --with-mpc=/usr/local/mpc-1.0.3 --with-isl=/usr/local/isl-0.18 export LD_LIBRARY_PATH=/usr/local/mpc-1.0.3/lib:/usr/local/gmp-6.1.2/lib:/usr/local/mpfr-3.1.5/lib:/usr/local/gcc-7.3.0/lib64:/usr/local/isl-0.18/lib:/usr/local/lib:/usr/lib:$LD_LIBRARY_PATH export PATH=/usr/local/gcc-7.3.0/bin:$PATH make -j make -j install
- Set the environment variables.
Add the following environment variables to the /etc/profile file:
1 2
export LD_LIBRARY_PATH=/usr/local/mpc-1.0.3/lib:/usr/local/gmp-6.1.2/lib:/usr/local/mpfr-3.1.5/lib:/usr/local/gcc-7.3.0/lib64:/usr/local/isl-0.18/lib:/usr/local/lib:/usr/lib:$LD_LIBRARY_PATH export PATH=/usr/local/gcc-7.3.0/bin:$PATH
- Make the environment variables take effect.
1source /etc/profile
- Check the GCC version.
1gcc -v
- Install glibc.
1 2 3 4 5 6
cd /home tar -zxvf glibc-2.27.tar.gz cd glibc-2.27 /home/glibc-2.27/configure --prefix=/usr/local/glibc-2.27 make -j make install
- Set the environment variable.
Add the following environment variable to the /etc/profile file:
1export PATH=/usr/local/glibc-2.27/bin:$PATH
- Make the environment variable take effect.
1source /etc/profile
- Check the glibc version.
1ldd --version
If the GCC version is upgraded to 7.3.0, you can add the compilation option -march=armv8-a to CFLAGS and CPPFLAGS to use the armv8 instruction set compatible with the Kunpeng processors.
If the GCC version is upgraded to 9.1.0 or later, you can add the compilation option -mtune=tsv110 to specify that the tsv110 pipeline is used.