comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Re: gnat compiler issues with a partial build
Date: Wed, 10 Jun 2015 17:59:29 +0100
Date: 2015-06-10T17:59:29+01:00	[thread overview]
Message-ID: <lypp53mrda.fsf@pushface.org> (raw)
In-Reply-To: 295e0eb8-4779-4c72-ba98-3fb0c507640d@googlegroups.com

jan.de.kruyf@gmail.com writes:

> In any case: the runtime cooking business is like this (in its most
> basic form)
> 1. extract something very basic from ravenscar or zfp.
> 2. compile little test programs with (1) in a subdirectory and no libraries.
> 3. run nm to look for 'U' symbols. and use grep to find where they
> originate and where they are defined in any runtime.
> 4. Then adapt that piece of code where they are defined, one way or
> another, to you new runtime.
>    Normally of course either ravenscar or zfp will have a piece of
> code that fits without hacking too much.
> only for heap memory I had to modify s-memory quite a bit to fit the
> kernel environment so it is all strictly controlled and not
> pageable. (one of my requirements)
> 5. repeat 2,3,4 until satisfied that it is usable now. Then you can
> build the runtime subdirectory into a runtime library.
>
> So in that process I discovered those pesky undefined symbols, that
> _should_ disappear with some compiler switch, either in System.ads or
> on the command line. Since it is superfluous code that is generated by
> the compiler, for which there are no symbols in the arm ravenscar
> profile, that I am sure of.

The compiler needs to know that it's compiling against a runtime system,
which is a complete set of Ada units for your purposes. This means it
won't look anywhere else for units it needs.

You could try a structure like

  top/kernel/adainclude
            /adalib
     /proj

kernel will be your RTS, adainclude is where the Ada source goes, adalib
is where the library and ALI files end up. adainclude and adalib are the
default names; don't use anything else or it won't be recognised as an
RTS (there are some bells & whistles here, not needed to start with).

proj is where your test code goes.

In kernel you need a GPR file to build the RTS. I'm not sure what the
minimum needed is, but looking at the one I use in the STM32F4 RTS,
it'll be something like

   library project Build_Runtime is

       for Library_Name use "gnat";
       for Library_Kind use "static";
       --  Results in libgnat.a. This should be OK since the RTS will be
       --  linked into your module.

       for Library_Dir use "adalib";
       for Object_Dir use ".build";

       for Source_Dirs use ("adainclude");

       package Builder is
          --  An RTS that has built with this package will build without
          --  it; it may prevent picking up missing units from your
          --  host compiler's RTS; that may also be why -nostdinc is in
          --  ADAFLAGS below
          for Switches ("Ada") use ("--RTS=" & Project'Project_Dir);
       end Builder;

       package Compiler is
          ADAFLAGS :=
            ("-gnatpgn", "-gnatqQ", "-O2", "-nostdinc");
          --  Do you need -fpic or -fPIC? probably
          --  I'm not sure about the -nostdinc here

          for Switches ("Ada") use ADAFLAGS;
      end Compiler;

   end Build_Runtime;

As I said, your source files go in kernel/adainclude. I don't know about
gnat.adc; what I (and AdaCore) have done is put all the restrictions in
package System, seems to work just fine barring compiler errors.

You need to be careful about the Ada features you use in the RTS. Stick
to Ada95, only include packages under Ada, Interfaces, and GNAT.

Strongly recommend doing all your builds with gprbuild rather than
gnatmake; if you have any C or C++ code, you must use gprbuild.

To test out your RTS, use code in the proj directory, and a project
file. You can say

   gprbuild --RTS=../kernel -P foo.gpr

or you can include this in foo.gpr:

   package Builder is
      for Default_Switches ("ada") use ("--RTS=../kernel");
   end Builder;

It's possible you might need an absolute path to find the RTS.


  reply	other threads:[~2015-06-10 16:59 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-04 11:12 gnat compiler issues with a partial build jan.de.kruyf
2015-06-04 19:03 ` Lucretia
2015-06-09  8:11   ` jan.de.kruyf
2015-06-09 10:21 ` Mark Lorenzen
2015-06-09 11:28   ` jan.de.kruyf
2015-06-09 13:03     ` Mark Lorenzen
2015-06-09 18:57       ` jan.de.kruyf
2015-06-10 10:11         ` Mark Lorenzen
2015-06-10 15:34           ` jan.de.kruyf
2015-06-10 16:59             ` Simon Wright [this message]
2015-06-10 17:01               ` Simon Wright
2015-06-10 20:36                 ` jan.de.kruyf
2015-06-11  5:01                   ` Simon Wright
2015-06-11 14:08                     ` jan.de.kruyf
2015-06-11 16:10 ` rrr.eee.27
2015-06-11 19:38   ` Simon Wright
2015-06-12 14:37     ` jan.de.kruyf
2015-06-12 15:05       ` Simon Wright
2015-06-12 15:12         ` jan.de.kruyf
2015-06-12 15:31   ` jan.de.kruyf
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox