From: Ralf Wildenhues Date: Sat, 31 Jan 2009 10:34:06 +0000 (+0100) Subject: Nonexistent `main' does not guarantee link failure. X-Git-Tag: v2.2.7b~119 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a8bb7bd817c7606e848b4c57069d49f6b5b82ed6;p=thirdparty%2Flibtool.git 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. Signed-off-by: Ralf Wildenhues --- diff --git a/ChangeLog b/ChangeLog index c6eb87e51..10fdbd98e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2009-01-31 Ralf Wildenhues + 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 diff --git a/tests/fail.at b/tests/fail.at index 088ad9efa..fb05f8cfc 100644 --- a/tests/fail.at +++ b/tests/fail.at @@ -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)