What is the state of Ada on Android?

Hi, I am building a graphics and audio engine (In Zig) and for a while I wanted to port some of my code to Ada but one of my targets is android and gcc does not support it. It is unfortunately a major target for me.

I found out that there is a llvm front-end but what is the state of it? I cannot really find relevant information. Has anyone tried to target android with it? Or is it still experimental?

I also found that there is a some sort of android compiler ported to bsd but I have no idea how well it works or even maintained anymore…

1 Like

I’ve seen some things about Ada on Android, and will pop a few links, but I’ve never compiled for Android. — Keep in mind that Android is essentially Java, and so the question is going to be tied to “Ada on the JVM” [IIUC].

  1. Using AJIS for Android
  2. Gem #56: Creating Ada to Java calls using GNAT-AJIS
  3. How to Integrate Ada Code in Android Applications?
  4. Use Ada code in Android
1 Like

Am I mistaken, or does this require Gnat PRO?

I don’t know if GNAT Pro still has it, the community edition of Ada had it, so if you are ok with an older compiler, then you can play around with interfacing with Java

2 Likes

I build gcc years back with ada enabled for android, you can interface with the native activity, you don’t have to go via JNI. But the latest android toolchain is llvm based, no idea how to build that and I can’t remember what the target is for gcc.

This is just an idea, but it might be possible to build GNAT LLVM (targeting the desired Android architecture) using the Android NDK (as a sysroot). Troy has identified a working configuration of GNAT LLVM [1] you could start with.

With an LLVM compiler that can generate C and Ada code on the correct platform you could try to build a the “rawdrawandroid” project by cnlohr [2]. This brilliant project demonstrates building Android applications using just C and Makefiles (no Java).

At this point you will have a project that runs in the Android platform and a compiler that can generate Ada code. Continuing on, in theory you could create an Ada run time that integrates with the Android framework and use it basis for Ada application development on Android.

References:

[1] build-gnat-llvm/.github/workflows/build.yml at ab69c73526e1291a40873c645b7e36738507a00b · brownts/build-gnat-llvm · GitHub
[2] GitHub - cnlohr/rawdrawandroid: Build android apps without any java, entirely in C and Make

2 Likes

I’m kinda curious about the state of the termux thing, too. I know android was trying to restrict things like Termux from creating and running executables, but that was over a year ago and you can still download termux. I remember using that tutorial (and a few others) and compiling an example app for android ON android.

AFAIK, support for arm64 and Android has been improved in the latest versions of GCC (as per the changelogs). Also, as already pointed out, there is LLVM-19 support for GNAT-LLVM, which should be plenty flexible to get Android stuff running with Ada.

It is true that in the past there was more “easy to get started” support, but not anymore. But that does not mean that the behind the scenes support has not been improving!

Best regards,
Fer

2 Likes

Thank you all for the support, if I make a substantial progress I will post it here so it can help others as well.

That would be excellent; I need to investigate how to compile Ada to JVM-class, so as to “break the cycle” on bootstrapping.

1 Like