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=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,364dfbdf0a113a56 X-Google-Attributes: gid103376,public From: Mats Weber Subject: Re: Looking for a smart linker for GNAT/DOS Date: 1997/04/21 Message-ID: <335B6E77.4CC6@elca-matrix.ch>#1/1 X-Deja-AN: 236368932 References: <1997Apr15.202909.5879@news> <1997Apr16.162852.5886@news> Organization: ELCA Matrix SA Reply-To: Mats.Weber@elca-matrix.ch Newsgroups: comp.lang.ada Date: 1997-04-21T00:00:00+00:00 List-Id: > P.S. GNAT already does something about Text_IO. In GNAT, packages > like Integer_IO, Float_IO etc are implemented as child units (which > is how they should have been defined in the first place if we were > not constrained by Ada 83 compatibility), so they are only loaded > if needed. This implementation is transparent to a user (interested > people may enjoy looking at the routine Text_IO_Kludge in rtsfind > in the GNAT sources to see how this is done :-) The subpackages in Text_IO are all generic, and GNAT implements generics via macro expansion, so I don't see what this wins in exe size when these generics are not instantiated. Or am I missing something ? > Certainly we have decided that we cannot count on smart linkers for > elimination of unused subprograms, which is why we have decided on > a source based approach to solve this problem. Basically our approach > works as follows: > > There is a configuration pragma which declares that a certain > subprogram is unused. In the presence of the pragma, the compiler > (a) stubs out the subprogram, and (b) makes sure it is not called. One of the situations where I would like dead code elimination in the linker or compiler is in generic instances. It often happens that a generic unit (e.g. AVL trees with set operations, iterators, etc.) is instantiated very often with only a small subset of its operations being used (e.g. Insert, Member and Remove) and all the other stuff is unused. The compilers/linkers I have used so far do not eliminate this kind of dead code. (I know I can split the generic using generic children, but the code exists (Ada 83) and I don't want to do this). Even if the new GNAT pragma approach seems to make this possible (if I understand it correctly, and assuming that the pragma is allowed for subprograms created via generic instantiation), the process will be manual. Is there any chance of having this done automatically ?