I need to compare performance of various C,C++, Fortran,Go and ADA compiler. So I need to install or build various version of GCC compilers. Installing from apt is easier but not all versions are available from apt.
Most gcc is in C/C++, so we need to install any gcc compiler
To build Ada compiler (gnat), we need other Ada compiler. Hence we install any gnat version.
Clone gcc github repository. Only need to do once. When building each gcc version, we need only to clone from this local repository.
git clone https://github.com/gcc-mirror/gcc
Some gcc versions can only be built on a specific Ubuntu version. Here is the summary result of compiling gcc in various Ubuntu versions. Old versions can only be built on Ubuntu 16.04. Modern versions can be built/compiled on Ubuntu 20.04
cd ~
mkdir gcc-5.1
cd gcc-5.1
mkdir build
git clone ../gcc
cd gcc
git checkout releases/gcc-5.1.0
contrib/download_prerequisites
cd ../build
../gcc/configure -v --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --prefix=/usr/local/gcc-5.1 --enable-checking=release --enable-languages=c,c++,fortran,go,ada --disable-multilib --program-suffix=-5.1 CC=gnatgcc
make
make install
Build failed with the following message:
In file included from ../../gcc/gcc/cp/except.c:1023:0:
cfns.gperf: In function ‘const char* libc_name_p(const char*, unsigned int)’:
cfns.gperf:101:1: error: ‘const char* libc_name_p(const char*, unsigned int)’ redeclared inline with ‘gnu_inline’ attribute
cfns.gperf:26:14: note: ‘const char* libc_name_p(const char*, unsigned int)’ previously declared here
cfns.gperf: At global scope:
cfns.gperf:26:14: warning: inline function ‘const char* libc_name_p(const char*, unsigned int)’ used but never defined
Discussion of the problem: https://stackoverflow.com/questions/41204632/unable-to-build-gcc-due-to-c11-errors
GCC 5.2.0
cd ~
mkdir gcc-5.2
cd gcc-5.2
mkdir build
git clone ../gcc
cd gcc
git checkout releases/gcc-5.2.0
contrib/download_prerequisites
cd ../build
../gcc/configure -v --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --prefix=/usr/local/gcc-5.2 --enable-checking=release --enable-languages=c,c++,fortran,go,ada --disable-multilib --program-suffix=-5.2 CC=gnatgcc
make -j 8
make install
Error
x86_64-linux-gnu-g++ -c -DIN_GCC_FRONTEND -g -DIN_GCC -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wno-format -Wmissing-format-attribute -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -DHAVE_CONFIG_H -I. -Icp -I../../gcc/gcc -I../../gcc/gcc/cp -I../../gcc/gcc/../include -I../../gcc/gcc/../libcpp/include -I/root/gcc-5.2/build/./gmp -I/root/gcc-5.2/gcc/gmp -I/root/gcc-5.2/build/./mpfr -I/root/gcc-5.2/gcc/mpfr -I/root/gcc-5.2/gcc/mpc/src -I../../gcc/gcc/../libdecnumber -I../../gcc/gcc/../libdecnumber/bid -I../libdecnumber -I../../gcc/gcc/../libbacktrace -I/root/gcc-5.2/build/./isl/include -I/root/gcc-5.2/gcc/isl/include -o cp/except.o -MT cp/except.o -MMD -MP -MF cp/.deps/except.TPo ../../gcc/gcc/cp/except.c
In file included from ./tm.h:27:0,
from ../../gcc/gcc/cp/except.c:27:
../../gcc/gcc/config/elfos.h:102:21: warning: invalid suffix on literal; C++11 requires a space between literal and string macro [-Wliteral-suffix]
fprintf ((FILE), "%s"HOST_WIDE_INT_PRINT_UNSIGNED"\n",\
^
../../gcc/gcc/config/elfos.h:170:24: warning: invalid suffix on literal; C++11 requires a space between literal and string macro [-Wliteral-suffix]
fprintf ((FILE), ","HOST_WIDE_INT_PRINT_UNSIGNED",%u\n", \
^
In file included from ./tm.h:48:0,
from ../../gcc/gcc/cp/except.c:27:
../../gcc/gcc/defaults.h:126:24: warning: invalid suffix on literal; C++11 requires a space between literal and string macro [-Wliteral-suffix]
fprintf ((FILE), ","HOST_WIDE_INT_PRINT_UNSIGNED",%u\n", \
^
In file included from ../../gcc/gcc/cp/except.c:1023:0:
cfns.gperf: In function ‘const char* libc_name_p(const char*, unsigned int)’:
cfns.gperf:101:1: error: ‘const char* libc_name_p(const char*, unsigned int)’ redeclared inline with ‘gnu_inline’ attribute
cfns.gperf:26:14: note: ‘const char* libc_name_p(const char*, unsigned int)’ previously declared here
cfns.gperf: At global scope:
cfns.gperf:26:14: warning: inline function ‘const char* libc_name_p(const char*, unsigned int)’ used but never defined
Makefile:1065: recipe for target 'cp/except.o' failed
make[3]: *** [cp/except.o] Error 1
GCC 5.3.0
cd ~
mkdir gcc-5.3
cd gcc-5.3
mkdir build
git clone ../gcc
cd gcc
git checkout releases/gcc-5.3.0
contrib/download_prerequisites
cd ../build
../gcc/configure -v --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --prefix=/usr/local/gcc-5.3 --enable-checking=release --enable-languages=c,c++,fortran,go,ada --disable-multilib --program-suffix=-5.3 CC=gnatgcc
make -j 8
make install
Result: compile fail on Ubuntu 18.04
x86_64-linux-gnu-g++ -c -DIN_GCC_FRONTEND -g -DIN_GCC -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wno-format -Wmissing-format-attribute -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -DHAVE_CONFIG_H -I. -Icp -I../../gcc/gcc -I../../gcc/gcc/cp -I../../gcc/gcc/../include -I../../gcc/gcc/../libcpp/include -I/root/gcc-5.3/build/./gmp -I/root/gcc-5.3/gcc/gmp -I/root/gcc-5.3/build/./mpfr -I/root/gcc-5.3/gcc/mpfr -I/root/gcc-5.3/gcc/mpc/src -I../../gcc/gcc/../libdecnumber -I../../gcc/gcc/../libdecnumber/bid -I../libdecnumber -I../../gcc/gcc/../libbacktrace -I/root/gcc-5.3/build/./isl/include -I/root/gcc-5.3/gcc/isl/include -o cp/except.o -MT cp/except.o -MMD -MP -MF cp/.deps/except.TPo ../../gcc/gcc/cp/except.c
In file included from ./tm.h:27:0,
from ../../gcc/gcc/cp/except.c:27:
../../gcc/gcc/config/elfos.h:102:21: warning: invalid suffix on literal; C++11 requires a space between literal and string macro [-Wliteral-suffix]
fprintf ((FILE), "%s"HOST_WIDE_INT_PRINT_UNSIGNED"\n",\
^
../../gcc/gcc/config/elfos.h:170:24: warning: invalid suffix on literal; C++11 requires a space between literal and string macro [-Wliteral-suffix]
fprintf ((FILE), ","HOST_WIDE_INT_PRINT_UNSIGNED",%u\n", \
^
In file included from ./tm.h:48:0,
from ../../gcc/gcc/cp/except.c:27:
../../gcc/gcc/defaults.h:126:24: warning: invalid suffix on literal; C++11 requires a space between literal and string macro [-Wliteral-suffix]
fprintf ((FILE), ","HOST_WIDE_INT_PRINT_UNSIGNED",%u\n", \
^
In file included from ../../gcc/gcc/cp/except.c:1023:0:
cfns.gperf: In function ‘const char* libc_name_p(const char*, unsigned int)’:
cfns.gperf:101:1: error: ‘const char* libc_name_p(const char*, unsigned int)’ redeclared inline with ‘gnu_inline’ attribute
cfns.gperf:26:14: note: ‘const char* libc_name_p(const char*, unsigned int)’ previously declared here
cfns.gperf: At global scope:
cfns.gperf:26:14: warning: inline function ‘const char* libc_name_p(const char*, unsigned int)’ used but never defined
Makefile:1065: recipe for target 'cp/except.o' failed
GCC 5.4.0
cd ~
mkdir gcc-5.4
cd gcc-5.4
mkdir build
git clone ../gcc
cd gcc
git checkout releases/gcc-5.4.0
contrib/download_prerequisites
cd ../build
../gcc/configure -v --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --prefix=/usr/local/gcc-5.4 --enable-checking=release --enable-languages=c,c++,fortran,go,ada --disable-multilib --program-suffix=-5.4 CC=gnatgcc
make -j 8
make install
cd /root
mkdir build-8.1
cd build-8.1
mkdir build
git clone ../gcc
cd gcc
git checkout releases/gcc-8.1.0
contrib/download_prerequisites
cd ../build
../gcc/configure -v --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --prefix=/usr/local/gcc-8.1 --enable-checking=release --enable-languages=c,c++,fortran,go,ada --disable-multilib --program-suffix=-8.1 CC=gnatgcc
make -j 8
make install
It works in Ubuntu 18.04
Fails in Ubuntu 20.04
GCC 8.2.0
#instalasi gcc 8.2
cd /root
mkdir build-8.2
cd build-8.2
mkdir build
git clone ../gcc
cd gcc
git checkout releases/gcc-8.2.0
contrib/download_prerequisites
cd ../build
../gcc/configure -v --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --prefix=/usr/local/gcc-8.2 --enable-checking=release --enable-languages=c,c++,fortran,go,ada --disable-multilib --program-suffix=-8.2 CC=gnatgcc
make -j 8
make install
It works in Ubuntu 18.04
Fails in Ubuntu 20.04
GCC 8.3.0
cd /root
mkdir build-8.3
cd build-8.3
mkdir build
git clone ../gcc
cd gcc
git checkout releases/gcc-8.3.0
contrib/download_prerequisites
cd ../build
../gcc/configure -v --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --prefix=/usr/local/gcc-8.3 --enable-checking=release --enable-languages=c,c++,fortran,go,ada --disable-multilib --program-suffix=-8.3 CC=gnatgcc
make -j 8
make install
It works in Ubuntu 18.04
Fails in Ubuntu 20.04
GCC 8.4.0
available on apt
cd /root
mkdir build-8.4
cd build-8.4
mkdir build
git clone ../gcc
cd gcc
git checkout releases/gcc-8.4.0
contrib/download_prerequisites
cd ../build
../gcc/configure -v --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --prefix=/usr/local/gcc-8.4 --enable-checking=release --enable-languages=c,c++,fortran,go,ada --disable-multilib --program-suffix=-8.4 CC=gnatgcc
make
make install
GCC-8.5.0
cd /root
mkdir gcc-8.5
cd gcc-8.5
mkdir build
git clone ../gcc
cd gcc
git checkout releases/gcc-8.5.0
contrib/download_prerequisites
cd ../build
../gcc/configure -v --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --prefix=/usr/local/gcc-8.5 --enable-checking=release --enable-languages=c,c++,fortran,go,ada --disable-multilib --program-suffix=-8.5 CC=gnatgcc
make
make install
GCC 9.1.0
Ubuntu 20.04: error
glibc make[4]: *** No rule to make target '../libbacktrace/libbacktrace.la', needed by
GCC 9.2.0
cd ~
mkdir gcc-9.2
cd gcc-9.2
mkdir build
git clone ../gcc
cd gcc
git checkout releases/gcc-9.2.0
contrib/download_prerequisites
cd ../build
../gcc/configure -v --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --prefix=/usr/local/gcc-9.2 --enable-checking=release --enable-languages=c,c++,fortran,go,ada --disable-multilib --program-suffix=-9.2 CC=gnatgcc
make -j 8
make install
GCC 9.3.0
Successfull build in Ubuntu 20.04
Procedure:
cd
mkdir gcc-9.3
cd gcc-9.3
git clone ../gcc
cd gcc
git checkout releases/gcc-9.3.0
contrib/download_prerequisites
cd ..
mkdir build
cd build
../gcc/configure -v --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --prefix=/usr/local/gcc-9.3 --enable-checking=release --enable-languages=c,c++,fortran,go,ada --disable-multilib --program-suffix=-9.3 CC=gnatgcc
make
make install
GCC 9.4.0
GCC 9.5.0
GCC 10.1.0
GCC 10.2.0
GCC 10.3.0
GCC 10.4.0
GCC 11.1.0
GCC 11.2.0
GCC 11.3.0
GCC 12.1.0
cd
mkdir gcc-12.1
cd gcc-12.1
mkdir build
git clone ../gcc
cd gcc
git checkout releases/gcc-12.1.0
contrib/download_prerequisites
cd ../build
../gcc/configure -v --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --prefix=/usr/local/gcc-12.1 --enable-checking=release --enable-languages=c,c++,fortran,go,ada --disable-multilib --program-suffix=-12.1 CC=gnatgcc
make -j 8
make install
GCC 12.2.0
cd
mkdir build-12.2
cd build-12.2
mkdir build
git clone ../gcc
cd gcc
git checkout releases/gcc-12.2.0
contrib/download_prerequisites
cd ../build
../gcc/configure -v --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --prefix=/usr/local/gcc-12.2 --enable-checking=release --enable-languages=c,c++,fortran,go,ada --disable-multilib --program-suffix=-12.2 CC=gnatgcc
make -j 8
make install
Di medan perang ada banyak sisa bom yang tidak meledak namun masih tetap potensi berbahaya. Untuk itu ada yang membuat algoritma pendeteksi bom tersebut dengan machine learning.
Permasalahan: setiap kali menjalankan ‘apt’, muncul pesan error
debconf: Perl may be unconfigured (Can't locate Debconf/Log.pm in @INC (you may need to install the Debconf::Log module) (@INC contains: /usr/local/perl-5.36.0/lib/site_perl/5.36.0/x86_64-linux /usr/local/perl-5.36.0/lib/site_perl/5.36.0 /usr/local/perl-5.36.0/lib/5.36.0/x86_64-linux /usr/local/perl-5.36.0/lib/5.36.0) at (eval 1) line 4.
Kemungkinan tampilan kesalahan lain yang serupa
Reading package lists... Done
Building dependency tree
Reading state information... Done
npm is already the newest version (6.14.4+ds-1ubuntu2).
The following packages were automatically installed and are no longer required:
libgnat-10 libgnat-8 libgnat-9 libgnat-util10 libgnatvsn8 libgnatvsn9
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 16 not upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
debconf: Perl may be unconfigured (Can't locate Debconf/Log.pm in @INC (you may need to install the Debconf::Log module) (@INC contains: /usr/local/perl-5.36.0/lib/site_perl/5.36.0/x86_64-linux-thread-multi /usr/local/perl-5.36.0/lib/site_perl/5.36.0 /usr/local/perl-5.36.0/lib/5.36.0/x86_64-linux-thread-multi /usr/local/perl-5.36.0/lib/5.36.0) at (eval 1) line 4.
BEGIN failed--compilation aborted at (eval 1) line 4.
) -- aborting
Sedang menata tzdata (2023c-0ubuntu0.20.04.0) ...
Can't locate Debconf/Db.pm in @INC (you may need to install the Debconf::Db module) (@INC contains: /usr/local/perl-5.36.0/lib/site_perl/5.36.0/x86_64-linux-thread-multi /usr/local/perl-5.36.0/lib/site_perl/5.36.0 /usr/local/perl-5.36.0/lib/5.36.0/x86_64-linux-thread-multi /usr/local/perl-5.36.0/lib/5.36.0) at /usr/share/debconf/frontend line 6.
BEGIN failed--compilation aborted at /usr/share/debconf/frontend line 6.
dpkg: error processing package tzdata (--configure):
installed tzdata package post-installation script subprocess returned error exit status 2
Sedang menata pkg-config (0.29.1-0ubuntu4) ...
Can't locate Dpkg/Arch.pm in @INC (you may need to install the Dpkg::Arch module) (@INC contains: /usr/local/perl-5.36.0/lib/site_perl/5.36.0/x86_64-linux-thread-multi /usr/local/perl-5.36.0/lib/site_perl/5.36.0 /usr/local/perl-5.36.0/lib/5.36.0/x86_64-linux-thread-multi /usr/local/perl-5.36.0/lib/5.36.0) at /usr/share/pkg-config-dpkghook line 14.
BEGIN failed--compilation aborted at /usr/share/pkg-config-dpkghook line 14.
dpkg: error processing package pkg-config (--configure):
installed pkg-config package post-installation script subprocess returned error exit status 2
Ada kesalahan saat memproses:
tzdata
pkg-config
Penyebab: ada masalah di file-file debconf, sehingga apt tidak dapat berfungsi baik
Solusi: install ulang perl-base dengan perintah berikut: