This is the mail archive of the
automake@gnu.org
mailing list for the automake project.
Re: Partially Linked Objects
In article <Pine.SGI.4.03.9905101503520.1503-100000@uscream.vss.fsi.com>, Brian Ford wrote:
>> >Two suggestions. Use libtool convienence libraries
>>
>> There's a problem with using a library (which is why we currently use
>> partial linking) because many of these objects are almost unreferenced. The
>> only references are via a master table of function pointers, and a static
>> C++ object in each file has a constrcutor which fills in the relevant
>> entries in the table. Unfortunately if you put these objects in a library,
>> the linker thinks it knows best and throws most of them away.
>>
>That is why I suggested libtool convienence libraries. They actually make
>an archive, extract back out the objects, and do the link. It is a bit of
>overhead, but it is portable and will do what you want. It also makes the
>Makefile.am's a bit less hackish. But, if you don't need libtool for
>anything else, it is probably too much overkill.
Ah, I'd missed this. I am using libtool, so this sounds like a good
approach.
>> Another minor issue is that the library is much larger than the partially
>> linked object (nearly twice the size if memory serves).
>I wouldn't think this would happen unless you are using PIC code, but I'm
>no expert on this.
That's not it - it's the same code in both the library and the
partially-linked object.
We're talking about a couple of hundred object here, many of which are
pretty small - I suspect the size reduction is caused by some combination
of:
* space savings from merging object symbol tables and text/data segments
* overheads per object in the library
It's not a big deal, but I would guess that partially linking speeds up
subsequent use of the library (because it's smaller, and maybe also because
the linker has fewer objects to deal with) - and because of the way the
linking happens, none of these objects are unreferenced so all will be
linked anyway. And it also saves on disk space.
>> Aha, cunning - it hadn't occured to me that I could supply the "-r" using
>> LDFLAGS. I've just tried this approach and it seems to work perfectly -
>> many thanks.
>>
>This is probably very unportable, though. Since automake uses the
>compiler to do the linking, you would have to find out how or if that
>compiler can pass flags directly to the linker. Wl,-r or something
>similar. The hack I posted probably only works reliable with gcc.
I only need to work with gcc (at the moment at least). But the libtool
convenience library approach sounds like a better plan.
Cheers,
Olly