Gprconfig: can't find native toolchain for language 'ada'

Hello,

I have installed the gnat-10 Debian package on Linux and I can build Ada sources using gnatmake but gprconfig is not detecting my Ada compiler.

Here are some outputs that I’ve collected from my system:

gprconfig output:

$ gprconfig
--------------------------------------------------
gprconfig has found the following compilers on your PATH.
Only those matching the target and the selected compilers are displayed.
   1. GCC-ASM for Asm in /usr/local/bin/ version 13.2.0
   2. GCC-ASM for Asm in /usr/bin/ version 11.4.0
   3. GCC-ASM for Asm2 in /usr/local/bin/ version 13.2.0
   4. GCC-ASM for Asm2 in /usr/bin/ version 11.4.0
   5. GCC-ASM for Asm_Cpp in /usr/local/bin/ version 13.2.0
   6. GCC-ASM for Asm_Cpp in /usr/bin/ version 11.4.0
   7. LD for Bin_Img in /usr/bin/ version 2.38
   8. GCC for C in /usr/local/bin/ version 13.2.0
   9. GCC for C in /usr/bin/ version 11.4.0
  10. G++ for C++ in /usr/bin/ version 11.4.0
Select or unselect the following compiler (or "s" to save):

gprconfig targets:

$ gprconfig --show-targets
List of targets supported by a compiler:
x86_64-linux (native target)
x86_64-linux

gcc version:

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/bin/../libexec/gcc/x86_64-pc-linux-gnu/13.2.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../src/configure --prefix=/home/runner/work/GNAT-FSF-builds/GNAT-FSF-builds/sbx/x86_64-linux/gcc/install --with-build-time-tools=/home/runner/work/GNAT-FSF-builds/GNAT-FSF-builds/sbx/x86_64-linux/binutils/install/bin --enable-languages=c,ada,c++ --enable-libstdcxx --enable-libstdcxx-threads --enable-libada --disable-nls --without-libiconv-prefix --disable-libstdcxx-pch --enable-lto --disable-multilib --enable-threads=posix --with-gnu-ld --with-gnu-as --with-mpfr=/home/runner/work/GNAT-FSF-builds/GNAT-FSF-builds/sbx/x86_64-linux/mpfr/install --with-gmp=/home/runner/work/GNAT-FSF-builds/GNAT-FSF-builds/sbx/x86_64-linux/gmp/install --with-mpc=/home/runner/work/GNAT-FSF-builds/GNAT-FSF-builds/sbx/x86_64-linux/mpc/install --with-isl=/home/runner/work/GNAT-FSF-builds/GNAT-FSF-builds/sbx/x86_64-linux/isl/install --build=x86_64-pc-linux-gnu
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 13.2.0 (GCC)

Any help would be greatly appreciated.

Thanks,
N

1 Like

I got this working with some help from Alire (see below):

Use the toolchain assistant:

$ alr toolchain --select
Welcome to the toolchain selection assistant     

In this assistant you can set up the default toolchain to be used with any crate
that does not specify its own top-level dependency on a version of gnat or 
gprbuild.

If you choose "None", Alire will use whatever version is found in the 
environment.

ⓘ Currently configured: gnat_native=13.2.1

Please select the gnat version for use with this configuration
  1. gnat_native=13.2.1
  2. None
  3. gnat_arm_elf=13.2.1
  4. gnat_avr_elf=13.2.1
  5. gnat_riscv64_elf=13.2.1
  6. gnat_arm_elf=13.1.0
  7. gnat_avr_elf=13.1.0
  8. gnat_native=13.1.0
  9. gnat_riscv64_elf=13.1.0
  0. gnat_arm_elf=12.2.1
  a. (See more choices...)
Enter your choice index (first is default): 
> 1
ⓘ Selected tool version gnat_native=13.2.1

ⓘ Choices for the following tool are narrowed down to releases compatible with just selected gnat_native=13.2.1

ⓘ Currently configured: gprbuild=22.0.1

Please select the gprbuild version for use with this configuration
  1. gprbuild=22.0.1
  2. None
  3. gprbuild=21.0.2
  4. gprbuild=21.0.1
Enter your choice index (first is default): 
> 1
ⓘ Selected tool version gprbuild=22.0.1

Next run ‘alr printenv’ and use these settings in your environment configuration.

1 Like

gprconfig can be a bit picky. Your 13.2.0 compiler has target x86_64-pc-linux-gnu, but gprconfig is looking for x86_64-linux. The matching logic in gprconfig isn’t simple; this might work better with gprconfig --target=x86_64-pc-linux-gnu.

Not sure why that gprconfig didn’t see the Debian package, though.

It’s always best to use a gprconfig/gprbuild built by the compiler you want it to detect! which is why alr toolchain --select worked.

Thanks Simon.

What I don’t understand is why gprconfig does not detect the gcc that is installed by the gnat package (‘gcc’ 11.4.0) which is located in PATH at /usr/bin/gcc

Here is the output of gcc:

$ /usr/bin/gcc -v
Using built-in specs.
COLLECT_GCC=/usr/bin/gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/11/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 11.4.0-1ubuntu1~22.04' --with-bugurl=file:///usr/share/doc/gcc-11/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-11 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --enable-cet --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-11-XeT9lY/gcc-11-11.4.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-11-XeT9lY/gcc-11-11.4.0/debian/tmp-gcn/usr --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-serialization=2
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.4.0 (Ubuntu 11.4.0-1ubuntu1~22.04)

gprconfig output (with target):

$ gprconfig --target=x86_64-linux-gnu
--------------------------------------------------
gprconfig has found the following compilers on your PATH.
Only those matching the target and the selected compilers are displayed.
   1. GNAT for Ada in /home/computer/.config/alire/cache/dependencies/gnat_native_13.2.1_788a01f9/bin/ version 13.2 (default runtime)
   2. GCC-ASM for Asm in /home/computer/.config/alire/cache/dependencies/gnat_native_13.2.1_788a01f9/bin/ version 13.2.0
   3. GCC-ASM for Asm in /usr/local/bin/ version 13.2.0
   4. GCC-ASM for Asm in /usr/bin/ version 11.4.0
   5. GCC-ASM for Asm2 in /home/computer/.config/alire/cache/dependencies/gnat_native_13.2.1_788a01f9/bin/ version 13.2.0
   6. GCC-ASM for Asm2 in /usr/local/bin/ version 13.2.0
   7. GCC-ASM for Asm2 in /usr/bin/ version 11.4.0
   8. GCC-ASM for Asm_Cpp in /home/computer/.config/alire/cache/dependencies/gnat_native_13.2.1_788a01f9/bin/ version 13.2.0
   9. GCC-ASM for Asm_Cpp in /usr/local/bin/ version 13.2.0
  10. GCC-ASM for Asm_Cpp in /usr/bin/ version 11.4.0
  11. LD for Bin_Img in /home/computer/.config/alire/cache/dependencies/gnat_native_13.2.1_788a01f9/bin/ version 2.40
  12. LD for Bin_Img in /usr/bin/ version 2.38
  13. GCC for C in /home/computer/.config/alire/cache/dependencies/gnat_native_13.2.1_788a01f9/bin/ version 13.2.0
  14. GCC for C in /usr/local/bin/ version 13.2.0
  15. GCC for C in /usr/bin/ version 11.4.0  
  16. G++ for C++ in /home/computer/.config/alire/cache/dependencies/gnat_native_13.2.1_788a01f9/bin/ version 13.2.0
  17. G++ for C++ in /usr/bin/ version 11.4.0
Select or unselect the following compiler (or "s" to save):

GNAT tools are installed in /usr/bin:

$ ls /usr/bin/gnat*
/usr/bin/gnat         /usr/bin/gnatchop-10   /usr/bin/gnatgcc      /usr/bin/gnatlink     /usr/bin/gnatmake-10  /usr/bin/gnatprove
/usr/bin/gnat-10      /usr/bin/gnatclean     /usr/bin/gnathtml     /usr/bin/gnatlink-10  /usr/bin/gnatname     /usr/bin/gnatxref
/usr/bin/gnatbind     /usr/bin/gnatclean-10  /usr/bin/gnathtml-10  /usr/bin/gnatls       /usr/bin/gnatname-10  /usr/bin/gnatxref-10
/usr/bin/gnatbind-10  /usr/bin/gnatfind      /usr/bin/gnatkr       /usr/bin/gnatls-10    /usr/bin/gnatprep
/usr/bin/gnatchop     /usr/bin/gnatfind-10   /usr/bin/gnatkr-10    /usr/bin/gnatmake     /usr/bin/gnatprep-10

So, it looks like it cannot find the runtime associated with the compiler installed at /usr/bin:

gprconfig verbose shows:

$ gprconfig -v --target=x86_64-linux-gnu
...snip...
   GNAT is candidate: filename=gnatls    
     target: executing "gcc -dumpmachine" output=<use -v -v> no match    
     target: grep matched="x86_64-linux-gnu"    
     version: executing "gnatls -v --version" output=<use -v -v> no match    
     version: grep matched="10.5"    
     variables: executing "gcc -v" output=<use -v -v> no match    
     variables: grep matched="11.4.0"    
     languages: constant := Ada
     runtimes: search directories matching \.\./lib/gcc(-lib)?/x86_64-linux-gnu/11.4.0/adalib/, starting from /usr/bin/    
       <dir>: Recurse into /usr/bin/..
       <dir>: Recurse into /usr/lib    
       <dir>: Check directories in /usr/lib/ that match gcc(-lib)?    
       <dir>: Matched gcc    
       <dir>: Recurse into /usr/lib/gcc/x86_64-linux-gnu    
       <dir>: Check directories in /usr/lib/gcc/x86_64-linux-gnu/ that match 11.4.0
     Done search directories
     runtimes: search directories matching \.\./lib/gcc(-lib)?/x86_64-linux-gnu/11.4.0/ada_object_path, starting from /usr/bin/    
       <dir>: Recurse into /usr/bin/..    
       <dir>: Recurse into /usr/lib    
       <dir>: Check directories in /usr/lib/ that match gcc(-lib)?    
       <dir>: Matched gcc    
       <dir>: Recurse into /usr/lib/gcc/x86_64-linux-gnu    
       <dir>: Check directories in /usr/lib/gcc/x86_64-linux-gnu/ that match 11.4.0    
     Done search directories                                                                                                                                            
     runtimes: search directories matching \.\./lib/gcc(-lib)?/x86_64-linux-gnu/11.4.0/rts-(.*)/adalib/, starting from /usr/bin/    
       <dir>: Recurse into /usr/bin/..    
       <dir>: Recurse into /usr/lib    
       <dir>: Check directories in /usr/lib/ that match gcc(-lib)?    
       <dir>: Matched gcc    
       <dir>: Recurse into /usr/lib/gcc/x86_64-linux-gnu    
       <dir>: Check directories in /usr/lib/gcc/x86_64-linux-gnu/ that match 11.4.0    
     Done search directories    
     runtimes: search directories matching \.\./x86_64-linux-gnu/lib/gnat/(.*)/adalib/, starting from /usr/bin/    
       <dir>: Recurse into /usr/bin/..    
       <dir>: No such directory: /usr/x86_64-linux-gnu    
     Done search directories    
     No runtime found where one is required for: /usr/bin/
...snip...

I wonder where your gprconfig came from? The Debian gprbuild package includes one, installed in /usr/bin, so you’d think it’d match the compiler.

$ which gprconfig
$ gprconfig --version.

Here is the gprconfig that is first selected by the PATH:

$ which gprconfig
/usr/local/bin/gprconfig

$ gprconfig --version
GPRCONFIG 22.0.0 (2023-10-20) (x86_64-pc-linux-gnu)
Copyright (C) 2006-2023, AdaCore
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

I just noticed there are two gprconfigs installed, one in /usr/bin and one in /usr/local/bin. One of them detects an Ada compiler (and runtime) and the other does not.

/usr/local/bin:

$ /usr/local/bin/gprconfig --version
GPRCONFIG 22.0.0 (2023-10-20) (x86_64-pc-linux-gnu)
Copyright (C) 2006-2023, AdaCore
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ /usr/local/bin/gprconfig
--------------------------------------------------
gprconfig has found the following compilers on your PATH.
Only those matching the target and the selected compilers are displayed.
   1. GCC-ASM for Asm in /usr/local/bin/ version 13.2.0
   2. GCC-ASM for Asm in /usr/bin/ version 11.4.0
   3. GCC-ASM for Asm2 in /usr/local/bin/ version 13.2.0
   4. GCC-ASM for Asm2 in /usr/bin/ version 11.4.0
   5. GCC-ASM for Asm_Cpp in /usr/local/bin/ version 13.2.0
   6. GCC-ASM for Asm_Cpp in /usr/bin/ version 11.4.0
   7. LD for Bin_Img in /usr/bin/ version 2.38
   8. GCC for C in /usr/local/bin/ version 13.2.0
   9. GCC for C in /usr/bin/ version 11.4.0
  10. G++ for C++ in /usr/bin/ version 11.4.0
Select or unselect the following compiler (or "s" to save):

/usr/bin:

$ /usr/bin/gprconfig --version
GPRCONFIG Pro 18.0w (19940713) (x86_64-pc-linux-gnu)
Copyright (C) 2006-2016, AdaCore
This is free software; see the source for copying conditions.
See your AdaCore support agreement for details of warranty and support.
If you do not have a current support agreement, then there is absolutely
no warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.
$ /usr/bin/gprconfig
--------------------------------------------------
gprconfig has found the following compilers on your PATH.
Only those matching the target and the selected compilers are displayed.
   1. GNAT for Ada in /usr/bin/ version 10.5 (default runtime)
   2. GCC-ASM for Asm in /usr/local/bin/ version 13.2.0
   3. GCC-ASM for Asm in /usr/bin/ version 11.4.0
   4. GCC-ASM for Asm2 in /usr/local/bin/ version 13.2.0
   5. GCC-ASM for Asm2 in /usr/bin/ version 11.4.0
   6. GCC-ASM for Asm_Cpp in /usr/local/bin/ version 13.2.0
   7. GCC-ASM for Asm_Cpp in /usr/bin/ version 11.4.0
   8. LD for Bin_Img in /usr/bin/ version 2.38
   9. GCC for C in /usr/local/bin/ version 13.2.0
  10. GCC for C in /usr/bin/ version 11.4.0
  11. G++ for C++ in /usr/bin/ version 11.4.0
Select or unselect the following compiler (or "s" to save):

To find the ada runtime I used:

$ find / 2> /dev/null | grep system\.ads$
/usr/lib/gcc/x86_64-linux-gnu/10/adainclude/system.ads

I would expect both gprconfigs to be able to detect an Ada compiler because each toolchain has an Ada compiler:

$ /usr/bin/gcc -v
Using built-in specs.
COLLECT_GCC=/usr/bin/gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/11/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 11.4.0-1ubuntu1~22.04' --with-bugurl=file:///usr/share/doc/gcc-11/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-11 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --enable-cet --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-11-XeT9lY/gcc-11-11.4.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-11-XeT9lY/gcc-11-11.4.0/debian/tmp-gcn/usr --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-serialization=2
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.4.0 (Ubuntu 11.4.0-1ubuntu1~22.04)
$ /usr/local/bin/gcc -v
Using built-in specs.
COLLECT_GCC=/usr/local/bin/gcc
COLLECT_LTO_WRAPPER=/usr/local/bin/../libexec/gcc/x86_64-pc-linux-gnu/13.2.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../src/configure --prefix=/home/runner/work/GNAT-FSF-builds/GNAT-FSF-builds/sbx/x86_64-linux/gcc/install --with-build-time-tools=/home/runner/work/GNAT-FSF-builds/GNAT-FSF-builds/sbx/x86_64-linux/binutils/install/bin --enable-languages=c,ada,c++ --enable-libstdcxx --enable-libstdcxx-threads --enable-libada --disable-nls --without-libiconv-prefix --disable-libstdcxx-pch --enable-lto --disable-multilib --enable-threads=posix --with-gnu-ld --with-gnu-as --with-mpfr=/home/runner/work/GNAT-FSF-builds/GNAT-FSF-builds/sbx/x86_64-linux/mpfr/install --with-gmp=/home/runner/work/GNAT-FSF-builds/GNAT-FSF-builds/sbx/x86_64-linux/gmp/install --with-mpc=/home/runner/work/GNAT-FSF-builds/GNAT-FSF-builds/sbx/x86_64-linux/mpc/install --with-isl=/home/runner/work/GNAT-FSF-builds/GNAT-FSF-builds/sbx/x86_64-linux/isl/install --build=x86_64-pc-linux-gnu
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 13.2.0 (GCC)

So would I. Anyone else got any thoughts?