comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Building an encapsulated library that uses GNAT sockets under Windows
Date: Wed, 27 Apr 2016 10:27:21 +0200
Date: 2016-04-27T10:27:21+02:00	[thread overview]
Message-ID: <nfpt65$1nf5$1@gioia.aioe.org> (raw)
In-Reply-To: lyd1pcm5cp.fsf@pushface.org

On 26/04/2016 23:23, Simon Wright wrote:
> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes:
>
>> On 2016-04-23 23:16, Simon Wright wrote:
>>> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes:
>>>
>>>> Can [gprlib] build a static equivalent too? I.e. a static library
>>>> containing a closure of all referenced objects plus initialization
>>>> code.
>>>
>>> I'm not sure it's relevant, but I posted a bug[1] on gnatmake &
>>> static standalone libraries; I sent AdaCore a similar report on
>>> gprbuild, no reply.
>>>
>>> The problem was, for a static SAL, the using Ada main program needs
>>> to see all the ALIs for it to be sure to call in all the dylibs
>>> required by the library; so if e.g. libgnarl was only called by
>>> non-interface units it would get linked but not elaborated.
>>>
>>> I wanted to use SALs because they automatically populate the include
>>> directory with relevant source.
>>
>> How do you build a static stand-alone library? In my case gprbuild
>> wants it dynamic.
>
> I see what you mean, I've been calling it the wrong thing all these
> years.
>
> If you provide a Library_Interface and you're building a dynamic
> library, gprbuild populates the include Library_Src_Dir directory with
> the library interface units and builds a dynamic library with
> auto-initialization.
>
> If you provide a Library_Interface and you're building a static library,
> gprbuild uses the same rule to populate the include directory; but this
> mey be wrong if the non-visible units require elaboration (e.g. they
> call in the tasking runtime).
>
> The patch I provided meant that if you provided a Library_Interface for
> a static library, the include directory would be populated with all the
> units regardless of whether they were actually listed; I now see that
> using Interfaces and naming all the source files achieves the same
> effect! so no need for a patch (but maybe a blog posting?)
>
> For the BCs this would mean
>
>    case Library_Type is
>       when "relocatable" =>
>          for Library_Src_Dir use "./include";
>          for Library_Interface use Source_Units;
>       when "static" =>
>          for Library_Src_Dir use "./include";
>          for Interfaces use Sources;
>    end case;
>
> where I already have
>
>    Source_Units :=
>      (
>       "BC.Containers.Bags.Bounded",
>       "BC.Containers.Bags.Dynamic",
>       ...
>
> and
>
>    Sources :=
>      (
>       "bc-containers-bags-bounded.adb",
>       "bc-containers-bags-bounded.ads",
>       "bc-containers-bags-dynamic.adb",
>       "bc-containers-bags-dynamic.ads",
>       ...

It is still deeply confusing to me. Does it mean that Interfaces must be 
the list of all source file from all projects?

The case is:

with "A.gpr";
with "B.gpr";
...
with "Z.gpr";

library project Foo is
    for Source_Files use (); -- No own sources, to stress the point
    for Library_Kind use "static";
    for Library_Standalone use "encapsulated"; -- ??
    for Library_Auto_Init use "true"; -- ??
    for Library_Interface use (<things-to-be-visible-are-outside>);
    for Interface use (<what?>);
end Foo;

> I don't really like the idea of using Library_Interface (what units
> should be visible) to indicate that auto-initialization is required;
> especially because there are already Library_Standalone and
> Library_Auto_Init. Perhaps they weren't available at the time.
>
>> Another question is regarding the library interface. gprbuild rejects
>> interface units from other projects. But usually the library is just a
>> combination of many projects some of which providing interface units.
>
> You would only need to know about the interface units of other libraries
> if you were going to call them yourself directly.

But there is no other libraries after libFoo.a is built. The whole 
purpose of the exercise to have libFoo a closure containing all static 
libraries it depends on and GNAT RTL too.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de


  parent reply	other threads:[~2016-04-27  8:27 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-21 12:59 Building an encapsulated library that uses GNAT sockets under Windows Dmitry A. Kazakov
2016-04-22  7:58 ` ahlan.marriott
2016-04-22  8:23   ` Dmitry A. Kazakov
2016-04-23  9:20     ` Ahlan
2016-04-23  9:48       ` Dmitry A. Kazakov
2016-04-23 14:45         ` ahlan.marriott
2016-04-23 19:56           ` Dmitry A. Kazakov
2016-04-23 21:16             ` Simon Wright
2016-04-24  8:13               ` ahlan
2016-04-24  8:31                 ` Simon Wright
2016-04-26 19:43                   ` ahlan.marriott
2016-04-26 20:24                     ` Simon Wright
2016-04-26 22:32                     ` Jeffrey R. Carter
2016-04-27 22:16                     ` Randy Brukardt
2016-04-27 23:43                       ` Jeffrey R. Carter
2016-04-28  5:18                         ` J-P. Rosen
2016-04-28  5:59                           ` Jeffrey R. Carter
2016-05-09 22:32                             ` David Thompson
2016-04-28 20:23                         ` Randy Brukardt
2016-04-28 21:47                           ` Jeffrey R. Carter
2016-04-28  5:13                       ` J-P. Rosen
2016-04-26 20:20               ` Dmitry A. Kazakov
2016-04-26 21:23                 ` Simon Wright
2016-04-27  6:53                   ` Simon Wright
2016-04-27  7:25                     ` ahlan
2016-04-27  8:27                   ` Dmitry A. Kazakov [this message]
2016-04-27  9:59                     ` Simon Wright
replies disabled

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