libtool
[Top][All Lists]
Advanced

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

Re: libtool doesn't hardcode libg2c when linking with g77


From: John David Anglin
Subject: Re: libtool doesn't hardcode libg2c when linking with g77
Date: Fri, 16 Aug 2002 13:42:47 -0400 (EDT)

> > g77  -O2 -c /xxx/gnu/libtool-1.4e/tests/../f77demo/fprogram.f
> > /bin/sh ./libtool --mode=link g77  -O2  -o fprogram  fprogram.o libfoo.la 
> > g77 -O2 -o fprogram fprogram.o  ./.libs/libfoo.a
> 
> Ok, looked at this again. Does libtool add the -rpath entry correctly
> when building C++ programs? I don't think so. Based on the input file
> above, how can it tell the correct path of where libg2c.sl is located?

I linked a simple C++ program with libtool.  It doesn't add the
-rpath for libstdc++.sl.4 :-(

Regarding how libtool can tell the correct path for libg2c, libstdc++,
etc., I think the best way is to link a simple test program.  For example,

g77 -o main main.o -Wl,-v 
collect2 version 3.1.1 (hppa)
/opt/gnu64/bin/ld -E -u main -o main /usr/ccs/lib/pa20_64/crt0.o 
-L/opt/gnu64/lib/gcc-lib/hppa64-hp-hpux11.00/3.1.1 
-L/opt/gnu64/lib/gcc-lib/hppa64-hp-hpux11.00/3.1.1/../../../../hppa64-hp-hpux11.00/lib
 -L/usr/ccs/bin -L/usr/ccs/lib/pa20_64 -L/opt/langtools/lib/pa20_64 
-L/opt/gnu64/lib/gcc-lib/hppa64-hp-hpux11.00/3.1.1/../../.. main.o -v 
-lfrtbegin -lg2c -lm -lgcc -lc /usr/lib/pa20_64/milli.a -lgcc
...

g++ -o main main.o -Wl,-v 
collect2 version 3.1.1 (hppa)
/opt/gnu64/bin/ld -E -u main -o main /usr/ccs/lib/pa20_64/crt0.o 
-L/opt/gnu64/lib/gcc-lib/hppa64-hp-hpux11.00/3.1.1 
-L/opt/gnu64/lib/gcc-lib/hppa64-hp-hpux11.00/3.1.1/../../../../hppa64-hp-hpux11.00/lib
 -L/usr/ccs/bin -L/usr/ccs/lib/pa20_64 -L/opt/langtools/lib/pa20_64 
-L/opt/gnu64/lib/gcc-lib/hppa64-hp-hpux11.00/3.1.1/../../.. main.o -v -lstdc++ 
-lm -lgcc -lc /usr/lib/pa20_64/milli.a -lgcc
...

The autoconf macro, AC_F77_LIBRARY_LDFLAGS, provides an example of how to
parse the above output.  If you look at the Makefile in f77demo, you will
see a FLIBS define.  This is set using AC_F77_LIBRARY_LDFLAGS to

FLIBS =  -L/opt/gnu64/lib/gcc-lib/hppa64-hp-hpux11.00/3.1.1 -L/opt/gnu64/lib/gcc
-lib/hppa64-hp-hpux11.00/3.1.1/../../../../hppa64-hp-hpux11.00/lib -L/usr/ccs/bi
n -L/usr/ccs/lib/pa20_64 -L/opt/langtools/lib/pa20_64 -L/opt/gnu64/lib/gcc-lib/h
ppa64-hp-hpux11.00/3.1.1/../../.. -lfrtbegin -lg2c -lm /usr/lib/pa20_64/milli.a

If I add FLIBS to the libtool link, the embedded path for libg2c gets encoded
into the binary:

# /bin/sh ./libtool --mode=link g77 -o main main.o 
-L/opt/gnu64/lib/gcc-lib/hppa64-hp-hpux11.00/3.1.1 
-L/opt/gnu64/lib/gcc-lib/hppa64-hp-hpux11.00/3.1.1/../../../../hppa64-hp-hpux11.00/lib
 -L/usr/ccs/bin -L/usr/ccs/lib/pa20_64 -L/opt/langtools/lib/pa20_64 
-L/opt/gnu64/lib/gcc-lib/hppa64-hp-hpux11.00/3.1.1/../../.. -lfrtbegin -lg2c 
-lm /usr/lib/pa20_64/milli.a
g77 -o main main.o  -L/opt/gnu64/lib/gcc-lib/hppa64-hp-hpux11.00/3.1.1 
-L/opt/gnu64/lib/gcc-lib/hppa64-hp-hpux11.00/3.1.1/../../../../hppa64-hp-hpux11.00/lib
 -L/usr/ccs/bin -L/usr/ccs/lib/pa20_64 -L/opt/langtools/lib/pa20_64 
-L/opt/gnu64/lib/gcc-lib/hppa64-hp-hpux11.00/3.1.1/../../.. -lfrtbegin 
/opt/gnu64/lib/libg2c.sl -lm /usr/lib/pa20_64/milli.a -Wl,--rpath 
-Wl,/opt/gnu64/lib -Wl,--rpath -Wl,/opt/gnu64/lib

# chatr main
main:
         64-bit ELF executable
         shared library dynamic path search:
             LD_LIBRARY_PATH    enabled  first 
             SHLIB_PATH         enabled  second
             embedded path      enabled  third  /opt/gnu64/lib
         shared library list:
             libg2c.sl.0
             libm.2
             libc.2

The AC_F77_LIBRARY_LDFLAGS macro seems drop various options like "-lc" and
"-lgcc".  It would be nice to drop "milli.a".  We need to ensure that we
don't drop the shared libgcc.

Dave
-- 
J. David Anglin                                  address@hidden
National Research Council of Canada              (613) 990-0752 (FAX: 952-6605)




reply via email to

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