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.
First step is to install all prerequisites
apt install -y build-essential linux-tools-common libapr1-dev
apt install libgmp3-dev apache2-dev libapr1-dev libaprutil1-dev apache2-dev libapr1-dev libaprutil1-dev
apt install -y gcc make libhts-dev libgl1-mesa-glx libegl1-mesa libxrandr2 libxrandr2 libxss1 libxcursor1 libxcomposite1 libasound2 libxi6 libxtst6 libpcre3-dev flex gnat
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
Summary
GCC Version | Ubuntu 16.04 | Ubuntu 18.04 | Ubuntu 20.04 |
GCC 4.9.3 (gnat) | install from apt | ||
GCC 5.1.0 | build ok | build fail | build fail |
GCC 5.2.0 | build fail | build fail | |
GCC 5.3.0 | build fail | build fail | |
GCC 5.4.0 | install from apt | build fail | build fail |
GCC 5.5.0 | install from apt | build fail | |
GCC 6.1.0 | build fail | build fail | |
GCC 6.2.0 | (building) | build fail | build fail |
GCC 6.3.0 | build fail | build fail | |
GCC 6.4.0 | build fail | build fail | |
GCC 6.5.0 | apt not available | install from apt | build fail |
GCC 7.1.0 | build ok | build fail | build fail |
GCC 7.2.0 | build ok | build fail | |
GCC 7.3.0 | build ok | build fail | |
GCC 7.4.0 | build ok | build fail | |
GCC 7.5.0 | install from apt | install from apt | |
GCC 8.1.0 | build ok | build fail | |
GCC 8.2.0 | build ok | build fail | |
GCC 8.3.0 | build ok | build fail | |
GCC 8.4.0 | install from apt | install from apt | |
GCC 8.5.0 | build ok | build ok | |
GCC 9.1.0 | build ok | build fail | |
GCC 9.2.0 | build ok | build fail | |
GCC 9.3.0 | (building) | ??? | |
GCC 9.4.0 | apt not available | install from apt | |
GCC 9.5.0 | build ok | ||
GCC 10.1.0 | build ok | ||
GCC 10.2.0 | build ok | ||
GCC 10.3.0 | build ok | ||
GCC 10.4.0 | apt not available | build ok | |
GCC 11.1.0 | build ok | ||
GCC 11.2.0 | build ok | ||
GCC 11.3.0 | apt not available | apt | |
GCC 12.1.0 | build ok | ||
GCC 12.2.0 | apt not available | build ok |
cd ~
git clone https://github.com/gcc-mirror/gcc
GCC 5.1.0
Install gcc 5.1.0 in Ubuntu 18.04
gnatgcc version 6.5.0
gcc version 6.5.0
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
build fail
/root/gcc-5.4/build/./gcc/xgcc -B/root/gcc-5.4/build/./gcc/ -B/usr/local/gcc-5.4/x86_64-linux-gnu/bin/ -B/usr/local/gcc-5.4/x86_64-linux-gnu/lib/ -isystem /usr/local/gcc-5.4/x86_64-linux-gnu/include -isystem /usr/local/gcc-5.4/x86_64-linux-gnu/sys-include -g -O2 -O2 -g -O2 -DIN_GCC -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wno-format -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -isystem ./include -fpic -mlong-double-80 -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector -fpic -mlong-double-80 -I. -I. -I../.././gcc -I../../../gcc/libgcc -I../../../gcc/libgcc/. -I../../../gcc/libgcc/../gcc -I../../../gcc/libgcc/../include -I../../../gcc/libgcc/config/libbid -DENABLE_DECIMAL_BID_FORMAT -DHAVE_CC_TLS -DUSE_TLS -o unwind-dw2.o -MT unwind-dw2.o -MD -MP -MF unwind-dw2.dep -fexceptions -c ../../../gcc/libgcc/unwind-dw2.c -fvisibility=hidden -DHIDE_EXPORTS
In file included from ../../../gcc/libgcc/unwind-dw2.c:401:0:
./md-unwind-support.h: In function ‘x86_64_fallback_frame_state’:
./md-unwind-support.h:65:47: error: dereferencing pointer to incomplete type ‘struct ucontext’
sc = (struct sigcontext *) (void *) &uc_->uc_mcontext;
^
../../../gcc/libgcc/shared-object.mk:14: recipe for target 'unwind-dw2.o' failed
make[3]: *** [unwind-dw2.o] Error 1
GCC 5.5.0
available on apt, no need to compile
apt install gcc-5
apt install g++-5
apt install gfortran-5
apt install gnat-5
apt install gccgo-5
GCC 6.1.0
cd
mkdir gcc-6.1
cd gcc-6.1
mkdir build
git clone ../gcc
cd gcc
git checkout releases/gcc-6.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-6.1 --enable-checking=release --enable-languages=c,c++,fortran,go,ada --disable-multilib --program-suffix=-6.1 CC=gnatgcc
make -j 8
make install
build fail
/root/gcc-6.1/build/./gcc/xgcc -B/root/gcc-6.1/build/./gcc/ -B/usr/local/gcc-6.1/x86_64-linux-gnu/bin/ -B/usr/local/gcc-6.1/x86_64-linux-gnu/lib/ -isystem /usr/local/gcc-6.1/x86_64-linux-gnu/include -isystem /usr/local/gcc-6.1/x86_64-linux-gnu/sys-include -g -O2 -O2 -g -O2 -DIN_GCC -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wno-format -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -isystem ./include -fpic -mlong-double-80 -DUSE_ELF_SYMVER -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector -fpic -mlong-double-80 -DUSE_ELF_SYMVER -I. -I. -I../.././gcc -I../../../gcc/libgcc -I../../../gcc/libgcc/. -I../../../gcc/libgcc/../gcc -I../../../gcc/libgcc/../include -I../../../gcc/libgcc/config/libbid -DENABLE_DECIMAL_BID_FORMAT -DHAVE_CC_TLS -DUSE_TLS -o unwind-dw2.o -MT unwind-dw2.o -MD -MP -MF unwind-dw2.dep -fexceptions -c ../../../gcc/libgcc/unwind-dw2.c -fvisibility=hidden -DHIDE_EXPORTS
In file included from ../../../gcc/libgcc/unwind-dw2.c:401:0:
./md-unwind-support.h: In function ‘x86_64_fallback_frame_state’:
./md-unwind-support.h:65:47: error: dereferencing pointer to incomplete type ‘struct ucontext’
sc = (struct sigcontext *) (void *) &uc_->uc_mcontext;
^~
../../../gcc/libgcc/shared-object.mk:14: recipe for target 'unwind-dw2.o' failed
make[3]: *** [unwind-dw2.o] Error 1
GCC 6.2.0
cd
mkdir gcc-6.2
cd gcc-6.2
mkdir build
git clone ../gcc
cd gcc
git checkout releases/gcc-6.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-6.2 --enable-checking=release --enable-languages=c,c++,fortran,go,ada --disable-multilib --program-suffix=-6.2 CC=gnatgcc
make -j 8
make install
build failed on Ubuntu 18.04
/root/gcc-6.2/build/./gcc/xgcc -B/root/gcc-6.2/build/./gcc/ -B/usr/local/gcc-6.2/x86_64-linux-gnu/bin/ -B/usr/local/gcc-6.2/x86_64-linux-gnu/lib/ -isystem /usr/local/gcc-6.2/x86_64-linux-gnu/include -isystem /usr/local/gcc-6.2/x86_64-linux-gnu/sys-include -g -O2 -O2 -g -O2 -DIN_GCC -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wno-format -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -isystem ./include -fpic -mlong-double-80 -DUSE_ELF_SYMVER -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector -fpic -mlong-double-80 -DUSE_ELF_SYMVER -I. -I. -I../.././gcc -I../../../gcc/libgcc -I../../../gcc/libgcc/. -I../../../gcc/libgcc/../gcc -I../../../gcc/libgcc/../include -I../../../gcc/libgcc/config/libbid -DENABLE_DECIMAL_BID_FORMAT -DHAVE_CC_TLS -DUSE_TLS -o unwind-dw2.o -MT unwind-dw2.o -MD -MP -MF unwind-dw2.dep -fexceptions -c ../../../gcc/libgcc/unwind-dw2.c -fvisibility=hidden -DHIDE_EXPORTS
In file included from ../../../gcc/libgcc/unwind-dw2.c:401:0:
./md-unwind-support.h: In function ‘x86_64_fallback_frame_state’:
./md-unwind-support.h:65:47: error: dereferencing pointer to incomplete type ‘struct ucontext’
sc = (struct sigcontext *) (void *) &uc_->uc_mcontext;
^~
../../../gcc/libgcc/shared-object.mk:14: recipe for target 'unwind-dw2.o' failed
GCC 6.3.0
cd
mkdir gcc-6.3
cd gcc-6.3
mkdir build
git clone ../gcc
cd gcc
git checkout releases/gcc-6.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-6.3 --enable-checking=release --enable-languages=c,c++,fortran,go,ada --disable-multilib --program-suffix=-6.3 CC=gnatgcc
make -j 8
make install
build fail on Ubuntu 18.04
/root/gcc-6.3/build/./gcc/xgcc -B/root/gcc-6.3/build/./gcc/ -B/usr/local/gcc-6.3/x86_64-linux-gnu/bin/ -B/usr/local/gcc-6.3/x86_64-linux-gnu/lib/ -isystem /usr/local/gcc-6.3/x86_64-linux-gnu/include -isystem /usr/local/gcc-6.3/x86_64-linux-gnu/sys-include -g -O2 -O2 -g -O2 -DIN_GCC -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wno-format -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -isystem ./include -fpic -mlong-double-80 -DUSE_ELF_SYMVER -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector -fpic -mlong-double-80 -DUSE_ELF_SYMVER -I. -I. -I../.././gcc -I../../../gcc/libgcc -I../../../gcc/libgcc/. -I../../../gcc/libgcc/../gcc -I../../../gcc/libgcc/../include -I../../../gcc/libgcc/config/libbid -DENABLE_DECIMAL_BID_FORMAT -DHAVE_CC_TLS -DUSE_TLS -o unwind-dw2.o -MT unwind-dw2.o -MD -MP -MF unwind-dw2.dep -fexceptions -c ../../../gcc/libgcc/unwind-dw2.c -fvisibility=hidden -DHIDE_EXPORTS
In file included from ../../../gcc/libgcc/unwind-dw2.c:401:0:
./md-unwind-support.h: In function ‘x86_64_fallback_frame_state’:
./md-unwind-support.h:65:47: error: dereferencing pointer to incomplete type ‘struct ucontext’
sc = (struct sigcontext *) (void *) &uc_->uc_mcontext;
^~
../../../gcc/libgcc/shared-object.mk:14: recipe for target 'unwind-dw2.o' failed
make[3]: *** [unwind-dw2.o] Error 1
GCC 6.4.0
cd
mkdir gcc-6.4
cd gcc-6.4
mkdir build
git clone ../gcc
cd gcc
git checkout releases/gcc-6.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-6.4 --enable-checking=release --enable-languages=c,c++,fortran,go,ada --disable-multilib --program-suffix=-6.4 CC=gnatgcc
make -j 8
make install
Build fail in Ubuntu 18.04
/root/gcc-6.4/build/./gcc/xgcc -B/root/gcc-6.4/build/./gcc/ -B/usr/local/gcc-6.4/x86_64-linux-gnu/bin/ -B/usr/local/gcc-6.4/x86_64-linux-gnu/lib/ -isystem /usr/local/gcc-6.4/x86_64-linux-gnu/include -isystem /usr/local/gcc-6.4/x86_64-linux-gnu/sys-include -g -O2 -O2 -g -O2 -DIN_GCC -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wno-format -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -isystem ./include -fpic -mlong-double-80 -DUSE_ELF_SYMVER -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector -fpic -mlong-double-80 -DUSE_ELF_SYMVER -I. -I. -I../.././gcc -I../../../gcc/libgcc -I../../../gcc/libgcc/. -I../../../gcc/libgcc/../gcc -I../../../gcc/libgcc/../include -I../../../gcc/libgcc/config/libbid -DENABLE_DECIMAL_BID_FORMAT -DHAVE_CC_TLS -DUSE_TLS -o unwind-dw2.o -MT unwind-dw2.o -MD -MP -MF unwind-dw2.dep -fexceptions -c ../../../gcc/libgcc/unwind-dw2.c -fvisibility=hidden -DHIDE_EXPORTS
In file included from ../../../gcc/libgcc/unwind-dw2.c:401:0:
./md-unwind-support.h: In function ‘x86_64_fallback_frame_state’:
./md-unwind-support.h:65:47: error: dereferencing pointer to incomplete type ‘struct ucontext’
sc = (struct sigcontext *) (void *) &uc_->uc_mcontext;
^~
../../../gcc/libgcc/shared-object.mk:14: recipe for target 'unwind-dw2.o' failed
make[3]: *** [unwind-dw2.o] Error 1
GCC 6.5.0
available on apt
apt install gcc-6
apt install g++-6
apt install gfortran-6
apt install gnat-6
apt install gccgo-6
GCC 7.1.0
cd
mkdir gcc-7.1
cd gcc-7.1
mkdir build
git clone ../gcc
cd gcc
git checkout releases/gcc-7.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-7.1 --enable-checking=release --enable-languages=c,c++,fortran,go,ada --disable-multilib --program-suffix=-7.1 CC=gnatgcc
make -j 8
make install
build fail
/root/gcc-7.1/build/./gcc/xgcc -B/root/gcc-7.1/build/./gcc/ -B/usr/local/gcc-7.1/x86_64-linux-gnu/bin/ -B/usr/local/gcc-7.1/x86_64-linux-gnu/lib/ -isystem /usr/local/gcc-7.1/x86_64-linux-gnu/include -isystem /usr/local/gcc-7.1/x86_64-linux-gnu/sys-include -g -O2 -O2 -g -O2 -DIN_GCC -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wno-format -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -isystem ./include -fpic -mlong-double-80 -DUSE_ELF_SYMVER -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector -fpic -mlong-double-80 -DUSE_ELF_SYMVER -I. -I. -I../.././gcc -I../../../gcc/libgcc -I../../../gcc/libgcc/. -I../../../gcc/libgcc/../gcc -I../../../gcc/libgcc/../include -I../../../gcc/libgcc/config/libbid -DENABLE_DECIMAL_BID_FORMAT -DHAVE_CC_TLS -DUSE_TLS -o unwind-dw2.o -MT unwind-dw2.o -MD -MP -MF unwind-dw2.dep -fexceptions -c ../../../gcc/libgcc/unwind-dw2.c -fvisibility=hidden -DHIDE_EXPORTS
In file included from ../../../gcc/libgcc/unwind-dw2.c:403:0:
./md-unwind-support.h: In function ‘x86_64_fallback_frame_state’:
./md-unwind-support.h:65:47: error: dereferencing pointer to incomplete type ‘struct ucontext’
sc = (struct sigcontext *) (void *) &uc_->uc_mcontext;
^~
../../../gcc/libgcc/shared-object.mk:14: recipe for target 'unwind-dw2.o' failed
make[3]: *** [unwind-dw2.o] Error 1
mentioned in “gcc does not compile when using glib 2.2.6 (everything works fine with 2.25)“
GCC 7.2.0
cd /root
mkdir build-7.2
cd build-7.2
mkdir build
git clone ../gcc
cd gcc
git checkout releases/gcc-7.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-7.2 --enable-checking=release --enable-languages=c,c++,fortran,go,ada --disable-multilib --program-suffix=-7.2 CC=gnatgcc
make
make install
build ok on Ubuntu 18.04
GCC 7.3.0
cd /root
mkdir gcc-7.3
cd gcc-7.3
mkdir build
git clone ../gcc
cd gcc
git checkout releases/gcc-7.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-7.3 --enable-checking=release --enable-languages=c,c++,fortran,go,ada --disable-multilib --program-suffix=-7.3 CC=gnatgcc
make -j 8
make install
GCC 7.4.0
GCC 7.5.0
GCC 7.5.0 is available in Ubuntu 18.04 and Ubuntu 20.04. Easier to install with apt rather than compiling itself.
apt install gcc-7
apt install g++-7
apt install gfortran-7
apt install gnat-7
apt install gccgo-7
GCC 8.1.0
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
Installing Update Alternatives
Update Alternatives for GCC
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 55
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 65
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 75
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 84
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 94
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 103
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 111
update-alternatives --install /usr/bin/gcc gcc /usr/local/gcc-8.5/bin/gcc-8.5 85
update-alternatives --install /usr/bin/gcc gcc /usr/local/gcc-9.4/bin/gcc-9.4 94
update-alternatives --install /usr/bin/gcc gcc /usr/local/gcc-9.5/bin/gcc-9.5 95
update-alternatives --install /usr/bin/gcc gcc /usr/local/gcc-10.1/bin/gcc-10.1 101
update-alternatives --install /usr/bin/gcc gcc /usr/local/gcc-10.2/bin/gcc-10.2 102
update-alternatives --install /usr/bin/gcc gcc /usr/local/gcc-10.3/bin/gcc-10.3 103
update-alternatives --install /usr/bin/gcc gcc /usr/local/gcc-10.4/bin/gcc-10.4 104
update-alternatives --install /usr/bin/gcc gcc /usr/local/gcc-11.1/bin/gcc-11.1 111
update-alternatives --install /usr/bin/gcc gcc /usr/local/gcc-11.2/bin/gcc-11.2 112
update-alternatives --install /usr/bin/gcc gcc /usr/local/gcc-11.3/bin/gcc-11.3 113
update-alternatives --install /usr/bin/gcc gcc /usr/local/gcc-12.1/bin/gcc-12.1 121
update-alternatives --install /usr/bin/gcc gcc /usr/local/gcc-12.2/bin/gcc-12.2 122
Updater alternatives for g++
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-5 55
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-6 65
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 75
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-8 84
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-9 94
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-10 103
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-11 111
update-alternatives --install /usr/bin/g++ g++ /usr/local/gcc-8.5/bin/g++-8.5 85
update-alternatives --install /usr/bin/g++ g++ /usr/local/gcc-9.4/bin/g++-9.4 94
update-alternatives --install /usr/bin/g++ g++ /usr/local/gcc-9.5/bin/g++-9.5 95
update-alternatives --install /usr/bin/g++ g++ /usr/local/gcc-10.1/bin/g++-10.1 101
update-alternatives --install /usr/bin/g++ g++ /usr/local/gcc-10.2/bin/g++-10.2 102
update-alternatives --install /usr/bin/g++ g++ /usr/local/gcc-10.3/bin/g++-10.3 103
update-alternatives --install /usr/bin/g++ g++ /usr/local/gcc-10.4/bin/g++-10.4 104
update-alternatives --install /usr/bin/g++ g++ /usr/local/gcc-11.1/bin/g++-11.1 111
update-alternatives --install /usr/bin/g++ g++ /usr/local/gcc-11.2/bin/g++-11.2 112
update-alternatives --install /usr/bin/g++ g++ /usr/local/gcc-11.3/bin/g++-11.3 113
update-alternatives --install /usr/bin/g++ g++ /usr/local/gcc-12.1/bin/g++-12.1 121
update-alternatives --install /usr/bin/g++ g++ /usr/local/gcc-12.2/bin/g++-12.2 122
Update Alternatives for gfortran
Update alternatives for gccgo
Update alternatives for gnat (Ada compiler)
update-alternatives --install /usr/bin/gnat gnat /usr/bin/gnat-7 75 --slave /usr/bin/gnatchop gnatchop /usr/bin/gnatchop-7 --slave /usr/bin/gnatmake gnatmake /usr/bin/gnatmake-7 --slave /usr/bin/gnatbind gnatbind /usr/bin/gnatbind-7 --slave /usr/bin/gnatlink gnatlink /usr/bin/gnatlink-7
update-alternatives --install /usr/bin/gnat gnat /usr/local/gcc-8.5/bin/gnat-8.5 85 --slave /usr/bin/gnatchop gnatchop /usr/local/gcc-8.5/bin/gnatchop-8.5 --slave /usr/bin/gnatmake gnatmake /usr/local/gcc-8.5/bin/gnatmake-8.5 --slave /usr/bin/gnatbind gnatbind /usr/local/gcc-8.5/bin/gnatbind-8.5 --slave /usr/bin/gnatlink gnatlink /usr/local/gcc-8.5/bin/gnatlink-8.5
update-alternatives --install /usr/bin/gnat gnat /usr/local/gcc-9.4/bin/gnat-9.4 94 --slave /usr/bin/gnatchop gnatchop /usr/local/gcc-9.4/bin/gnatchop-9.4 --slave /usr/bin/gnatmake gnatmake /usr/local/gcc-9.4/bin/gnatmake-9.4 --slave /usr/bin/gnatbind gnatbind /usr/local/gcc-9.4/bin/gnatbind-9.4 --slave /usr/bin/gnatlink gnatlink /usr/local/gcc-9.4/bin/gnatlink-9.4
update-alternatives --install /usr/bin/gnat gnat /usr/local/gcc-9.5/bin/gnat-9.5 95 --slave /usr/bin/gnatchop gnatchop /usr/local/gcc-9.5/bin/gnatchop-9.5 --slave /usr/bin/gnatmake gnatmake /usr/local/gcc-9.5/bin/gnatmake-9.5 --slave /usr/bin/gnatbind gnatbind /usr/local/gcc-9.5/bin/gnatbind-9.5 --slave /usr/bin/gnatlink gnatlink /usr/local/gcc-9.5/bin/gnatlink-9.5
update-alternatives --install /usr/bin/gnat gnat /usr/local/gcc-10.1/bin/gnat-10.1 101 --slave /usr/bin/gnatchop gnatchop /usr/local/gcc-10.1/bin/gnatchop-10.1 --slave /usr/bin/gnatmake gnatmake /usr/local/gcc-10.1/bin/gnatmake-10.1 --slave /usr/bin/gnatbind gnatbind /usr/local/gcc-10.1/bin/gnatbind-10.1 --slave /usr/bin/gnatlink gnatlink /usr/local/gcc-10.1/bin/gnatlink-10.1
update-alternatives --install /usr/bin/gnat gnat /usr/local/gcc-10.2/bin/gnat-10.2 102 --slave /usr/bin/gnatchop gnatchop /usr/local/gcc-10.2/bin/gnatchop-10.2 --slave /usr/bin/gnatmake gnatmake /usr/local/gcc-10.2/bin/gnatmake-10.2 --slave /usr/bin/gnatbind gnatbind /usr/local/gcc-10.2/bin/gnatbind-10.2 --slave /usr/bin/gnatlink gnatlink /usr/local/gcc-10.2/bin/gnatlink-10.2
update-alternatives --install /usr/bin/gnat gnat /usr/local/gcc-10.3/bin/gnat-10.3 103 --slave /usr/bin/gnatchop gnatchop /usr/local/gcc-10.3/bin/gnatchop-10.3 --slave /usr/bin/gnatmake gnatmake /usr/local/gcc-10.3/bin/gnatmake-10.3 --slave /usr/bin/gnatbind gnatbind /usr/local/gcc-10.3/bin/gnatbind-10.3 --slave /usr/bin/gnatlink gnatlink /usr/local/gcc-10.3/bin/gnatlink-10.3
update-alternatives --install /usr/bin/gnat gnat /usr/local/gcc-10.4/bin/gnat-10.4 104 --slave /usr/bin/gnatchop gnatchop /usr/local/gcc-10.4/bin/gnatchop-10.4 --slave /usr/bin/gnatmake gnatmake /usr/local/gcc-10.4/bin/gnatmake-10.4 --slave /usr/bin/gnatbind gnatbind /usr/local/gcc-10.4/bin/gnatbind-10.4 --slave /usr/bin/gnatlink gnatlink /usr/local/gcc-10.4/bin/gnatlink-10.4
update-alternatives --install /usr/bin/gnat gnat /usr/local/gcc-11.1/bin/gnat-11.1 111 --slave /usr/bin/gnatchop gnatchop /usr/local/gcc-11.1/bin/gnatchop-11.1 --slave /usr/bin/gnatmake gnatmake /usr/local/gcc-11.1/bin/gnatmake-11.1 --slave /usr/bin/gnatbind gnatbind /usr/local/gcc-11.1/bin/gnatbind-11.1 --slave /usr/bin/gnatlink gnatlink /usr/local/gcc-11.1/bin/gnatlink-11.1
update-alternatives --install /usr/bin/gnat gnat /usr/local/gcc-11.2/bin/gnat-11.2 112 --slave /usr/bin/gnatchop gnatchop /usr/local/gcc-11.2/bin/gnatchop-11.2 --slave /usr/bin/gnatmake gnatmake /usr/local/gcc-11.2/bin/gnatmake-11.2 --slave /usr/bin/gnatbind gnatbind /usr/local/gcc-11.2/bin/gnatbind-11.2 --slave /usr/bin/gnatlink gnatlink /usr/local/gcc-11.2/bin/gnatlink-11.2
update-alternatives --install /usr/bin/gnat gnat /usr/local/gcc-11.3/bin/gnat-11.3 113 --slave /usr/bin/gnatchop gnatchop /usr/local/gcc-11.3/bin/gnatchop-11.3 --slave /usr/bin/gnatmake gnatmake /usr/local/gcc-11.3/bin/gnatmake-11.3 --slave /usr/bin/gnatbind gnatbind /usr/local/gcc-11.3/bin/gnatbind-11.3 --slave /usr/bin/gnatlink gnatlink /usr/local/gcc-11.3/bin/gnatlink-11.3
update-alternatives --install /usr/bin/gnat gnat /usr/local/gcc-12.1/bin/gnat-12.1 121 --slave /usr/bin/gnatchop gnatchop /usr/local/gcc-12.1/bin/gnatchop-12.1 --slave /usr/bin/gnatmake gnatmake /usr/local/gcc-12.1/bin/gnatmake-12.1 --slave /usr/bin/gnatbind gnatbind /usr/local/gcc-12.1/bin/gnatbind-12.1 --slave /usr/bin/gnatlink gnatlink /usr/local/gcc-12.1/bin/gnatlink-12.1
update-alternatives --install /usr/bin/gnat gnat /usr/local/gcc-12.2/bin/gnat-12.2 122 --slave /usr/bin/gnatchop gnatchop /usr/local/gcc-12.2/bin/gnatchop-12.2 --slave /usr/bin/gnatmake gnatmake /usr/local/gcc-12.2/bin/gnatmake-12.2 --slave /usr/bin/gnatbind gnatbind /usr/local/gcc-12.2/bin/gnatbind-12.2 --slave /usr/bin/gnatlink gnatlink /usr/local/gcc-12.2/bin/gnatlink-12.2
References
- https://linuxize.com/post/how-to-install-gcc-on-ubuntu-20-04/
- https://iamsorush.com/posts/build-gcc11/
- https://github.com/gcc-mirror/gcc
- https://commons.wikimedia.org/wiki/File:GNU_Compiler_Collection_logo.svg