Repository: spack/spack

Issue:
Installation issue: petsc
### Steps to reproduce the issue

I am running into an issue with spack build of petsc+suite-sparse not finding suite-sparse during configuration:
```console
$ spack install petsc@3.16.1%gcc +X~batch+cgns~complex~cuda~debug+double~exodusii+fftw+giflib+hdf5+hpddm+hwloc+hypre~int64+jpeg~knl~kokkos+libpng+libyaml+memkind+metis~mkl-pardiso+mmg~moab+mpfr+mpi+mumps+openmp+p4est+parmmg+ptscotch+random123~rocm+saws+scalapack+shared+strumpack+suite-sparse+superlu-dist+tetgen+trilinos~valgrind clanguage=C

==> petsc: Executing phase: 'install'
[...]
TESTING: check from config.libraries(/tmp/spackswinst/spack-stage/spack-stage-petsc-3.16.1-2x264ehnsj62g4u62324ejuibtsm3pns/spack-src/config/BuildSystem/config/libraries.py:157)
*******************************************************************************
         UNABLE to CONFIGURE with GIVEN OPTIONS    (see configure.log for details):
-------------------------------------------------------------------------------
--with-suitesparse-lib=['/cvmfs/hpcsw.umd.edu/spack-software/2021.11.29/linux-rhel8-zen2/gcc-9.4.0/suite-sparse-5.10.1-inp5rksh67qsfoggzgikqxw6sulxkqep/lib/libumfpack.so', '/cvmfs/hpcsw.umd.edu/spack-software/2021.11.29/linux-rhel8-zen2/gcc-9.4.0/suite-sparse-5.10.1-inp5rksh67qsfoggzgikqxw6sulxkqep/lib/libklu.so', '/cvmfs/hpcsw.umd.edu/spack-software/2021.11.29/linux-rhel8-zen2/gcc-9.4.0/suite-sparse-5.10.1-inp5rksh67qsfoggzgikqxw6sulxkqep/lib/libcholmod.so', '/cvmfs/hpcsw.umd.edu/spack-software/2021.11.29/linux-rhel8-zen2/gcc-9.4.0/suite-sparse-5.10.1-inp5rksh67qsfoggzgikqxw6sulxkqep/lib/libbtf.so', '/cvmfs/hpcsw.umd.edu/spack-software/2021.11.29/linux-rhel8-zen2/gcc-9.4.0/suite-sparse-5.10.1-inp5rksh67qsfoggzgikqxw6sulxkqep/lib/libccolamd.so', '/cvmfs/hpcsw.umd.edu/spack-software/2021.11.29/linux-rhel8-zen2/gcc-9.4.0/suite-sparse-5.10.1-inp5rksh67qsfoggzgikqxw6sulxkqep/lib/libcolamd.so', '/cvmfs/hpcsw.umd.edu/spack-software/2021.11.29/linux-rhel8-zen2/gcc-9.4.0/suite-sparse-5.10.1-inp5rksh67qsfoggzgikqxw6sulxkqep/lib/libcamd.so', '/cvmfs/hpcsw.umd.edu/spack-software/2021.11.29/linux-rhel8-zen2/gcc-9.4.0/suite-sparse-5.10.1-inp5rksh67qsfoggzgikqxw6sulxkqep/lib/libamd.so', '/cvmfs/hpcsw.umd.edu/spack-software/2021.11.29/linux-rhel8-zen2/gcc-9.4.0/suite-sparse-5.10.1-inp5rksh67qsfoggzgikqxw6sulxkqep/lib/libsuitesparseconfig.so'] and
--with-suitesparse-include=['/cvmfs/hpcsw.umd.edu/spack-software/2021.11.29/linux-rhel8-zen2/gcc-9.4.0/suite-sparse-5.10.1-inp5rksh67qsfoggzgikqxw6sulxkqep/include'] did not work
*******************************************************************************
```

Delving into this for the root cause, the configure.log shows the following error when trying to compile a test code:
```console
Possible ERROR while running linker: exit code 1
stderr:
/tmp/petsc-poqahanb/config.libraries/conftest.o: In function `_check_SuiteSparseQR_C_solve':
conftest.c:(.text+0x3d): undefined reference to `SuiteSparseQR_C_solve'
collect2: error: ld returned 1 exit status
Linker output before filtering:

/tmp/petsc-poqahanb/config.libraries/conftest.o: In function `_check_SuiteSparseQR_C_solve':
conftest.c:(.text+0x3d): undefined reference to `SuiteSparseQR_C_solve'
collect2: error: ld returned 1 exit status
:
Linker output after filtering:

/tmp/petsc-poqahanb/config.libraries/conftest.o: In function `_check_SuiteSparseQR_C_solve':
conftest.c:(.text+0x3d): undefined reference to `SuiteSparseQR_C_solve'
```

The SuiteSparseQR_C_solve symbol can be found in libspqr.so from suite-sparse, but the spack recipe is not passing that specific library to the petsc build system via the --with-suitesparse-lib flag.



### Information on your system

```console
$ spack debug report
* **Spack:** 0.17.0-319-5dce4d79bd
* **Python:** 3.6.8
* **Platform:** linux-rhel8-zen2
* **Concretizer:** clingo
```

### Additional information

- [configure.log](https://github.com/spack/spack/files/7890096/configure.log)
- [spack-build-env.txt](https://github.com/spack/spack/files/7890097/spack-build-env.txt)
- [spack-build-out.txt](https://github.com/spack/spack/files/7890098/spack-build-out.txt)

Maintainers of petsc: @balay, @barrysmith, @jedbrown

### 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:

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/petsc/package.py b/var/spack/repos/builtin/packages/petsc/package.py
--- a/var/spack/repos/builtin/packages/petsc/package.py
+++ b/var/spack/repos/builtin/packages/petsc/package.py
@@ -425,7 +425,7 @@ def install(self, spec, prefix):
                 ('superlu-dist', 'superlu_dist', True, True),
                 ('scotch', 'ptscotch', True, True),
                 ('suite-sparse:umfpack,klu,cholmod,btf,ccolamd,colamd,camd,amd, \
-                suitesparseconfig', 'suitesparse', True, True),
+                suitesparseconfig,spqr', 'suitesparse', True, True),
                 ('hdf5:hl,fortran', 'hdf5', True, True),
                 'zlib',
                 'mumps',


Test patch: