bug-libtool
[Top][All Lists]
Advanced

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

Re: Second (non-fPIC) pass messages being suppressed on failure


From: Ralf Wildenhues
Subject: Re: Second (non-fPIC) pass messages being suppressed on failure
Date: Thu, 22 Nov 2007 08:19:56 +0100
User-agent: Mutt/1.5.13 (2006-08-11)

Hello Ed,

Thanks for the suggestion.

* Ed Catmur wrote on Mon, Nov 19, 2007 at 02:18:58AM CET:
> 
>       # Allow error messages only from the first compilation.
>       if test "$suppress_opt" = yes; then
>         suppress_output=' >/dev/null 2>&1'
>       fi
> ...
>       # Suppress compiler output if we already did a PIC compilation.
>       command="$command$suppress_output"
> 
> This is presumably intended to ensure that when an object file gets
> compiled twice (once with -fPIC, once without) warning messages etc. are
> not duplicated.

Yes.

>  However, if the second position-dependent run fails
> (compiler bug, usually, but could also be running out of disk space) it
> will fail without any error message being printed.

Yes.  Have you actually hit a compiler bug that way before?  I think
it's much more likely that the set of warnings is different rather
than a failure, but others may have a different experience.

> Would it make sense to capture output from the second compilation
> instead of discarding it, then print it if the second compilation fails?

Suggested patch against HEAD.  It costs one more fork of `rm' per
compile, and makes the typical echoed command line longer, but saves
the user from having to type something like
  make || env CFLAGS='... -no-suppress' make -e

WDYT?  (Adding Ed to THANKS not shown.)

Cheers,
Ralf

2007-11-20  Ralf Wildenhues  <address@hidden>

        * libltdl/config/ltmain.m4sh (func_mode_compile): Fix evaluation
        level of `trap' command, thereby also saving one.
        Catch compile log of suppressed second compile, and output it in
        case only the second compile failed but not the first.
        * tests/suppress.at: New test.
        * Makefile.am: Adjust.
        * THANKS: Update.
        Suggested by Ed Catmur.

Index: Makefile.am
===================================================================
RCS file: /cvsroot/libtool/libtool/Makefile.am,v
retrieving revision 1.226
diff -u -r1.226 Makefile.am
--- Makefile.am 8 Nov 2007 21:38:27 -0000       1.226
+++ Makefile.am 20 Nov 2007 22:00:37 -0000
@@ -436,6 +436,7 @@
                  tests/link-order.at \
                  tests/link-order2.at \
                  tests/fail.at \
+                 tests/suppress.at \
                  tests/shlibpath.at \
                  tests/runpath-in-lalib.at \
                  tests/static.at \
Index: libltdl/config/ltmain.m4sh
===================================================================
RCS file: /cvsroot/libtool/libtool/libltdl/config/ltmain.m4sh,v
retrieving revision 1.91
diff -u -r1.91 ltmain.m4sh
--- libltdl/config/ltmain.m4sh  12 Oct 2007 16:35:15 -0000      1.91
+++ libltdl/config/ltmain.m4sh  20 Nov 2007 22:00:42 -0000
@@ -1254,6 +1254,7 @@
     srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
     suppress_opt=yes
     suppress_output=
+    compilelog=
     arg_mode=normal
     libobj=
     later=
@@ -1434,7 +1435,7 @@
     fi
 
     $opt_dry_run || $RM $removelist
-    trap "$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE" 1 2 15
+    trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
 
     # On Cygwin there's no "real" PIC flag so we must build both object types
     case $host_os in
@@ -1453,7 +1454,6 @@
       output_obj=`$ECHO "X$srcfile" | $Xsed -e 's%^.*/%%' -e 
's%\.[^.]*$%%'`.${objext}
       lockfile="$output_obj.lock"
       removelist="$removelist $output_obj $lockfile"
-      trap "$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE" 1 2 15
     else
       output_obj=
       need_locks=no
@@ -1546,7 +1546,9 @@
 
       # Allow error messages only from the first compilation.
       if test "$suppress_opt" = yes; then
-       suppress_output=' >/dev/null 2>&1'
+       compilelog=$xdir$objdir/$objname-log
+       removelist="$removelist $compilelog"
+       suppress_output=' >$compilelog 2>&1'
       fi
     fi
 
@@ -1566,7 +1568,8 @@
       command="$command$suppress_output"
       $opt_dry_run || $RM "$obj" "$output_obj"
       func_show_eval "$command" \
-        '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
+        'test -n "$compilelog" && cat "$compilelog"
+        $opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
 
       if test "$need_locks" = warn &&
         test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
@@ -1602,6 +1605,9 @@
       if test "$need_locks" != no; then
         $RM "$lockfile"
       fi
+      if test -n "$compilelog"; then
+       $RM $compilelog
+      fi
     }
 
     exit $EXIT_SUCCESS
--- /dev/null   2007-11-02 00:08:58.220064749 +0100
+++ tests/suppress.at   2007-11-20 23:07:55.000000000 +0100
@@ -0,0 +1,64 @@
+# suppress.at -- test libtool -no-suppress     -*- Autotest -*-
+#
+#   Copyright (C) 2007 Free Software Foundation, Inc.
+#   Written by Ralf Wildenhues, 2007
+#
+#   This file is part of GNU Libtool.
+#
+# GNU Libtool 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 of
+# the License, or (at your option) any later version.
+#
+# GNU Libtool 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 GNU Libtool; see the file COPYING.  If not, a copy
+# can be downloaded from  http://www.gnu.org/licenses/gpl.html,
+# or obtained by writing to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+####
+
+AT_SETUP([Compile tests])
+AT_KEYWORDS([libtool])
+eval `$LIBTOOL --config | $EGREP 
'^(build_old_libs|build_libtool_libs|objdir|pic_flag)='`
+
+AT_CHECK([case $pic_flag in *-DPIC*) :;; *) exit 77;; esac])
+
+AT_DATA([nopicfail.c],
+[[
+#ifndef PIC
+choke me
+#endif
+int ans = 42;
+]])
+
+AT_DATA([picfail.c],
+[[
+#ifndef PIC
+choke me
+#endif
+int ans = 42;
+]])
+
+if test $build_libtool_libs = yes; then
+  AT_CHECK([$LIBTOOL --mode=compile $CC $CPPFLAGS $CFLAGS -c picfail.c],
+          [1], [stdout], [stderr])
+  AT_CHECK([grep -v " -c" stdout stderr], [], [ignore])
+  AT_CHECK([test ! -f $objdir/picfail.o-log])
+fi
+if test $build_old_libs = yes; then
+  AT_CHECK([$LIBTOOL --mode=compile $CC $CPPFLAGS $CFLAGS -no-suppress -c 
nopicfail.c],
+          [1], [stdout], [stderr])
+  AT_CHECK([grep -v " -c" stdout stderr], [], [ignore])
+  AT_CHECK([test ! -f $objdir/nopicfail.o-log])
+  AT_CHECK([$LIBTOOL --mode=compile $CC $CPPFLAGS $CFLAGS -c nopicfail.c],
+          [1], [stdout], [stderr])
+  AT_CHECK([grep -v " -c" stdout stderr], [], [ignore])
+  AT_CHECK([test ! -f $objdir/nopicfail.o-log])
+fi
+
+AT_CLEANUP




reply via email to

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