Configuring for bare hw ia32 PC's

Jonathan S. Shapiro shap@eros-os.com
Mon May 12 22:30:00 GMT 2008


On Mon, 2008-05-12 at 19:40 +0100, Luke A. Guest wrote:
> On Mon, 2008-05-12 at 14:17 -0400, Jonathan S. Shapiro wrote:
> > Back up a second. You are, in effect, compiling Ada code to run on a
> > bare board. The "hosted" specification of the standard C library assumes
> > that you are running on top of an operating system. The "freestanding"
> > version does not.
> > 
> > It is okay if the Ada compiler emits things that rely on the
> > freestanding version of libc. Pragmatically, it is also okay if it
> 
> Do you mean, "is it?" I would say, no that's fine. I want a basic
> runtime, just not the extra bits. Unfortunately, the way the GNAT source
> is built, there doesn't seem (I could be wrong) to be a way to say, I
> only want this and this and this, not that.

No, I mean "it is". That is: an Ada compilation environment targeting
bare metal may rely on:

  - Anything in the freestanding libc subset
  - Anything that is provided by your hand-crafted kernel runtime

and nothing else.

> As an example, say I have an array and I want to initialise it:
> 
> package Something is
>    ...
> private
>    type My_Array(1 .. 3) of Integer;
> 
>    My_Instance : My_Array := (3, 5, 2);
> end Something;
> 
> The initialisation code will generate a call to memcpy. This is
> something I will most probably want to include in *my runtime*.

I agree, but this is not a libc matter. As you say, this wants to be
provided by your bare-kernel runtime.

> Also, to actually get the gnat tools (e.g. gnatmake, gnatclean, etc) you
> have to build the runtime. Also, I suspect that to get ASIS (which may
> be necessary) you also need the runtime and the tools. :(

Yes to all of this, but this isn't really relevant to your original
question. The Ada tool chain itself runs in a hosted environment, and it
is reasonable for it to rely on hosted aspects of libc. Compiling a
kernel using Ada is another matter. The compilation can be be performed
by a hosted tool chain, but the target of the compilation wants to be
freestanding.

My suspicion is that an Ada compilation targeting bare metal should not
be linking libc at all, in the same way that the Coyotos build (written
in C) doesn't link libc -- any dependencies that it has should be
provided by a subset library whose implementation is part of the
relevant kernel code base.

shap



More information about the Newlib mailing list