comp.lang.ada
 help / color / mirror / Atom feed
* Interfacing Ada with Ada
@ 2009-12-02 14:54 dhenry
  2009-12-02 16:21 ` Jean-Pierre Rosen
  2009-12-02 22:15 ` sjw
  0 siblings, 2 replies; 7+ messages in thread
From: dhenry @ 2009-12-02 14:54 UTC (permalink / raw)


Hello,

Is it possible to interface Ada code compiled with an older compiler
(gnat 3.14) and for which I just have specs (ads), objects and ali
files (so I can't recompile it), with Ada code compiled with a newer
compiler (gnat 2009), and for which I have all the sources?

Yours,
David.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Interfacing Ada with Ada
  2009-12-02 14:54 Interfacing Ada with Ada dhenry
@ 2009-12-02 16:21 ` Jean-Pierre Rosen
  2009-12-02 17:40   ` Pascal Obry
  2009-12-02 22:15 ` sjw
  1 sibling, 1 reply; 7+ messages in thread
From: Jean-Pierre Rosen @ 2009-12-02 16:21 UTC (permalink / raw)


dhenry a �crit :
> Hello,
> 
> Is it possible to interface Ada code compiled with an older compiler
> (gnat 3.14) and for which I just have specs (ads), objects and ali
> files (so I can't recompile it), with Ada code compiled with a newer
> compiler (gnat 2009), and for which I have all the sources?
> 
Simple answer: no. The ali file contains the version of the compiler
that was used, and the binder will refuse a unit from a different version.

Now, if you are in a desperate situation, you can try and edit the ali
file to fool the binder (it is a plain text file, and quite easy to
understand). Who knows? If you are very lucky, it might even work...
-- 
---------------------------------------------------------
           J-P. Rosen (rosen@adalog.fr)
Visit Adalog's web site at http://www.adalog.fr



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Interfacing Ada with Ada
  2009-12-02 16:21 ` Jean-Pierre Rosen
@ 2009-12-02 17:40   ` Pascal Obry
  0 siblings, 0 replies; 7+ messages in thread
From: Pascal Obry @ 2009-12-02 17:40 UTC (permalink / raw)


Le 02/12/2009 17:21, Jean-Pierre Rosen a �crit :
> Simple answer: no. The ali file contains the version of the compiler
> that was used, and the binder will refuse a unit from a different version.

Hum... For "simple" code not using the Ada runtime, won't it work to 
consider this old Ada code as it was some external C code:

    0. Remove all .ali files coming from 3.14 compiler. Move away
       specs too.

    1. Create interface specs for say "old.o" object code:

          procedure Foo (P : in Integer);
          pragma Import (Ada, Foo);

    2. When linking add the old object file

          $ gnatmake xyz -largs old.o

If the old code uses the Ada runtime (tasks, controlled objects, ...) 
this just won't work of course.

Pascal.

-- 

--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|    http://www.obry.net  -  http://v2p.fr.eu.org
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver keys.gnupg.net --recv-key F949BD3B




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Interfacing Ada with Ada
  2009-12-02 14:54 Interfacing Ada with Ada dhenry
  2009-12-02 16:21 ` Jean-Pierre Rosen
@ 2009-12-02 22:15 ` sjw
  2009-12-03  7:48   ` dhenry
  1 sibling, 1 reply; 7+ messages in thread
From: sjw @ 2009-12-02 22:15 UTC (permalink / raw)


On Dec 2, 2:54 pm, dhenry <tfc.d...@gmail.com> wrote:

> Is it possible to interface Ada code compiled with an older compiler
> (gnat 3.14) and for which I just have specs (ads), objects and ali
> files (so I can't recompile it), with Ada code compiled with a newer
> compiler (gnat 2009), and for which I have all the sources?

Your problem (well, one of them!) is going to be with getting
elaboration right.

Then there's differences between the runtimes expected by generated
code.

For the elaboration problem, do you have enough 3.14 artefacts to
allow you to run the 3.14 binder? You could maybe make a library out
of the 3.14 code (+ 3.14 runtime)?

Not sure how much reliance I'd want to place on the result.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Interfacing Ada with Ada
  2009-12-02 22:15 ` sjw
@ 2009-12-03  7:48   ` dhenry
  2009-12-03 20:03     ` Pascal Obry
  2009-12-05 10:22     ` Florian Weimer
  0 siblings, 2 replies; 7+ messages in thread
From: dhenry @ 2009-12-03  7:48 UTC (permalink / raw)


Ok, I see that it won't be easy ;)

I'm afraid my old code is using the gnat runtime :(
I imagined once something like interfacing old code with C and then
the C with new code. But linking may be hard, especially with the gnat
runtime dependency.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Interfacing Ada with Ada
  2009-12-03  7:48   ` dhenry
@ 2009-12-03 20:03     ` Pascal Obry
  2009-12-05 10:22     ` Florian Weimer
  1 sibling, 0 replies; 7+ messages in thread
From: Pascal Obry @ 2009-12-03 20:03 UTC (permalink / raw)


Le 03/12/2009 08:48, dhenry a �crit :
> Ok, I see that it won't be easy ;)
> 
> I'm afraid my old code is using the gnat runtime :(
> I imagined once something like interfacing old code with C and then
> the C with new code. But linking may be hard, especially with the gnat
> runtime dependency.

Yes, if there is some GNAT runtime dependencies that's almost
impossible. Especially in your case where you have code using a very old
runtime where some routines may have changed or even removed in new runtime.

Pascal.

-- 

--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|    http://www.obry.net  -  http://v2p.fr.eu.org
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver keys.gnupg.net --recv-key F949BD3B




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Interfacing Ada with Ada
  2009-12-03  7:48   ` dhenry
  2009-12-03 20:03     ` Pascal Obry
@ 2009-12-05 10:22     ` Florian Weimer
  1 sibling, 0 replies; 7+ messages in thread
From: Florian Weimer @ 2009-12-05 10:22 UTC (permalink / raw)


* dhenry:

> I'm afraid my old code is using the gnat runtime :(
> I imagined once something like interfacing old code with C and then
> the C with new code. But linking may be hard, especially with the gnat
> runtime dependency.

If your platform has a decent linker, you can link the old code and
only make very few symbols available.  You need to link the GNAT
run-time library statically, but that's probably the least of your
problems.



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2009-12-05 10:22 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-02 14:54 Interfacing Ada with Ada dhenry
2009-12-02 16:21 ` Jean-Pierre Rosen
2009-12-02 17:40   ` Pascal Obry
2009-12-02 22:15 ` sjw
2009-12-03  7:48   ` dhenry
2009-12-03 20:03     ` Pascal Obry
2009-12-05 10:22     ` Florian Weimer

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