bug-libtool
[Top][All Lists]
Advanced

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

why -lc on AIX


From: Miroslaw Dobrzanski-Neumann
Subject: why -lc on AIX
Date: Fri, 15 Feb 2002 18:04:16 +0100
User-agent: Mutt/1.3.16i

Hi,

Why libtool (1.4) insists on directly linking libc on almost all systems?


Each platform specific compiler knows better how to link the correct version
of libc.

Especially AIX Systems with the IBM compiler family xlc:

libtool links always libc in the wrong order.
You can see this when using xlc_r4 on AIX 4.3

command line produced by libtool (for glib)
$ xlc_r4 -bM:SRE -o .libs/libglib-1.3.so.13 <<<many object files>>>
.libs/libglib-1.3.lax/libcharset.al/localcharset.lo
-L/net/DAGOBERT/dataE3/bef/mne/SYSTEM/lib libcharset/.libs/libcharset.al
-liconv -lintl  -lc  ${wl}-berok -bnoentry -bexport:.libs/libglib-1.3.exp

let's see what the xlc_r4 is doing (using -v option)
$ xlc_r4 -v ...

exec:
/bin/ld(ld,/lib/crt0.o,-bpT:0x10000000,-bpD:0x20000000,-bM:SRE,-o.libs/libglib-1.3.so.13,<<<many
 object 
files>>>,-L/net/DAGOBERT/dataE3/bef/mne/SYSTEM/lib,-liconv,-lc,-berok,-bnoentry,-bexport:.libs/libglib-1.3.exp,-L/usr/lib/threads,-ldcelibc_r,-ldcepthreads,-lpthreads_compat,-lpthreads,-lc_r,-lc,NULL)

You can investigate the import table of the created binary
$ dump -Tv .libs/libglib-1.3.a
...
[19]    0x00000000    undef      IMP     DS EXTref   libc.a(shr.o) malloc
...

uups: -ldcelibc_r, the dce wraper, has no chance to be activated
because -lc appears before. The critical functionality as memory allocation or
signal handling are no more taken from the libdcelibc_r which causes program
crashes. (dce library maintains separate memory heap)

If you let the compiler choose the correct library set (and their link
order) you get the followint CORRECT import table

$ dump -Tv .libs/libglib-1.3.a
...
[100]   0x00000000    undef      IMP     DS EXTref 
libdcelibc_r.a(dcelibc_r_shr.o) malloc
...

The same is true for all systems I'm working with:
(libc should not be directly linked)

AIX
OS/390
True Unix
Linux
SunOS

Proposal for solution
try to link a program with $(CC) which uses some of the libc functions.
If you get no error and the program executes as expected you should not try
to link libc (-lc) directly (the compiler knows what it is doing).

Best regards,
Miroslaw
-- 
Miroslaw Dobrzanski-Neumann

MOSAIC SOFTWARE AG
Base Development and Research
Tel +49-2225-882-291
Fax +49-2225-882-201
E-mail: address@hidden




reply via email to

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