Ada Compiler Crashes with "Ada Compiler Not Installed on This System." After Downgrading Gcc Version

GNAT GPL Ada fails will linkage error when cross-compiling for the Raspberry pi

Before using this particular version of the GNAT (cross-)compiler, you need to copy some additional files from your RPi 2 to the host first. The exact steps are explained in the README file that accompanies the particular GNAT release. I copied the relevant section to the end of this answer for convenience.

That said, also consider developing your program on Ubuntu first using a more recent version of GNAT (Community Edition or an FSF version), then copy the source code the Raspberry Pi, and recompile it on the Pi itself. The GNAT FSF compiler (and related tools) that is available from the Debian repositories is also available on Raspberry Pi OS:

$ sudo apt install gnat gprbuild

Finally, you could also consider to use Alire (at least on the host). Alire has no official support for Raspberry Pi yet, but an experimental release is already available here.


Excerpt from the README file:

Raspberrypi 2 (hosted on Linux)

  • The GNAT GPL compiler for raspberrypi is a cross compiler, hosted on linux-x86 (or linux-x86_64). You need to copy from the boards some library files. The following script achieves that. It should be executed from <GNAT GPL>/arm-linux-gnueabihf (the RPI variable is login@target):

    #!/bin/sh

    RPI=pi@myboard

    mkdir sysroot sysroot/lib sysroot/lib/arm-linux-gnueabihf
    cd sysroot/lib
    rsync -a $RPI:/lib/arm-linux-gnueabihf/{ld-*,lib?.*,lib?-*,libpthread*,librt*} arm-linux-gnueabihf
    ln -s arm-linux-gnueabihf/lib?.* .
    cd ../..
    mkdir sysroot/usr sysroot/usr/lib sysroot/usr/lib/arm-linux-gnueabihf
    cd sysroot/usr/lib/arm-linux-gnueabihf
    rsync -a $RPI:/usr/lib/arm-linux-gnueabihf {crt*,libc.*,libc_no*,libpthread*} .
    ln -s ../../../lib/arm-linux-gnueabihf/libm.so.* libm.so
    ln -s ../../../lib/arm-linux-gnueabihf/librt.so.* librt.so
    cd ..
    ln -s arm-linux-gnueabihf/* .

    Before running a GNAT GPL tool, set ENV_PREFIX variable like this:

    export ENV_PREFIX=<GNAT GPL>/arm-linux-gnueabihf/sysroot

How can I get Ada GNAT gcc 7.3 for Solaris 11?

I've successfully built gcc 7.50 (x86_64 native with i386 cross-compiler) with GNAT on OpenIndiana (Hipster 2020/10) using the following procedure.

  1. Download the bootstrap compiler from Dragonlace at http://downloads.dragonlace.net/src/ada-bootstrap.x86_64.solaris.511.tar.bz2

  2. Get the illumos gcc 7.5.0 source from https://github.com/illumos/gcc/tree/il-7_5_0

  3. Put the bootstrap compiler's bin directory at the front of $PATH, replace /usr/bin/gcc /usr/bin/cpp /usr/bin/g++ with symlinks to their counterparts in the bootstrap compiler directory (see note below re g++ and c++)

  4. Make sure you've got gnu-binutils and gmake; then run contrib/download_prerequisites

  5. Configure with
    --enable-languages='c ada c++' --build=x86_64-aux-solaris2.11 --enable-threads=posix --disable-libmudflap --disable-libgomp --disable-libssp --disable-libquadmath --disable-nls --disable-shared --disable-lto --disable-libstdcxx-pch --enable-multilib --with-gnu-as --with-as=/usr/bin/gas --without-gnu-ld --with-ld=/usr/bin/ld

  6. gmake and then gmake install

NOTES:
This setup should be close enough to Solaris 11 to work. If it doesn't, try using the regular gcc 7.5.0 release rather than the illumos-modified branch.

If you get stuck at a linking stage, try using a gcc ld, but you should definitely try to use the Solaris ld first. The gnu as (gas) makes the build go much more smoothly. I didn't have any problems, but if you get stuck at the end of stage 1 or the beginning of stage 2, try setting $CONFIG_SHELL=/usr/bin/ksh -- I think it has been fixed, but at least with older gcc releases one needed to specify ksh because the built-in sh had some non-POSIX peculiarities that didn't work with some of the components' makefiles

I couldn't get one of the support libs for gnat to compile easily without building gcc c++ and using g++ with a full bootstrap. You might be able to figure it out, but the path of least resistance is likely to build gcc c++ and put the g++ symlink in /usr/bin, which is where the makefile wanted to find it.

Ada tag comparison causes compiler to crash

The following program works properly using the 2018 release of GNAT and GPS.

with Ada.text_IO; use Ada.Text_IO;
with Ada.Tags; use Ada.Tags;

procedure Tag_Main is
package foo is
type A is tagged private;
type B is tagged private;
private
type A is tagged null record;
type B is tagged null record;
end foo;

use Foo;

function Tag_To_String(From : Ada.Tags.Tag) return String is(
if From = A'Tag then
"This is tag A"
else
"This is tag B"
);

begin
Put_Line(Tag_To_String(A'Tag));
Put_Line(Tag_To_String(B'Tag));
end Tag_Main;

Note that I have edited the code to use a function expression. It still works on the GNAT/GPS 2018 release.
This version was compiled with gprbuild -d -PD



Related Topics



Leave a reply



Submit