Compiling petsc4py-3.11.0 against petsc-3.11.3

Issue #133 resolved
sagitter created an issue

Hi all.

petsc4py-3.11.0 does not compile against petsc-3.11.3 with this error:

+ export 'CFLAGS= -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic'
+ CFLAGS=' -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic'
+ export PETSC_DIR=/usr
+ PETSC_DIR=/usr
+ CFLAGS='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic'
+ /usr/bin/python3.6 setup.py build '--executable=/usr/bin/python3.6 -s'
running build
running build_src
running build_py
creating build
creating build/lib.linux-x86_64-3.6
creating build/lib.linux-x86_64-3.6/petsc4py
copying src/PETSc.py -> build/lib.linux-x86_64-3.6/petsc4py
copying src/__main__.py -> build/lib.linux-x86_64-3.6/petsc4py
copying src/__init__.py -> build/lib.linux-x86_64-3.6/petsc4py
creating build/lib.linux-x86_64-3.6/petsc4py/lib
copying src/lib/__init__.py -> build/lib.linux-x86_64-3.6/petsc4py/lib
creating build/lib.linux-x86_64-3.6/petsc4py/include
creating build/lib.linux-x86_64-3.6/petsc4py/include/petsc4py
copying src/include/petsc4py/petsc4py.PETSc.h -> build/lib.linux-x86_64-3.6/petsc4py/include/petsc4py
copying src/include/petsc4py/numpy.h -> build/lib.linux-x86_64-3.6/petsc4py/include/petsc4py
copying src/include/petsc4py/petsc4py.h -> build/lib.linux-x86_64-3.6/petsc4py/include/petsc4py
copying src/include/petsc4py/petsc4py.PETSc_api.h -> build/lib.linux-x86_64-3.6/petsc4py/include/petsc4py
copying src/include/petsc4py/petsc4py.i -> build/lib.linux-x86_64-3.6/petsc4py/include/petsc4py
copying src/include/petsc4py/__init__.pxd -> build/lib.linux-x86_64-3.6/petsc4py/include/petsc4py
copying src/include/petsc4py/PETSc.pxd -> build/lib.linux-x86_64-3.6/petsc4py/include/petsc4py
copying src/include/petsc4py/__init__.pyx -> build/lib.linux-x86_64-3.6/petsc4py/include/petsc4py
copying src/PETSc.pxd -> build/lib.linux-x86_64-3.6/petsc4py
copying src/lib/petsc.cfg -> build/lib.linux-x86_64-3.6/petsc4py/lib
running build_ext
PETSC_DIR:    /usr
PETSC_ARCH:   
version:      3.11.3 release
integer-size: 32-bit
scalar-type:  real
precision:    double
language:     CONLY
compiler:     mpicc
linker:       mpicc
building 'PETSc' extension
creating build/temp.linux-x86_64-3.6
creating build/temp.linux-x86_64-3.6/src
mpicc -pthread -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -O3 -fPIC -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -DPETSC_DIR=/usr -I/usr/include/openmpi-x86_64 -I/usr/include/openmpi-x86_64/hypre -I/usr/lib64/gfortran/modules/openmpi/petsc -I/usr/include/openmpi-x86_64/petsc -I/usr/include -Isrc/include -I/usr/lib64/python3.6/site-packages/numpy/core/include -I/usr/include/python3.6m -c src/PETSc.c -o build/temp.linux-x86_64-3.6/src/PETSc.o
In file included from /usr/include/openmpi-x86_64/petsc/petscsys.h:14:0,
                 from /usr/include/openmpi-x86_64/petsc/petscbag.h:4,
                 from /usr/include/openmpi-x86_64/petsc/petsc.h:5,
                 from src/petsc4py.PETSc.c:591,
                 from src/PETSc.c:4:
/usr/include/openmpi-x86_64/petsc/petscconf.h:85:36: error: expected ',' or '}' before '__attribute'
 #define PETSC_DEPRECATED_ENUM(why) __attribute((deprecated))
                                    ^
/usr/include/openmpi-x86_64/petsc/petscksp.h:430:76: note: in expansion of macro 'PETSC_DEPRECATED_ENUM'
 #define KSP_DIVERGED_PCSETUP_FAILED_DEPRECATED KSP_DIVERGED_PCSETUP_FAILED PETSC_DEPRECATED_ENUM("Use KSP_DIVERGED_PC_FAILED (since v3.11)")
                                                                            ^
/usr/include/openmpi-x86_64/petsc/petscksp.h:452:15: note: in expansion of macro 'KSP_DIVERGED_PCSETUP_FAILED_DEPRECATED'
               KSP_DIVERGED_PCSETUP_FAILED_DEPRECATED  = -11,
               ^
In file included from src/PETSc.c:4:0:
src/petsc4py.PETSc.c: In function '__pyx_f_8petsc4py_5PETSc_KSP_Converged':
src/petsc4py.PETSc.c:35723:22: error: 'KSP_CONVERGED_ITERATING' undeclared (first use in this function)
     (__pyx_v_r[0]) = KSP_CONVERGED_ITERATING;
                      ^
src/petsc4py.PETSc.c:35723:22: note: each undeclared identifier is reported only once for each function it appears in
src/petsc4py.PETSc.c: In function '__pyx_pf_8petsc4py_5PETSc_3KSP_50callConvergenceTest':
src/petsc4py.PETSc.c:171473:20: error: 'KSP_CONVERGED_ITERATING' undeclared (first use in this function)
   __pyx_v_reason = KSP_CONVERGED_ITERATING;
                    ^
src/petsc4py.PETSc.c: In function '__pyx_pf_8petsc4py_5PETSc_3KSP_112getConvergedReason':
src/petsc4py.PETSc.c:174687:20: error: 'KSP_CONVERGED_ITERATING' undeclared (first use in this function)
   __pyx_v_reason = KSP_CONVERGED_ITERATING;
                    ^
src/petsc4py.PETSc.c: In function '__pyx_pymod_exec_PETSc':
src/petsc4py.PETSc.c:303605:51: error: 'KSP_CONVERGED_ITERATING' undeclared (first use in this function)
   __pyx_t_7 = __Pyx_PyInt_From_KSPConvergedReason(KSP_CONVERGED_ITERATING); if (unlikely(!__pyx_t_7)) __PYX_ERR(37, 64, __pyx_L1_error)
                                                   ^
error: command 'mpicc' failed with exit status

Comments (10)

  1. Lisandro Dalcin

    What’s your GCC version? Can you try to compile any C example with #include <petsc.h>? Doest it work or does it fail the same way?

    @BarryFSmith @Satish Balay This does not look like a petsc4py issue, but rather the PETSC_DEPRECATED_ENUM macro not working as expected. Am I right?

    I believe the only way to fix this issue is to patch petsc4py sources to undefine a redefine the offending macro.

  2. BarryFSmith

    I think Satish conclude on the PETSc gitlab site the problem was a different GCC version was used for PETSc and then for petsc4py. One that allowed the deprecated and one that did not. So maybe a way to check that the underlying compilers are the same when petsc4py is built?

  3. sagitter reporter

    I think Satish conclude on the PETSc gitlab site the problem was a different GCC version was used for PETSc and then for petsc4py

    PETSc and petsc4py are compiled on CentOS-7 machines with same MPI compilers (openmpi-1.10.7 and mpich-3.0.4).

    I’m testing Satish’s patch for PETSc:

    diff --git a/include/petscksp.h b/include/petscksp.h
    index b75810337b..a201c97d3e 100644
    --- a/include/petscksp.h
    +++ b/include/petscksp.h
    @@ -450,8 +450,6 @@ typedef enum {/* converged */
                   KSP_DIVERGED_NANORINF            = -9,
                   KSP_DIVERGED_INDEFINITE_MAT      = -10,
                   KSP_DIVERGED_PC_FAILED           = -11,
    -              KSP_DIVERGED_PCSETUP_FAILED_DEPRECATED  = -11,
    -
                   KSP_CONVERGED_ITERATING          =  0} KSPConvergedReason;
     PETSC_EXTERN const char *const*KSPConvergedReasons;
    

  4. sagitter reporter

    I’m testing Satish’s patch for PETSc

    it is not enough, unfortunately.

    I forced GCC-8.3.1 to compile petsc4py: it’s working finally.

  5. BarryFSmith

    How did you force it?

    What does mpicc --show print out?

    We’d like to fix the problem permanently by somehow making sure that the underlying compilers always match between PETSc and petsc4py.

    Is it as simple as your path was different in the two runs so it picked up a different gcc?

    Thanks

  6. sagitter reporter

    How did you force it?

    It was an RPM packaging issue on EPEL-7 environment: i compiled PETSc with a more recent version (8.3.1) of GNU compilers than default ones already on CentOS-7 (4.8.5) by using Developer Toolset 8

    petsc4py, now i know, needs to be compiled with the same version of GNU compilers otherwise it does not compile with an error like that one in my beginning post of this ticket.

    From CentOS-7, after devtoolset-8 installation:

    \$ /usr/bin/gcc --version
    gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-39)
    Copyright (C) 2015 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions. There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

    \$ /usr/lib64/openmpi/bin/mpicc --show
    gcc -I/usr/include/openmpi-x86_64 -pthread -m64 -Wl,-rpath -Wl,/usr/lib64/openmpi/lib -Wl,--enable-new-dtags -L/usr/lib64/openmpi/lib -lmpi

    \$ source /opt/rh/devtoolset-8/enable

    \$ gcc --version
    gcc (GCC) 8.3.1 20190311 (Red Hat 8.3.1-3)
    Copyright (C) 2018 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions. There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

    \$ module load mpi/mpich-x86_64 && mpicc --version
    cc (GCC) 8.3.1 20190311 (Red Hat 8.3.1-3)
    Copyright (C) 2018 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions. There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE

  7. Log in to comment