change static definition of MPI constants
We have been applying this patch, originally by Erik Schnetter (@eschnett), for the last few years in order to be able to pre-compile PETSc binaries using binary builder (see https://github.com/JuliaPackaging/Yggdrasil/blob/master/P/PETSc/build_tarballs.jl), along with MPITrampoline which allows precompiled binaries to be deployed on systems with a different MPI implementations.
Without this, compilations that use MPITrampoline fail as can be seen here, with messages of the type:
[09:47:43] /workspace/srcdir/petsc-3.22.1/src/sys/objects/pinit.c:59:38: error: initializer element is not constant
[09:47:43] PetscMPIInt Petsc_SharedWD_keyval = MPI_KEYVAL_INVALID;
[09:47:43] ^~~~~~~~~~~~~~~~~~
[09:47:43] /workspace/srcdir/petsc-3.22.1/src/sys/objects/pinit.c:60:38: error: initializer element is not constant
[09:47:43] PetscMPIInt Petsc_SharedTmp_keyval = MPI_KEYVAL_INVALID;
[09:47:43] ^~~~~~~~~~~~~~~~~~
[09:47:43] /workspace/srcdir/petsc-3.22.1/src/sys/objects/pinit.c:449:37: error: initializer element is not constant
[09:47:43] PetscMPIInt PETSC_MPI_ERROR_CLASS = MPI_ERR_LASTCODE, PETSC_MPI_ERROR_CODE;
[09:47:43] ^~~~~~~~~~~~~~~~
[09:47:43] make[3]: *** [gmakefile:198: i686-linux-gnu_double_real_Int64/obj/src/sys/objects/pinit.o] Error 1
Co-authored-by: Erik Schnetter eschnetter@perimeterinstitute.ca
Edited by Boris Kaus