Skip to contentSkip to conversation

ada support status in gcc-cross (braindump)

DISCUSSION Richard Purdie 1 participant 1 message Nov 5, 2022

lore
Share & tools
lore
#0 lore raw

One of our patches submitted to upstream gcc caused a regression in the ada test suite. To debug it I did look at whether we could enable ada in our builds. I'm writing down and sharing my notes for the archives in case we ever want to pick this up again as it took me quite a while to work this much out.

To do it you need gnat on the host which on my ubuntu system resulted in something like:

HOSTTOOLS += "gnat gnatbind gnatmake x86_64-linux-gnu-gcc-11 x86_64-linux-gnu-gnatbind-11 x86_64-linux-gnu-gnatlink-11"

and I changed gcc's LANAGAGES to:

LANGUAGES ?= "c,c++${FORTRAN},ada"

Sadly this fails to build with errors like:

| s-valuns.ads:55:04: instantiation error at s-valueu.ads:579
| s-valuns.ads:55:04: expected type derived from "System.Val_Uns." from instance at line 55
| s-valuns.ads:55:04: found type "Standard.String"
| s-valuns.ads:55:04: instantiation error at s-valueu.ads:581
| s-valuns.ads:55:04: expected type "Standard.String"

which is basically because the host's gnat version doesn't match the target version we're building in gcc-cross.

Digging on why a standalone build eventually works out ok, it seems that when building gcc stage 1, ada is built against the host system libgnat. In later gcc stages, libgnat is built using the new compiler and since there is now no mismatch, the build works.
(see gcc/ada/gcc-interface/Make-lang)

How we'd solve that in OE, I'm less sure. We'd probably need a gcc-ada- native recipe which was an ada stage 1 compiler which we'd then configure gcc-cross to use to build ada.

I sorted the upstream issue so I don't plan to pursue this any further at this point, just document what I worked out.

Cheers,

Richard