Successfully created gcc16.1.0 cross compiler for aarch64 from source

Hello All,

Recently I have been struggling with trying to create from source a working gnat compiler for aarch64 using gcc 16.1.0.

By digging through a variety of web/forum postings I created 9 simple (but perhaps ugly) bash scripts that give a working setup. Have verified that the compiled binaries work on my Raspberry Pi 5 running Void Linux.

If there is interest I’d be happy to post them here. (If so, I would need someone to explain to the best way to post the 10 files here. I did not see a good way to do this from the forum interface, thanks.)

if you want a more automated way of building an aarch64 gnat compiler you could try to use the GitHub - alire-project/GNAT-FSF-builds: Builds of the GNAT Ada compiler from FSF GCC releases · GitHub buildsystem. There are also the tools that Alire uses when you download a cross-compiler. I personally don’t like the custom buildsystem as it’s quite unconventional tho. (And it took me some time to understand how everything works)

You can also build gcc manually to create your gnat compiler. There is GNAT Cross-Compiler - OSDev.wiki which is a bit outdated but still good. I also have a guide (and script!) but for a more obscure architecture. You can adapt it if you want but it’s mainly targeted at some calculator OS. GitHub - AdaOrbit/AdaCasio · GitHub

Both of these resources use x86_64 as the host arch so I’m not sure how different the build process is compared to arm but I’d assume they are similar.


The best way would be to make a git repo and post a link :P. (You can also post the files in the forum by copying the contents of the files but that’s going to make everything even messier)

Edit: I should mention that GNAT-FSF is currently under some “heavy” development due to gnat 16 being relatively new and MacOS arm shenanigans. If something doesn’t work look into older commits.

Thanks for the reply. I did try GNAT-FSF-builds. But I really wanted a way that would do this without any dependencies other than source files from gcc, and from linux headers. So, a few bash scripts was preferable to my tastes.

Also, I wanted to compile gcc 16.1.0 WITH the algol68 language, as well as ada and fortran.

A git repo is a possibility, but thought a forum post would be better. I had seen that “Max” had a nice way to post some script files.

Check out this post:

Would love to know how Max put those listings in a post.

(This had some good information for building, but also required some dependencies.)

(for posting your build scripts)
In that case you can just write

```bash
#!/usr/bin/env bash
your file content
```

that will get rendered as

#!/usr/bin/env bash
your file content

as for building gnat on void: I’m not sure about musl support (if you use that on void). I haven’t tried it yet but I know that alpine has a gnat compiler so there is definitely a way to use gnat on musl. And enabling the other languages should be as easy as adding --enable-languages="c,c++,ada,..." to your gcc config step. I don’t know much about algol or fortran but if they also have some runtime dependencies make sure to include them as well!