PETSc ignores the user specified compiler and uses the system default
When using openmpi, the PETSc build system ignores the OMPI_FC, OMPI_CC and OMPI_CXX environment variables set by cmake and uses the default compilers instead. a workaround is to export these variables manually before running make, e.g.
$ export OMPI_FCFLAGS= OMPI_CC=/usr/bin/clang OMPI_CXX=/usr/bin/clang++ OMPI_FC=/usr/bin/gfortran $ make -j 6
I wasn't able to fix this in a portable way, so i am filing this issue in case somebody else runs into this problem.