From: Tom on
On May 3, 12:03 pm, Simon Wright <si...(a)pushface.org> wrote:
> I think your problem may be that your host compiler is an older version
> (4.4.3) than the source tree you're using to build the cross compiler
> (4.5.0). The recommendation is to build the host compiler first, then
> use that to build the cross.
>
> The symbols you're missing are (in 4.5.0 but not in 4.3.4, the only
> handy version I have for comparison) defined in adaint.c, and it looks
> as though adaint.o is being picked up from the pre-built host libraries
> (not surprising, the cross-compiler has to run on the host so needs to
> use host file attributes etc).

Thanks Simon. That did the trick. I now have a functioning Ada cross
compiler; I just need to learn how to use it. I could use a few
pointers to get me started...

On our particular application -- an automotive ECU -- we're locked
into a proprietary C-based flow. The operating system and hardware
abstraction layer come precompiled and the application code must be
compiled and linked with the established tool chain (GHS C, not Ada).
The application programmer defines a procedure, which is invoked by
the OS as a periodic rate. This procedure references global C
variables to access the hardware abstraction layer.

The question is how can I best use Ada and GNAT in such an
environment? One method that comes to mind is to compile Ada to
assembly code, which is then passed to GHS for assembling and linking
with the closed source OS and HAL. I don't see an assembly switch,
like GCC's -S. Would this mean I would need the compile Ada modules
individually with GCC instead of using gnatmake? Are there any
options to compile Ada down to C by chance?

And how does gnatbind fit into this picture? It appears to create
initialization code. Would I just need to insert this code such that
it is invoked at power up?

-Tom
From: Simon Wright on
Tom <tomahawkins(a)gmail.com> writes:

> On our particular application -- an automotive ECU -- we're locked
> into a proprietary C-based flow. The operating system and hardware
> abstraction layer come precompiled and the application code must be
> compiled and linked with the established tool chain (GHS C, not Ada).
> The application programmer defines a procedure, which is invoked by
> the OS as a periodic rate. This procedure references global C
> variables to access the hardware abstraction layer.

I would have expected engine control software to require a pretty high
degree of certification, if not for safety-related reasons then because
fixing problems in deployed firmware is going to be expensive and
possibly embarrassing, see Toyota, and part of that involves the tool
chain. OK, I work on military systems, but my Software Design Authority
would need A Whole Lot Of Convincing to change the tool chain in a way
not supported by the tool vendor.

> The question is how can I best use Ada and GNAT in such an
> environment? One method that comes to mind is to compile Ada to
> assembly code, which is then passed to GHS for assembling and linking
> with the closed source OS and HAL. I don't see an assembly switch,
> like GCC's -S. Would this mean I would need the compile Ada modules
> individually with GCC instead of using gnatmake? Are there any
> options to compile Ada down to C by chance?

"gnatmake -c -S foo.adb" compiles the closure of foo to assembler (.s)
files. Of course these are going to be in GNU assembler, which may or
may not be that used by GHS.

There is a tool created by Sofcheck called AdaMagic which generates
C. GCC does not. (I'm not sure that Sofcheck is still in business? there
was a discussion here recently).

> And how does gnatbind fit into this picture? It appears to create
> initialization code. Would I just need to insert this code such that
> it is invoked at power up?

I think you'd call gnatbind with -C (to generate C binder code rather
than Ada) and -n (no Ada main program).

The generated code includes an adainit() to be called to initialize the
Ada runtime and an adafinal() to finalize it (not that I've ever had to
call adafinal()).
From: Randy Brukardt on
"Simon Wright" <simon(a)pushface.org> wrote in message
news:m2sk67jvjw.fsf(a)pushface.org...
> Tom <tomahawkins(a)gmail.com> writes:
....
> There is a tool created by Sofcheck called AdaMagic which generates
> C. GCC does not. (I'm not sure that Sofcheck is still in business? there
> was a discussion here recently).

Sofcheck still exists (www.sofcheck.com); they're behind the new AdaCore
CodePeer tool.

Randy.


From: Robert A Duff on
Simon Wright <simon(a)pushface.org> writes:

> I'm not sure that Sofcheck is still in business?

SofCheck is certainly still in business.

- Bob
From: Tom on
On May 4, 2:50 pm, Simon Wright <si...(a)pushface.org> wrote:

> OK, I work on military systems, but my Software Design Authority
> would need A Whole Lot Of Convincing to change the tool chain in a way
> not supported by the tool vendor.

This is strictly prototyping.

>
> > The question is how can I best use Ada and GNAT in such an
> > environment?  One method that comes to mind is to compile Ada to
> > assembly code, which is then passed to GHS for assembling and linking
> > with the closed source OS and HAL.  I don't see an assembly switch,
> > like GCC's -S.  Would this mean I would need the compile Ada modules
> > individually with GCC instead of using gnatmake?  Are there any
> > options to compile Ada down to C by chance?
>
> "gnatmake -c -S foo.adb" compiles the closure of foo to assembler (.s)
> files. Of course these are going to be in GNU assembler, which may or
> may not be that used by GHS.

This will work. And GHS does indeed read GNU assembly, with minor
post processing.

BTW, I've moved the scripts and patch files used to build the powerpc-
eabi cross compiler to github if anyone's interested:

http://github.com/tomahawkins/powerpc-eabi