Hello, I’m doing some basic bare metal programming on SPARC V9 and currently using freestanding C cross-compiler to build my stage-1 and stage-2 bootloaders for this target.
I would like to experiment with Ada and was looking at GitHub - AdaCore/bb-runtimes: Source repository for the GNAT Bare Metal BSPs · GitHub however I do not actually need a run time with exceptions, tasking, etc. It looks like Ada supports ZFP (Zero Footprint Profile) but I’m not sure if this is equivalent to a freestanding C environment or if this is much more, which requires manual porting to SPARC V9.
I can build a freestanding C cross-compiler, however I’m looking for pointers on how to achieve something similar for Ada. My previous attempt with GCC --target=sparc64-unknown-elf --enable-languages=c,ada resulted in build failures for some of the Ada components. Maybe I also need to exclude certain Ada standard libraries or port a new ZFP run time?
Currently I build my bootloaders as SPARC V9 ELF64 binaries with -ffreestanding -nostdlib -nostartfiles from C code and I would like to try something similar with Ada instead.
Can anyone suggest how to build a minimal Ada cross-compiler for this target? Do I need ZFP and if yes, how should I go about configuring it?
PS. If it helps, details on bootloaders and how I build Binutils and GCC can be found here:
I’m hoping to document my Ada efforts in Part 3 and may be take it further and develop and small Ada run time for SPARC V9.
I could write an entire article about cross compiling gnat but this should be a good starting point!
It’s nearly done but I still have to learn what some of the configuration flags mean and do. I also had build failures trying to get gcc14 to work but gcc15 just worked in my case. Maybe try other versions?
OK thanks for the info. It looks like building Ada cross-compiler should be done with the same compiler version, which is different to how I normally build C cross-compilers. My build Ada compiler was gcc-12.2.0 and I was building Ada gcc-15.2.0 which resulted in strange failures. Now building a native gcc-15.2.0 with which I built the final cross-compiler resolved those failures.
So the next step for me is to understand how a minimal Ada run time can be integrated. I’m not yet able to build even the simplest Ada binaries:
to add the runtime you need to add --RTS=/path/to/runtime to your compile, bind and link steps.
To compile the runtime you need the -gnatp flag.
Best would be if you just copy the .gpr file and build everything using gprbuild (Adas build system).
Here is also a small tip by me. If you have some undefined references like __gnat_somthing missing you can just add it to a stub.c file, give it an empty definition and link it at the end. Your runtime is probably broken now but it’s not guaranteed highly probably still working.
As far as I remember it is platform independent and there is chance that it is compiler independed, so you can try to use it with your compiler.
Try to download it, cd into runtime directory, run gprbuild -P bare_runtime.gpr. If it completes well - you have ready to use minimal runtime. To use it specify path to runtime directory in the project file
It’s because it is an Alire based project and bare_runtime_config.ads is generated by Alire, so you would first need to install Alire (if you don’t have it) and then run the command alr build in the project’s directory. It’ll generate the file.
Note that the top level alire.toml file also has some project specific instructions to be aware of.
Thanks for the tip. I looked at the included alire.toml file but was hoping gprbuild alone was going to be sufficient. I’ll get the alr tool installed and try again.
There’s a lot of people here with Alire experience, so definitely ask if you run into any problems. I’m less experienced with it myself though.
If you have trouble installing it, there is also a resource for some pre made installation packages and instruction (by platform) reference at: https://www.getada.dev/