GNAT-LLVM (for macOS)

If you want to build a single source file, you can say llvm-gnatmake foo.adb and all will be well. The link is done using llvm-gcc -shared-libgcc.

If you try building with gprbuild (the equivalent of the above would be gprbuild --target=llvm --no-project foo.adb), gprbuild tries to do the link with clang -static-libgcc, which fails because clang doesn’t support that option.

The only way I’ve found round this is to use an actual project with

package Linker is
   for Driver use "g++";
end Linker;

but does anyone know a way of saying the same thing to gprbuild from the command line?

Why g++ I hear you ask? It looks to me as though gprbuild would normally use a C compiler, unless it detects the faintest whiff of C++, in which case it’ll use a C++ compiler, so as to be sure of getting the C++ libraries. It looks on the PATH for a C[++] compiler that’s compatible with the target, llvm, and the only one it finds is /usr/bin/clang[++].

It turns out that gnatbind emits -static (by default, otherwise -shared) and something in gprbuild translates that to -static-libgcc, unless you tell it not to by including for Bindfile_Option_Substitution ("-static") use (""); in package Binder in your GPR.

That took some finding.

Anyway, see this pre-release!