libtool-patches
[Top][All Lists]
Advanced

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

Re: fix order of -L flags added for libtool dep libs


From: Ralf Wildenhues
Subject: Re: fix order of -L flags added for libtool dep libs
Date: Mon, 11 Apr 2005 11:30:03 +0200
User-agent: Mutt/1.4.1i

[ Zachary, I have Cc:ed you because this may relate to an old bugreport
by you, and I would like to make a test case for it if at all possible.
See [4] for the archive of this thread so far. ]

* Gary V. Vaughan wrote on Fri, Apr 08, 2005 at 02:05:46PM CEST:
> Ralf Wildenhues wrote:
> > Here is a patch with a test and your fix.
> > 
> > OK to apply to branch-1-5 and forward-port?
> 
> Yep, looks good to me.

I am quite uncertain that the patch is correct, or indeed sufficient, or
even there is only one problem to solve, when I see this proposed patch
and discussion[1].

Furthermore, I am really unsure whether the patch I applied to
branch-1-5 breaks existing setups: There was a patch[2] applied to
explicitly revert this order, presumably prompted by this bug report[3],
which may or may not be darwin-specific.

I think this issue still applies to branch-1-5, but probably not to
branch-2-0/HEAD.  We need a testcase for the bug report, so that we
don't break that setup.

In any case, below is the suggested forward-port to branch-2-0.

Regards,
Ralf

[1] http://lists.gnu.org/archive/html/libtool-patches/2004-02/msg00069.html
continued at
http://lists.gnu.org/archive/html/libtool-patches/2004-03/msg00093.html
[2] http://lists.gnu.org/archive/html/libtool-patches/2004-03/msg00029.html
[3] http://lists.gnu.org/archive/html/libtool/2004-01/msg00117.html
[4] http://lists.gnu.org/archive/html/libtool-patches/2005-04/msg00032.html


2005-04-08  Alexandre Oliva  <address@hidden>,
            Ralf Wildenhues  <address@hidden>

        * config/ltmain.m4sh (link mode): Add to tmp_libs paths for libtool dep
        libs in reverse order as well.
        * tests/Makefile.am, tests/link-order.test: New test.

Index: config/ltmain.m4sh
===================================================================
RCS file: /cvsroot/libtool/libtool/config/ltmain.m4sh,v
retrieving revision 1.1.2.48
diff -u -r1.1.2.48 ltmain.m4sh
--- config/ltmain.m4sh  18 Mar 2005 15:56:13 -0000      1.1.2.48
+++ config/ltmain.m4sh  10 Apr 2005 17:42:12 -0000
@@ -4022,7 +4022,7 @@
              esac
              case " $deplibs " in
              *" $path "*) ;;
-             *) deplibs="$deplibs $path" ;;
+             *) deplibs="$path $deplibs" ;;
              esac
            done
          fi # link_all_deplibs != no
Index: tests/Makefile.am
===================================================================
RCS file: /cvsroot/libtool/libtool/tests/Makefile.am,v
retrieving revision 1.41.2.6
diff -u -r1.41.2.6 Makefile.am
--- tests/Makefile.am   26 Jan 2005 17:53:26 -0000      1.41.2.6
+++ tests/Makefile.am   10 Apr 2005 17:42:12 -0000
@@ -64,7 +64,8 @@
        depdemo-inst.test depdemo-relink.test depdemo-unst.test \
        mdemo-shared.test mdemo-make.test mdemo-exec.test \
        mdemo-inst.test mdemo-unst.test \
-       cdemo-undef.test cdemo-make.test cdemo-exec.test
+       cdemo-undef.test cdemo-make.test cdemo-exec.test \
+       link-order.test
 
 if HAVE_CXX
 if HAVE_F77

--- /dev/null   2005-04-04 11:53:15.417024464 +0200
+++ tests/link-order.test       2005-04-10 19:16:29.536847584 +0200
@@ -0,0 +1,105 @@
+#! /bin/sh
+# link-order.test - make sure that library linking order matches
+
+# Copyright (C) 2003, 2005 Free Software Foundation, Inc.
+# This is free software; see the source for copying conditions.  There is NO
+# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, a copy can be downloaded from
+# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free
+# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+# MA 02111-1307, USA.
+
+. ./defs || exit 1
+
+retcode=0
+
+rm -rf linkorder.dir
+mkdir linkorder.dir
+top_dir=`pwd`/linkorder.dir
+prefix_old=$top_dir/old
+prefix_new=$top_dir/new
+srcdir=linkorder.dir/src
+mkdir $srcdir $prefix_old $prefix_new $prefix_old/lib $prefix_new/lib
+
+cat >$srcdir/c.c <<EOF
+int c = 1;
+EOF
+
+$LIBTOOL --mode=compile $CC $CFLAGS -c $srcdir/c.c -o $srcdir/c.lo
+$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o $srcdir/libcee.la $srcdir/c.lo \
+    -rpath $prefix_old/lib
+$LIBTOOL --mode=install cp $srcdir/libcee.la $prefix_old/lib/libcee.la
+
+for i in old new; do
+  rm -rf $srcdir
+  mkdir $srcdir
+
+  cat >$srcdir/a_$i.c <<EOF
+extern int c;
+extern int b_$i();
+int a_$i() { return c + b_$i(); }
+EOF
+
+  cat >$srcdir/b_$i.c <<EOF
+extern int c;
+int b_$i() { return 1 + c; }
+EOF
+
+  prefix=`eval echo \\$prefix_$i`
+  $LIBTOOL --mode=compile $CC $CFLAGS -c $srcdir/a_$i.c -o $srcdir/a.lo
+  $LIBTOOL --mode=compile $CC $CFLAGS -c $srcdir/b_$i.c -o $srcdir/b.lo
+  $LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o $srcdir/libb.la $srcdir/b.lo \
+      -L$prefix_old/lib -lcee -rpath $prefix/lib
+  $LIBTOOL --mode=link $CC $CFLAGS -o $srcdir/liba.la $srcdir/a.lo \
+      $srcdir/libb.la -L$prefix_old/lib -lcee -rpath $prefix/lib
+  $LIBTOOL --mode=install cp $srcdir/libb.la $prefix/lib/libb.la
+  $LIBTOOL --mode=install cp $srcdir/liba.la $prefix/lib/liba.la \
+      >$srcdir/stdout 2>$srcdir/stderr || retcode=1
+  cat $srcdir/stdout
+  cat $srcdir/stderr >&2
+done
+
+# Do not error if we do not relink (e.g. static-only systems)
+if $EGREP relinking $srcdir/stderr; then
+  if $EGREP ' -L.*\/new\/lib -lb -L.*\/old\/lib -lcee' $srcdir/stdout; then :; 
else
+    echo "$0: wrong link order" 1>&2
+    retcode=1
+  fi
+fi
+
+for i in old new; do
+  cat >$srcdir/main_$i.c <<EOF
+extern int a_$i();
+int main(void) { return a_$i() != 3; }
+EOF
+
+  prefix=`eval echo \\$prefix_$i`
+  $LIBTOOL --mode=compile $CC $CFLAGS -c $srcdir/main_$i.c -o 
$srcdir/main_$i.lo
+  $LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o $srcdir/main_$i 
$srcdir/main_$i.lo \
+      -L$prefix/lib -la || retcode=1
+  if $srcdir/main_$i; then :
+  else
+    echo "$0: cannot execute $srcdir/main_$i" 1>&2
+    if test "X$host" != "X$build"; then
+      echo "This may be ok since you seem to be cross-compiling." 1>&2
+      retcode=77
+    else
+      retcode=1
+    fi
+  fi
+done
+
+rm -rf $top_dir
+exit $retcode




reply via email to

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