[Dropping bug-autoconf]

Reference: <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=10859>

On 02/21/2012 10:52 PM, Stefano Lattarini wrote:
>
> Now that we have identified the problem, fixing it shouldn't be too difficult;
> I will follow-up in the next days with a patch.
> 
Here it is (for master).  Please let us know whether it fixes your issue.

Thanks,
  Stefano
>From c9a3ab3b134665cbb3b9b568f36724245e2bd093 Mon Sep 17 00:00:00 2001
Message-Id: <c9a3ab3b134665cbb3b9b568f36724245e2bd093.1329990333.git.stefano.lattar...@gmail.com>
From: Stefano Lattarini <stefano.lattar...@gmail.com>
Date: Wed, 22 Feb 2012 22:39:03 +0100
Subject: [PATCH] tests: looks for GNU compilers at configure time

This way, if the generic C compiler determined configure time is
recognized to be the GNU C compiler, we can reuse it instead of
looking for a compiler named "gcc" (over and over again) in the
test scripts requiring the GNU C compiler.  Ditto for the C++,
Fortran, and Fortran 77 compilers.

This change will improve coverage by allowing us to more easily
use non-default GNU compilers throughout the testsuite.

And as a bonus, this change also removes a weakness from our
testsuite that could cause spurious failures when flags passed
to the generic compilers were erroneously reused for the GNU
compilers; see automake bug#10859.

* configure.ac: Look for the GNU compilers explicitly.  Improve
some configure output and diagnostic since we are at it.
* tests/defs-static.in ($GNU_CC, $GNU_CXX, $GNU_FC, $GNU_F77):
Initialize with the values determined at configure time (while
allowing user overrides).
* tests/Makefile.am (do_edit): Also substitute the configure-time
values of GNU_CC, GNU_CXX, GNU_FC and GNU_F77.
* tests/defs (gcc, g++, gfortran, g77): Use the values for the GNU
compilers determined at configure time (i.e., $GNU_CC for the GNU
C compiler, and so on).
---
 configure.ac         |   86 +++++++++++++++++++++++++++++++++++++++++--------
 tests/Makefile.am    |    4 ++
 tests/defs           |   44 ++++++--------------------
 tests/defs-static.in |    6 +++-
 4 files changed, 91 insertions(+), 49 deletions(-)

diff --git a/configure.ac b/configure.ac
index eed1c3c..743f979 100644
--- a/configure.ac
+++ b/configure.ac
@@ -265,14 +265,22 @@ AC_DEFUN([_AM_COMPILER_CAN_FAIL], [
   m4_popdef([AC_MSG_ERROR])
 ])
 
+AC_DEFUN([_AM_SKIP_COMP_TESTS],
+  [AC_MSG_NOTICE([tests requiring the $1 compiler will be skipped])])
+
 # Prefer generic compilers to GNU ones when possible.  This will ensure
 # more testsuite coverage "in the wild".
 # Note that we don't look for the MSVC C/C++ compiler here.  This is
 # deliberate; for more discussion an rationale, see:
 # <http://lists.gnu.org/archive/html/automake-patches/2012-01/msg00130.html>
 
+AC_MSG_NOTICE([will now look for generic compilers])
+
 # C compiler.
-_AM_COMPILER_CAN_FAIL([AC_PROG_CC([cc gcc])], [CC=false])
+_AM_COMPILER_CAN_FAIL(dnl
+  [AC_PROG_CC([cc gcc])],
+  [CC=false; _AM_SKIP_COMP_TESTS([C])])
+
 AS_IF([test x"$GCC" = x"yes"], [am_CC_is_GNU=yes], [am_CC_is_GNU=no])
 
 # The list of C++ compilers here has been copied, pasted and edited
@@ -281,7 +289,8 @@ AS_IF([test x"$GCC" = x"yes"], [am_CC_is_GNU=yes], [am_CC_is_GNU=no])
 # duplication.
 _AM_COMPILER_CAN_FAIL([AC_PROG_CXX(dnl
   [aCC CC FCC KCC RCC xlC_r xlC c++ cxx cc++ gpp g++])],
-  [CXX=false])
+  [CXX=false; _AM_SKIP_COMP_TESTS([C++])])
+
 AS_IF([test x"$GXX" = x"yes"], [am_CXX_is_GNU=yes], [am_CXX_is_GNU=no])
 
 # The lists of Fortran compilers here has been copied, pasted and edited
@@ -292,34 +301,83 @@ AS_IF([test x"$GXX" = x"yes"], [am_CXX_is_GNU=yes], [am_CXX_is_GNU=no])
 _AM_COMPILER_CAN_FAIL([AC_PROG_FC(dnl
   [xlf95 f95 fort ifort ifc efc pgfortran pgf95 lf95 ftn nagfor] dnl
   [xlf90 f90 pgf90 pghpf epcf90 g95 gfortran])],
-  [FC=false])
+  [FC=false; _AM_SKIP_COMP_TESTS([Fortran])])
+
 # FIXME this won't work as expected until we can assume autoconf 2.69 :-(
 AS_IF([test x"$GFC" = x"yes"], [am_FC_is_GNU=yes], [am_FC_is_GNU=no])
 
 _AM_COMPILER_CAN_FAIL([AC_PROG_F77(dnl
   [xlf f77 frt pgf77 cf77 fort77 fl32 af77 g77 gfortran])],
-  [F77=false])
+  [F77=false; _AM_SKIP_COMP_TESTS([Fortran 77])])
+
 AS_IF([test x"$G77" = x"yes"], [am_F77_is_GNU=yes], [am_F77_is_GNU=no])
 
 # Some tests will need the GNU compilers.  Searching for them here would
 # be overkill, since our testsuite already handles their search and setup
-# pretty well.  However, in case the compilers detected above at configure
-# time are not the GNU ones, we cannot use the values of CFLAGS, CXXFLAGS,
-# FCFLAGS and FFLAGS detected for them with the GNU compilers too, since
-# it's likely they won't be compatible.  So we allow the user to define
-# variants of this variables for the GNU compilers separately.
-
-test $am_CC_is_GNU = yes && GNU_CFLAGS=${GNU_CFLAGS-$CFLAGS}
+# pretty well.  But in case the compilers already found are the GNU ones,
+# we want to use them in the testsuite where GNU compilers are required.
+# Also, in case the compilers detected above (at configure time) are not
+# the GNU ones, we cannot use the values of CFLAGS, CXXFLAGS, FCFLAGS and
+# FFLAGS detected for them with the GNU compilers too, since it's likely
+# they won't be compatible.  So we allow the user to define variants of
+# these variables for the GNU compilers separately.
+
+AC_MSG_NOTICE([will now look for GNU compilers])
+
+# GNU C compiler.
+AC_ARG_VAR([GNU_CC],     [GNU C compiler])
 AC_ARG_VAR([GNU_CFLAGS], [GNU C compiler flags])
+if test $am_CC_is_GNU = yes; then
+  AC_MSG_NOTICE([$CC is already a GNU C compiler])
+  GNU_CC=$CC GNU_CFLAGS=${GNU_CFLAGS-$CFLAGS}
+else
+  AC_CHECK_TOOLS([GNU_CC], [gcc], [false])
+fi
+AS_IF([AM_RUN_LOG([$GNU_CC --version && $GNU_CC -v])], [],
+      [AC_MSG_WARN([botched installation for GNU C compiler])
+       _AM_SKIP_COMP_TESTS([GNU C])])
 
-test $am_CXX_is_GNU = yes && GNU_CXXFLAGS=${GNU_CXXFLAGS-$CXXFLAGS}
+# GNU C++ compiler.
+AC_ARG_VAR([GNU_CXX],      [GNU C++ compiler])
 AC_ARG_VAR([GNU_CXXFLAGS], [GNU C++ compiler flags])
+if test $am_CXX_is_GNU = yes; then
+  AC_MSG_NOTICE([$CXX is already a GNU C++ compiler])
+  GNU_CXX=$CXX
+  GNU_CXXFLAGS=${GNU_CXXFLAGS-$CXXFLAGS}
+else
+  AC_CHECK_TOOLS([GNU_CXX], [g++ gpp], [false])
+fi
+AS_IF([AM_RUN_LOG([$GNU_CXX --version && $GNU_CXX -v])], [],
+      [AC_MSG_WARN([botched installation for GNU C++ compiler])
+       _AM_SKIP_COMP_TESTS([GNU C++])])
 
-test $am_F77_is_GNU = yes && GNU_FCFLAGS=${GNU_FCFLAGS-$FCFLAGS}
+# GNU Fortran compiler.
+AC_ARG_VAR([GNU_FC],      [GNU Fortran compiler])
 AC_ARG_VAR([GNU_FCFLAGS], [GNU Fortran compiler flags])
+if test $am_FC_is_GNU = yes; then
+  AC_MSG_NOTICE([$FC is already a GNU Fortran compiler])
+  GNU_FC=$FC
+  GNU_FCFLAGS=${GNU_FCFLAGS-$FCFLAGS}
+else
+  AC_CHECK_TOOLS([GNU_FC], [gfortran], [false])
+fi
+AS_IF([AM_RUN_LOG([$GNU_FC --version && $GNU_FC -v])], [],
+      [AC_MSG_WARN([botched installation for GNU Fortran compiler])
+       _AM_SKIP_COMP_TESTS([GNU Fortran])])
 
-test $am_FC_is_GNU = yes && GNU_FFLAGS=${GNU_FFLAGS-$FFLAGS}
+# GNU Fortran 77 compiler.
+AC_ARG_VAR([GNU_F77],    [GNU Fortran 77 compiler])
 AC_ARG_VAR([GNU_FFLAGS], [GNU Fortran 77 compiler flags])
+if test $am_F77_is_GNU = yes; then
+  AC_MSG_NOTICE([$F77 is already a GNU Fortran 77 compiler])
+  GNU_F77=$F77
+  GNU_FFLAGS=${GNU_FFLAGS-$FFLAGS}
+else
+  AC_CHECK_TOOLS([GNU_F77], [g77 gfortran], [false])
+fi
+AS_IF([AM_RUN_LOG([$GNU_F77 --version && $GNU_F77 -v])], [],
+      [AC_MSG_WARN([botched installation for GNU Fortran 77 compiler])
+      _AM_SKIP_COMP_TESTS([GNU Fortran 77])])
 
 # If we have been able to find at least a working compiler above, we
 # know what the object and executable extensions for this platform are.
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 8a77681..bf276a2 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -148,9 +148,13 @@ do_subst = sed \
   -e 's|@FFLAGS[@]|$(FFLAGS)|g' \
   -e 's|@FC[@]|$(FC)|g' \
   -e 's|@FCFLAGS[@]|$(FCFLAGS)|g' \
+  -e 's|@GNU_CC[@]|$(GNU_CC)|g' \
   -e 's|@GNU_CFLAGS[@]|$(GNU_CFLAGS)|g' \
+  -e 's|@GNU_CXX[@]|$(GNU_CXX)|g' \
   -e 's|@GNU_CXXFLAGS[@]|$(GNU_CXXFLAGS)|g' \
+  -e 's|@GNU_F77[@]|$(GNU_F77)|g' \
   -e 's|@GNU_FFLAGS[@]|$(GNU_FFLAGS)|g' \
+  -e 's|@GNU_FC[@]|$(GNU_FC)|g' \
   -e 's|@GNU_FCFLAGS[@]|$(GNU_FCFLAGS)|g' \
   -e 's|@YACC[@]|$(YACC)|g' \
   -e 's|@LEX[@]|$(LEX)|g' \
diff --git a/tests/defs b/tests/defs
index fd0a8ad..00b3cbe 100644
--- a/tests/defs
+++ b/tests/defs
@@ -802,19 +802,6 @@ do
       export MAKE
       unset make_
       ;;
-    gcc)
-      # When gcc is required, export `CC=gcc' so that ./configure
-      # always use it.  This is important only when the user
-      # has defined CC in his environment, otherwise ./configure will
-      # prefer gcc to other compilers.
-      CC=${am__tool_prefix}gcc
-      CFLAGS=$GNU_CFLAGS
-      export CC CFLAGS CPPFLAGS
-      echo "$me: running $CC --version"
-      $CC --version || skip_all_ "GNU C compiler not available"
-      echo "$me: running $CC -v"
-      $CC -v || skip_all_ "botched installation for GNU C compiler"
-      ;;
     gcj)
       GCJ=${am__tool_prefix}gcj
       export GCJ
@@ -823,36 +810,25 @@ do
       echo "$me: running $GCJ -v"
       $GCJ -v || skip_all_ "botched installation for GNU Java compiler"
       ;;
+    gcc)
+      CC=$GNU_CC CFLAGS=$GNU_CFLAGS; export CC CFLAGS CPPFLAGS
+      test "$CC" = false && skip_all_ "GNU C compiler unavailable"
+      ;;
     g++)
-      CXX=${am__tool_prefix}g++
-      CXXFLAGS=$GNU_CXXFLAGS
-      export CXX CXXFLAGS CPPFLAGS
-      echo "$me: running $CXX --version"
-      $CXX --version || skip_all_ "GNU C++ compiler not available"
-      echo "$me: running $CXX -v"
-      $CXX -v || skip_all_ "botched installation for GNU C++ compiler"
+      CXX=$GNU_CXX CXXFLAGS=$GNU_CXXFLAGS; export CXX CXXFLAGS CPPFLAGS
+      test "$CXX" = false && skip_all_ "GNU C++ compiler unavailable"
       ;;
     gfortran)
-      FC=${am__tool_prefix}gfortran
-      FCFLAGS=$GNU_FCFLAGS
-      export FC FCFLAGS
-      echo "$me: running $FC --version"
-      $FC --version || skip_all_ "GNU Fortran compiler not available"
-      echo "$me: running $FC -v"
-      $FC -v || skip_all_ "botched installation for GNU Fortran compiler"
+      FC=$GNU_FC FCFLAGS=$GNU_FCFLAGS; export FC FCFLAGS
+      test "$FC" = false && skip_all_ "GNU Fortran compiler unavailable"
       case " $required " in
         *\ g77\ *) ;;
         *) F77=$FC FFLAGS=$FCFLAGS; export F77 FFLAGS;;
       esac
       ;;
     g77)
-      F77=${am__tool_prefix}g77
-      FFLAGS=$GNU_FFLAGS
-      export F77 FFLAGS
-      echo "$me: running $F77 --version"
-      $F77 --version || skip_all_ "GNU Fortran 77 compiler not available"
-      echo "$me: running $F77 -v"
-      $F77 -v || skip_all_ "botched installation for GNU Fortran 77 compiler"
+      F77=$GNU_F77 FFLAGS=$GNU_FFLAGS; export F77 FFLAGS
+      test "$F77" = false && skip_all_ "GNU Fortran 77 compiler unavailable"
       case " $required " in
         *\ gfortran\ *) ;;
         *) FC=$F77 FCFLAGS=$FFLAGS; export FC FCFLAGS;;
diff --git a/tests/defs-static.in b/tests/defs-static.in
index c474d7a..f72e606 100644
--- a/tests/defs-static.in
+++ b/tests/defs-static.in
@@ -196,7 +196,11 @@ FCFLAGS=${AM_TESTSUITE_FCFLAGS-${FCFLAGS-'@FCFLAGS@'}}
 FFLAGS=${AM_TESTSUITE_FFLAGS-${FFLAGS-'@FFLAGS@'}}
 CPPFLAGS=${AM_TESTSUITE_CPPFLAGS-${CPPFLAGS-'@CPPFLAGS@'}}
 
-# Flags for the GNU compilers.
+# GNU compilers and their flags.
+GNU_CC=${AM_TESTSUITE_GNU_CC-${GNU_CC-'@GNU_CC@'}}
+GNU_CXX=${AM_TESTSUITE_GNU_CXX-${GNU_CXX-'@GNU_CXX@'}}
+GNU_F77=${AM_TESTSUITE_GNU_F77-${GNU_F77-'@GNU_F77@'}}
+GNU_FC=${AM_TESTSUITE_GNU_FC-${GNU_FC-'@GNU_FC@'}}
 GNU_FFLAGS=${AM_TESTSUITE_GNU_FFLAGS-${GNU_FFLAGS-'@GNU_FFLAGS@'}}
 GNU_FCFLAGS=${AM_TESTSUITE_GNU_FCFLAGS-${GNU_FCFLAGS-'@GNU_FCFLAGS@'}}
 GNU_CXXFLAGS=${AM_TESTSUITE_GNU_CXXFLAGS-${GNU_CXXFLAGS-'@GNU_CXXFLAGS@'}}
-- 
1.7.9

Reply via email to