gcc-7.5.0 source installation

      Because I want to learn gcc, I found a book about gcc source code when collecting information. The version based on the book is gcc-4.4.0, so I want to recompile a version with debugging information. When I first installed gcc-4.4.0 on ubuntu18.04, I didn't succeed. I feel that there will be compatibility problems when compiling with gcc-7.5.0 that comes with the system. So I gave up compiling the 4.4.0 version and chose the same version 7.5.0 as ubuntu18.04, and added "-g -O0" to facilitate debugging when compiling.

 

1. Download
wget http://mirror.linux-ia64.org/gnu/gcc/releases/gcc-7.5.0/gcc-7.5.0.tar.gz
2. Unzip:
tar -zxvf gcc-7.5.0. tar.gz
3. Enter the directory and execute the script to download the dependent package:
cd gcc-7.5.0
./contrib/download_prerequisites
output result
[root@localhost gcc-7.5.0]# ./contrib/download_prerequisites
2019-11-19 17:19 :29 URL: ftp://gcc.gnu.org/pub/gcc/infrastructure/gmp-6.1.0.tar.bz2 [2383840] -> "./gmp-6.1.0.tar.bz2" [1]
2019-11-19 17:19:52 URL: ftp://gcc.gnu.org/pub/gcc/infrastructure/mpfr-3.1.4.tar.bz2 [1279284] -> "./mpfr-3.1.4 .tar.bz2" [1]
2019-11-19 17:20:11 URL: ftp://gcc.gnu.org/pub/gcc/infrastructure/mpc-1.0.3.tar.gz [669925] -> "./Mpc-1.0.3.tar.gz" [1]
2019-11-19 17:21:26 URL: ftp://gcc.gnu.org/pub/gcc/infrastructure/isl-0.16.1.tar.bz2 [1626446] -> "./isl-0.16.1 .tar.bz2" [1]
If the download is unsuccessful, you can go directly to the corresponding official website to download the corresponding version

. 4. Compile:
First create a folder and copy all the four dependencies into it.
mkdir gcc-Builder-7.5.0
cp gmp-6.1.0.tar.bz2 mpfr-3.1.4.tar.bz2 mpc-1.0.3.tar.gz isl-0.16.1.tar.bz2 gcc-Builder-7.5 .0
Then enter the folder
cd gcc-Builder-7.5.0
to compile and configure first, generate makefile file
Execute
../configure --enable-checking=release --enable-languages=c,c++ --disable-multilib CFLAGS ="-g -O0"
After success, a Makefile file will be generated in the current directory and
start to compile:
make (compilation time is a bit long)

make install

The files will be installed under /usr/local/bin, /usr/local/lib64, /usr/local/lib and /usr/local/include

Add environment variables in .bashrc: export PATH=/usr/local/lib64:/usr/local/lib:/usr/local/bin:$PATH

 

Guess you like

Origin blog.csdn.net/kh815/article/details/104990214