I am trying to compile GCC 8.5.0 from source in UBI8. Specifically, I want to build GNAT alongside it. Starting with the Docker image
redhat/ubi8
I install the required packages
dnf install -y gcc-gnat gcc-c++ gmp-devel mpfr-devel libmpc-devel
and download the source code of GCC 8.5.0 (same version as the system compiler) from the GNU website.
I unzip, make the build directory, and run configure from there. Most flags are irrelevant here, but I am adding ada to the build:
../configure --enable-bootstrap --enable-languages=c,c++,fortran,lto,ada ...
And I get this error:
configure: error: GNAT is required to build ada
Clearly gnat
is installed:
# gnat --version
GNAT 8.5.0 20210514 (Red Hat 8.5.0-21)
Copyright (C) 1996-2018, Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
So what's happening? gcc
appears to not have been built with the ada frontend so it does not understand ada files. As seen here
# touch a.adb
# gcc -c a.adb
gcc: error: a.adb: Ada compiler not installed on this system
Which begs my question: is it at all possible to build GNAT using the system compiler? I was able to on CentOS7 since the package there had the frontend built in, however here it seemingly does not
Probably not. Looking at the description of the gcc-gnat package in EPEL:
Important: Please use 'gnatgcc' rather than 'gcc' for a GCC with Ada/GNAT support because 'gcc' is unfortunately not really modular and was also built without Ada/GNAT support by Red Hat (or a vendor of a 100% bug-for-bug compatible drop-in distribution).
The package that provides a GCC with GNAT provides it as a standalone GCC compiler with Ada support (gnatgcc
). The "normal" gcc
executable is installed from a Red Hat repository. That compiler is (as of RHEL 8, link) build without Ada support.
The above can be verified in the output of the package installer. It shows that gcc-gnat
is installed from epel
and gcc
is installed from ubi-9-appstream-rpms
.
Note: Output shows the installation of gcc-gnat
on UBI 9 as I couldn't get it installed on UBI 8. The reasoning seems the same though.
# dnf install -y gcc-gnat
[...]
Extra Packages for Enterprise Linux 9 - x86_64 7.5 MB/s | 21 MB 00:02
Extra Packages for Enterprise Linux 9 openh264 5.9 kB/s | 2.5 kB 00:00
Dependencies resolved.
=======================================================================================
Package Arch Version Repository Size
=======================================================================================
Installing:
gcc-gnat x86_64 11.4.1-4.el9 epel 16 M
Upgrading:
glibc x86_64 2.34-100.el9_4.2 ubi-9-baseos-rpms 2.0 M
glibc-common x86_64 2.34-100.el9_4.2 ubi-9-baseos-rpms 313 k
glibc-minimal-langpack x86_64 2.34-100.el9_4.2 ubi-9-baseos-rpms 28 k
Installing dependencies:
binutils x86_64 2.35.2-43.el9 ubi-9-baseos-rpms 4.6 M
binutils-gold x86_64 2.35.2-43.el9 ubi-9-baseos-rpms 736 k
cpp x86_64 11.4.1-3.el9 ubi-9-appstream-rpms 11 M
elfutils-debuginfod-client x86_64 0.190-2.el9 ubi-9-baseos-rpms 39 k
gcc x86_64 11.4.1-3.el9 ubi-9-appstream-rpms 32 M
glibc-devel x86_64 2.34-100.el9_4.2 ubi-9-appstream-rpms 42 k
glibc-headers x86_64 2.34-100.el9_4.2 ubi-9-appstream-rpms 548 k
kernel-headers x86_64 5.14.0-427.18.1.el9_4 ubi-9-appstream-rpms 7.4 M
libgnat x86_64 11.4.1-4.el9 epel 1.3 M
libgnat-devel x86_64 11.4.1-4.el9 epel 4.1 M
libmpc x86_64 1.2.1-4.el9 ubi-9-appstream-rpms 65 k
libpkgconf x86_64 1.7.3-10.el9 ubi-9-baseos-rpms 37 k
libxcrypt-devel x86_64 4.4.18-3.el9 ubi-9-appstream-rpms 32 k
make x86_64 1:4.3-8.el9 ubi-9-baseos-rpms 541 k
pkgconf x86_64 1.7.3-10.el9 ubi-9-baseos-rpms 45 k
pkgconf-m4 noarch 1.7.3-10.el9 ubi-9-baseos-rpms 16 k
pkgconf-pkg-config x86_64 1.7.3-10.el9 ubi-9-baseos-rpms 12 k
Installing weak dependencies:
glibc-langpack-en x86_64 2.34-100.el9_4.2 ubi-9-baseos-rpms 666 k