libtool-patches
[Top][All Lists]
Advanced

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

PATCH: inst-prefix support enhancements forhardcode_action=immediate sys


From: Alexander Dupuy
Subject: PATCH: inst-prefix support enhancements forhardcode_action=immediate systems
Date: Thu, 05 Jun 2003 20:17:31 -0400
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3) Gecko/20030314

Libtool supports a "hidden" switch for relinking, --inst-prefix-dir, which allows the destination target of a mode=install to include a prefix relative to the -rpath destination that was specified.

For example if a module was built with -rpath /usr/local/lib, the install destination could be /tmp/build/usr/local/lib or some such.

Libtool detects such cases automatically: the --inst-prefix-dir switch isn't intended for users; rather it is passed to recursive libtool relink commands when evaluating .la wrapper scripts on systems where relinking is necessary (hardcode_action=relink) or requested (--disable-fast-install on some systems).

While this works for a single shared library or module, it has some limitations if you are building a whole set of programs, libraries, and modules that have interdependencies; to work correctly, all dependent libraries must be installed in their true locations, without any prefix.

The attached patch, relative to vanilla libtool-1.5, extends this support to allow references to dependent libraries that only exist in prefixed locations, at least on some systems. It may not work on systems where hardcode_action=relink, but as I can only test on Linux and FreeBSD 4.8 (and soon MacOS X), where hardcode_action=immediate, I don't know for sure. On systems where hardcode_action=unsupported, it should work on some systems, but again, I cannot test this myself.

The patch should not cause anything to fail to link that used to do so; it merely allows some things to link where they would previously fail.

On systems where hardcode_action=relink, it might allow a link to succeed, but leave temporary prefixed directories in the embedded runpaths; however it's just as likely to fail (which is the existing behavior), so I did not put in any code to check for that case and force failure.

On systems where hardcode_action=unsupported, this should allow links to succeed, but on systems where hardcoding of non-existent directories is impossible (a subset of the hardcode_action=unsupported systems) the embedded runpath may be incomplete if the true runpath directory does not exist (again, it's just as likely to fail in this case).

If desired, an explicit check for hardcode_action != relink or hardcode_action = immediate could be added to two places in the patch that set inst_prefix_dir, since if inst_prefix_dir is not set, there is no change in the linking behavior.

This patch can be applied separately or together with the other patches I have submitted, they none of them require each other nor do they interfere with each other.

@alex
--
mailto:address@hidden
Index: ltmain.in
===================================================================
RCS file: /tmp/libtool-1.5/ltmain.in,v
retrieving revision 1.1
diff -u -r1.1 ltmain.in
--- ltmain.in   5 Jun 2003 23:32:12 -0000       1.1
+++ ltmain.in   5 Jun 2003 23:32:01 -0000
@@ -1964,6 +1964,8 @@
          ;;
        esac # case $deplib
        if test "$found" = yes || test -f "$lib"; then :
+       elif test -f "$inst_prefix_dir$lib"; then
+         lib="$inst_prefix_dir$lib"
        else
          $echo "$modename: cannot find the library \`$lib'" 1>&2
          exit 1
@@ -2077,10 +2079,26 @@
        # Find the relevant object directory and library name.
        if test "X$installed" = Xyes; then
          if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
-           $echo "$modename: warning: library \`$lib' was moved." 1>&2
-           dir="$ladir"
-           absdir="$abs_ladir"
-           libdir="$abs_ladir"
+           if test -z "$inst_prefix_dir"; then
+             # Determine the prefix the user has applied to our future dir.
+             inst_prefix_dir=`$echo "$abs_ladir" | $SED "s%$libdir\$%%"`
+
+             # If user has "moved" library outside of our expected location
+             # it is not a valid install prefix, b/c it prevents finding
+             # dependent libraries that are installed to the same prefix.
+             if test "$inst_prefix_dir" = "$destdir"; then
+               unset inst_prefix_dir
+             fi
+           fi
+           if test ! -f "$inst_prefix_dir$libdir/$linklib"; then
+             $echo "$modename: warning: library \`$lib' was moved." 1>&2
+             dir="$ladir"
+             absdir="$abs_ladir"
+             libdir="$abs_ladir"
+           else
+             dir="$ladir"
+             absdir="$libdir"
+           fi
          else
            dir="$libdir"
            absdir="$libdir"
@@ -2421,7 +2439,7 @@
              # We cannot seem to hardcode it, guess we'll fake it.
              add_dir="-L$libdir"
              # Try looking first in the location we're being installed to.
-             if test -n "$inst_prefix_dir"; then
+             if test -n "$inst_prefix_dir" && test -d 
"$inst_prefix_dir$libdir" ; then
                case "$libdir" in
                  [\\/]*)
                    add_dir="-L$inst_prefix_dir$libdir $add_dir"
@@ -2543,6 +2561,10 @@
                  fi
                  ;;
                esac
+               if test -n "$inst_prefix_dir" && test ! -f "$deplib" &&
+                   test -f "$inst_prefix_dir$deplib"; then
+                 deplib="$inst_prefix_dir$deplib"
+               fi
                if grep "^installed=no" $deplib > /dev/null; then
                  path="$absdir/$objdir"
                else
@@ -2552,7 +2574,21 @@
                    exit 1
                  fi
                  if test "$absdir" != "$libdir"; then
-                   $echo "$modename: warning: \`$deplib' seems to be moved" 
1>&2
+                   if test -z "$inst_prefix_dir"; then
+                     # Determine prefix user has applied to our future dir.
+                     inst_prefix_dir=`$echo "$absdir" | $SED "s%$libdir\$%%"`
+
+                     # If user has "moved" library outside of our expected
+                     # location it is not a valid install prefix, b/c it
+                     # prevents finding dependent libraries that are installed
+                     # to the same prefix.
+                     if test "$inst_prefix_dir" = "$destdir"; then
+                       unset inst_prefix_dir
+                     fi
+                   fi
+                   if test "$absdir" != "$inst_prefix_dir$libdir"; then
+                     $echo "$modename: warning: \`$deplib' seems to be moved" 
1>&2
+                   fi
                  fi
                  path="$absdir"
                fi
@@ -5066,6 +5102,10 @@
              case $deplib in
              *.la)
                name=`$echo "X$deplib" | $Xsed -e 's%^.*/%%'`
+               if test -n "$inst_prefix_dir" && test ! -f "$deplib" &&
+                   test -f "$inst_prefix_dir$deplib"; then
+                 deplib="$inst_prefix_dir$deplib"
+               fi
                eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
                if test -z "$libdir"; then
                  $echo "$modename: \`$deplib' is not a valid libtool archive" 
1>&2
@@ -5080,6 +5120,10 @@
            newdlfiles=
            for lib in $dlfiles; do
              name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
+             if test -n "$inst_prefix_dir" && test ! -f "$lib" &&
+                 test -f "$inst_prefix_dir$lib"; then
+               lib="$inst_prefix_dir$lib"
+             fi
              eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
              if test -z "$libdir"; then
                $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
@@ -5091,6 +5135,10 @@
            newdlprefiles=
            for lib in $dlprefiles; do
              name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
+             if test -n "$inst_prefix_dir" && test ! -f "$lib" &&
+                 test -f "$inst_prefix_dir$lib"; then
+               lib="$inst_prefix_dir$lib"
+             fi
              eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
              if test -z "$libdir"; then
                $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2

reply via email to

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