libtool-patches
[Top][All Lists]
Advanced

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

[PATCH] change order of -L options when relinking


From: Scott James Remnant
Subject: [PATCH] change order of -L options when relinking
Date: Fri, 31 Oct 2003 11:38:32 +0000

Now I've got the copyright assignment paperwork out of the way, it's
time to provide all the patches I've written for Debian's libtool
package and see if we can get into sync.

I'm going to provide the patches against CVS HEAD rather than the 1.5
release, on the basis that these should probably be destined for there
rather than branch-1-5 anyway.

First up, a simple patch to change the order that the -L options are
constructed when relinking so that $add_dir is put before the directory
with the $inst_prefix rather than after it.

This fixes a problem where you have a program depending on a shared
library from within the same source tree, you have an OLDER version of
that shared library on the system already and you install the newer
version using a prefix= or DESTDIR= diversion.

Libtool currently supplies "-L/tmp/usr/lib -L/usr/lib -lfoo" to the
linker, which means the linker will actually pick up /usr/lib/libfoo.so
-- the OLDER version of the shared library.  If this library has
different dependencies, things can go very wrong indeed.

The patch changes the order to "-L/usr/lib -L/tmp/usr/lib -lfoo"
instead, which causes /tmp/usr/lib/libfoo.so to be picked up, the right
version.

The origin of this patch is myself, after figuring out was wrong with a
large number of (mostly GNOMEish) packages.  It turns out that the patch
is identical to one RedHat use as well, so it must be doing the right
thing for both of us.

Scott
-- 
Have you ever, ever felt like this?
Had strange things happen?  Are you going round the twist?
diff -ruNp libtool-CVS~/ChangeLog libtool-CVS/ChangeLog
--- libtool-CVS~/ChangeLog      2003-10-30 14:40:11.000000000 +0000
+++ libtool-CVS/ChangeLog       2003-10-31 11:35:23.000000000 +0000
@@ -0,0 +1,6 @@
+2003-10-31  Scott James Remnant  <address@hidden>
+
+       * ltmain.in: When relinking, place the -L parameter containing
+       the installation prefix directory after the intended destination,
+       so we don't accidentally link against an older installed library.
+
diff -ruNp libtool-CVS~/ltmain.in libtool-CVS/ltmain.in
--- libtool-CVS~/ltmain.in      2003-10-20 14:36:10.000000000 +0100
+++ libtool-CVS/ltmain.in       2003-10-31 11:33:32.000000000 +0000
@@ -2427,7 +2427,7 @@ EOF
                if test -n "$inst_prefix_dir"; then
                  case "$libdir" in
                    [\\/]*)
-                     add_dir="-L$inst_prefix_dir$libdir $add_dir"
+                     add_dir="$add_dir -L$inst_prefix_dir$libdir"
                      ;;
                  esac
                fi
@@ -2499,7 +2499,7 @@ EOF
              if test -n "$inst_prefix_dir"; then
                case "$libdir" in
                  [\\/]*)
-                   add_dir="-L$inst_prefix_dir$libdir $add_dir"
+                   add_dir="$add_dir -L$inst_prefix_dir$libdir"
                    ;;
                esac
              fi

Attachment: signature.asc
Description: This is a digitally signed message part


reply via email to

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