Gprconfig for bare metal target

I have a bare metal cross compiler without any Ada runtime which targets sparc64-unknown-elf. I previously manually (i.e. copying and pasting) created a project config .cgpr file so I could build minimal Ada runtime from its project .gpr file.

I’m trying to use gprconfig tool to generate .cgpr file for this target. Unfortunately, it is not detecting Ada compiler as I think it may also be looking for a runtime/adalib, which of cause is not there for a bare metal cross compiler:

$ PATH=~/gcc-15.2.0_native/bin:~/gcc-15.2.0_sparc64-unknown-elf/bin ~/gcc-15.2.0_native/bin/gprconfig --target=sparc64-unknown-elf
--------------------------------------------------
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 /home/user/gcc-15.2.0_sparc64-unknown-elf/bin/ version 15.2.0
   2. GCC-ASM for Asm2 in /home/user/gcc-15.2.0_sparc64-unknown-elf/bin/ version 15.2.0
   3. GCC-ASM for Asm_Cpp in /home/user/gcc-15.2.0_sparc64-unknown-elf/bin/ version 15.2.0
   4. LD for Bin_Img in /home/user/gcc-15.2.0_sparc64-unknown-elf/bin/ version 2.46.0.20260210
   5. GCC for C in /home/user/gcc-15.2.0_sparc64-unknown-elf/bin/ version 15.2.0
Select or unselect the following compiler (or "s" to save):

I also tried the following gprconfig options and setting runtime to empty:

PATH=~/gcc-15.2.0_native/bin:~/gcc-15.2.0_sparc64-unknown-elf/bin \
  ~/gcc-15.2.0_native/bin/gprconfig --batch --target=sparc64-unknown-elf \
  --config=Ada,15.2,,/home/user/gcc-15.2.0_sparc64-unknown-elf/bin/,GNAT \
  -o out
gprconfig: can't find a toolchain for the following configuration:
gprconfig: language 'Ada', target 'sparc64-unknown-elf', default runtime

but it still fails to detect Ada compiler.

Is there a way to force gprconfig to generate .cgpr file for Ada without any runtime? I can edit an existing config file and substitute compiler paths, but it would be nice to figure out how to get gprconfig to work properly for bare metal targets.

Try to run gprconfig -v and check what it do and where it fails.

I guess that output of gcc doesn’t match compiler’s prefix and/or target.

PS. Compiler for Xtensa doesn’t distribute runtime at all, and detected successfully. I didn’t find any match of “xtensa” in gprbuild’s knowledge base, so your case should work most probably.

Thanks, however I’ve tried -v option already and did not find anything informative from its output, apart from:

  GNAT is candidate: filename=gnatls
    target: executing "gcc -dumpmachine" output=<use -v -v> no match
    target: grep matched="aarch64-unknown-linux-gnu"
    Target for this compiler does not match --target

Not quite sure what this means, but I guess it is looking for gnatls binary and it was never built for *-unknown-elf bare metal targets.

I used gprconfig with a native compiler and then manually tweaked its *.cgpr file and substituted paths to cross-compiler.

It is just gcc, without target platform prefix. Look for invocations of <target>-gcc

It doesn’t log any attempts or failures, just a list of compilers it managed to find. There is no GNAT is the list below and no indication of what it did in order to detect it:

Foreach compiler in /home/user/gcc-15.2.0_sparc64-unknown-elf/bin regexp=TRUE extra_dir=FALSE
  LD is candidate: filename=sparc64-unknown-elf-ld
    target: executing "sparc64-unknown-elf-gcc -dumpmachine" output=<use -v -v> no match
    target: grep matched="sparc64-unknown-elf"
    version: executing "sparc64-unknown-elf-ld -v" output=<use -v -v> no match
    version: grep matched="2.46.0.20260210"
    languages: constant := Bin_Img
    Adding compiler to interactive menu Bin_Img,2.46.0.20260210,,/home/user/gcc-15.2.0_sparc64-unknown-elf/bin/,LD selected=FALSE
  GCC is candidate: filename=sparc64-unknown-elf-gcc
    target: executing "sparc64-unknown-elf-gcc -dumpmachine" output=<use -v -v> no match
    target: grep matched="sparc64-unknown-elf"
    version: executing "sparc64-unknown-elf-gcc -v" output=<use -v -v> no match
    version: nogrep no match
    version: grep matched="15.2.0"
    languages: constant := C
    Adding compiler to interactive menu C,15.2.0,,/home/user/gcc-15.2.0_sparc64-unknown-elf/bin/,GCC selected=FALSE
  GCC_Pro is candidate: filename=sparc64-unknown-elf-gcc
    target: executing "sparc64-unknown-elf-gcc -dumpmachine" output=<use -v -v> no match
    target: grep matched="sparc64-unknown-elf"
    version: executing "sparc64-unknown-elf-gcc -v" output=<use -v -v> no match
    version: grep no match
    Ignore compiler, since couldn't guess its version
  GCC-ASM is candidate: filename=sparc64-unknown-elf-gcc
    target: executing "sparc64-unknown-elf-gcc -dumpmachine" output=<use -v -v> no match
    target: grep matched="sparc64-unknown-elf"
    version: executing "sparc64-unknown-elf-gcc -v" output=<use -v -v> no match
    version: nogrep no match
    version: grep matched="15.2.0"
    languages: constant := Asm,Asm_Cpp,Asm2
    Adding compiler to interactive menu Asm,15.2.0,,/home/user/gcc-15.2.0_sparc64-unknown-elf/bin/,GCC-ASM selected=FALSE
    Adding compiler to interactive menu Asm_Cpp,15.2.0,,/home/user/gcc-15.2.0_sparc64-unknown-elf/bin/,GCC-ASM selected=FALSE
    Adding compiler to interactive menu Asm2,15.2.0,,/home/user/gcc-15.2.0_sparc64-unknown-elf/bin/,GCC-ASM selected=FALSE
  GCC-ASM_Pro is candidate: filename=sparc64-unknown-elf-gcc
    target: executing "sparc64-unknown-elf-gcc -dumpmachine" output=<use -v -v> no match
    target: grep matched="sparc64-unknown-elf"
    version: executing "sparc64-unknown-elf-gcc -v" output=<use -v -v> no match
    version: grep no match
    Ignore compiler, since couldn't guess its version
List of targets supported by a compiler:
sparc64-unknown-elf
Filtering the list of compilers
--------------------------------------------------
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 /home/user/gcc-15.2.0_sparc64-unknown-elf/bin/ version 15.2.0
   2. GCC-ASM for Asm2 in /home/user/gcc-15.2.0_sparc64-unknown-elf/bin/ version 15.2.0
   3. GCC-ASM for Asm_Cpp in /home/user/gcc-15.2.0_sparc64-unknown-elf/bin/ version 15.2.0
   4. LD for Bin_Img in /home/user/gcc-15.2.0_sparc64-unknown-elf/bin/ version 2.46.0.20260210
   5. GCC for C in /home/user/gcc-15.2.0_sparc64-unknown-elf/bin/ version 15.2.0
Select or unselect the following compiler (or "s" to save): 

It is almost fine, it can find compiler.

Now it is time to add

   for Runtime ("Ada") use "<path/to/runtime>";

to project file, or run

gprconfig --target=sparc64-unknown-elf --config=ada,,/absolute/path/to/runtime,, -o autocgpr.cgpr

to generate configuration file (gprbuild calls gprconfig automatically when necessary)

There is no Ada runtime. The Ada cross-compiler was built with: --enable-languages=c,ada --disable-libada.

The target is sparc64-unknown-elf where I use this cross-compiler to build my own custom runtime. I will be using .gpr project files to manage the build for the runtime, however I don’t want gprbuild to autoguess compilers and linkers, hence why I was trying to generate .cgpr config file, before tweaking it.

As I mentioned before, I managed to generate config file by selecting a native Ada compiler. I was simply trying to understand why gprconfig with bare metal cross-compiler target, detected C but not Ada compiler. I suspect it was because gnatls was missing for this target, plus may be gprconfig detection logic was not designed for bare metal Ada cross-compilers?

GNAT can’t work without runtime. So, you will need it anyway. It might be simple one, but it is mandatory.

gprconfig know that GNAT requires runtime for language "Ada", and can’t find compiler if there is no runtime specified.

PS. There is simple runtime GitHub - Fabien-Chouteau/bare_runtime: Minimal Ada/SPARK run-time for embedded or other restricted targets · GitHub

PS. I’ve tested with Xtensa, gprconfig is unable to find GNAT compiler, however, automatic configuration done by gprbuild works fine.

OK thanks, I think I arrived at the same conclusion.