]> git.ipfire.org Git - thirdparty/libtool.git/commitdiff
Nonexistent `main' does not guarantee link failure.
authorRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Sat, 31 Jan 2009 10:34:06 +0000 (11:34 +0100)
committerRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Sat, 31 Jan 2009 10:40:42 +0000 (11:40 +0100)
* tests/fail.at (Failure tests): Use an unresolved symbol,
rather than non-presence of `main', to provoke a link failure
also on QNX.  Only check for failure of the libtool script if
the link without libtool would have failed, too.
Report by Mike Gorchak.

Signed-off-by: Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
ChangeLog
tests/fail.at

index c6eb87e514461b3023ee24e8b07050dea5908cea..10fdbd98efec840ab02f5146a6fbadafa05f05c0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2009-01-31  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
 
+       Nonexistent `main' does not guarantee link failure.
+       * tests/fail.at (Failure tests): Use an unresolved symbol,
+       rather than non-presence of `main', to provoke a link failure
+       also on QNX.  Only check for failure of the libtool script if
+       the link without libtool would have failed, too.
+       Report by Mike Gorchak.
+
        Use AT_CHECK more liberally in duplicate members test.
        * tests/duplicate_members.at (duplicate members in archive
        tests): Wrap link commands in AT_CHECK, they might fail, as seen
index 088ad9efa8e319162cdac831f1b34481418b2275..fb05f8cfc498fb24426e1e3133c0854ea6c44426 100644 (file)
@@ -1,6 +1,6 @@
 # fail.at -- test that libtool really fail when it should     -*- Autotest -*-
 #
-#   Copyright (C) 2005, 2008 Free Software Foundation, Inc.
+#   Copyright (C) 2005, 2008, 2009 Free Software Foundation, Inc.
 #   Written by Ralf Wildenhues, 2005
 #
 #   This file is part of GNU Libtool.
@@ -64,13 +64,26 @@ case $pic_mode in default | yes)
   ;;
 esac
 
-# program creation failure
-echo 'int not_main(void) { return 0; }' > a.c
+# program creation failure.
+# We can't rely on `main' not being present: the QNX linker
+# won't error out in that case, although the resulting binary won't work.
+# So we provoke a link failure due to an unresolved symbol, and require
+# libtool to fail only if the link without libtool would have failed, too.
+cat > a.c <<'EOF'
+extern int nonexistent_function (void);
+int main (void)
+{
+  return nonexistent_function ();
+}
+EOF
 $CC $CPPFLAGS $CFLAGS -c a.c
-FAIL_CHECK([$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o a$EXEEXT a.$OBJEXT])
-AT_CHECK([{ test -f a && $test_x a; } || { test -f a$EXEEXT && $test_x a$EXEEXT; }], [1])
-FAIL_CHECK([$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o a$EXEEXT a.$OBJEXT -static])
-AT_CHECK([{ test -f a && $test_x a; } || { test -f a$EXEEXT && $test_x a$EXEEXT; }], [1])
+if $CC $CFLAGS $LDFLAGS -o a$EXEEXT a.$OBJEXT; then :; else
+  rm -f a a$EXEEXT
+  FAIL_CHECK([$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o a$EXEEXT a.$OBJEXT])
+  AT_CHECK([{ test -f a && $test_x a; } || { test -f a$EXEEXT && $test_x a$EXEEXT; }], [1])
+  FAIL_CHECK([$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o a$EXEEXT a.$OBJEXT -static])
+  AT_CHECK([{ test -f a && $test_x a; } || { test -f a$EXEEXT && $test_x a$EXEEXT; }], [1])
+fi
 
 # shared library creation failure
 case $build_libtool_libs in yes)