]> git.ipfire.org Git - thirdparty/libtool.git/commitdiff
* tests/link-order2.at: Add missing $bindir setting. Prevent
authorRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Fri, 27 Oct 2006 22:57:00 +0000 (22:57 +0000)
committerRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Fri, 27 Oct 2006 22:57:00 +0000 (22:57 +0000)
compiler optimization of sqrt call.  Fix logic inversion and
add some comments about this stunt.  Add a test with reversed
library link order that should fail if the system has a libm.
Report by Patrick Welche.

ChangeLog
tests/link-order2.at

index 26ffc4b2271b331ef2c9aa209b0b1cbb80b56264..788666bc9fa9801d1164d88920e02421bfa20c7b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2006-10-28  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
+
+       * tests/link-order2.at: Add missing $bindir setting.  Prevent
+       compiler optimization of sqrt call.  Fix logic inversion and
+       add some comments about this stunt.  Add a test with reversed
+       library link order that should fail if the system has a libm.
+       Report by Patrick Welche.
+
 2006-10-26  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
 
        Assume presence of a config header in all files, to provoke
index 74c8aefa50c2d08c0bc7c7cb27c1f9ef86d29159..329d4589e2f8286422b5eab45acc8e9ba4808599 100644 (file)
@@ -26,6 +26,7 @@ AT_SETUP([Link order of deplibs.])
 AT_KEYWORDS([libtool])
 LDFLAGS="$LDFLAGS -no-undefined"
 libdir=`pwd`/inst/lib
+bindir=`pwd`/inst/bin
 mkdir inst inst/bin inst/lib
 
 cat >a.c <<\EOF
@@ -41,9 +42,17 @@ EOF
 cat >main.c <<\EOF
 #include <math.h>
 extern double b (double);
+extern double four;
+double four = 4.0;
 int main (void)
 {
-  return fabs (b (3.1415 / 2.)) < 0.01 && fabs (sqrt (4.) - 2.) < 0.01;
+  /* The ! is to invert C true to shell true
+   * 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
+   */
+  return !( fabs (b (3.1415 / 2.)) < 0.01 && fabs (sqrt (four) - 2.) < 0.01 );
 }
 EOF
 
@@ -55,6 +64,14 @@ for static in '' -static; do
   $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