Upgrading GCC
- Check the GCC version.
1gcc --version - Determine whether an upgrade is required.
- If the GCC version is 8.3.0 or later, skip this section.
- If the GCC version is earlier than 8.3.0, upgrade it to 8.3.0 or later. For details, see Obtaining the Source Package and Compiling and Installing GCC.
Obtaining the Source Package
- Obtain the GCC 8.3.0 source package.
Download the GCC 8.3.0 source package using a local browser.
- Copy the GCC source package to the /home directory on the server.
If the server can access the Internet, you can also run the wget command on the server to download the source code.
1 2
cd /home wget https://mirrors.tuna.tsinghua.edu.cn/gnu/gcc/gcc-8.3.0/gcc-8.3.0.tar.gz --no-check-certificate
Compiling and Installing GCC
- Decompress the GCC source package in the directory where the source package is located.
1 2
cd /home tar -xvf gcc-8.3.0.tar.gz

- Go to the source code directory.
1cd gcc-8.3.0
- Configure GCC.
1./configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-bootstrap

Table 1 describes the related parameters.
Table 1 Parameter description Parameter
Description
--prefix=PATH
Specifies the GCC installation directory. The default directory is /usr.
--mandir=PATH
Specifies the directory for storing GCC files. The default directory is /usr/share/man.
--infodir=PATH
Specifies the directory for storing GCC logs. The default directory is /usr/share/info.
--enable-bootstrap
Enables bootstrap installation.
- Perform compilation and installation.
1make -j20
The -j20 parameter leverages the multi-core CPUs to accelerate the compilation. The compilation process takes about 10 minutes.

1make install
- Check whether the GCC version is 8.3.0.
1/usr/bin/gcc -v
Parent topic: Configuring the Compilation Environment