This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

gnattools cannot be built for freestanding/bare metal environment without hacking up the build machinery


Hi,

I've been over this before and have got nowhere with it. As I've just
retried building the latest sources after a long break I'd thought I'd
add some further comment in the hope that someone somewhere cares enough
to fix this issue; this is over my head at this time.

Say you want to build an Ada compiler for embedded work, small
SBC/micro's/osdev/whatever, you will want to set target to <arch>-elf or
similar. You can do this, to a point. You can configure the build as:

../../../source/gcc-git-ro/configure --prefix=/home/laguest/opt/tinyada
--target=arm-none-eabi --enable-interwork --enable-multilib
--without-headers --disable-nls --disable-shared --disable-threads
--disable-lto --with-gnu-as --with-gnu-ld --enable-languages=c,ada
--disable-libssp --disable-cloog-version-check
--disable-isl-version-check --with-gmp=/home/laguest/opt/tinyada
--with-mpfr=/home/laguest/opt/tinyada
--with-mpc=/home/laguest/opt/tinyada
--with-isl=/home/laguest/opt/tinyada
--with-cloog=/home/laguest/opt/tinyada

You can build it with "make all-gcc" and install with "make install-gcc"
and you get a gnat1 and <target>-gnatbind, this is fine, you can use the
system tools, gnatmake, etc. along with these tools - I have done this
before.

But what about the gnattools? Not buildable. A message in the ml
archives states to build them with "make -C gcc gnattools," but this
fails:

make: Entering directory
`/home/laguest/src/mine/tinyada-new/build/arm-none-eabi/gcc2-built-with-git-ro/gcc'
make -C ada CC="gcc" CXX="g++" "ADA_CFLAGS=" "BISON=bison" "BISONFLAGS="
"CFLAGS=-g " "LDFLAGS=-static-libstdc++ -static-libgcc " "FLEX=flex"
"FLEXFLAGS=" "LN=ln" "LN_S=ln -s" "MAKEINFO=makeinfo
--split-size=5000000" "MAKEINFOFLAGS=--no-split" "MAKEOVERRIDES="
"SHELL=/bin/sh" "exeext=" "build_exeext=" "objext=.o"
"exec_prefix=/home/laguest/opt/tinyada"
"prefix=/home/laguest/opt/tinyada" "local_prefix=/usr/local"
"gxx_include_dir=/home/laguest/opt/tinyada/lib/gcc/arm-none-eabi/4.9.0/../../../../arm-none-eabi/include/c++/4.9.0" "build_tooldir=/home/laguest/opt/tinyada/arm-none-eabi" "gcc_tooldir=/home/laguest/opt/tinyada/lib/gcc/arm-none-eabi/4.9.0/../../../../arm-none-eabi" "bindir=/home/laguest/opt/tinyada/bin" "libexecsubdir=/home/laguest/opt/tinyada/libexec/gcc/arm-none-eabi/4.9.0" "datarootdir=/home/laguest/opt/tinyada/share" "datadir=/home/laguest/opt/tinyada/share" "localedir=/home/laguest/opt/tinyada/share/locale" "ADA_FOR_BUILD=" "ADA_INCLUDE_DIR=/home/laguest/opt/tinyada/lib/gcc/arm-none-eabi/4.9.0/adainclude" "ADA_RTL_OBJ_DIR=/home/laguest/opt/tinyada/lib/gcc/arm-none-eabi/4.9.0/adalib" "ADAFLAGS=-gnatpg -gnatwns -W -Wall" "ADA_FOR_TARGET=" "INSTALL=/usr/bin/install -c" "INSTALL_DATA=/usr/bin/install -c -m 644" "INSTALL_PROGRAM=/usr/bin/install -c" ADA_INCLUDES="-I/home/laguest/opt/tinyada/lib/gcc/x86_64-unknown-linux-gnu/4.9.0/adalib/../adainclude -I/home/laguest/opt/tinyada/lib/gcc/x86_64-unknown-linux-gnu/4.9.0/adalib/" GNATMAKE="gnatmake" GNATBIND="gnatbind" GNATLINK="gnatlink" LIBGNAT="" gnattools1
make[1]: Entering directory
`/home/laguest/src/mine/tinyada-new/build/arm-none-eabi/gcc2-built-with-git-ro/gcc/ada'
touch ../stamp-tools
You must first build the GNAT library: make gnatlib
make[1]: *** [../stamp-gnatlib-rts] Error 1
make[1]: Leaving directory
`/home/laguest/src/mine/tinyada-new/build/arm-none-eabi/gcc2-built-with-git-ro/gcc/ada'
make: *** [gnattools] Error 2
make: Leaving directory
`/home/laguest/src/mine/tinyada-new/build/arm-none-eabi/gcc2-built-with-git-ro/gcc'

You can't disable libada using the command line as that also disables
gnattools - I don't know the reason for requiring this behaviour.

So there are 3 ways to get this work:

1) Do what AVR-Ada (and MSP430 as they use the same patch) to knock out
the dependency of libada on gnattools, from configure:

if test "${ENABLE_LIBADA}" != "yes" ; then
  noconfigdirs="$noconfigdirs"
fi

This then breaks normal builds, i.e. hosted, so you can use the same
sources reliably to build a new host compiler and the cross compiler(s).

2) Do as shown above to get gnat1 and <target>-gnatbind and use these
through the host's system tools.

3) Patch the source up to build a custom and pointless RTS that will
just take up disk space and never get used as the user will be
implementing their own. Currently, I'm getting a bug box on my patches
for arm-none-eabi.

Given that the C compiler can be build for a freestanding environment,
as can the C++ compiler and I'm betting some of the others can too, I
can't see why the Ada compiler can't as it is supported, at least in the
source, just not in the build infrastructure.

The following (or similar) will need to be added to gnattools/configure
to enable this kind of build (under the "Per-target case statement"):

  *-*-elf* | *-*-eabi*)
    TOOLS_TARGET_PAIRS="\
    mlib-tgt-specific.adb<mlib-tgt-specific-xi.adb"
    ;;

Also, the above is still in the main makefile as well which causes a lot
of confusion and should be removed from there.

I am aware that "freestanding" is actually a C standard term and not
applicable to Ada, but this is figurative only. GNAT's equivalent term
is Zero Foot Print (ZFP).

I think that we need a configure flag to disable libada and not
gnattools for these bare board targets.

Thanks,
Luke.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]