[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Link order of deplibs test (was: FYI: lt_dlexit.at test needs 'libtool -
From: |
Ralf Wildenhues |
Subject: |
Link order of deplibs test (was: FYI: lt_dlexit.at test needs 'libtool --mode=execute') |
Date: |
Sun, 18 Feb 2007 16:41:44 +0100 |
User-agent: |
Mutt/1.5.13 (2006-08-11) |
Hello Peter,
* Ralf Wildenhues wrote on Wed, Feb 14, 2007 at 12:13:51AM CET:
> * Peter O'Gorman wrote on Tue, Feb 13, 2007 at 03:15:19PM CET:
> > On Feb 13, 2007, at 4:54 AM, Ralf Wildenhues wrote:
> >
> > >This fixes lt_dlexit.at test on some systems (e.g., Darwin), where a
> > >main program without uninstalled library dependencies doesn't get a
> > >shell wrapper.
> >
> > Thanks, was wondering what was up with this. Still unexpectedly
> > failing two tests on darwin though - 16 and 49. I haven't looked
> > closely, should I?
>
> I think I'll rewrite link-order2.at (16) to not use libm, that fails
> just about everywhere. 49 is just failing on Darwin because it reruns
> test 16. You could look into it if it still fails afterwards. ;-)
Here's a rewrite of the test. I think it still fails on Darwin (with
duplicate symbols IIRC; I only tested an earlier version of this) and
AIX without runtimelinking. Could you look into the issue on Darwin?
(Of course I'd also appreciate a review of the proposed patch. ;-)
Cheers, and thanks,
Ralf
2007-02-18 Ralf Wildenhues <address@hidden>
* tests/link-order2.at: Rewrite completely. Do not use `sin'
from the math library, there are too many problems with this.
Instead, use a self-written library, install it without the
Libtool library file, to emulate a native library in a system
directory, and adjust $shlibpat_var. Try overriding its symbol.
Further, also try an installed `wrong' binary.
Avoid failing test bits on AIX without runtimelinking, SKIP at
the end in this case.
Index: tests/link-order2.at
===================================================================
RCS file: /cvsroot/libtool/libtool/tests/link-order2.at,v
retrieving revision 1.4
diff -u -r1.4 link-order2.at
--- tests/link-order2.at 14 Dec 2006 20:59:26 -0000 1.4
+++ tests/link-order2.at 18 Feb 2007 15:37:40 -0000
@@ -1,5 +1,5 @@
# Hand crafted tests for GNU Libtool. -*- Autotest -*-
-# Copyright 2006 Free Software Foundation, Inc.
+# Copyright 2006, 2007 Free Software Foundation, Inc.
# 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
@@ -18,86 +18,119 @@
# link-order2.test: make sure that depdepls are added right after
# the libs that pull them in: necessary at least for static linking
-# and on systems where libraries do not link against other libraries,
-# in order to do this: override a commonly used symbol in a commonly
-# used library.
+# and on systems where libraries do not link against other libraries.
+#
+# We test by overriding one symbol from a depdepl library.
+# Test both a libtool library and a non-libtool library (simulated
+# by removing the .la file, and setting $shlibpath_var so it is
+# found at runtime). In order to ensure that the depdepl is
+# actually loaded in each case, we also use an unrelated symbol
+# from it directly in the main program. We test for failure by
+# reversing the link order.
+# We test both static and shared: it should work in both cases.
+# But for the static case to work, the two symbols in the depdepl
+# need to be in separate object files, otherwise duplicate symbol
+# definitions can happen.
+
+# The shared case fails on AIX without runtimelinking and on Darwin.
AT_SETUP([Link order of deplibs.])
AT_KEYWORDS([libtool])
-# g++ reorders `-lm' on the command line. :-(
-AT_DATA([t.c], [[
-#if defined(__cplusplus) && defined(__GNUC__)
-choke me
-#endif
-int t = 42;
-]])
-AT_CHECK([$CC $CPPFLAGS $CFLAGS -c t.c || exit 77], [], [ignore], [ignore])
+eval `$LIBTOOL --config | $EGREP '^shlibpath_var='`
+
+shared_fails=no
+case $host_os,$LDFLAGS in
+aix*,*-brtl*) ;;
+aix*) shared_fails=yes ;;
+esac
-LDFLAGS="$LDFLAGS -no-undefined"
+deflibdir=`pwd`/lib
+defbindir=`pwd`/lib
libdir=`pwd`/inst/lib
bindir=`pwd`/inst/bin
-mkdir inst inst/bin inst/lib
+mkdir bin lib inst inst/bin inst/lib
+LDFLAGS="$LDFLAGS -no-undefined -L$deflibdir"
+
+cat >a0.c <<\EOF
+int a0 (void) { return 0; }
+EOF
-cat >a.c <<\EOF
-/* pretend we have a better sine function */
-#ifdef __cplusplus
-extern "C"
-#endif
-double sin (double x) { return 0.0; }
+cat >a1.c <<\EOF
+int a (void) { return 1; }
+EOF
+
+cat >a2.c <<\EOF
+int a (void) { return 0; }
EOF
cat >b.c <<\EOF
-#ifdef __cplusplus
-extern "C"
-#endif
-double sin (double);
-double b (double x) { return sin (x); }
+int a (void);
+int b (void) { return a (); }
EOF
cat >main.c <<\EOF
-#include <math.h>
#include <stdlib.h>
-extern double b (double);
-extern double four;
-double four = 4.0;
+extern int a0 (void);
+extern int b (void);
int main (void)
{
- /* The function b should call our sin (that returns 0) and not libm's
- * (in the latter case, b returns approximately 1)
- * the sqrt is to force linking against libm
- * the variable four is to prevent most compiler optimizations
- */
- int status = EXIT_FAILURE;
- if (fabs (b (3.1415 / 2.)) < 0.01 && fabs (sqrt (four) - 2.) < 0.01)
- status = EXIT_SUCCESS;
- return status;
+ return a0 () + b ();
}
EOF
-$LIBTOOL --mode=compile $CC $CPPFLAGS $CFLAGS -c a.c
-$LIBTOOL --mode=compile $CC $CPPFLAGS $CFLAGS -c b.c
+for file in a0 a1 a2 b; do
+ $LIBTOOL --mode=compile $CC $CPPFLAGS $CFLAGS -c $file.c
+done
$CC $CPPFLAGS $CFLAGS -c main.c
-for static in '' -static; do
- $LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS $static -o liba.la a.lo -rpath
$libdir
- $LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS $static -o libb.la b.lo liba.la
-rpath $libdir
- $LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o main main.$OBJEXT libb.la -lm
- LT_AT_EXEC_CHECK([./main])
- # Now test that if we reverse the link order, the program fails.
- # The execution failure can only work on systems that actually have a libm.
- $LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o wrong main.$OBJEXT -lm libb.la
- case $host_os in
- cygwin* | mingw* | pw32* | beos* ) ;;
- *) LT_AT_EXEC_CHECK([./wrong], [1]) ;;
- esac
-
- $LIBTOOL --mode=install cp liba.la $libdir/liba.la
- $LIBTOOL --mode=install cp libb.la $libdir/libb.la
- $LIBTOOL --mode=install cp main $bindir/main
- $LIBTOOL --mode=clean rm -f liba.la libb.la
- LT_AT_EXEC_CHECK([$bindir/main])
+
+# Build an old, installed library.
+$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS $static -o liba1.la a0.lo a1.lo
-rpath $deflibdir
+$LIBTOOL --mode=install cp liba1.la $deflibdir/liba1.la
+$LIBTOOL --mode=clean rm -f liba1.la
+
+for type_of_depdepl in libtool non-libtool; do
+ echo "type of depdepl: $type_of_depdepl"
+ if test $type_of_depdepl = non-libtool; then
+ # Simulate a non-Libtool system library.
+ rm $deflibdir/liba1.la
+ addpath=$deflibdir
+ if test "$shlibpath_var" = PATH; then
+ addpath=$defbindir
+ fi
+ sep=
+ eval test -n \"\$$shlibpath_var\" && sep=:
+ eval $shlibpath_var='$addpath$sep$'$shlibpath_var
+ export $shlibpath_var
+ fi
+ for static in '' -static-libtool-libs; do
+ test "$type_of_depdepl,$static" = "non-libtool,-static-libtool-libs" &&
+ static=-all-static
+ $LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS $static -o liba.la a2.lo -rpath
$libdir
+ $LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS $static -o libb.la b.lo liba.la
-rpath $libdir
+ AT_CHECK([$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o main main.$OBJEXT
libb.la -la1],
+ [], [ignore], [ignore])
+ LT_AT_EXEC_CHECK([./main])
+ # Now test that if we reverse the link order, the program fails.
+ AT_CHECK([$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o wrong main.$OBJEXT
-la1 libb.la],
+ [], [ignore], [ignore])
+ if test $shared_fails,$static != yes,; then
+ LT_AT_EXEC_CHECK([./wrong], [1])
+ fi
+
+ $LIBTOOL --mode=install cp liba.la $libdir/liba.la
+ $LIBTOOL --mode=install cp libb.la $libdir/libb.la
+ $LIBTOOL --mode=install cp main $bindir/main
+ $LIBTOOL --mode=install cp wrong $bindir/wrong
+ $LIBTOOL --mode=clean rm -f liba.la libb.la
+ LT_AT_EXEC_CHECK([$bindir/main])
+ if test $shared_fails,$static != yes,; then
+ LT_AT_EXEC_CHECK([$bindir/wrong], [1])
+ fi
+ done
done
+AT_CHECK([test $shared_fails = no || (exit 77)])
# Now the converse: if both the program and the library need libm, then
# it needs to be sorted last. (TODO)