Ada development on FreeBSD 13.1

By Stephane Carrez

The Ada support has been removed from FreeBSD 13.1 ports because it was deprecated. Indeed, the gcc6-aux port was deprecated and expired on 2022-02-28. There is no indication about a replacement solution and using Ada for FreeBSD is a challenge but this is still possible. This article records a number of steps and commands that helped me setup a new Ada compiler based on GCC 12 on a fresh FreeBSD 13.1 installation.

Warning: this is full of hacks and I don't pretend to provide any complete detailed and completely reproducible steps for getting a new Ada compiler.

Before proceeding, make sure you have gmake installed because the BSD make uses an old Makefile syntax and is not able to handle GNU specific Makefiles.

pkg install gmake

Get gcc6-aux from an old FreeBSD installation

First step is to get the gcc6-aux port as is from an old FreeBSD installation. Basically, a tar-gz of the /usr/local/gcc6-aux directory tree is enougth. Basically, what I did is to run a tar cf /tmp/gcc.tar /usr/local/gcc6-aux on an old FreeBSD and then extract that tar as is on the FreeBSD 13.1 system (Of course, it must be the same architecture).

Build gcc 12

Get the GCC 12 sources from and extract them:

tar xzf gcc-12.1.0.tar.xz

Building GCC must be made in another directory and we must also setup the PATH to give access to the old Ada compiler. You must setup and run the configure script as follows:

export PATH=/usr/local/gcc6-aux/bin:$PATH
mkdir build
cd build
../gcc-12.1.0/configure --disable-nls --enable-gnu-indirect-function --enable-host-shared --with-as=/usr/local/bin/as --with-gmp=/usr/local --with-ld=/usr/local/bin/ld --with-system-zlib --without-zstd --enable-libada --localstatedir=/var --prefix=/build/gcc-12.1 --build=x86_64-portbld-freebsd13.0 --enable-languages=c,ada,c++

The --with-as and --with-ld are important to use the correct as and ld commands. A subset of the above configure command is taken from the configure command that FreeBSD ports is using to build GCC 12.

After the configure, run the gmake command:


or to run several compilations in parallel use:

gmake -j4

While building, the compiler is built a first time with gcc6-aux and another time with itself. Building the Ada libraries failed for me with:

/home/ciceron/src/build/./gcc/xgcc -B/home/ciceron/src/build/./gcc/ -B/build/gcc-12.1/x86_64-portbld-freebsd13.0/bin/ -B/build/gcc-12.1/x86_64-portbld-freebsd13.0/lib/ -isystem /build/gcc-12.1/x86_64-portbld-freebsd13.0/include -isystem /build/gcc-12.1/x86_64-portbld-freebsd13.0/sys-include   -fchecking=1 -c -g -O2 -m32 -fpic  -W -Wall -gnatpg -nostdinc -m32  s-exnllf.adb -o s-exnllf.o warning: in instantiation at s-dorepr.adb:82 [enabled by default] warning: in instantiation at s-exponr.adb:54 [enabled by default] warning: "Temp" overlays smaller object [enabled by default] warning: program execution may be erroneous [enabled by default] warning: size of "Temp" is 96 [enabled by default] warning: size of "Rep64" is 64 [enabled by default]
gmake[9]: *** [../gcc-interface/Makefile:301: s-exnllf.o] Error 1

This error is caused by some inconsistency between the floating point mantissa size returned by Machine_Mantissa' Ada predicate and the size of the floating point number. After hacking the gcc/ada/libgnat/s-dorepr.adb I've managed to build the Ada libraries.

After a successful build, installation in /build/gcc-12.1 is done with:

gmake install

Build gprbuild

Yet, another challenge is building gprbuild. First, get the following sources:

git clone
git clone
git clone

Then run the boostrap script from gprbuild and make sure to setup your PATH to use the new GCC Ada compiler:

export PATH=/build/gcc-12.1/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
cd gprbuild
./ --with-xmlada=../xmlada --with-kb=../gprconfig_kb --prefix=./bootstrap

Then, build again and install in the same location as GCC:

gmake prefix=/build/gcc-12.1 SOURCE_DIR=`pwd` setup
gmake all
gmake install

Don't stop at building only gprbuild because you'll probably need the libgpr library (if you want to build Ada Web Server which now depends on GNAT libcoll which needs libgpr).

gmake libgpr.install

Installation of vscode

It is possible to use vscode and the Ada plugin for development under FreeBSD. The vscode Ada plugin contains the ada_language_server binary which is executed as a language server for vscode. No binary is provided for FreeBSD but since the binary is provided for Linux, we can use it by using the Linux support in FreeBSD. First, install vscode with:

pkg install vscode

then, launch it and install the Language Support for Ada extension. When the extension is activated, you will see a message indicating that the language server cannot be started. There are two things to do:

  • create a freebsd directory with the ada_language_server binary,
  • activate and setup the Linux support in FreeBSD

For the first part, copy

cd ~/.vscode-oss/extensions/adacore.ada-23.0.8
cp -rp linux freebsd

Now we must setup the Linux support in FreeBSD, and follow the FreeBSD Chapter 10. Linux Binary Compatibility.

Add in /etc/rc.conf:


and start with:

sudo service linux start

Install the debootsrap:

sudo pkg install debootstrap
sudo debootstrap focal /compat/ubuntu.

Add the line in /etc/sysctl.conf:


and configure with:

sudo sysctl -f /etc/sysctl.conf

Mark the binary as Linux:

brandelf -t Linux ~/.vscode-oss/extensions/adacore.ada-23.0.8/freebsd/ada_language_server

Replace the symbolic link /compat/ubuntu/lib64/ to a real file otherwise the Linux linker is not found by the kernel.

Now, restart vscode and the Ada language server should be started.

The description on how to build ada_language_server for FreeBSD is left as an exercise to the reader :-)

Add a comment

To add a comment, you must be connected. Login