libtool
[Top][All Lists]
Advanced

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

Re: Install of libtool module on AIX 4.2 does not work.


From: Ralf Wildenhues
Subject: Re: Install of libtool module on AIX 4.2 does not work.
Date: Mon, 17 Jan 2005 18:07:01 +0100
User-agent: Mutt/1.4.1i

Hi Gary,

* Gary Kumfert wrote on Sat, Jan 15, 2005 at 02:04:55AM CET:
> 
> There aren't two types of shared libraries... there's shared
> and there's dynamic (or "run time linked" in AIX speak. hence -brtl.)

This I can mostly agree with.

> Even then, the switch doesn't *really* care about the type... just the
> suffix in the filesystem. (Below is an exercise I just did
> to confirm this.)

This I must respectfully disagree with.  See below.

> The bigger issue in Peter's question, I thought was:
> why should he (or me, or my customers for that matter) have to know
> to configure with "LDFLAGS=-brtl" in the first place?
> The point of libtool is to hide such platform-specific details.

I would love to simplify things here -- and in any way, I see the need
to either do that or at least update Libtool documentation on the joys
encountered on AIX, so the user knows what to do.

> (I concede that its not easy since AIX has a unique mapping of
>  the 3 linkage concepts [static, shared, dynamic] onto the two
>  file suffices [*.a, *.so].  OTOH, I suppose IBM figures its a
>  novel feature of ELF that all shared libraries can be dynamically
>  loaded.)
> 
> Requiring LDFLAGS=-brtl at configure time is IMHO a bit
> heavy-handed.  In my own build, I don't want -brtl to show up
> *everywhere*.... only certain places.
> I'd much rather specify it my makefiles using a
> platform-independent libtool option, and let libtool intuit
> that its "-Wl,-brtl" on AIX, and "" elsewhere.

When?  Under which circumstances would it make sense?
What does portable software that does this on AIX do
on other systems which do not allow so many choices?

> P.S.  For all kinds of nitty-gritty's, I recommend
>       http://www.ibm.com/developerworks/eserver/pdfs/aix_ll.pdf

Thank you very much for this pointer.

> P.P.S.  Now for the exercise which builds a lib*.a and then renames
>       it lib*.so to indicate -brtl really is a filename thing,
>       not a library-type issue.
> 
> > cat foo1.c
> #include <stdio.h>
> foo() {
>   printf("foo1\n");
> }
> 
> > cat foo2.c
> #include <stdio.h>
> foo() {
>   printf("foo2\n");
> }
> 
> > cat main.c
> int main() {
>   foo();
> }
> 
> > xlc -g -c foo1.c
> > ar cru libfoo.a foo1.o
> > ranlib libfoo.a
> > mv libfoo.a libfoo.so # if its a type thing, maybe this would upset it?

This comment is misleading.
It's not just the type.  It's also the fact that ..

> > xlc -g -c foo2.c
> > ar cru libfoo.a foo2.o
> > ranlib libfoo.a
> > xlc -brtl -o main1 main.c -L. -lfoo  # this picks up libfoo.so (foo1.o)

..at this point, foo is bound:
$ dump -HTv main1 | grep foo
$

Just like how you use a static library, and very much unlike shared
linking.

> > xlc -o main2 main.c -L -lfoo         # this picks up libfoo.a (foo2.o)
> > ./main1
> foo1
> > ./main2
> foo2
> 
> The AIX *convention* is to reserve the *.so suffix for dynamic loaded
> libraries ("run time linkage" in AIX-speak.... which is probably the
> reason for the flag's name -brtl).  It seems intended to apply shared
> linkage to run-time linked libraries.  (Which makes sense since in AIX,
> there's also a switch to apply static linkage to otherwise shared
> libraries).  Note that if I build libfoo.so the usual way, this also works
> 
> > xlc -G -o libfoo.so foo3.o  #assume this prints foo3, without me showing 
> > code
> > ./main1  # no need to relink main1
> foo3

$ cat >foo3.c
#include <stdio.h>
foo() {
  printf("foo3\n");
}
int vfoo = 99;

$ xlc -g -c foo3.c
$ xlc -G -o libfoo.so foo3.o
$ ./main1
foo1

Unless you also build libfoo.so with -G resp. -brtl, you do not get the
desired linking behavior.  Furthermore, if you create an archive but
defer the linking, the linking above does not only involve the library
name and the symbol, but also the archive member that contains the
symbol.

You have many choices on AIX.  Globally using -brtl is too expensive,
else libtool should probably use that.

Maybe all this is just me misunderstanding you.  I'd love to be
corrected then.  In any case, ideas for improvement on how libtool
handles all this are welcome.

> I didn't bother trying to dlopen a library built with ar.
> We all know what happens there on AIX.  ;)

No, I don't.  But that doesn't matter much to me.

Regards,
Ralf




reply via email to

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