libtool-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

fix func_show_eval, do not use $status (was: weird ksh eval behavior)


From: Ralf Wildenhues
Subject: fix func_show_eval, do not use $status (was: weird ksh eval behavior)
Date: Fri, 2 Dec 2005 16:36:55 +0100
User-agent: Mutt/1.5.11

[ moving from the autoconf and the ports at openbsd lists ]

* Ralf Wildenhues wrote on Thu, Dec 01, 2005 at 08:43:31PM CET:
> This one is the reason for a subtle CVS Libtool testsuite failure..

To be specific: demo-noinst-link.test would FAIL, because
'libtool --mode=link' bogusly returns 0 after an unsuccessful link.

> With ash-0.3.8, OpenBSD 3.8 'sh' and 'ksh' PD KSH v5.2.14 99/07/13.2,
> I get
> 
> $ false; eval 'foo=$?'; echo $foo
> 0

Any reason against applying these two patches to HEAD and branch-1-5
respectively?

They should work around this issue, and also remove our use of forbidden
`status' (because of zsh; see Autoconf documentation).  For HEAD, it
introduces a new test file with a few tests for this; not yet very
thorough yet but better than nothing.  They expose the func_show_eval
failure, but they are far from testing each of its possible invocations.

Cheers,
Ralf

HEAD:
        * libltdl/config/general.m4sh (func_show_eval):
        Rewrite use the failure expression, because the exit status of
        the previous command may not be preserved in the next `eval' by
        some shells, such as pdksh.
        * libltdl/config/ltmain.m4sh (func_extract_an_archive):
        Use func_show_eval correctly.
        (func_mode_link): Likewise.  Also, do not use `$status'.
        * tests/fail.at: New set of tests to ensure libtool fails.
        * Makefile.am, tests/testsuite.at: Adjusted.

Index: libltdl/config/general.m4sh
===================================================================
RCS file: /cvsroot/libtool/libtool/libltdl/config/general.m4sh,v
retrieving revision 1.1
diff -u -r1.1 general.m4sh
--- libltdl/config/general.m4sh 22 Aug 2005 22:33:35 -0000      1.1
+++ libltdl/config/general.m4sh 1 Dec 2005 22:41:02 -0000
@@ -336,5 +336,11 @@
       eval "func_echo $func_quote_for_expand_result"
     }
 
-    ${opt_dry_run-false} || eval "$my_cmd" || eval "$my_fail_exp"
+    if ${opt_dry_run-false}; then :; else
+      eval "$my_cmd"
+      my_status=$?
+      if test "$my_status" -eq 0; then :; else
+       eval "(exit $my_status); $my_fail_exp"
+      fi
+    fi
 }
Index: libltdl/config/ltmain.m4sh
===================================================================
RCS file: /cvsroot/libtool/libtool/libltdl/config/ltmain.m4sh,v
retrieving revision 1.21
diff -u -r1.21 ltmain.m4sh
--- libltdl/config/ltmain.m4sh  25 Nov 2005 18:13:53 -0000      1.21
+++ libltdl/config/ltmain.m4sh  1 Dec 2005 22:41:03 -0000
@@ -1014,7 +1014,7 @@
     $opt_debug
     f_ex_an_ar_dir="$1"; shift
     f_ex_an_ar_oldlib="$1"
-    func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \$f_ex_an_ar_oldlib)" || 
exit $?
+    func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \$f_ex_an_ar_oldlib)" 'exit 
$?'
     if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
      :
     else
@@ -5583,15 +5583,15 @@
        link_command="$compile_command$compile_rpath"
 
        # We have no uninstalled library dependencies, so finalize right now.
-       func_show_eval "$link_command"
-       status=$?
+       exit_status=0
+       func_show_eval "$link_command" 'exit_status=$?'
 
        # Delete the generated files.
        if test -f "$output_objdir/${outputname}S.${objext}"; then
          func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
        fi
 
-       exit $status
+       exit $exit_status
       fi
 
       if test -n "$compile_shlibpath$finalize_shlibpath"; then
Index: Makefile.am
===================================================================
RCS file: /cvsroot/libtool/libtool/Makefile.am,v
retrieving revision 1.180
diff -u -r1.180 Makefile.am
--- Makefile.am 20 Nov 2005 10:33:26 -0000      1.180
+++ Makefile.am 1 Dec 2005 22:41:02 -0000
@@ -372,6 +372,7 @@
                  tests/stresstest.at \
                  tests/subproject.at \
                  tests/link-order.at \
+                 tests/fail.at \
                  tests/convenience.at \
                  tests/early-libtool.at \
                  tests/template.at
Index: tests/testsuite.at
===================================================================
RCS file: /cvsroot/libtool/libtool/tests/testsuite.at,v
retrieving revision 1.32
diff -u -r1.32 testsuite.at
--- tests/testsuite.at  14 Nov 2005 22:19:40 -0000      1.32
+++ tests/testsuite.at  1 Dec 2005 22:41:03 -0000
@@ -282,6 +282,8 @@
 m4_include([convenience.at])
 # link order test
 m4_include([link-order.at])
+# ensure failure
+m4_include([fail.at])
 # Ensure our continued support for old interfaces.
 m4_include([old-m4-iface.at])
 # Torturing subdir-objects builds
--- /dev/null   2004-01-01 00:01:00.000000000 +0200
+++ tests/fail.at       2005-12-01 22:23:16.000000000 +0100
@@ -0,0 +1,70 @@
+# Hand crafted tests for GNU Libtool.                         -*- Autotest -*-
+# Copyright 2005 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
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA.
+
+# Test that libtool really fails when it should.
+# TODO: many possible failure cases missing.  (But how to simulate a full 
disk?)
+
+AT_SETUP([Failure tests])
+eval `$LIBTOOL --config | $EGREP 
'^(pic_mode|pic_flag|build_old_libs|build_libtool_libs)='`
+LDFLAGS="$LDFLAGS -no-undefined"
+
+m4_pushdef([FAIL_CHECK],
+[AT_CHECK([if $1; then (exit 1); else :; fi], [0], [ignore], [ignore])
+])
+
+# compile failure
+echo 'choke me' > a.c
+FAIL_CHECK([$LIBTOOL --mode=compile $CC $CPPFLAGS $CFLAGS -c a.c])
+AT_CHECK([test -f a.lo], [1])
+
+# non-PIC compile failure
+case $pic_mode in default | yes)
+  case $build_old_libs,$pic_flag in yes,*-DPIC*)
+    AT_DATA([a.c], [[
+#ifndef PIC
+  choke me
+#endif
+]])
+    FAIL_CHECK([$LIBTOOL --mode=compile $CC $CPPFLAGS $CFLAGS -no-suppress -c 
a.c])
+    AT_CHECK([test -f a.lo], [1])
+    ;;
+  esac
+  ;;
+esac
+
+# program creation failure
+echo 'int not_main(void) { return 0; }' > a.c
+$CC $CPPFLAGS $CFLAGS -c a.c
+FAIL_CHECK([$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o a a.$OBJEXT])
+AT_CHECK([test -f a || test -f a$EXEEXT], [1])
+FAIL_CHECK([$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o a a.$OBJEXT -static])
+AT_CHECK([test -f a || test -f a$EXEEXT], [1])
+
+# shared library creation failure
+case $build_libtool_libs in yes)
+  echo 'int duplicate_name(void) { return 0; }' > a.c
+  echo 'double duplicate_name(double x) { return 2.*x; }' > b.c
+  $LIBTOOL --mode=compile $CC $CPPFLAGS $CFLAGS -c a.c
+  $LIBTOOL --mode=compile $CC $CPPFLAGS $CFLAGS -c b.c
+  FAIL_CHECK([$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o liba.la a.lo b.lo 
-rpath /foo])
+  AT_CHECK([test -f liba.la], [1])
+  ;;
+esac
+
+m4_popdef([FAIL_CHECK])
+AT_CLEANUP





branch-1-5:

        * ltmain.in (func_extract_archives, compile mode, link mode):
        Use `$exit_status' rather than forbidden `$status'.

Index: ltmain.in
===================================================================
RCS file: /cvsroot/libtool/libtool/Attic/ltmain.in,v
retrieving revision 1.334.2.105
diff -u -r1.334.2.105 ltmain.in
--- ltmain.in   25 Nov 2005 18:36:15 -0000      1.334.2.105
+++ ltmain.in   1 Dec 2005 21:46:52 -0000
@@ -294,9 +294,9 @@
       $run ${rm}r "$my_xdir"
       $show "$mkdir $my_xdir"
       $run $mkdir "$my_xdir"
-      status=$?
-      if test "$status" -ne 0 && test ! -d "$my_xdir"; then
-       exit $status
+      exit_status=$?
+      if test "$exit_status" -ne 0 && test ! -d "$my_xdir"; then
+       exit $exit_status
       fi
       case $host in
       *-darwin*)
@@ -855,9 +855,9 @@
       if test ! -d "${xdir}$objdir"; then
        $show "$mkdir ${xdir}$objdir"
        $run $mkdir ${xdir}$objdir
-       status=$?
-       if test "$status" -ne 0 && test ! -d "${xdir}$objdir"; then
-         exit $status
+       exit_status=$?
+       if test "$exit_status" -ne 0 && test ! -d "${xdir}$objdir"; then
+         exit $exit_status
        fi
       fi
 
@@ -1920,9 +1920,9 @@
     if test ! -d "$output_objdir"; then
       $show "$mkdir $output_objdir"
       $run $mkdir $output_objdir
-      status=$?
-      if test "$status" -ne 0 && test ! -d "$output_objdir"; then
-       exit $status
+      exit_status=$?
+      if test "$exit_status" -ne 0 && test ! -d "$output_objdir"; then
+       exit $exit_status
       fi
     fi
 
@@ -4607,7 +4607,7 @@
        # We have no uninstalled library dependencies, so finalize right now.
        $show "$link_command"
        $run eval "$link_command"
-       status=$?
+       exit_status=$?
 
        # Delete the generated files.
        if test -n "$dlsyms"; then
@@ -4615,7 +4615,7 @@
          $run $rm "$output_objdir/${outputname}S.${objext}"
        fi
 
-       exit $status
+       exit $exit_status
       fi
 
       if test -n "$shlibpath_var"; then
@@ -5345,9 +5345,9 @@
            $run ${rm}r "$gentop"
            $show "$mkdir $gentop"
            $run $mkdir "$gentop"
-           status=$?
-           if test "$status" -ne 0 && test ! -d "$gentop"; then
-             exit $status
+           exit_status=$?
+           if test "$exit_status" -ne 0 && test ! -d "$gentop"; then
+             exit $exit_status
            fi
          fi
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]