libMesh / libmesh

libMesh github repository
http://libmesh.github.io
GNU Lesser General Public License v2.1
654 stars 286 forks source link

libmesh configure fails with PETSc 3.17 but not PETSc 3.13 #3325

Open elbert5770 opened 2 years ago

elbert5770 commented 2 years ago

Here's the error message during libmesh configure (this is through autoibamr but I had the same failure yesterday with manually installed PETSc 3.17 and manually installed libmesh 1.7).

---------------------------------------------
----------- Configuring libMesh -------------
---------------------------------------------
...lots of checking...

----- Configuring for optional packages -----
---------------------------------------------
checking for built-in XDR support... no
checking for XDR support in /usr/include/tirpc... yes
checking /home/elbert5770/autoibamr/packages/petsc-3.17.2//include/petscversion.h usability... no
checking /home/elbert5770/autoibamr/packages/petsc-3.17.2//include/petscversion.h presence... no
checking for /home/elbert5770/autoibamr/packages/petsc-3.17.2//include/petscversion.h... no
checking /home/elbert5770/autoibamr/packages/petsc-3.17.2/include/petscversion.h usability... no
checking /home/elbert5770/autoibamr/packages/petsc-3.17.2/include/petscversion.h presence... no
checking for /home/elbert5770/autoibamr/packages/petsc-3.17.2/include/petscversion.h... no
configure: error: *** PETSc was not found, but --enable-petsc-required was specified.
Failure with exit status: 3
Exit message: There was a problem configuring libmesh 1.6.2.

The double slashes are not ideal, but in the second call, petscversion.h is in fact in that location.

What's happening is the following in libmesh's configure file at line 34473:

if test "$enablepetsc" !=  no; then :

    # AC_REQUIRE:
    # If the M4 macro AC_PROG_F77 has not already been called, call
    # it (without any arguments). Make sure to quote AC_PROG_F77 with
    # square brackets. AC_PROG_F77 must have been defined using
    # AC_DEFUN or else contain a call to AC_PROVIDE to indicate
    # that it has been called.

    # Let's use a C compiler for the AC_CHECK_HEADER test, although this is
    # not strictly necessary...
    ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu

    as_ac_Header=`$as_echo "ac_cv_header_${PETSC_DIR}/${PETSC_ARCH}/include/petscversion.h" | $as_tr_sh`
ac_fn_c_check_header_mongrel "$LINENO" "${PETSC_DIR}/${PETSC_ARCH}/include/petscversion.h" "$as_ac_Header" "$ac_includes_default"
if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
  enablepetsc=yes; enablepetsc_mpi=yes
                     petsc_version_h_file=${PETSC_DIR}/${PETSC_ARCH}/include/petscversion.h
else

      as_ac_Header=`$as_echo "ac_cv_header_${PETSC_DIR}/include/petscversion.h" | $as_tr_sh`
ac_fn_c_check_header_mongrel "$LINENO" "${PETSC_DIR}/include/petscversion.h" "$as_ac_Header" "$ac_includes_default"
if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
  enablepetsc=yes; enablepetsc_mpi=yes
                       petsc_version_h_file=${PETSC_DIR}/include/petscversion.h
else
  enablepetsc=no; enablepetsc_mpi=no
fi
fi

The failure occurs within the function 'ac_fn_c_check_header_mongrel'. The c compilation doesn't succeed

The problem is that the file petscversion.h in PETSc_3.17 now includes another header file that makes the test fail, this #include was not in PETSc_3.13

#if !defined(PETSCVERSION_H)
#define PETSCVERSION_H
#include <petscconf.h> // This include is new to 3.17, otherwise the file is essentially identical to 3.13

#define PETSC_VERSION_RELEASE    1
#define PETSC_VERSION_MAJOR      3
#define PETSC_VERSION_MINOR      17
#define PETSC_VERSION_SUBMINOR   2
#define PETSC_RELEASE_DATE       "Mar 30, 2022"
#define PETSC_VERSION_DATE       "Jun 02, 2022"

#if !defined (PETSC_VERSION_GIT)
#define PETSC_VERSION_GIT        "v3.17.2"
#endif

#if !defined(PETSC_VERSION_DATE_GIT)
#define PETSC_VERSION_DATE_GIT   "2022-06-02 20:01:53 -0500"
#endif

#define PETSC_VERSION_EQ(MAJOR,MINOR,SUBMINOR) \
  ((PETSC_VERSION_MAJOR == (MAJOR)) &&       \
   (PETSC_VERSION_MINOR == (MINOR)) &&       \
   (PETSC_VERSION_SUBMINOR == (SUBMINOR)) && \
   (PETSC_VERSION_RELEASE  == 1))

#define PETSC_VERSION_ PETSC_VERSION_EQ

#define PETSC_VERSION_LT(MAJOR,MINOR,SUBMINOR)          \
  (PETSC_VERSION_RELEASE == 1 &&                        \
   (PETSC_VERSION_MAJOR < (MAJOR) ||                    \
    (PETSC_VERSION_MAJOR == (MAJOR) &&                  \
     (PETSC_VERSION_MINOR < (MINOR) ||                  \
      (PETSC_VERSION_MINOR == (MINOR) &&                \
       (PETSC_VERSION_SUBMINOR < (SUBMINOR)))))))

#define PETSC_VERSION_LE(MAJOR,MINOR,SUBMINOR) \
  (PETSC_VERSION_LT(MAJOR,MINOR,SUBMINOR) || \
   PETSC_VERSION_EQ(MAJOR,MINOR,SUBMINOR))

#define PETSC_VERSION_GT(MAJOR,MINOR,SUBMINOR) \
  (0 == PETSC_VERSION_LE(MAJOR,MINOR,SUBMINOR))

#define PETSC_VERSION_GE(MAJOR,MINOR,SUBMINOR) \
  (0 == PETSC_VERSION_LT(MAJOR,MINOR,SUBMINOR))

#endif

Comment out the include line and the libmesh configure succeeds.

Does it make sense that ac_fn_c_check_header_mongrel would fail with nested #includes?

jwpeterson commented 2 years ago

Can you let us know what version of libmesh you are using? I pushed a fix in a3b71c4b5f3ad788a6fd0b88abbfdd4f7933a16d (back in April 2022) that I think may address this problem for you, basically we no longer use AC_CHECK_HEADER to simply check for the existence of a file (which is what that test is intended to do. If you are using a release version of libmesh, it would probably be worth us backporting this change to a point release.

jwpeterson commented 2 years ago

Oh, sorry, I just re-read your message and you did say libMesh 1.7. So, yeah, I think the commit I mentioned will fix the problem for you, and we should probably release a 1.7.1 which includes that.

jwpeterson commented 2 years ago

@elbert5770 would you mind trying the 1.7.1 release and letting us know here if that works for you? I appreciate your feedback since I don't think many projects (and certainly none of the main developers) actually use the release tarballs, so it is difficult to know when there are issues with them.

elbert5770 commented 2 years ago

I will try this with a fresh install on a new machine that I will be getting. It might soon or it might take some time. I'm confident that this fix worked though. Interestingly, check out how Dr. Wells at IBAMR fixed this such that it should work with libmesh < 1.7.1 and PETSc > 3.13: https://github.com/IBAMR/autoibamr/commit/d02ef0491ccd08b2587e61eda01fad37975c3f8d

Thank you for responding so quickly!