Repository: spack/spack

Issue:
Installation issue: intel-oneapi-compilers with intel-oneapi-mpi: MPI for C++ not working
### Steps to reproduce the issue

```console
spack install petsc +libpng +fftw +scalapack +ptscotch -metis -superlu-dist %oneapi ^intel-oneapi-mkl ^intel-oneapi-mpi ^hdf5 + fortran
```


### Error message

<details><summary>Relevant part of `configure.log` from PETSc</summary><pre>
Error testing C++ compiler: Cannot compile Cxx
</pre></details>

Spacks error message is rather generic
<details><summary>Spacks error message</summary><pre>
==> Installing petsc-3.17.0-y7mv43zfbzkfoar3qyva2ehoei4ivjlw
==> No binary for petsc-3.17.0-y7mv43zfbzkfoar3qyva2ehoei4ivjlw found: installing from source
==> Using cached archive: /opt/spack/var/spack/cache/_source-cache/archive/96/96d5aca684e1ce1425891a620d278773c25611cb144165a93b17531238eaaf8a.tar.gz
==> No patches needed for petsc
==> petsc: Executing phase: 'configure'
==> Error: ProcessError: Command exited with status 1:
    '/opt/spack/opt/spack/linux-ubuntu20.04-sandybridge/oneapi-2022.0.0/python-3.9.12-ryhfen2bixiapj7jjuddfab3gtapuox5/bin/python3.9' 'configure' '--prefix=/opt/spack/opt/spack/linux-ubuntu20.04-sandybridge/oneapi-2022.0.0/petsc-3.17.0-y7mv43zfbzkfoar3qyva2ehoei4ivjlw' '--with-ssl=0' '--download-c2html=0' '--download-sowing=0' '--download-hwloc=0' 'CFLAGS=' 'FFLAGS=' 'CXXFLAGS=' '--with-cc=/opt/spack/opt/spack/linux-ubuntu20.04-sandybridge/oneapi-2022.0.0/intel-oneapi-mpi-2021.5.1-yqnwmf3onb4fm55gbbkf6bk4lnzx6yrz/mpi/2021.5.1/bin/mpicc' '--with-cxx=/opt/spack/opt/spack/linux-ubuntu20.04-sandybridge/oneapi-2022.0.0/intel-oneapi-mpi-2021.5.1-yqnwmf3onb4fm55gbbkf6bk4lnzx6yrz/mpi/2021.5.1/bin/mpicxx' '--with-fc=/opt/spack/opt/spack/linux-ubuntu20.04-sandybridge/oneapi-2022.0.0/intel-oneapi-mpi-2021.5.1-yqnwmf3onb4fm55gbbkf6bk4lnzx6yrz/mpi/2021.5.1/bin/mpifc' '--with-precision=double' '--with-scalar-type=real' '--with-shared-libraries=1' '--with-debugging=0' '--with-openmp=0' '--with-64-bit-indices=0' 'COPTFLAGS=' 'FOPTFLAGS=' 'CXXOPTFLAGS=' '--with-blas-lapack-lib=/opt/spack/opt/spack/linux-ubuntu20.04-sandybridge/oneapi-2022.0.0/intel-oneapi-mkl-2022.0.2-7zhw3k5tqfxdiyzm7huskknfp755zc47/mkl/2022.0.2/lib/intel64/libmkl_intel_lp64.so /opt/spack/opt/spack/linux-ubuntu20.04-sandybridge/oneapi-2022.0.0/intel-oneapi-mkl-2022.0.2-7zhw3k5tqfxdiyzm7huskknfp755zc47/mkl/2022.0.2/lib/intel64/libmkl_sequential.so /opt/spack/opt/spack/linux-ubuntu20.04-sandybridge/oneapi-2022.0.0/intel-oneapi-mkl-2022.0.2-7zhw3k5tqfxdiyzm7huskknfp755zc47/mkl/2022.0.2/lib/intel64/libmkl_core.so /lib/x86_64-linux-gnu/libpthread.so /lib/x86_64-linux-gnu/libm.so /lib/x86_64-linux-gnu/libdl.so' '--with-x=0' '--with-clanguage=C' '--with-cuda=0' '--with-hip=0' '--with-metis=0' '--with-hypre=1' '--with-hypre-include=/opt/spack/opt/spack/linux-ubuntu20.04-sandybridge/oneapi-2022.0.0/hypre-2.24.0-awd4zoe3orltawxpyoq3c6os4vutb5ms/include' '--with-hypre-lib=/opt/spack/opt/spack/linux-ubuntu20.04-sandybridge/oneapi-2022.0.0/hypre-2.24.0-awd4zoe3orltawxpyoq3c6os4vutb5ms/lib/libHYPRE.so' '--with-parmetis=0' '--with-kokkos=0' '--with-kokkos-kernels=0' '--with-superlu_dist=0' '--with-ptscotch=1' '--with-ptscotch-include=/opt/spack/opt/spack/linux-ubuntu20.04-sandybridge/oneapi-2022.0.0/scotch-7.0.1-ke42wt64lfdmk6sjuj5v5dhezoq3pyap/include' '--with-ptscotch-lib=/opt/spack/opt/spack/linux-ubuntu20.04-sandybridge/oneapi-2022.0.0/scotch-7.0.1-ke42wt64lfdmk6sjuj5v5dhezoq3pyap/lib/libesmumps.so /opt/spack/opt/spack/linux-ubuntu20.04-sandybridge/oneapi-2022.0.0/scotch-7.0.1-ke42wt64lfdmk6sjuj5v5dhezoq3pyap/lib/libptscotch.so /opt/spack/opt/spack/linux-ubuntu20.04-sandybridge/oneapi-2022.0.0/scotch-7.0.1-ke42wt64lfdmk6sjuj5v5dhezoq3pyap/lib/libptscotcherr.so /opt/spack/opt/spack/linux-ubuntu20.04-sandybridge/oneapi-2022.0.0/scotch-7.0.1-ke42wt64lfdmk6sjuj5v5dhezoq3pyap/lib/libscotch.so /opt/spack/opt/spack/linux-ubuntu20.04-sandybridge/oneapi-2022.0.0/scotch-7.0.1-ke42wt64lfdmk6sjuj5v5dhezoq3pyap/lib/libscotcherr.so /opt/spack/opt/spack/linux-ubuntu20.04-sandybridge/oneapi-2022.0.0/zlib-1.2.12-yr4fffbpyi74xz6d2di2vtmqlrepbaqx/lib/libz.so' '--with-suitesparse=0' '--with-hdf5=1' '--with-hdf5-include=/opt/spack/opt/spack/linux-ubuntu20.04-sandybridge/oneapi-2022.0.0/hdf5-1.12.1-lgpcjqeujcn24kbp6qxiyj7vzwkia74f/include' '--with-hdf5-lib=/opt/spack/opt/spack/linux-ubuntu20.04-sandybridge/oneapi-2022.0.0/hdf5-1.12.1-lgpcjqeujcn24kbp6qxiyj7vzwkia74f/lib/libhdf5_fortran.so /opt/spack/opt/spack/linux-ubuntu20.04-sandybridge/oneapi-2022.0.0/hdf5-1.12.1-lgpcjqeujcn24kbp6qxiyj7vzwkia74f/lib/libhdf5_f90cstub.so /opt/spack/opt/spack/linux-ubuntu20.04-sandybridge/oneapi-2022.0.0/hdf5-1.12.1-lgpcjqeujcn24kbp6qxiyj7vzwkia74f/lib/libhdf5.so' '--with-zlib=1' '--with-zlib-include=/opt/spack/opt/spack/linux-ubuntu20.04-sandybridge/oneapi-2022.0.0/zlib-1.2.12-yr4fffbpyi74xz6d2di2vtmqlrepbaqx/include' '--with-zlib-lib=/opt/spack/opt/spack/linux-ubuntu20.04-sandybridge/oneapi-2022.0.0/zlib-1.2.12-yr4fffbpyi74xz6d2di2vtmqlrepbaqx/lib/libz.so' '--with-mumps=0' '--with-trilinos=0' '--with-fftw=1' '--with-fftw-include=/opt/spack/opt/spack/linux-ubuntu20.04-sandybridge/oneapi-2022.0.0/fftw-3.3.10-yb7ukwsjrqqrntuh3ikufflnjfwhrjlw/include' '--with-fftw-lib=/opt/spack/opt/spack/linux-ubuntu20.04-sandybridge/oneapi-2022.0.0/fftw-3.3.10-yb7ukwsjrqqrntuh3ikufflnjfwhrjlw/lib/libfftw3_mpi.so /opt/spack/opt/spack/linux-ubuntu20.04-sandybridge/oneapi-2022.0.0/fftw-3.3.10-yb7ukwsjrqqrntuh3ikufflnjfwhrjlw/lib/libfftw3.so' '--with-valgrind=0' '--with-gmp=0' '--with-libpng=1' '--with-libpng-include=/opt/spack/opt/spack/linux-ubuntu20.04-sandybridge/oneapi-2022.0.0/libpng-1.6.37-rn4fopasnqcuhg47pz24elnonilkdt6u/include' '--with-libpng-lib=/opt/spack/opt/spack/linux-ubuntu20.04-sandybridge/oneapi-2022.0.0/libpng-1.6.37-rn4fopasnqcuhg47pz24elnonilkdt6u/lib/libpng.so' '--with-giflib=0' '--with-mpfr=0' '--with-netcdf=0' '--with-pnetcdf=0' '--with-moab=0' '--with-random123=0' '--with-exodusii=0' '--with-cgns=0' '--with-memkind=0' '--with-p4est=0' '--with-saws=0' '--with-yaml=0' '--with-hwloc=0' '--with-libjpeg=0' '--with-scalapack=1' '--with-scalapack-lib=/opt/spack/opt/spack/linux-ubuntu20.04-sandybridge/oneapi-2022.0.0/netlib-scalapack-2.2.0-medelrkyzdxigbhoutpllpvuza5qbnhu/lib/libscalapack.so' '--with-strumpack=0' '--with-mmg=0' '--with-parmmg=0' '--with-tetgen=0'
See build log for details:
  /tmp/m.diehl/spack-stage/spack-stage-petsc-3.17.0-y7mv43zfbzkfoar3qyva2ehoei4ivjlw/spack-build-out.txt
</pre></details>

### Information on your system

* **Spack:** 0.18.0.dev0 (3ad3e53ff810ae9047882cabda2ecf929a4b0a65)
* **Python:** 3.8.10
* **Platform:** linux-ubuntu20.04-sandybridge
* **Concretizer:** clingo

### Additional information

The problem occurs when compiling PETSc, but it is not directly related to it. The issue is rather related to the names of the compilers and MPI compiler wrappers.

For the new, Clang-based compilers, `I_MPI_CXX` needs to be set `icpx`. This does not work for `mpicxx` which raises the error `Error: unsupported compiler name 'icpx'`.

The source of the issues is in https://github.com/spack/spack/blob/develop/var/spack/repos/builtin/packages/intel-oneapi-mpi/package.py: The names of the compiler wrappers are the generic names `mpicc`, `mpicxx`, `mpif77`, `mpif90`, and `mpifc`. However, Intel MPI also has specific names `mpiicc`, `mpiicpc`, and `mpiifort`. To me, it seems that they should be preferred. At least `mpiicpc` works with `I_MPI_CXX=icpx`.

@rscohn2: Are you aware of any problems when using the Intel specific wrapper names? Otherwise, it seems to be a straight forward fix.

@balay, @barrysmith, @jedbrown: Not sure if you are aware of this already

[configure.log](https://github.com/spack/spack/files/8458663/configure.log)
[spack-build-out.txt](https://github.com/spack/spack/files/8458665/spack-build-out.txt)



### General information

- [X] I have run `spack debug report` and reported the version of Spack/Python/Platform
- [X] I have run `spack maintainers <name-of-the-package>` and **@mentioned** any maintainers
- [X] I have uploaded the build log and environment files
- [X] I have searched the issues of this repo and believe this is not a duplicate


Discussion:
[spack-build-env.txt](https://github.com/spack/spack/files/8458711/spack-build-env.txt)

I am checking with the mpi team if there are any issues with switching.
The MPI team believes it will be ok, but suggests we give the user the ability to switch back. I think it could be done with a boolean variant that defaults to mpiicpc/mpiicc. I can do this next week, but feel free submit a PR if you have time.

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/intel-oneapi-mpi/package.py b/var/spack/repos/builtin/packages/intel-oneapi-mpi/package.py
--- a/var/spack/repos/builtin/packages/intel-oneapi-mpi/package.py
+++ b/var/spack/repos/builtin/packages/intel-oneapi-mpi/package.py
@@ -44,7 +44,10 @@ class IntelOneapiMpi(IntelOneApiLibraryPackage):
 
     variant('ilp64', default=False,
             description='Build with ILP64 support')
-    variant('external-libfabric', default=False, description='Enable external libfabric dependency')
+    variant('generic-names', default=False,
+            description='Use generic names, e.g mpicc instead of mpiicc')
+    variant('external-libfabric', default=False,
+            description='Enable external libfabric dependency')
     depends_on('libfabric', when='+external-libfabric', type=('link', 'run'))
 
     provides('mpi@:3.1')
@@ -55,10 +58,16 @@ def component_dir(self):
 
     def setup_dependent_package(self, module, dep_spec):
         dir = join_path(self.component_path, 'bin')
-        self.spec.mpicc  = join_path(dir, 'mpicc')
-        self.spec.mpicxx = join_path(dir, 'mpicxx')
-        self.spec.mpif77 = join_path(dir, 'mpif77')
-        self.spec.mpifc  = join_path(dir, 'mpifc')
+        if '+generic-names' in self.spec:
+            self.spec.mpicc  = join_path(dir, 'mpicc')
+            self.spec.mpicxx = join_path(dir, 'mpicxx')
+            self.spec.mpif77 = join_path(dir, 'mpif77')
+            self.spec.mpifc  = join_path(dir, 'mpifc')
+        else:
+            self.spec.mpicc  = join_path(dir, 'mpiicc')
+            self.spec.mpicxx = join_path(dir, 'mpiicpc')
+            self.spec.mpif77 = join_path(dir, 'mpiifort')
+            self.spec.mpifc  = join_path(dir, 'mpiifort')
 
     def setup_dependent_build_environment(self, env, dependent_spec):
         env.set('MPICH_CC', spack_cc)
@@ -69,11 +78,18 @@ def setup_dependent_build_environment(self, env, dependent_spec):
 
         # Set compiler wrappers for dependent build stage
         dir = join_path(self.component_path, 'bin')
-        env.set('MPICC', join_path(dir, 'mpicc'))
-        env.set('MPICXX', join_path(dir, 'mpicxx'))
-        env.set('MPIF77', join_path(dir, 'mpif77'))
-        env.set('MPIF90', join_path(dir, 'mpif90'))
-        env.set('MPIFC', join_path(dir, 'mpifc'))
+        if '+generic-names' in self.spec:
+            env.set('MPICC', join_path(dir, 'mpicc'))
+            env.set('MPICXX', join_path(dir, 'mpicxx'))
+            env.set('MPIF77', join_path(dir, 'mpif77'))
+            env.set('MPIF90', join_path(dir, 'mpif90'))
+            env.set('MPIFC', join_path(dir, 'mpifc'))
+        else:
+            env.set('MPICC', join_path(dir, 'mpiicc'))
+            env.set('MPICXX', join_path(dir, 'mpiicpc'))
+            env.set('MPIF77', join_path(dir, 'mpiifort'))
+            env.set('MPIF90', join_path(dir, 'mpiifort'))
+            env.set('MPIFC', join_path(dir, 'mpiifort'))
 
         env.set('I_MPI_ROOT', self.component_path)
 


Test patch: