libtool-patches
[Top][All Lists]
Advanced

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

compensate compiler warnings and boilerplate


From: Ralf Wildenhues
Subject: compensate compiler warnings and boilerplate
Date: Sun, 10 Apr 2005 17:38:05 +0200
User-agent: Mutt/1.4.1i

Two problems I want to kill with this patch:
- picky compiler(s|flags) warn about innocuous code and thus make the
  `-c -o' and the pic_flag tests (among others) spuriously fail.
- some proprietary compilers output boilerplate every time.  Same
  effect on libtool tests.

A third, similar problem I don't care much about:
- some proprietary compilers provide you with evaluation licenses which
  output the time limit left for use (this output is non-constant).

Right now, in above tests we test for return value != 0 or existence of
warnings, i.e. nonempty stderr; we cannot rely on exit status since some
compiler don't fail with unknown switches.  However, picky compiler
warning flags will warn even
  int someflag=0;
Point here is that there is no trivial source code which compiles
without any warning for every compiler and compiler flag combo.

This patch makes tests succeed in case of empty warnings, but also in
case the stderr output is identical to the compile without the specific
option we are currently testing.

For consistency, the same is done with linker tests.

OK to apply to HEAD and backport?

I'm unsure whether I should additionally put something like
    m4_require(_LT_COMPILER_BOILERPLATE)
at the beginning of respective tests?

Notes:
- Deleting empty lines in output prevents spurious missing last line due
  to shell variable assignment.
- No config.cache'able test because of newline support.

Regards,
Ralf

        * m4/libtool.m4 (_LT_COMPILER_BOILERPLATE, _LT_LINKER_BOILERPLATE):
        New macros: save warnings and boilerplate of simple compile/link tests.
        (_LT_LANG_C_CONFIG, _LT_LANG_CXX_CONFIG, _LT_LANG_F77_CONFIG,
        _LT_LANG_GCJ_CONFIG, _LT_LANG_RC_CONFIG): Call. 
        (_LT_COMPILER_OPTION, _LT_LINKER_OPTION, _LT_COMPILER_C_O, ):
        Fail only if nonempty warnings different from default compile/link.

Index: m4/libtool.m4
===================================================================
RCS file: /cvsroot/libtool/libtool/m4/libtool.m4,v
retrieving revision 1.180
diff -u -r1.180 libtool.m4
--- m4/libtool.m4       7 Apr 2005 17:58:26 -0000       1.180
+++ m4/libtool.m4       10 Apr 2005 15:28:25 -0000
@@ -690,6 +690,32 @@
 ])# _LT_TAG_COMPILER
 
 
+# _LT_COMPILER_BOILERPLATE
+# ------------------------
+# Check for compiler boilerplate output or warnings with
+# the simple compiler test code.
+m4_defun([_LT_COMPILER_BOILERPLATE],
+[ac_outfile=conftest.$ac_objext
+printf "$lt_simple_compile_test_code" >conftest.$ac_ext
+eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d' >conftest.err
+_lt_compiler_boilerplate=`cat conftest.err`
+$RM conftest*
+])# _LT_COMPILER_BOILERPLATE
+
+
+# _LT_LINKER_BOILERPLATE
+# ----------------------
+# Check for linker boilerplate output or warnings with
+# the simple link test code.
+m4_defun([_LT_LINKER_BOILERPLATE],
+[ac_outfile=conftest.$ac_objext
+printf "$lt_simple_link_test_code" >conftest.$ac_ext
+eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d' >conftest.err
+_lt_linker_boilerplate=`cat conftest.err`
+$RM conftest*
+])# _LT_LINKER_BOILERPLATE
+
+
 # _LT_SYS_MODULE_PATH_AIX
 # -----------------------
 # Links a minimal program and checks the executable
@@ -1069,8 +1095,10 @@
    echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
-     # So say no if there are warnings
-     if test ! -s conftest.err; then
+     # So say no if there are warnings other than the usual output.
+     $ECHO "X$_lt_compiler_boilerplate" | $Xsed >conftest.exp
+     $SED '/^$/d' conftest.err >conftest.er2
+     if test ! -s conftest.err || diff conftest.exp conftest.er2 >/dev/null; 
then
        $2=yes
      fi
    fi
@@ -1106,6 +1134,11 @@
      if test -s conftest.err; then
        # Append any errors to the config.log.
        cat conftest.err 1>&AS_MESSAGE_LOG_FD
+       $ECHO "X$_lt_linker_boilerplate" | $Xsed > conftest.exp
+       $SED '/^$/d' conftest.err >conftest.er2
+       if diff conftest.exp conftest.er2 >/dev/null; then
+         $2=yes
+       fi
      else
        $2=yes
      fi
@@ -1493,7 +1526,9 @@
    then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings
-     if test ! -s out/conftest.err; then
+     $ECHO "X$_lt_compiler_boilerplate" | $Xsed > out/conftest.exp
+     $SED '/^$/d' out/conftest.err >out/conftest.er2
+     if test ! -s out/conftest.err || diff out/conftest.exp out/conftest.er2 
>/dev/null; then
        _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
      fi
    fi
@@ -4537,6 +4580,10 @@
 # tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP.
 compiler_DEFAULT=$CC
 
+# save warnings/boilerplate of simple test code
+_LT_COMPILER_BOILERPLATE
+_LT_LINKER_BOILERPLATE
+
 #
 # Check for any special shared library compilation flags.
 #
@@ -4680,6 +4727,10 @@
   # ltmain only uses $CC for tagged configurations so make sure $CC is set.
   _LT_TAG_COMPILER
 
+  # save warnings/boilerplate of simple test code
+  _LT_COMPILER_BOILERPLATE
+  _LT_LINKER_BOILERPLATE
+
   # Allow CC to be a program name with arguments.
   lt_save_CC=$CC
   lt_save_LD=$LD
@@ -5823,6 +5881,10 @@
   # ltmain only uses $CC for tagged configurations so make sure $CC is set.
   _LT_TAG_COMPILER
 
+  # save warnings/boilerplate of simple test code
+  _LT_COMPILER_BOILERPLATE
+  _LT_LINKER_BOILERPLATE
+
   # Allow CC to be a program name with arguments.
   lt_save_CC="$CC"
   CC=${F77-"f77"}
@@ -5912,6 +5974,10 @@
 # ltmain only uses $CC for tagged configurations so make sure $CC is set.
 _LT_TAG_COMPILER
 
+# save warnings/boilerplate of simple test code
+_LT_COMPILER_BOILERPLATE
+_LT_LINKER_BOILERPLATE
+
 # Allow CC to be a program name with arguments.
 lt_save_CC="$CC"
 CC=${GCJ-"gcj"}
@@ -5970,6 +6036,10 @@
 # ltmain only uses $CC for tagged configurations so make sure $CC is set.
 _LT_TAG_COMPILER
 
+# save warnings/boilerplate of simple test code
+_LT_COMPILER_BOILERPLATE
+_LT_LINKER_BOILERPLATE
+
 # Allow CC to be a program name with arguments.
 lt_save_CC="$CC"
 CC=${RC-"windres"}




reply via email to

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