From ac698173b9e3911ccebf64125d26512f3528de03 Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Tue, 21 Oct 2008 20:25:20 +0000 Subject: [PATCH] * Ensure to pass the C++ exceptions flags to the C and Fortran compilers as well. Not doing this was causing problems with MPI::ERRORS_THROW_EXCEPTIONS with gcc in 32 bit (but not 64 bit!). * Ensure that the C and Fortran compilers actually like the C++ exceptions flags. If not, currently just abort. Let's see if anyone complains about this -- I doubt they will because a) C++ exception support is not enabled by default, and b) I think C++ exceptions really only make sense within the same compiler family. This commit was SVN r19783. --- config/ompi_setup_cxx.m4 | 20 ++++++++++++++++++-- config/ompi_setup_f77.m4 | 21 +++++++++++++++++++++ config/ompi_setup_f90.m4 | 21 +++++++++++++++++++++ 3 files changed, 60 insertions(+), 2 deletions(-) diff --git a/config/ompi_setup_cxx.m4 b/config/ompi_setup_cxx.m4 index 8ba130de16..4d7e901f98 100644 --- a/config/ompi_setup_cxx.m4 +++ b/config/ompi_setup_cxx.m4 @@ -116,8 +116,24 @@ AC_DEFUN([OMPI_SETUP_CXX],[ OMPI_CXX_FIND_EXCEPTION_FLAGS if test "$OMPI_CXX_EXCEPTIONS" = "1"; then HAVE_CXX_EXCEPTIONS=1 - CFLAGS="$CFLAGS $OMPI_CXX_EXCEPTIONS_CFLAGS" - FFLAGS="$FFLAGS $OMPI_CXX_EXCEPTIONS_FFLAGS" + + # Test to see if the C compiler likes these flags + AC_MSG_CHECKING([to see if C compiler likes the exception flags]) + CFLAGS="$CFLAGS $OMPI_CXX_EXCEPTIONS_CXXFLAGS" + AC_LANG_SAVE + AC_LANG_C + AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[]], [[int i = 0;]]), + [AC_MSG_RESULT([yes])], + [AC_MSG_RESULT([no]) + AC_MSG_WARN([C++ exception flags are different between the C and C++ compilers; this configure script cannot currently handle this scenario. Either disable C++ exception support or send mail to the Open MPI users list.]) + AC_MSG_ERROR([*** Cannot continue])]) + AC_LANG_RESTORE + + # We can't test the F77 and F90 compilers now because we + # haven't found/set the up yet. So just save the flags + # and test them later (in ompi_setup_f77.m4 and + # ompi_setup_f90.m4). + CXXFLAGS="$CXXFLAGS $OMPI_CXX_EXCEPTIONS_CXXFLAGS" LDFLAGS="$LDFLAGS $OMPI_CXX_EXCEPTIONS_LDFLAGS" diff --git a/config/ompi_setup_f77.m4 b/config/ompi_setup_f77.m4 index aa970cb40d..0d9a57ce42 100644 --- a/config/ompi_setup_f77.m4 +++ b/config/ompi_setup_f77.m4 @@ -108,6 +108,27 @@ directory. EOF AC_MSG_ERROR([C and Fortran 77 compilers are not link compatible. Can not continue.])])]) +# Test to see if the F90 compilers likes the C++ exceptions flags. If +# it doesn't, just abort. We *could* handle this scenario (e.g., +# probe the F90 compiler for what flags would be necessary), but we're +# kinda assuming that no one will care. If they do, they'll e-mail us. +AC_MSG_CHECKING([to see if F77 compiler likes the C++ exception flags]) +if test $OMPI_WANT_F77_BINDINGS -eq 0; then + AC_MSG_RESULT([skipped (no F77 bindings)]) +elif test "$OMPI_CXX_EXCEPTIONS_CXXFLAGS" = ""; then + AC_MSG_RESULT([skipped (no C++ exceptions flags)]) +else + FFLAGS="$FFLAGS $OMPI_CXX_EXCEPTIONS_CXXFLAGS" + AC_LANG_PUSH(Fortran 77) + AC_COMPILE_IFELSE(AC_LANG_PROGRAM([], [[ INTEGER I + I = 3]]), + [AC_MSG_RESULT([yes])], + [AC_MSG_RESULT([no]) + AC_MSG_WARN([C++ exception flags are different between the C and C++ compilers; this configure script cannot currently handle this scenario. Either disable C++ exception support or send mail to the Open MPI users list.]) + AC_MSG_ERROR([*** Cannot continue])]) + AC_LANG_POP +fi + AC_DEFINE_UNQUOTED(OMPI_WANT_F77_BINDINGS, $OMPI_WANT_F77_BINDINGS, [Whether we want the MPI f77 bindings or not]) AC_DEFINE_UNQUOTED(OMPI_F77, "$OMPI_F77", [OMPI underlying F77 compiler]) diff --git a/config/ompi_setup_f90.m4 b/config/ompi_setup_f90.m4 index c6649f7ba1..5f28e754d1 100644 --- a/config/ompi_setup_f90.m4 +++ b/config/ompi_setup_f90.m4 @@ -172,6 +172,27 @@ AS_IF([test $OMPI_WANT_F90_BINDINGS -eq 1], AC_FC_SRCEXT(f90) AC_LANG_POP(Fortran)]) +# Test to see if the F90 compilers likes the C++ exceptions flags. If +# it doesn't, just abort. We *could* handle this scenario (e.g., +# probe the F90 compiler for what flags would be necessary), but we're +# kinda assuming that no one will care. If they do, they'll e-mail us. +AC_MSG_CHECKING([to see if F90 compiler likes the C++ exception flags]) +if test "$OMPI_WANT_F90_BINDINGS" = "0"; then + AC_MSG_RESULT([skipped (no F90 bindings)]) +elif test "$OMPI_CXX_EXCEPTIONS_CXXFLAGS" = ""; then + AC_MSG_RESULT([skipped (no C++ exceptions flags)]) +else + FCFLAGS="$FFLAGS $OMPI_CXX_EXCEPTIONS_CXXFLAGS" + AC_LANG_PUSH(Fortran) + AC_COMPILE_IFELSE(AC_LANG_PROGRAM([], [[ INTEGER I + I = 3]]), + [AC_MSG_RESULT([yes])], + [AC_MSG_RESULT([no]) + AC_MSG_WARN([C++ exception flags are different between the C and C++ compilers; this configure script cannot currently handle this scenario. Either disable C++ exception support or send mail to the Open MPI users list.]) + AC_MSG_ERROR([*** Cannot continue])]) + AC_LANG_POP +fi + # All done -- save values AC_DEFINE_UNQUOTED(OMPI_WANT_F90_BINDINGS, $OMPI_WANT_F90_BINDINGS, [Whether we want the MPI f90 bindings or not])