]> git.ipfire.org Git - thirdparty/libtool.git/commitdiff
Fix the order of -L flags added for libtool dep libs.
authorAlexandre Oliva <aoliva@redhat.com>
Fri, 8 Apr 2005 13:00:50 +0000 (13:00 +0000)
committerRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Fri, 8 Apr 2005 13:00:50 +0000 (13:00 +0000)
* ltmain.in (link mode): Add to tmp_libs paths for libtool dep
libs in reverse order as well.
* tests/defs: Set $build to allow to detect cross-compiles.
* tests/Makefile.am, tests/linkorder.test: New test.

ChangeLog
ltmain.in
tests/Makefile.am
tests/defs
tests/linkorder.test [new file with mode: 0644]

index 144ee7e00d9b50c9c12b87ffc44909ff98ac570c..ef9914a0725c308b315afdf2447a6d2cd17a597f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2005-04-08  Alexandre Oliva  <aoliva@redhat.com>,
+           Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
+
+       Fix the order of -L flags added for libtool dep libs.
+
+       * ltmain.in (link mode): Add to tmp_libs paths for libtool dep
+       libs in reverse order as well.
+       * tests/defs: Set $build to allow to detect cross-compiles.
+       * tests/Makefile.am, tests/linkorder.test: New test.
+
 2005-04-01  Mike Stump  <mrs@apple.com>
 
        * libtool.m4 (AC_LIBTOOL_SYS_MAX_CMD_LEN) [ netbsd, freebsd, openbsd,
index 46e6393dc26cfd1082f161ba083f32a1db20ae96..d5687046ee08ab292a2ea344e889619e0914d4cf 100644 (file)
--- a/ltmain.in
+++ b/ltmain.in
@@ -2867,12 +2867,12 @@ EOF
              *) continue ;;
              esac
              case " $deplibs " in
-             *" $depdepl "*) ;;
-             *) deplibs="$depdepl $deplibs" ;;
+             *" $path "*) ;;
+             *) deplibs="$path $deplibs" ;;
              esac
              case " $deplibs " in
-             *" $path "*) ;;
-             *) deplibs="$deplibs $path" ;;
+             *" $depdepl "*) ;;
+             *) deplibs="$depdepl $deplibs" ;;
              esac
            done
          fi # link_all_deplibs != no
index ccee574b3598be2fa81830915b026fced281002d..9fa3f15eebc8f64b86899a7ab3fe7bbdc48dbe10 100644 (file)
@@ -46,7 +46,7 @@ COMMON_TESTS = \
        pdemo-make.test pdemo-exec.test pdemo-inst.test \
        mdemo-conf.test mdemo-make.test mdemo2-conf.test \
        mdemo2-make.test mdemo2-exec.test \
-       func_extract_archives.test 
+       func_extract_archives.test linkorder.test
 
 
 if HAVE_CXX
index e7a12be5ca1fef0e09426b20c0203b566a8afc66..ad76311aea79c2740bdd5668911d6f8df5677d63 100644 (file)
@@ -47,6 +47,9 @@ eval `$libtool --config | grep '^CC='`
 # Extract host from the libtool configuration
 eval `$libtool --config | grep '^host='`
 
+# Extract build from the libtool configuration
+eval `$libtool --config | grep '^build='`
+
 # Disable usage of config.site for autoconf, unless DJGPP is present.
 # The DJGPP port of autoconf requires config.site, to work correctly.
 if test -z "$DJGPP"; then
diff --git a/tests/linkorder.test b/tests/linkorder.test
new file mode 100644 (file)
index 0000000..ec5e274
--- /dev/null
@@ -0,0 +1,92 @@
+#! /bin/sh
+# linkorder.test - make sure that library linking order matches
+
+# Test script header.
+need_prefix=no
+if test -z "$srcdir"; then
+  srcdir=`echo "$0" | sed 's%/[^/]*$%%'`
+  test "$srcdir" = "$0" && srcdir=.
+  test "${VERBOSE+set}" != "set" && VERBOSE=yes
+fi
+. $srcdir/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