AArch64 cross toolchain
The community has long expressed interest in supporting Ada on ARM64 and Apple Silicon platforms. Unfortunately, GitHub Action Runners are not available for ARM for open-source projects. The publication of the Ada extension for VS Code (as well as Alire) relies on GitHub Actions, limiting ARM support. However, it turns out that creating an ARM version is still possible, and Iβd like to share my experience with using cross-compilers for this purpose.
Through the actions described below, I managed to obtain two cross-compilers for the aarch64 CPU (running on x86_64), one for Linux and the other for macOS. These proved sufficient to build ALS and VSCode extensions for these platforms.
I began by building the Ada Language Server version for ARM64/Linux since this platform is more familiar to me. Ubuntu provides cross-versions of dependencies for GNAT (glibc, binutils). Ubuntu even has GNAT GCC 13, but on newer versions than the one (20.04) we use for ALS building. The first thing I did was attempt to rebuild GCC 13 on Ubuntu 20.04 from the source package of the latest Ubuntu distribution (23.10). Although this might be the most correct method from a reuse perspective, it didnβt suit me - too many packages and installation steps.
Building GNAT from the GCC 13 source texts proved much simpler. The resulting script was just a dozen lines long.
If you unpack the resulting archive in /, gprbuild finds the cross-compiler and using it subsequently is straightforward: you just need to specify the option --target=aarch64-linux.
Mac OS also provides cross-versions of binutils and libc, which come with the standard installation of Xcode Command Line Tools. For example, /usr/bin/as can create object files for both x86_64 and aarch64, depending on the --target. Therefore, we only need to build GNAT using the GCC sources from the repository iains/gcc-13-branch.
If you need binaries for these cross-compilers or have ideas on how to use them, please leave a comment in this thread.
PS Thanks to Simon Wright for experimenting with Mac OS and providing advices.
2 posts - 2 participants