libtool
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Explicit init/finalization in a libtool .so/.dll


From: Gary V. Vaughan
Subject: Re: Explicit init/finalization in a libtool .so/.dll
Date: Tue, 6 Feb 2001 22:37:41 +0000
User-agent: Mutt/1.3.12i

On Tue, Feb 06, 2001 at 11:35:09AM -0800, Kaelin Colclasure wrote:
> Greetings,

Hi there!

> I'm a relative newcomer to libtool and have just subscribed to this list,
> so please forgive me if I'm re-raising an old issue here.
> 
> I have noticed an issue with including explicit _init and _fini
> definitions in a Linux .so with the following version of libtool:
> 
> address@hidden downloads]$ libtool --version
> ltmain.sh (GNU libtool) 1.3.4 (1.385.2.196 1999/12/07 21:47:57)

This is an ancient copy of libtool!  I recommend upgrading to an alpha
release of libtool-1.4, either from CVS (which may have transitory
bugs), or 1.3b from ftp://alpha.gnu.org which is still rather old, but
has broadly the same feature set as CVS HEAD.

> I understand the problem and know how to resolve it when not using
> libtool. And I also found via google an article which describes a
> `fix' using something like `-Wc,-nostartfiles' to pass the required
> option through libtool directly to gcc. However I have a few
> questions about this approach.
> 
>  1) First, is this indeed implemented in the current, latest CVS
>     version of libtool? If so, is it anticipated that this is going
>     to be released this way?

I'm not sure what you are asking here.  If you want to know about -Wc
as a libtool argument, then yes -- this feature will be in the 1.4
release.  If you want to know about -nostartfiles, I was not aware
that this affected the _init and _fini functions.  What is the issue
that you have noticed?

Either way, if you are trying to take advantage of the magic handling
of _init and _fini functions in linux shared libraries, you can only
do so at the expense of portability.  Perhaps you could use libltdl to
load your library at runtime, and call functions of your own
definition?  This will work everywhere that libltdl works (pretty much
everywhere, and certainly orders of magnitude ore boxes than
_init/_fini).


>  2) If I grab a snapshot of libtool from CVS and install it on my
>     development machine, will an `autoreconf' be sufficient to
>     integrate the new version into my package? And will people I
>     distribute this to need to do anything special? (I believe
>     not in the latter case, but I would like an authoritative
>     answer.)

In theory it should.  I would write a bootstrap script, to run
gettextize/aclocal/libtoolize/automake/autoconf/etc, as required by
the package.

>  3) Is this approach considered a completely satisfactory solution?

Are we still talking -Wc here?  If so then, yep.

> My 

...other... =)O|

> third question something of a troll, in that I see this as a bit
> of a side-step around the issue of how to deal with an admittedly
> thorney problem. Ideally I would like to see libtool explicitly
> support the concept that some .so/.dll libraries on some platforms
> have load-time initializers and unload-time finalizers. However,
> in practical terms I have no idea how many libtool platforms
> actually support this or how homogeneous a solution could appear.
> 
> I do know Solaris and Linux both use _init and _fini. And I have
> build Win32 .dll's that had explicit load/unload behavior -- though
> I forget now some of the details. [ISTR it was primarily a matter
> of telling the linker what function to call on attach/detach, and
> there were some arguments, etc. Not easily reconciled with the
> comparitively simple approach on Unix.]
> 
> My motivation for bringing this up is that I do need to incorporate
> *some* fix for this in my package, and if there's interest in some
> collaboration on an alternative approach I'd view it as a good
> excuse to learn more about the implementation of libtool.

For link-time load/unload function calling you must rely entirely on
the runtime loader: effectively whatever the OS implements.  If you
are interested in doing this portably, I think the best way is to use
libltdl, and set up your own conventions when loading and unloading
libraries.  Especially since this all works already!  Take a look at
the CVS version of GNU m4 to see how this sort of thing can be done
with libtool.

HTH,
        Gary.
-- 
  ___              _   ___   __              _         mailto: address@hidden
 / __|__ _ _ ___ _| | / / | / /_ _ _  _ __ _| |_  __ _ ___       address@hidden 
| (_ / _` | '_|// / |/ /| |/ / _` | || / _` | ' \/ _` | _ \
 \___\__,_|_|\_, /|___(_)___/\__,_|\_,_\__, |_||_\__,_|//_/
home page:  /___/                      /___/                  gpg public key:
http://www.oranda.demon.co.uk           http://www.oranda.demon.co.uk/key.asc



reply via email to

[Prev in Thread] Current Thread [Next in Thread]