[Top][All Lists]

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

Re: shared libraries and runtime linking on aix >= 4.2

From: Peter O'Gorman
Subject: Re: shared libraries and runtime linking on aix >= 4.2
Date: Wed, 19 Mar 2008 01:03:12 -0500
User-agent: Thunderbird (X11/20071115)

Michael Haubenwallner wrote:
> Hi,

Hi Michael,

There are quite a few oddities with AIX and libtool, some of them should
be relatively simple to fix.

> Without "-brtl":
> *) static is disabled when shared is enabled.
> *) libLib.so.1 is built using 'gcc -shared'
> *) libLIB.so.1 is packed into libLIB.a.
> *) this can provide some kind of 'soname' support.

The soname support would only come if, at install time, the new shared
object was added to the archive if one already existed at the install
location, correct? This would break DESTDIR installs on AIX (assuming
that they are not already broken), and would make an 'uninstall' target
a little harder too :)

> With "-brtl":
> *) static is enabled (into libLIB.a)
> *) libLIB.so.1.2.3 is created using 'gcc -shared -Wl,-G'
> *) symlink libLIB.so.1 -> libLIB.so.1.2.3 is created
> *) symlink libLIB.so -> libLIB.so.1.2.3 is created
> *) missing kind of 'soname' support.
> One problem is the missing kind of 'soname' support with enabled -brtl.

Yes, the linker encodes the name of the library it found at static link
time into the output, and that is always, with -lfoo, going to be
libfoo.so. Possible that we could change the versioning type to be
foo.N.so and pass -lfoo.N to the linker, which would "solve" that issue.
That might be doable, but also, ick.

> AFAICT, runtime linking also works with libLIB.so.1 packed into
> libLIB.a. And the decision wheter one executable uses runtime linking or
> not can only be done when linking that executable with/out -brtl.
> To allow shared libraries to use runtime linking (link with "${wl}-G")
> does not imply an executable linked against it does use runtime linking.

The documentation seems to agree with you, from the way I read it we
should always create shared libraries with -Wl,-G on AIX. Thanks.

There are problems, however, with undefined symbols when runtime linking
is not in effect, aren't there? A quick (probably too simple) test on
AIX-5.3 shows this (sorry for wrapping, some libtool output removed,
used libtool-1.5.24 because it was handy):

% cat baz.c
extern int mainly;
int baz() { return 10+mainly; }
% cat main.c
int mainly=20;
int main() { return baz();}
% ./libtool --mode=compile --tag=CC xlc -c -o main.lo main.c
% ./libtool --mode=compile --tag=CC xlc -c -o baz.lo baz.c
% ./libtool --mode=link --tag=CC xlc -o libbaz.la baz.lo -rpath /foo -Wl,-G
% ./libtool --mode=link --tag=CC xlc -o main main.lo libbaz.la
xlc -o .libs/main .libs/main.o  -L./.libs -lbaz
creating main
% ./main
% echo $?
% ./libtool --mode=link --tag=CC xlc -o main main.lo libbaz.la -Wl,-brtl
xlc -o .libs/main .libs/main.o -Wl,-brtl  -L./.libs -lbaz
creating main
% ./main
% echo $?

Peter O'Gorman

reply via email to

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