From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,cb9e1ed8412da744 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!b25g2000prb.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: Typical handling of packages through compilers Date: Wed, 22 Jul 2009 07:29:58 -0700 (PDT) Organization: http://groups.google.com Message-ID: <4c52e11d-891d-4019-a849-8824f4f5c5c5@b25g2000prb.googlegroups.com> References: NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1248272998 14541 127.0.0.1 (22 Jul 2009 14:29:58 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 22 Jul 2009 14:29:58 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: b25g2000prb.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; WOW64; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.21022; .NET CLR 3.5.30729; .NET CLR 3.0.30618),gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:7274 Date: 2009-07-22T07:29:58-07:00 List-Id: On Jul 22, 5:21=A0am, Hibou57 (Yannick Duch=EAne) wrote: > Hi all, > > I've noticed that the inclusion of a package, turns into the inclusion > of all of its content, despite just a few part of it is really used > (taking into account, internal dependencies). Using seperate data and > function sections and then the linker gc-section option, does not > change anything (the executable is even a bit bigger using these > options). > > There is indeed no implementation requirement about it. > > But I would like to know more on the handling of package through > various Ada compilers (including Janus if possible, if there are some > Janus users in the place). > > By the way, on most compilers, is an inner package handled the same > way a child package is ? I mean... child packages are included only > when withed, but what about inner packages ? Are they tipically > included in whole as there are part of another package body or are > they tipically included only when explicitely referenced (althought > inner packages does not need to be withed) ? I think that typically, when a single source file is compiled, the result is a single object file; and for many linkers, either that object file gets included in the final executable or it doesn't, in an all-or-nothing fashion. One of our compilers (for a particular target processor) comes with a linker that is able to eliminate unused sections. The code for each procedure, function, or other routine generated by the compiler is in a separate section, and the linker doesn't include sections that aren't referenced. So if you have a procedure Proc1 in a package, but it's never called (or referenced via 'Access, etc.) anywhere in the program, then Proc1 won't be included in the executable. Furthermore, if Proc1 is the only procedure in the program that calls Proc2, then if Proc1 isn't included then Proc2 won't be included either. I think the same applies to global variables---if there are no references to a variable then by default it never gets allocated. I'm not sure if this is similar to what Gautier was referring to. I know there are other linkers out there that do a similar optimization (e.g. Analog Devices' linker for 21000 series). By the way, "inner packages" don't have any effect at all on this, and I'd guess that that is true for other compilers as well. Inner packages are not at all reflected in the structure of the object file. Our linker considers each code or data item individually to see if it can be eliminated; it doesn't care at all about whether they've been grouped into another package. -- Adam