Backgrounds: coreboot uses its cross-toolchain for i386-elf
, arm-eabi
, etc. built from source, including the Ada frontend (GNAT). GNAT itself is written in Ada, so an Ada non-cross compiler is required to make the cross-toolchain.
The build system of coreboot contains a sequence of commands that is equivalent to the following one to check if Ada support is usable:
[ -x "$(${CC} -print-prog-name=gnat1)" ] &&
command -v gnatbind 2>/dev/null &&
[ "$(cat /dev/null |
gnatbind --version 2>&1 |
grep -c 'Free Software Foundation')" -gt 0 ]
[ -x "$(${CC} -print-prog-name=gnat1)" ]
checks if the toolchain supports Ada and it recognizes the frontend of the language. It may detect some situations triggering strange bugs where the environment provides a potentially incompatible combination of gcc
and gnat
.
For instance, the system administrator may install a full set of GCC 5 provided by the distribution in /usr/bin
while a developer builds C and C++ frontends of GCC 11, installs to ~/tools
and adds PATH="$HOME/tools/bin:$PATH"
to their .profile
.
While the command works with typical systems where cc1
, cc1plus
, gnat1
, and so on are installed to the same directory, the implication does not hold on nixpkgs because frontends are built separately and installed in different places.
The -print-prog-name
(and -x <language>
) options are documented interfaces of GCC, but it does not fit well with nixpkgs in the current form. An overhaul of toolchain-related packages would be needed, but is it feasible?
How could the packages be built and split to work correctly without wasting everyone’s disk space too much?
Related issue on GitHub:
https://github.com/NixOS/nixpkgs/issues/24708