Yep -- we discussed this after I committed that fix, and I read up on the AC docs to see why it worked. I now grok, and have a pending fix queued up for tonight (just so we don't commit autogen-worthy changes) that fixes exactly what you're talking about. My patch is almost exactly the same as yours. :-)

I was literally just about to attach a new patch for v1.3 with *all* of these fixes on to https://svn.open-mpi.org/trac/ompi/ticket/1993 (Brian noted exactly the same issues you did :-) ).

You have taught us well, Obi Wan...


On Aug 11, 2009, at 3:31 PM, Ralf Wildenhues wrote:

Hello,

* Jeff Squyres wrote on Tue, Aug 04, 2009 at 11:38:29PM CEST:
> https://svn.open-mpi.org/trac/ompi/changeset/21759 seems to make us
> play well with AC 2.64.  To be honest, I'm not sure why this change
> works, but it does.

First off, the warnings 2.64 spit out were about real issues (that could
have caused unwanted logic with older Autoconf versions, too, but with
2.64 there are a few more cases with consequences).  The fix in 21759
avoids the warnings but likely doesn't do what you would like it to do.

For example, this code in ompi_setup_f77.m4:

  AC_DEFUN([OMPI_PROG_F77],[
AC_PROG_F77([gfortran g77 f77 xlf frt ifort pgf77 fort77 fl32 af77])
  ])

  AC_DEFUN([OMPI_SETUP_F77],[

  #
  ompi_fflags_save="$FFLAGS"
  # Strangeness in AC2.64 forces us to require a macro that calls
  # PROG_FC instead of calling it directly.  Weird.
  AC_REQUIRE([OMPI_PROG_F77])
  FFLAGS="$ompi_fflags_save"

will cause the contents of the OMPI_PROG_F77 macro to be expanded
completely before the expansion of the OMPI_SETUP_F77 macro.

That means, the lines
  ompi_fflags_save="$FFLAGS"

  FFLAGS="$ompi_fflags_save"

will not bracket the AC_PROG_F77 call, as they should. What you should
do is move these lines to the required macro as well.

The patch below ought to fix up these issues, as well as the scope push
macro for C++.  For clarity, you could also put that in another,
separate macro, and AC_REQUIRE that.

Hope that helps.

Cheers,
Ralf


2009-08-11  Ralf Wildenhues  <ralf.wildenh...@gmx.de>

* config/ompi_setup_f90.m4 (OMPI_PROG_FC, OMPI_SETUP_F90):
Move FCFLAGS save/restore wrap in OMPI_PROG_FC.
* config/ompi_setup_f77.m4 (OMPI_PROG_F77, OMPI_SETUP_F77):
Likewise for FFLAGS.
* config/ompi_setup_cxx.m4 (OMPI_SETUP_CXX)
(_OMPI_SETUP_CXX_COMPILER_HELPER, _OMPI_SETUP_CXX_COMPILER):
Fold OMPI_VAR_SCOPE_PUSH and AC_PROG_CXX{,CPP} calls into a
new helper macro and require that, to fix semantics with respect
to AC_REQUIRE.

Index: config/ompi_setup_f90.m4
===================================================================
--- config/ompi_setup_f90.m4    (revision 21794)
+++ config/ompi_setup_f90.m4    (working copy)
@@ -42,7 +42,9 @@
 # This macro is necessary because PROG_FC is REQUIREd by multiple
 # places in SETUP_F90.
 AC_DEFUN([OMPI_PROG_FC],[
+    ompi_fcflags_save="$FCFLAGS"
AC_PROG_FC([gfortran f95 fort xlf95 ifort ifc efc pgf95 lf95 f90 xlf90 pgf90 epcf90])
+    FCFLAGS="$ompi_fcflags_save"
 ])dnl

 AC_DEFUN([OMPI_SETUP_F90],[
@@ -86,11 +88,9 @@
     # list of 95 and 90 compilers and use it here.
     #

-    ompi_fcflags_save="$FCFLAGS"
     # Strangeness in AC2.64 forces us to require a macro that calls
     # PROG_FC instead of calling it directly.  Weird.
     AC_REQUIRE([OMPI_PROG_FC])
-    FCFLAGS="$ompi_fcflags_save"
     if test -z "$FC"; then
AC_MSG_WARN([*** Fortran 90/95 bindings disabled (could not find compiler)])
         OMPI_WANT_F90_BINDINGS=0
Index: config/ompi_setup_cxx.m4
===================================================================
--- config/ompi_setup_cxx.m4    (revision 21794)
+++ config/ompi_setup_cxx.m4    (working copy)
@@ -47,11 +47,20 @@
     _OMPI_CXX_CHECK_2D_CONST_CAST
 ])

+# _OMPI_SETUP_CXX_COMPILER_HELPER
+# -------------------------------
+AC_DEFUN([_OMPI_SETUP_CXX_COMPILER_HELPER], [
+    OMPI_VAR_SCOPE_PUSH(ompi_cxx_compiler_works)
+    ompi_cxxflags_save="$CXXFLAGS"
+    AC_PROG_CXX
+    AC_PROG_CXXCPP
+    CXXFLAGS="$ompi_cxxflags_save"
+])
+
 # _OMPI_SETUP_CXX_COMPILER()
 # --------------------------
 # Setup the CXX compiler
 AC_DEFUN([_OMPI_SETUP_CXX_COMPILER],[
-    OMPI_VAR_SCOPE_PUSH(ompi_cxx_compiler_works)

     # There's a few cases here:
     #
@@ -66,11 +75,8 @@
# both found a c++ compiler and want the C++ bindings (i.e., either
     # case #1 or #3)

-    ompi_cxxflags_save="$CXXFLAGS"
-    AC_REQUIRE([AC_PROG_CXX])
-    AC_REQUIRE([AC_PROG_CXXCPP])
+    AC_REQUIRE([_OMPI_SETUP_CXX_COMPILER_HELPER])
     BASECXX="`basename $CXX`"
-    CXXFLAGS="$ompi_cxxflags_save"

     AS_IF([test "x$CXX" = "x"], [CXX=none])
     set dummy $CXX
Index: config/ompi_setup_f77.m4
===================================================================
--- config/ompi_setup_f77.m4    (revision 21794)
+++ config/ompi_setup_f77.m4    (working copy)
@@ -41,7 +41,9 @@
 # This macro is necessary because PROG_FC is REQUIREd by multiple
 # places in SETUP_F90.
 AC_DEFUN([OMPI_PROG_F77],[
+    ompi_fflags_save="$FFLAGS"
AC_PROG_F77([gfortran g77 f77 xlf frt ifort pgf77 fort77 fl32 af77])
+    FFLAGS="$ompi_fflags_save"
 ])

 AC_DEFUN([OMPI_SETUP_F77],[
@@ -58,11 +60,9 @@
 # Always run this test, even if fortran isn't wanted so that F77 has
 # value for the Fint tests
 #
-ompi_fflags_save="$FFLAGS"
 # Strangeness in AC2.64 forces us to require a macro that calls
 # PROG_FC instead of calling it directly.  Weird.
 AC_REQUIRE([OMPI_PROG_F77])
-FFLAGS="$ompi_fflags_save"
 if test -z "$F77"; then
AC_MSG_WARN([*** Fortran 77 bindings disabled (could not find compiler)])
     OMPI_WANT_F77_BINDINGS=0



--
Jeff Squyres
jsquy...@cisco.com

Reply via email to