libtool
[Top][All Lists]
Advanced

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

Re: Libtool misfeature on HP-UX


From: Martin Frydl
Subject: Re: Libtool misfeature on HP-UX
Date: Fri, 31 May 2002 18:46:38 +0200

Hello,

I've encountered the same problem. I've used your patches but they
haven't resolved it. This is because my library uses version info. 

I've used the examples you've supplied and removed -avoid-version from
Makefile.am. This resulted in generating libraries with version info,
i.e. libfoo.sl.0.0 and libbar.sl.0.0 along with all the links. When
(re)linking, libtool passes the library name without version, e.g.
libfoo.sl. However, the executable (or library) contains reference to
library with major number, e.g. libfoo.sl.0.

The fix you've provided does not work here since chatr tries to change
the flags for library withow version info and this is not found in the
executable:

chatr -l /tmp/foobar-22044/lib/libfoo.sl /tmp/libtool-23397/baz

The following command should be used instead:

chatr -l /tmp/foobar-22044/lib/libfoo.sl.0 /tmp/libtool-23397/baz

I've updated your patches to support also this situation. However, there
is no information about the library version info in relink command. I've
found a "dirty" trick to avoid this. In "for" look where you call chatr
for all the libraries I call it for libname*. For example if variable i
contains /.../libfoo.sl, chatr will be called for all the libraries
because shell will expand * to names of all libraries found in the
directory: libfoo.sl, libfoo.sl.0 and libfoo.sl.0.0.

I know this is not clean. Probably someone could look at this and solve
it better since I'm not familiar with libtool, m4 or cross-platform
scripts. I've attached the updated patch file.

I've also added chatr +s enable xxx to the commands. This will enable
SHLIB_PATH use for the executable or library. With this you don't need
to export LDOPTS.

Best regards
  Martin

"Schleicher Ralph (LLI)" wrote:
> 
> ltmain.sh (GNU libtool) 1.4.2 (1.922.2.54 2001/09/11 03:33:37)
> 
> Hi,
> 
> I encountered a problem with Libtool libraries on HP-UX.
> Consider the following (simplified) Makefile.am:
> 
> ----------------
> lib_LTLIBRARIES = libfoo.la libbar.la
> 
> libfoo_la_SOURCES = foo.c
> 
> libbar_la_SOURCES = bar.c
> libbar_la_LDFLAGS = libfoo.la
> ----------------
> 
> When relinking libbar.la for installation, the command sequence is
> 
> ----------------
> libtool: install: warning: relinking `libbar.la'
> cd /home/w3016.5/schleich/tmp/foo; /bin/sh ./libtool --mode=relink \
> gcc -g -O2 -o libbar.la -rpath /usr/local/lib libfoo.la libbar_la-bar.lo
> /usr/ccs/bin/ld -b +h libbar.sl +b /usr/local/lib -o .libs/libbar.sl \
> libbar_la-bar.lo /usr/local/lib/libfoo.sl -lc
> ----------------
> 
> The problem is that libfoo.sl is not subject to dynamic file name lookup
> via the built-in library search path or SHLIB_PATH environment variable
> (LD_LIBRARY_PATH on HP-UX 11.00) because it has been specified as an
> absolute file name and *not* via a -l or -l: switch.  This is a problem
> if you want to make a binary distribution with a different directory
> layout -- just setting SHLIB_PATH does not work.
> 
> I propose to translate the Libtool link command on HP-UX as follows:
> 
> ----------------
> /usr/ccs/bin/ld -b +h libbar.sl +b /usr/local/lib -o .libs/libbar.sl \
> libbar_la-bar.lo /usr/local/lib/libfoo.sl -lc
> /usr/ccs/bin/chatr -l /usr/local/lib/libfoo.sl .libs/libbar.sl >/dev/null
> ----------------
> 
> The chatr(1) command has the following effect:
> 
> ----------------
> $ chatr .libs/libbar.sl
> .libs/libbar.sl:
>          shared library
>          shared library dynamic path search:
>              SHLIB_PATH     enabled   first
>              embedded path  enabled   second /usr/local/lib
>          internal name:
>              libbar.sl
>          shared library list:
>              static    /usr/local/lib/libfoo.sl <<< *look here*
>              dynamic   /usr/lib/libc.1
> [...]
> 
> $ chatr -l /usr/local/lib/libfoo.sl .libs/libbar.sl
> .libs/libbar.sl:
>          shared library
>          shared library dynamic path search:
>              SHLIB_PATH     enabled   first
>              embedded path  enabled   second /usr/local/lib
>          internal name:
>              libbar.sl
>          shared library list:
>              dynamic   /usr/local/lib/libfoo.sl <<< *look here*
>              dynamic   /usr/lib/libc.1
> [...]
> ----------------
> 
> Here is the relevant section from the chatr(1) manual page:
> 
> ----------------
>            -l library     Indicate that the specified shared library is
>                           subject to run-time path lookup if directory
>                           path lists are provided (see +s and +b).
> ----------------
> 
> Best regards,
> 
> --
> Ralph
> 
> _______________________________________________
> Libtool mailing list
> address@hidden
> http://mail.gnu.org/mailman/listinfo/libtool
--- libtool.m4.orig     Tue Sep 11 05:16:01 2001
+++ libtool.m4  Fri May 31 16:04:09 2002
@@ -1622,7 +1622,8 @@
   hpux9* | hpux10* | hpux11*)
     case $host_os in
     hpux9*) archive_cmds='$rm $output_objdir/$soname~$LD -b +b $install_libdir 
-o $output_objdir/$soname $libobjs $deplibs $linker_flags~test 
$output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' ;;
-    *) archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs 
$deplibs $linker_flags' ;;
+    *) archive_cmds='$LD -b +h $soname +b $install_libdir +s -o $lib $libobjs 
$deplibs $linker_flags~
+                    for i in \$deplibs ; do case \$i in /*) for j in \$i* ; do 
$echo chatr -l \$j $lib ; chatr -l \$j $lib > /dev/null ; done ;; esac ; done' 
;;
     esac
     hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
     hardcode_libdir_separator=:
--- ltmain.in.orig      Tue Sep 11 01:40:18 2001
+++ ltmain.in   Fri May 31 15:59:49 2002
@@ -3515,6 +3519,16 @@
       # Now create the wrapper script.
       $show "creating $output"
 
+      # Fix relink command for HP-UX.
+      case $host in
+       *-*-hpux10* | *-*-hpux11*)
+         if test -n "$finalize_deplibs"
+         then
+             relink_command="$relink_command ; tem='$finalize_deplibs' ; for i 
in \$tem ; do case \$i in /*) for j in \$i* ; do $echo chatr -l \$j @OUTPUT@ ; 
chatr -l \$j @OUTPUT@ > /dev/null ; done ;; esac ; done ; $echo chatr +s enable 
@OUTPUT@ ; chatr +s enable @OUTPUT@ > /dev/null"
+         fi
+         ;;
+      esac
+
       # Quote the relink command for shipping.
       if test -n "$relink_command"; then
        # Preserve any variables that may affect compiler behavior

reply via email to

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