libtool-patches
[Top][All Lists]
Advanced

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

Re: Fix linking against uninstalled libs again (1/n)


From: Jacob Meuser
Subject: Re: Fix linking against uninstalled libs again (1/n)
Date: Sat, 21 Jan 2006 19:56:59 -0800
User-agent: Mutt/1.4.2i

On Sat, Jan 21, 2006 at 09:37:27AM +0100, Ralf Wildenhues wrote:
> I messed up pretty badly while trying to fix the "linking against
> uninstalled deplibs" right before 1.5.22 -- guess that's what I get
> for not testing extensively.  Please accept my apologies.
> 
> The changes applied to branch-1-5 had two flaws (at least):
> a) They did not move all paths to uninstalled libs up front.
> b) They removed some uninstalled libs in some cases.

c) the main flaw, not all deplibs paths are absolute, but the
   notinst_path paths are.

> Index: libltdl/config/ltmain.m4sh
> ===================================================================
> RCS file: /cvsroot/libtool/libtool/libltdl/config/ltmain.m4sh,v
> retrieving revision 1.28
> diff -u -r1.28 ltmain.m4sh
> --- libltdl/config/ltmain.m4sh        11 Jan 2006 17:24:56 -0000      1.28
> +++ libltdl/config/ltmain.m4sh        21 Jan 2006 00:32:36 -0000
> @@ -3503,12 +3518,12 @@
>           dir="$ladir"
>           absdir="$abs_ladir"
>           # Remove this search path later
> -         notinst_path="$notinst_path $abs_ladir"
> +         notinst_path="$notinst_path $abs_ladir $dir"
>         else
>           dir="$ladir/$objdir"
>           absdir="$abs_ladir/$objdir"
>           # Remove this search path later
> -         notinst_path="$notinst_path $abs_ladir"
> +         notinst_path="$notinst_path $abs_ladir $dir"
>         fi
>       fi # $installed = yes
>       func_stripname 'lib' '.la' "$laname"

is it guaranteed that this will always add the path exactly as it will
look later, when it is processed by the following?

> @@ -4887,15 +4902,16 @@
>        # installed libraries to the beginning of the library search list
>        new_libs=
>        for path in $notinst_path; do
> -     case " $new_libs " in
> -     *" -L$path/$objdir "*) ;;
> -     *)
> -       case " $deplibs " in
> -       *" -L$path/$objdir "*)
> -         new_libs="$new_libs -L$path/$objdir" ;;
> +     for p in $path $path/$objdir; do
> +       case " $new_libs " in
> +       *" -L$p "*) ;;
> +       *)
> +         case " $deplibs " in
> +         *" -L$p "*) new_libs="$new_libs -L$p" ;;
> +         esac
> +         ;;
>         esac
> -       ;;
> -     esac
> +     done
>        done
>        for deplib in $deplibs; do
>       case $deplib in

IIRC, notinst_path can also contain paths where objects reside, so
starting with notinst_path could add paths that shouldn't be there.

below is a revision of the original patch I made for this issue.
it is against 1.5.22.

the main differences from your patch are:
a) expand all paths to the absolute instead of relying on them to
   have already been expanded
b) filter against notinst_path instead of starting with notinst_path

however, the shell parameter substitution used here is probably not
portable by libtool standards.

-- 
<address@hidden>

--- ltmain.in.orig      Sun Dec 18 13:43:52 2005
+++ ltmain.in   Sat Jan 21 19:50:33 2006
@@ -3807,33 +3807,44 @@
        deplibs=$newdeplibs
       fi
 
-
       # move library search paths that coincide with paths to not yet
       # installed libraries to the beginning of the library search list
       new_libs=
-      for path in $notinst_path; do
-       case " $new_libs " in
-       *" -L$path/$objdir "*) ;;
-       *)
-         case " $deplibs " in
-         *" -L$path/$objdir "*)
-           new_libs="$new_libs -L$path/$objdir" ;;
-         esac
-         ;;
-       esac
-      done
-      for deplib in $deplibs; do
+      notinst_libs=
+      for deplib in $deplibs ; do
        case $deplib in
-       -L*)
-         case " $new_libs " in
-         *" $deplib "*) ;;
+         -L*)
+           dir=`$echo "X$deplib" | $Xsed -e 's/^-L//'`
+           # We need an absolute path.
+           case $dir in
+           [\\/]* | [A-Za-z]:[\\/]*) ;;
+           *)
+             absdir=`cd "$dir" && pwd`
+             if test -z "$absdir"; then
+               $echo "$modename: cannot determine absolute directory name of 
\`$dir'" 1>&2
+               exit $EXIT_FAILURE
+             fi
+             dir="$absdir"
+             ;;
+           esac
+           case " $notinst_libs $new_libs " in
+           *" -L$dir "*) ;;
+           *)
+             case " $notinst_path " in
+             *" ${dir:%/$objdir} "*)
+               notinst_libs="$notinst_libs -L$dir"
+               ;;
+             *)
+               new_libs="$new_libs -L$dir"
+               ;;
+             esac
+             ;;
+           esac
+           ;;
          *) new_libs="$new_libs $deplib" ;;
-         esac
-         ;;
-       *) new_libs="$new_libs $deplib" ;;
        esac
       done
-      deplibs="$new_libs"
+      deplibs="$notinst_libs $new_libs"
 
 
       # All the library-specific variables (install_libdir is set above).
@@ -4355,31 +4355,42 @@
       # move library search paths that coincide with paths to not yet
       # installed libraries to the beginning of the library search list
       new_libs=
-      for path in $notinst_path; do
-       case " $new_libs " in
-       *" -L$path/$objdir "*) ;;
-       *)
-         case " $compile_deplibs " in
-         *" -L$path/$objdir "*)
-           new_libs="$new_libs -L$path/$objdir" ;;
-         esac
-         ;;
-       esac
-      done
-      for deplib in $compile_deplibs; do
+      notinst_libs=
+      for deplib in $compile_deplibs ; do
        case $deplib in
-       -L*)
-         case " $new_libs " in
-         *" $deplib "*) ;;
+         -L*)
+           dir=`$echo "X$deplib" | $Xsed -e 's/^-L//'`
+           # We need an absolute path.
+           case $dir in
+           [\\/]* | [A-Za-z]:[\\/]*) ;;
+           *)
+             absdir=`cd "$dir" && pwd`
+             if test -z "$absdir"; then
+               $echo "$modename: cannot determine absolute directory name of 
\`$dir'" 1>&2
+               exit $EXIT_FAILURE
+             fi
+             dir="$absdir"
+             ;;
+           esac
+           case " $notinst_libs $new_libs " in
+           *" -L$dir "*) ;;
+           *)
+             case " $notinst_path " in
+             *" ${dir:%/$objdir} "*)
+               notinst_libs="$notinst_libs -L$dir"
+               ;;
+             *)
+               new_libs="$new_libs -L$dir"
+               ;;
+             esac
+             ;;
+           esac
+           ;;
          *) new_libs="$new_libs $deplib" ;;
-         esac
-         ;;
-       *) new_libs="$new_libs $deplib" ;;
        esac
       done
-      compile_deplibs="$new_libs"
+      compile_deplibs="$notinst_libs $new_libs"
 
-
       compile_command="$compile_command $compile_deplibs"
       finalize_command="$finalize_command $finalize_deplibs"
 
@@ -6257,40 +6297,6 @@
     # Exit here if they wanted silent mode.
     test "$show" = : && exit $EXIT_SUCCESS
 
-    $echo 
"X----------------------------------------------------------------------" | 
$Xsed
-    $echo "Libraries have been installed in:"
-    for libdir in $libdirs; do
-      $echo "   $libdir"
-    done
-    $echo
-    $echo "If you ever happen to want to link against installed libraries"
-    $echo "in a given directory, LIBDIR, you must either use libtool, and"
-    $echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
-    $echo "flag during linking and do at least one of the following:"
-    if test -n "$shlibpath_var"; then
-      $echo "   - add LIBDIR to the \`$shlibpath_var' environment variable"
-      $echo "     during execution"
-    fi
-    if test -n "$runpath_var"; then
-      $echo "   - add LIBDIR to the \`$runpath_var' environment variable"
-      $echo "     during linking"
-    fi
-    if test -n "$hardcode_libdir_flag_spec"; then
-      libdir=LIBDIR
-      eval flag=\"$hardcode_libdir_flag_spec\"
-
-      $echo "   - use the \`$flag' linker flag"
-    fi
-    if test -n "$admincmds"; then
-      $echo "   - have your system administrator run these commands:$admincmds"
-    fi
-    if test -f /etc/ld.so.conf; then
-      $echo "   - have your system administrator add LIBDIR to 
\`/etc/ld.so.conf'"
-    fi
-    $echo
-    $echo "See any operating system documentation about shared libraries for"
-    $echo "more information, such as the ld(1) and ld.so(8) manual pages."
-    $echo 
"X----------------------------------------------------------------------" | 
$Xsed
     exit $EXIT_SUCCESS
     ;;
 




reply via email to

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